Skip to content

Commit 1cccd90

Browse files
edumazetSasha Levin
authored andcommitted
net-sysfs: restore behavior for not running devices
[ Upstream commit 75bc3da ] modprobe dummy dumdummies=1 Old behavior : $ cat /sys/class/net/dummy0/carrier cat: /sys/class/net/dummy0/carrier: Invalid argument After blamed commit, an empty string is reported. $ cat /sys/class/net/dummy0/carrier $ In this commit, I restore the old behavior for carrier, speed and duplex attributes. Fixes: 79c6189 ("net-sysfs: remove rtnl_trylock from device attributes") Signed-off-by: Eric Dumazet <edumazet@google.com> Reported-by: Marco Leogrande <leogrande@google.com> Reviewed-by: Antoine Tenart <atenart@kernel.org> Link: https://patch.msgid.link/20250221051223.576726-1-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 5771f6a commit 1cccd90

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

net/core/net-sysfs.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,12 @@ static ssize_t carrier_show(struct device *dev,
232232
struct device_attribute *attr, char *buf)
233233
{
234234
struct net_device *netdev = to_net_dev(dev);
235-
int ret = -EINVAL;
235+
int ret;
236236

237237
if (!rtnl_trylock())
238238
return restart_syscall();
239239

240+
ret = -EINVAL;
240241
if (netif_running(netdev)) {
241242
/* Synchronize carrier state with link watch,
242243
* see also rtnl_getlink().
@@ -266,6 +267,7 @@ static ssize_t speed_show(struct device *dev,
266267
if (!rtnl_trylock())
267268
return restart_syscall();
268269

270+
ret = -EINVAL;
269271
if (netif_running(netdev)) {
270272
struct ethtool_link_ksettings cmd;
271273

@@ -292,6 +294,7 @@ static ssize_t duplex_show(struct device *dev,
292294
if (!rtnl_trylock())
293295
return restart_syscall();
294296

297+
ret = -EINVAL;
295298
if (netif_running(netdev)) {
296299
struct ethtool_link_ksettings cmd;
297300

0 commit comments

Comments
 (0)