Skip to content

Commit

Permalink
net: add unknown state to sysfs NIC duplex export
Browse files Browse the repository at this point in the history
Currently when the NIC duplex state is DUPLEX_UNKNOWN it is exported as
full through sysfs, this patch adds support for DUPLEX_UNKNOWN. It is
handled the same way as in ethtool.

 Signed-off-by: Nikolay Aleksandrov <naleksan@redhat.com>

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Nikolay Aleksandrov authored and David S. Miller committed Sep 5, 2012
1 parent f6fe569 commit c6c1396
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions net/core/net-sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,21 @@ static ssize_t show_duplex(struct device *dev,

if (netif_running(netdev)) {
struct ethtool_cmd cmd;
if (!__ethtool_get_settings(netdev, &cmd))
ret = sprintf(buf, "%s\n",
cmd.duplex ? "full" : "half");
if (!__ethtool_get_settings(netdev, &cmd)) {
const char *duplex;
switch (cmd.duplex) {
case DUPLEX_HALF:
duplex = "half";
break;
case DUPLEX_FULL:
duplex = "full";
break;
default:
duplex = "unknown";
break;
}
ret = sprintf(buf, "%s\n", duplex);
}
}
rtnl_unlock();
return ret;
Expand Down

0 comments on commit c6c1396

Please sign in to comment.