Skip to content

Commit c6c1396

Browse files
Nikolay Aleksandrovdavem330
authored andcommitted
net: add unknown state to sysfs NIC duplex export
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f6fe569 commit c6c1396

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

net/core/net-sysfs.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,21 @@ static ssize_t show_duplex(struct device *dev,
166166

167167
if (netif_running(netdev)) {
168168
struct ethtool_cmd cmd;
169-
if (!__ethtool_get_settings(netdev, &cmd))
170-
ret = sprintf(buf, "%s\n",
171-
cmd.duplex ? "full" : "half");
169+
if (!__ethtool_get_settings(netdev, &cmd)) {
170+
const char *duplex;
171+
switch (cmd.duplex) {
172+
case DUPLEX_HALF:
173+
duplex = "half";
174+
break;
175+
case DUPLEX_FULL:
176+
duplex = "full";
177+
break;
178+
default:
179+
duplex = "unknown";
180+
break;
181+
}
182+
ret = sprintf(buf, "%s\n", duplex);
183+
}
172184
}
173185
rtnl_unlock();
174186
return ret;

0 commit comments

Comments
 (0)