Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next] net-sysfs: restore behavior for not running devices
@ 2025-02-21  5:12 Eric Dumazet
  2025-02-21 16:38 ` Eric Dumazet
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Eric Dumazet @ 2025-02-21  5:12 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski, Paolo Abeni
  Cc: Simon Horman, netdev, Antoine Tenart, eric.dumazet, Eric Dumazet

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: 79c61899b5ee ("net-sysfs: remove rtnl_trylock from device attributes")
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 net/core/net-sysfs.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 3fe2c521e5740436687f09c572754c5d071038f4..f61c1d829811941671981a395fc4cbc57cf48d23 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -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;
 
-- 
2.48.1.601.g30ceb7b040-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] net-sysfs: restore behavior for not running devices
  2025-02-21  5:12 [PATCH net-next] net-sysfs: restore behavior for not running devices Eric Dumazet
@ 2025-02-21 16:38 ` Eric Dumazet
  2025-02-24  8:23 ` Antoine Tenart
  2025-02-24 22:30 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Dumazet @ 2025-02-21 16:38 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski, Paolo Abeni
  Cc: Simon Horman, netdev, Antoine Tenart, eric.dumazet

On Fri, Feb 21, 2025 at 6:12 AM Eric Dumazet <edumazet@google.com> wrote:
>
> 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: 79c61899b5ee ("net-sysfs: remove rtnl_trylock from device attributes")
> Signed-off-by: Eric Dumazet <edumazet@google.com>

If possible, can we add :

Reported-by: Marco Leogrande <leogrande@google.com>

Thanks !

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] net-sysfs: restore behavior for not running devices
  2025-02-21  5:12 [PATCH net-next] net-sysfs: restore behavior for not running devices Eric Dumazet
  2025-02-21 16:38 ` Eric Dumazet
@ 2025-02-24  8:23 ` Antoine Tenart
  2025-02-24 22:30 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Antoine Tenart @ 2025-02-24  8:23 UTC (permalink / raw)
  To: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: Simon Horman, netdev, eric.dumazet, Eric Dumazet

Quoting Eric Dumazet (2025-02-21 06:12:23)
> 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: 79c61899b5ee ("net-sysfs: remove rtnl_trylock from device attributes")
> Signed-off-by: Eric Dumazet <edumazet@google.com>

Reviewed-by: Antoine Tenart <atenart@kernel.org>

Thanks!

> ---
>  net/core/net-sysfs.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
> index 3fe2c521e5740436687f09c572754c5d071038f4..f61c1d829811941671981a395fc4cbc57cf48d23 100644
> --- a/net/core/net-sysfs.c
> +++ b/net/core/net-sysfs.c
> @@ -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;
>  
> -- 
> 2.48.1.601.g30ceb7b040-goog
> 
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] net-sysfs: restore behavior for not running devices
  2025-02-21  5:12 [PATCH net-next] net-sysfs: restore behavior for not running devices Eric Dumazet
  2025-02-21 16:38 ` Eric Dumazet
  2025-02-24  8:23 ` Antoine Tenart
@ 2025-02-24 22:30 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-02-24 22:30 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: davem, kuba, pabeni, horms, netdev, atenart, eric.dumazet

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-02-24 22:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-21  5:12 [PATCH net-next] net-sysfs: restore behavior for not running devices Eric Dumazet
2025-02-21 16:38 ` Eric Dumazet
2025-02-24  8:23 ` Antoine Tenart
2025-02-24 22:30 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox