net-sysfs: restore behavior for not running devices
Subsystems (2)
PATCH 1/1 net-sysfs: restore behavior for not running devices
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.
--- net/core/net-sysfs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/core/net-sysfs.c +4 -1
@@ -313,12 +313,13 @@ static ssize_t carrier_show(struct device *dev, struct device_attribute *attr, char *buf) { struct net_device *netdev = to_net_dev(dev); -int ret = -EINVAL ; +int ret; ret =sysfs_rtnl_lock (&dev->kobj, &attr->attr, netdev);if (ret)return ret; + ret = -EINVAL ;if (netif_running (netdev)) {/* Synchronize carrier state with link watch, * see also rtnl_getlink().
@@ -349,6 +350,7 @@ static ssize_t speed_show(struct device *dev,if (ret)return ret; + ret = -EINVAL ;if (netif_running (netdev)) {struct ethtool_link_ksettings cmd;
@@ -376,6 +378,7 @@ static ssize_t duplex_show(struct device *dev,if (ret)return ret; + ret = -EINVAL ;if (netif_running (netdev)) {struct ethtool_link_ksettings cmd;
Signature · 1 line
2.48.1.601.g30ceb7b040-goog
Quoted 10 lines · Eric Dumazet
modprobe dummy dumdummies=1
Old behavior :
$ cat /sys/class/net/dummy0/carrier cat: /sys/class/net/dummy0/carrier: Invalid argumentAfter blamed commit, an empty string is reported.
Quoted 8 lines
$ cat /sys/class/net/dummy0/carrier $In this commit, I restore the old behavior for carrier, speed and duplex attributes.
Fixes 79c61899b5ee ("net-sysfs: remove rtnl_trylock from device attributes")Signed-off-by Eric Dumazet <[email protected]>
If possible, can we add :
Thanks !
Quoting Eric Dumazet (2025-02-21 06:12:23)
Quoted 9 lines
modprobe dummy dumdummies=1
Old behavior :
$ cat /sys/class/net/dummy0/carrier cat: /sys/class/net/dummy0/carrier: Invalid argumentAfter blamed commit, an empty string is reported.
Quoted 8 lines
$ cat /sys/class/net/dummy0/carrier $In this commit, I restore the old behavior for carrier, speed and duplex attributes.
Fixes 79c61899b5ee ("net-sysfs: remove rtnl_trylock from device attributes")Signed-off-by Eric Dumazet <[email protected]>
Thanks!
Quoted 43 lines
--- net/core/net-sysfs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)net/core/net-sysfs.c +4
-1@@ -313,12 +313,13 @@ static ssize_t carrier_show(struct device *dev, struct device_attribute *attr, char *buf) { struct net_device *netdev = to_net_dev(dev); -int ret = -EINVAL ; +int ret; ret =sysfs_rtnl_lock (&dev->kobj, &attr->attr, netdev);if (ret)return ret; + ret = -EINVAL ;if (netif_running (netdev)) {/* Synchronize carrier state with link watch, * see also rtnl_getlink(). @@ -349,6 +350,7 @@ static ssize_t speed_show(struct device *dev,if (ret)return ret; + ret = -EINVAL ;if (netif_running (netdev)) {struct ethtool_link_ksettings cmd;@@ -376,6 +378,7 @@ static ssize_t duplex_show(struct device *dev,if (ret)return ret; + ret = -EINVAL ;if (netif_running (netdev)) {struct ethtool_link_ksettings cmd;Signature · 1 line
2.48.1.601.g30ceb7b040-goog
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Fri, 21 Feb 2025 05:12:23 +0000 you wrote:
modprobe dummy dumdummies=1
Old behavior :
$ cat /sys/class/net/dummy0/carrier cat: /sys/class/net/dummy0/carrier: Invalid argument[...]
Here is the summary with links:
- [net-next] net-sysfs: restore behavior for not running devices
https://git.kernel.org/netdev/net-next/c/75bc3dab4e49
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html