On Fri, Jul 7, 2017 at 5:39 AM, Nicolas Dichtel <nicolas.dich...@6wind.com> wrote: > Le 06/07/2017 à 20:16, Cong Wang a écrit : >> On Thu, Jul 6, 2017 at 5:08 AM, Nicolas Dichtel >> <nicolas.dich...@6wind.com> wrote: >>> Le 06/07/2017 à 00:43, Cong Wang a écrit : >>>> On Wed, Jul 5, 2017 at 8:57 AM, Nicolas Dichtel >>>> <nicolas.dich...@6wind.com> wrote: >>>>> When a device changes from one netns to another, it's first unregistered, >>>>> then the netns reference is updated and the dev is registered in the new >>>>> netns. Thus, when a slave moves to another netns, it is first >>>>> unregistered. This triggers a NETDEV_UNREGISTER event which is caught by >>>>> the bonding driver. The driver calls bond_release(), which calls >>>>> dev_set_mtu() and thus triggers NETDEV_CHANGEMTU (the device is still in >>>>> the old netns). >>>> >>>> I think in this special case it is meaningless to send >>>> NETDEV_CHANGEMTU, because the device is dying within >>>> its old netns, who still cares about its mtu change? >>>> >>>> Something like the attached patch... >>> Yes, your patch seems good and I hesitated with something like this. >>> But I don't see a valid case where the inet[6]dev must be created on a down >>> interface. I think the patch is valid, even with your patch. >> >> Your patch is more risky because it affects normal CHANGEMTU path, >> I am not sure if it is correct to not to add idev when it is down either. > Why would it be needed to add this idev on a down interface? > If idev wasn't there I don't see why changing the mtu would justify to create > this idev. >
There must be a reason to check idev->if_flags & IF_READY instead of IFF_UP. >> >> This is a very unusual path, we don't have to take the risk. > I still think that this approach is better for two reasons: > - we don't know if another path like this exists (need an audit) and it would > be easy to add one again by side effect in the future; Perhaps we need to add a warning for these events triggered after UNREGISTER, except UNREGISTER_FINAL, in case of trouble. But again, the CHANGEMTU case is so special because of the idev. > - the patch is easy to backport in older kernel. > Easy to backport doesn't mean easy to verify. ;) As David said, this code is mess, especially for the keep_addr_on_down logic.