All of lore.kernel.org
 help / color / mirror / Atom feed
* [RESEND net-next PATCH] net: rtnetlink: Enslave device before bringing it up
@ 2022-09-14 15:06 Phil Sutter
  2022-09-18 15:48 ` David Ahern
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Phil Sutter @ 2022-09-14 15:06 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, dsahern

Unlike with bridges, one can't add an interface to a bond and set it up
at the same time:

| # ip link set dummy0 down
| # ip link set dummy0 master bond0 up
| Error: Device can not be enslaved while up.

Of all drivers with ndo_add_slave callback, bond and team decline if
IFF_UP flag is set, vrf cycles the interface (i.e., sets it down and
immediately up again) and the others just don't care.

Support the common notion of setting the interface up after enslaving it
by sorting the operations accordingly.

Signed-off-by: Phil Sutter <phil@nwl.cc>
---
Resubmitting this after review, concerns uttered in original discussion
three years ago do not apply: Any flag changes happening during
do_set_master() call are preserved, unless user space intended to change
them. I verified that a team device in promisc mode still correctly
propagates the flag to a new slave after applying this patch.
---
 net/core/rtnetlink.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index ac45328607f77..2e15f744544e5 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -2776,13 +2776,6 @@ static int do_setlink(const struct sk_buff *skb,
 		call_netdevice_notifiers(NETDEV_CHANGEADDR, dev);
 	}
 
-	if (ifm->ifi_flags || ifm->ifi_change) {
-		err = dev_change_flags(dev, rtnl_dev_combine_flags(dev, ifm),
-				       extack);
-		if (err < 0)
-			goto errout;
-	}
-
 	if (tb[IFLA_MASTER]) {
 		err = do_set_master(dev, nla_get_u32(tb[IFLA_MASTER]), extack);
 		if (err)
@@ -2790,6 +2783,13 @@ static int do_setlink(const struct sk_buff *skb,
 		status |= DO_SETLINK_MODIFIED;
 	}
 
+	if (ifm->ifi_flags || ifm->ifi_change) {
+		err = dev_change_flags(dev, rtnl_dev_combine_flags(dev, ifm),
+				       extack);
+		if (err < 0)
+			goto errout;
+	}
+
 	if (tb[IFLA_CARRIER]) {
 		err = dev_change_carrier(dev, nla_get_u8(tb[IFLA_CARRIER]));
 		if (err)
-- 
2.34.1


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

* Re: [RESEND net-next PATCH] net: rtnetlink: Enslave device before bringing it up
  2022-09-14 15:06 [RESEND net-next PATCH] net: rtnetlink: Enslave device before bringing it up Phil Sutter
@ 2022-09-18 15:48 ` David Ahern
  2022-09-20 15:50 ` patchwork-bot+netdevbpf
  2022-09-26 11:13 ` Jiri Pirko
  2 siblings, 0 replies; 4+ messages in thread
From: David Ahern @ 2022-09-18 15:48 UTC (permalink / raw)
  To: Phil Sutter, David Miller; +Cc: netdev

On 9/14/22 9:06 AM, Phil Sutter wrote:
> Unlike with bridges, one can't add an interface to a bond and set it up
> at the same time:
> 
> | # ip link set dummy0 down
> | # ip link set dummy0 master bond0 up
> | Error: Device can not be enslaved while up.
> 
> Of all drivers with ndo_add_slave callback, bond and team decline if
> IFF_UP flag is set, vrf cycles the interface (i.e., sets it down and
> immediately up again) and the others just don't care.
> 
> Support the common notion of setting the interface up after enslaving it
> by sorting the operations accordingly.
> 
> Signed-off-by: Phil Sutter <phil@nwl.cc>
> ---
> Resubmitting this after review, concerns uttered in original discussion
> three years ago do not apply: Any flag changes happening during
> do_set_master() call are preserved, unless user space intended to change
> them. I verified that a team device in promisc mode still correctly
> propagates the flag to a new slave after applying this patch.
> ---
>  net/core/rtnetlink.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 

Reviewed-by: David Ahern <dsahern@kernel.org>



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

* Re: [RESEND net-next PATCH] net: rtnetlink: Enslave device before bringing it up
  2022-09-14 15:06 [RESEND net-next PATCH] net: rtnetlink: Enslave device before bringing it up Phil Sutter
  2022-09-18 15:48 ` David Ahern
@ 2022-09-20 15:50 ` patchwork-bot+netdevbpf
  2022-09-26 11:13 ` Jiri Pirko
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-09-20 15:50 UTC (permalink / raw)
  To: Phil Sutter; +Cc: davem, netdev, dsahern

Hello:

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

On Wed, 14 Sep 2022 17:06:23 +0200 you wrote:
> Unlike with bridges, one can't add an interface to a bond and set it up
> at the same time:
> 
> | # ip link set dummy0 down
> | # ip link set dummy0 master bond0 up
> | Error: Device can not be enslaved while up.
> 
> [...]

Here is the summary with links:
  - [RESEND,net-next] net: rtnetlink: Enslave device before bringing it up
    https://git.kernel.org/netdev/net-next/c/a4abfa627c38

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

* Re: [RESEND net-next PATCH] net: rtnetlink: Enslave device before bringing it up
  2022-09-14 15:06 [RESEND net-next PATCH] net: rtnetlink: Enslave device before bringing it up Phil Sutter
  2022-09-18 15:48 ` David Ahern
  2022-09-20 15:50 ` patchwork-bot+netdevbpf
@ 2022-09-26 11:13 ` Jiri Pirko
  2 siblings, 0 replies; 4+ messages in thread
From: Jiri Pirko @ 2022-09-26 11:13 UTC (permalink / raw)
  To: Phil Sutter; +Cc: David Miller, netdev, dsahern

Wed, Sep 14, 2022 at 05:06:23PM CEST, phil@nwl.cc wrote:
>Unlike with bridges, one can't add an interface to a bond and set it up
>at the same time:
>
>| # ip link set dummy0 down
>| # ip link set dummy0 master bond0 up
>| Error: Device can not be enslaved while up.
>
>Of all drivers with ndo_add_slave callback, bond and team decline if
>IFF_UP flag is set, vrf cycles the interface (i.e., sets it down and
>immediately up again) and the others just don't care.
>
>Support the common notion of setting the interface up after enslaving it
>by sorting the operations accordingly.
>
>Signed-off-by: Phil Sutter <phil@nwl.cc>

Reviewed-by: Jiri Pirko <jiri@nvidia.com>

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

end of thread, other threads:[~2022-09-26 12:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-14 15:06 [RESEND net-next PATCH] net: rtnetlink: Enslave device before bringing it up Phil Sutter
2022-09-18 15:48 ` David Ahern
2022-09-20 15:50 ` patchwork-bot+netdevbpf
2022-09-26 11:13 ` Jiri Pirko

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.