linkwatch_urgent_event can miss urgent events when the device and its
link have the same ifindex, which can happen when those devices are in
different network namespaces.

With this setup, the vlan0 device can remain in LOWERLAYERDOWN state
for a full second (the linkwatch delay for non-urgent events), while
the vlan1 device will come up immediately:

    ip netns add a
    ip netns add b
    ip -net a link add dummy0 type dummy
    ip -net a link add link dummy0 vlan0 netns b type vlan id 1
    ip -net a link add link dummy0 vlan1 netns b type vlan id 2

    ip -net a link set dummy0 up
    ip -net b link set vlan1 down ; ip -net b link set vlan0 down
    sleep 2
    ip -net b link set vlan1 up   ; ip -net b link set vlan0 up

Fixes: d8a5ec672768 ("[NET]: netlink support for moving devices between network 
namespaces.")
Signed-off-by: Sabrina Dubroca <s...@queasysnail.net>
---
 net/core/link_watch.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/link_watch.c b/net/core/link_watch.c
index 6932ad51aa4a..8a5d0ab820f9 100644
--- a/net/core/link_watch.c
+++ b/net/core/link_watch.c
@@ -92,7 +92,7 @@ static bool linkwatch_urgent_event(struct net_device *dev)
        if (!netif_running(dev))
                return false;
 
-       if (dev->ifindex != dev_get_iflink(dev))
+       if (dev->netdev_ops && dev->netdev_ops->ndo_get_iflink)
                return true;
 
        if (netif_is_lag_port(dev) || netif_is_lag_master(dev))
-- 
2.28.0

Reply via email to