diff mbox

[v4] net: fix hw_features ethtool_ops->set_flags compatibility

Message ID 20110421235921.89D1D13909@rere.qmqm.pl
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Michał Mirosław April 21, 2011, 11:59 p.m. UTC
__ethtool_set_flags() was not taking into account features set but not
user-toggleable.

Since GFLAGS returns masked dev->features, EINVAL is returned when
passed flags differ to it, and not to wanted_features.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
This should be the simpler way Ben was talking about.

 net/core/ethtool.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Comments

David Miller April 22, 2011, 12:21 a.m. UTC | #1
From: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Date: Fri, 22 Apr 2011 01:59:21 +0200 (CEST)

> __ethtool_set_flags() was not taking into account features set but not
> user-toggleable.
> 
> Since GFLAGS returns masked dev->features, EINVAL is returned when
> passed flags differ to it, and not to wanted_features.
> 
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> ---
> This should be the simpler way Ben was talking about.

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Eric Dumazet April 22, 2011, 5:16 a.m. UTC | #2
Le vendredi 22 avril 2011 à 01:59 +0200, Michał Mirosław a écrit :
> __ethtool_set_flags() was not taking into account features set but not
> user-toggleable.
> 
> Since GFLAGS returns masked dev->features, EINVAL is returned when
> passed flags differ to it, and not to wanted_features.
> 
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> ---
> This should be the simpler way Ben was talking about.
> 
>  net/core/ethtool.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/net/core/ethtool.c b/net/core/ethtool.c
> index 13d79f5..d8b1a8d 100644
> --- a/net/core/ethtool.c
> +++ b/net/core/ethtool.c
> @@ -546,12 +546,12 @@ int __ethtool_set_flags(struct net_device *dev, u32 data)
>  	}
>  
>  	/* allow changing only bits set in hw_features */
> -	changed = (data ^ dev->wanted_features) & flags_dup_features;
> +	changed = (data ^ dev->features) & flags_dup_features;
>  	if (changed & ~dev->hw_features)
>  		return (changed & dev->hw_features) ? -EINVAL : -EOPNOTSUPP;
>  
>  	dev->wanted_features =
> -		(dev->wanted_features & ~changed) | data;
> +		(dev->wanted_features & ~changed) | (data & dev->hw_features);
>  
>  	__netdev_update_features(dev);
>  

Reported-by: Eric Dumazet <eric.dumazet@gmail.com>
Tested-by: Eric Dumazet <eric.dumazet@gmail.com>

Thanks, this solves the bnx2x problem !


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Eric Dumazet April 22, 2011, 5:27 a.m. UTC | #3
Le vendredi 22 avril 2011 à 07:16 +0200, Eric Dumazet a écrit :

> Reported-by: Eric Dumazet <eric.dumazet@gmail.com>
> Tested-by: Eric Dumazet <eric.dumazet@gmail.com>
> 
> Thanks, this solves the bnx2x problem !
> 

And already in net-next-2.6 ;)



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 13d79f5..d8b1a8d 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -546,12 +546,12 @@  int __ethtool_set_flags(struct net_device *dev, u32 data)
 	}
 
 	/* allow changing only bits set in hw_features */
-	changed = (data ^ dev->wanted_features) & flags_dup_features;
+	changed = (data ^ dev->features) & flags_dup_features;
 	if (changed & ~dev->hw_features)
 		return (changed & dev->hw_features) ? -EINVAL : -EOPNOTSUPP;
 
 	dev->wanted_features =
-		(dev->wanted_features & ~changed) | data;
+		(dev->wanted_features & ~changed) | (data & dev->hw_features);
 
 	__netdev_update_features(dev);