When we create a macvlan device on top of a bond, the macvlan device
should always start with IF_OPER_LOWERLAYERDOWN if the bond is
down. Currently, this doesn't happen if the macvlan device gets the
same ifindex as the bond, which can happen because different
namespaces assign the ifindex independently:

    ip netns add main
    ip netns add peer
    ip -net main link add type bond # idx 9
    ip -net main link add link bond0 netns peer type macvlan # idx 10
    ip -net main link add link bond0 type macvlan # idx 9

    ip -net main link show type macvlan # M-DOWN since bond0 is DOWN
      10: macvlan0@bond0: <BROADCAST,MULTICAST,M-DOWN> ...

    ip -net peer link show type macvlan # should also be M-DOWN
       9: macvlan0@if9: <BROADCAST,MULTICAST> ...

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 75431ca9300f..6932ad51aa4a 100644
--- a/net/core/link_watch.c
+++ b/net/core/link_watch.c
@@ -38,7 +38,7 @@ static unsigned char default_operstate(const struct 
net_device *dev)
                return IF_OPER_TESTING;
 
        if (!netif_carrier_ok(dev))
-               return (dev->ifindex != dev_get_iflink(dev) ?
+               return (dev->netdev_ops && dev->netdev_ops->ndo_get_iflink ?
                        IF_OPER_LOWERLAYERDOWN : IF_OPER_DOWN);
 
        if (netif_dormant(dev))
-- 
2.28.0

Reply via email to