All of lore.kernel.org
 help / color / mirror / Atom feed
* net: netdev_sync_lower_features()
@ 2020-05-18  8:32 Michał Mirosław
  2020-05-18 19:14 ` Cong Wang
  0 siblings, 1 reply; 2+ messages in thread
From: Michał Mirosław @ 2020-05-18  8:32 UTC (permalink / raw)
  To: Cong Wang, Jarod Wilson; +Cc: netdev

Hi!

I just saw commit dd912306ff008 ("net: fix a potential recursive
NETDEV_FEAT_CHANGE") landing in Linux master. The problem with it (or
rather: with the netdev_sync_lower_features() function) is that
netdev_update_features() is allowed to change more than one feature
at a time, including force-enabling other feature than one that is
being disabled. I think that a better fix would be to trigger
notification only after all features are updated (outside of the loop).
When you consider net effect of the function, the loop's added value
is only to print debug messages. Other than that it's equivalent to:

lower->wanted_features &= ~upper_disables;
netdev_update_features(lower);

The problem of spurious notification can be fixed in
__netdev_update_features() by saving dev->features at the start and
only return -1 when it really changed.

BTW, I don't remember seeing the original commit fd867d51f889 ("net/core:
generic support for disabling netdev features down stack"). It looks
like it could have be implemented just by recursively calling
netdev_update_features() for lower devices - netdev_sync_upper_features()
called on their behalf should do just what netdev_sync_lower_features()
is doing now in the context of upper device, and also respect all the
other constraints we have on features.

Best Regards,
Michał Mirosław

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

* Re: net: netdev_sync_lower_features()
  2020-05-18  8:32 net: netdev_sync_lower_features() Michał Mirosław
@ 2020-05-18 19:14 ` Cong Wang
  0 siblings, 0 replies; 2+ messages in thread
From: Cong Wang @ 2020-05-18 19:14 UTC (permalink / raw)
  To: Michał Mirosław; +Cc: Jarod Wilson, Linux Kernel Network Developers

On Mon, May 18, 2020 at 1:32 AM Michał Mirosław <mirq-linux@rere.qmqm.pl> wrote:
>
> Hi!
>
> I just saw commit dd912306ff008 ("net: fix a potential recursive
> NETDEV_FEAT_CHANGE") landing in Linux master. The problem with it (or
> rather: with the netdev_sync_lower_features() function) is that
> netdev_update_features() is allowed to change more than one feature
> at a time, including force-enabling other feature than one that is
> being disabled. I think that a better fix would be to trigger
> notification only after all features are updated (outside of the loop).

Sounds reasonable. But I don't think this problem is introduced by
my commit, my commit merely skips the notification for the
failure.

> When you consider net effect of the function, the loop's added value
> is only to print debug messages. Other than that it's equivalent to:
>
> lower->wanted_features &= ~upper_disables;
> netdev_update_features(lower);
>
> The problem of spurious notification can be fixed in
> __netdev_update_features() by saving dev->features at the start and
> only return -1 when it really changed.

Please send a patch.

Thanks.

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

end of thread, other threads:[~2020-05-18 19:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-18  8:32 net: netdev_sync_lower_features() Michał Mirosław
2020-05-18 19:14 ` Cong Wang

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.