Thread (21 messages) flat view 21 messages, 6 authors, 2022-05-14
STALE1543d

[PATCH net 07/12] ipv6: always put IFLA_LINK for devices with ndo_get_iflink

From: Sabrina Dubroca <sd@queasysnail.net>
Date: 2020-10-01 08:07:18
Subsystem: networking [general], networking [ipv4/ipv6], the rest · Maintainers: "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, David Ahern, Ido Schimmel, Linus Torvalds

IPv6 tries to detect if devices have a lower link when dumping
addresses, but that detection doesn't work when the device and its
link have the same ifindex.

In this setup:
    ip netns add main
    ip netns add peer
    ip -net main link add dummy0 type dummy # ifidx 9
    ip -net main link add link dummy0 macvlan0 up netns peer type macvlan # ifidx 9

We'll get:
    ip -net peer -6 a
        9: macvlan0: <snip>

Instead of:
    ip -net peer -6 a
        9: macvlan0@if9: <snip>

Instead of calling dev_get_iflink(), we can use the existence of the
ndo_get_iflink operation (which dev_get_iflink would call) to check if
a device has a lower link.

Fixes: d8a5ec672768 ("[NET]: netlink support for moving devices between network namespaces.")
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
---
 net/ipv6/addrconf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 01146b66d666..688e441a8699 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -5835,7 +5835,7 @@ static int inet6_fill_ifinfo(struct sk_buff *skb, struct inet6_dev *idev,
 	    (dev->addr_len &&
 	     nla_put(skb, IFLA_ADDRESS, dev->addr_len, dev->dev_addr)) ||
 	    nla_put_u32(skb, IFLA_MTU, dev->mtu) ||
-	    (dev->ifindex != dev_get_iflink(dev) &&
+	    (dev->netdev_ops && dev->netdev_ops->ndo_get_iflink &&
 	     nla_put_u32(skb, IFLA_LINK, dev_get_iflink(dev))) ||
 	    nla_put_u8(skb, IFLA_OPERSTATE,
 		       netif_running(dev) ? dev->operstate : IF_OPER_DOWN))
-- 
2.28.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help