netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BUG] rtnl_newlink: Rogue MOVE event delivered on netns change
@ 2023-10-10 12:10 Daniel Gröber
  2023-10-13 22:36 ` Jakub Kicinski
  0 siblings, 1 reply; 10+ messages in thread
From: Daniel Gröber @ 2023-10-10 12:10 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: netdev, Richard Weinberger

Hi netdev,

Changing a device's netns and renaming it with one RTM_NEWLINK call causes
a rogue MOVE uevent to be delivered to the new netns in addition to the
expected ADD uevent.

iproute2 reproducer:

    $ ip netns add test
    $ ip link add dev eth0 netns test type dummy
    $ ip link add dev eth0 type dummy

    $ ip -netns test link set dev eth0 netns 1 name eth123

With the last command, which renames the device and moves it out of the
netns, we get the following:

    $ udevadm monitor -k
    KERNEL[230953.424834] add      /devices/virtual/net/eth0 (net)
    KERNEL[230953.424914] move     /devices/virtual/net/eth0 (net)
    KERNEL[230953.425066] move     /devices/virtual/net/eth123 (net)

The problem is the MOVE event hooribly confuses userspace. The particular
symptom we're seing is that systemd will bring down the ifup@eth0.service
on the host as it handles the MOVE of eth0->eth123 as a stop for the
BoundTo sys-subsystem-net-devices-eth0.device unit.

I also create a clashing eth0 device on the host in the repro to
demonstrate that the RTM_NETLINK move+rename call is atomic and so the MOVE
event is entirely nonsensical.

Looking at the code in __rtnl_newlink I see do_setlink first calls
__dev_change_net_namespace and then dev_change_name. My guess is the order
is just wrong here.

Thanks,
--Daniel

PS: Full debugging log in https://github.com/lxc/incus/issues/146

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

end of thread, other threads:[~2023-11-11  2:13 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-10 12:10 [BUG] rtnl_newlink: Rogue MOVE event delivered on netns change Daniel Gröber
2023-10-13 22:36 ` Jakub Kicinski
2023-10-13 22:43   ` Jakub Kicinski
2023-10-14  8:58     ` Greg Kroah-Hartman
2023-10-16 14:32       ` Jakub Kicinski
2023-10-16 17:20         ` Greg Kroah-Hartman
2023-10-16 19:03           ` Jakub Kicinski
2023-10-17  1:20           ` Daniel Gröber
2023-10-17  1:45             ` Jakub Kicinski
2023-11-11  2:13               ` [RFC net-next] net: do not send a MOVE event when netdev changes netns Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).