All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] net: fix __netdev_update_features return on ndo_set_features failure
@ 2015-11-13 14:20 Nikolay Aleksandrov
  2015-11-16 19:56 ` David Miller
  2015-11-17 13:54 ` Michał Mirosław
  0 siblings, 2 replies; 6+ messages in thread
From: Nikolay Aleksandrov @ 2015-11-13 14:20 UTC (permalink / raw)
  To: netdev; +Cc: davem, Nikolay Aleksandrov, Michał Mirosław

From: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>

If ndo_set_features fails __netdev_update_features() will return -1 but
this is wrong because it is expected to return 0 if no features were
changed (see netdev_update_features()), which will cause a netdev
notifier to be called without any actual changes. Fix this by returning
0 if ndo_set_features fails.

Fixes: 6cb6a27c45ce ("net: Call netdev_features_change() from netdev_update_features()")
CC: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
---
 net/core/dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index 4a1d198dbbff..1974aee005a6 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -6433,7 +6433,7 @@ int __netdev_update_features(struct net_device *dev)
 		netdev_err(dev,
 			"set_features() failed (%d); wanted %pNF, left %pNF\n",
 			err, &features, &dev->features);
-		return -1;
+		return 0;
 	}
 
 sync_lower:
-- 
2.4.3

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

* Re: [PATCH net] net: fix __netdev_update_features return on ndo_set_features failure
  2015-11-13 14:20 [PATCH net] net: fix __netdev_update_features return on ndo_set_features failure Nikolay Aleksandrov
@ 2015-11-16 19:56 ` David Miller
  2015-11-17 13:54 ` Michał Mirosław
  1 sibling, 0 replies; 6+ messages in thread
From: David Miller @ 2015-11-16 19:56 UTC (permalink / raw)
  To: razor; +Cc: netdev, nikolay, mirq-linux

From: Nikolay Aleksandrov <razor@blackwall.org>
Date: Fri, 13 Nov 2015 15:20:24 +0100

> From: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
> 
> If ndo_set_features fails __netdev_update_features() will return -1 but
> this is wrong because it is expected to return 0 if no features were
> changed (see netdev_update_features()), which will cause a netdev
> notifier to be called without any actual changes. Fix this by returning
> 0 if ndo_set_features fails.
> 
> Fixes: 6cb6a27c45ce ("net: Call netdev_features_change() from netdev_update_features()")
> CC: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>

Applied.

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

* Re: [PATCH net] net: fix __netdev_update_features return on ndo_set_features failure
  2015-11-13 14:20 [PATCH net] net: fix __netdev_update_features return on ndo_set_features failure Nikolay Aleksandrov
  2015-11-16 19:56 ` David Miller
@ 2015-11-17 13:54 ` Michał Mirosław
  2015-11-17 14:31   ` Nikolay Aleksandrov
  1 sibling, 1 reply; 6+ messages in thread
From: Michał Mirosław @ 2015-11-17 13:54 UTC (permalink / raw)
  To: Nikolay Aleksandrov; +Cc: netdev, davem, Nikolay Aleksandrov

On Fri, Nov 13, 2015 at 03:20:24PM +0100, Nikolay Aleksandrov wrote:
> From: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
> 
> If ndo_set_features fails __netdev_update_features() will return -1 but
> this is wrong because it is expected to return 0 if no features were
> changed (see netdev_update_features()), which will cause a netdev
> notifier to be called without any actual changes. Fix this by returning
> 0 if ndo_set_features fails.

Hmm. In case ndo_update_features() failed it might have changed the features.
The assumption I made was that we're better off initiating spurious notification
than miss one. This is an unlikely event - a bug in a driver or problem with the HW.

Best Regards,
Michał Mirosław

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

* Re: [PATCH net] net: fix __netdev_update_features return on ndo_set_features failure
  2015-11-17 13:54 ` Michał Mirosław
@ 2015-11-17 14:31   ` Nikolay Aleksandrov
  2015-11-17 14:49     ` [PATCH net] net/core: revert "net: fix __netdev_update_features return.." and add comment Nikolay Aleksandrov
  0 siblings, 1 reply; 6+ messages in thread
From: Nikolay Aleksandrov @ 2015-11-17 14:31 UTC (permalink / raw)
  To: Michał Mirosław, Nikolay Aleksandrov; +Cc: netdev, davem

On 11/17/2015 02:54 PM, Michał Mirosław wrote:
> On Fri, Nov 13, 2015 at 03:20:24PM +0100, Nikolay Aleksandrov wrote:
>> From: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
>>
>> If ndo_set_features fails __netdev_update_features() will return -1 but
>> this is wrong because it is expected to return 0 if no features were
>> changed (see netdev_update_features()), which will cause a netdev
>> notifier to be called without any actual changes. Fix this by returning
>> 0 if ndo_set_features fails.
> 
> Hmm. In case ndo_update_features() failed it might have changed the features.
> The assumption I made was that we're better off initiating spurious notification
> than miss one. This is an unlikely event - a bug in a driver or problem with the HW.
> 
> Best Regards,
> Michał Mirosław
> 

Hmm, good point. I went over a dozen drivers and I can see that some might
actually do that (e.g. bnx2x in bnx2x_set_features()). It's rare but possible,
most of them return only 0.
Okay then, I'll revert this change and add a comment with this so it's clear
in the future.

Thanks for the feedback,
 Nik

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

* [PATCH net] net/core: revert "net: fix __netdev_update_features return.." and add comment
  2015-11-17 14:31   ` Nikolay Aleksandrov
@ 2015-11-17 14:49     ` Nikolay Aleksandrov
  2015-11-17 20:27       ` David Miller
  0 siblings, 1 reply; 6+ messages in thread
From: Nikolay Aleksandrov @ 2015-11-17 14:49 UTC (permalink / raw)
  To: netdev; +Cc: davem, Nikolay Aleksandrov, Michał Mirosław

From: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>

This reverts commit 00ee59271777 ("net: fix __netdev_update_features return
on ndo_set_features failure")
and adds a comment explaining why it's okay to return a value other than
0 upon error. Some drivers might actually change flags and return an
error so it's better to fire a spurious notification rather than miss
these.

CC: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
---
Thanks to Michal for the explanation on why it was made to act like that.
Also sorry for the noise, unfortunately I missed this. IMO this should've
been an all or nothing op from the beginning.

 net/core/dev.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index 5dbc86ea6b58..ae00b894e675 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -6436,7 +6436,10 @@ int __netdev_update_features(struct net_device *dev)
 		netdev_err(dev,
 			"set_features() failed (%d); wanted %pNF, left %pNF\n",
 			err, &features, &dev->features);
-		return 0;
+		/* return non-0 since some features might have changed and
+		 * it's better to fire a spurious notification than miss it
+		 */
+		return -1;
 	}
 
 sync_lower:
-- 
2.4.3

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

* Re: [PATCH net] net/core: revert "net: fix __netdev_update_features return.." and add comment
  2015-11-17 14:49     ` [PATCH net] net/core: revert "net: fix __netdev_update_features return.." and add comment Nikolay Aleksandrov
@ 2015-11-17 20:27       ` David Miller
  0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2015-11-17 20:27 UTC (permalink / raw)
  To: razor; +Cc: netdev, nikolay, mirq-linux

From: Nikolay Aleksandrov <razor@blackwall.org>
Date: Tue, 17 Nov 2015 15:49:06 +0100

> From: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
> 
> This reverts commit 00ee59271777 ("net: fix __netdev_update_features return
> on ndo_set_features failure")
> and adds a comment explaining why it's okay to return a value other than
> 0 upon error. Some drivers might actually change flags and return an
> error so it's better to fire a spurious notification rather than miss
> these.
> 
> CC: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
> ---
> Thanks to Michal for the explanation on why it was made to act like that.
> Also sorry for the noise, unfortunately I missed this. IMO this should've
> been an all or nothing op from the beginning.

Applied.

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

end of thread, other threads:[~2015-11-17 20:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-13 14:20 [PATCH net] net: fix __netdev_update_features return on ndo_set_features failure Nikolay Aleksandrov
2015-11-16 19:56 ` David Miller
2015-11-17 13:54 ` Michał Mirosław
2015-11-17 14:31   ` Nikolay Aleksandrov
2015-11-17 14:49     ` [PATCH net] net/core: revert "net: fix __netdev_update_features return.." and add comment Nikolay Aleksandrov
2015-11-17 20:27       ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.