Subject: Re: [BUG] rtnl_newlink: Rogue MOVE event delivered on netns change

From: Jakub Kicinski <[email-masked]>
Date: Mon, 16 Oct 2023 18:45:14 -0700

On Tue, 17 Oct 2023 03:20:24 +0200 Daniel Gröber wrote:
> > 1. we have tb[IFLA_IFNAME] set, so do_setlink() will populate ifname
> > 
> > 2. Because of #1, __dev_change_net_namespace() gets called with 
> >    new name provide (pat = eth123)
> > 
> > 3. It will do netdev_name_in_use(), which returns true.  
> 
> At this point we're still looking at the old netns, right?

New one, already. We got it from the caller and the caller
from rtnl_link_get_net_capable().

> > 7. Now we finally call:
> > 
> >    err = device_rename(&dev->dev, dev->name);
> > 
> > Which tells device core that the name has changed, and gives you 
> > the (second) MOVE event. This time with the correct name.  
> 
> I don't like loose ends. Any idea why we only see the one MOVE now?

No, annoyingly I haven't. But I do have a host on 5.19.

[ ~]# uname -r
5.19.13-200.fc36.x86_64
[ ~]# ip netns add test
[ ~]# udevadm monitor -k &
[ ~]# ip li add name eth0 type dummy
KERNEL[67.377539] add      /module/dummy (module)
KERNEL[67.381720] add      /devices/virtual/net/eth0 (net)
KERNEL[67.381822] add      /devices/virtual/net/eth0/queues/rx-0 (queues)
KERNEL[67.381854] add      /devices/virtual/net/eth0/queues/tx-0 (queues)
[ ~]# ip -netns test li add name eth0 type dummy
[ ~]# ip -netns test link set dev eth0 netns 1 name eth1
KERNEL[99.681956] add      /devices/virtual/net/eth0 (net)
KERNEL[99.681975] move     /devices/virtual/net/eth1 (net)

I don't see it on older kernels either :S