Currently, we're not advertising link-netnsid when dumping IPv6 addresses, so the "ip -6 addr" command will not correctly interpret the value of the IFLA_LINK attribute.
For example, we'll get: 9: macvlan0@macvlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP qlen 1000 <snip> Instead of: 9: macvlan0@if9: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP qlen 1000 link-netns main <snip> ndisc_ifinfo_sysctl_change calls inet6_fill_ifinfo without rcu or rtnl, so I'm adding rcu_read_lock around rtnl_fill_link_netnsid. Signed-off-by: Sabrina Dubroca <s...@queasysnail.net> --- net/ipv6/addrconf.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index 688e441a8699..fb95c0227dfe 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c @@ -5533,6 +5533,7 @@ static inline size_t inet6_if_nlmsg_size(void) + nla_total_size(MAX_ADDR_LEN) /* IFLA_ADDRESS */ + nla_total_size(4) /* IFLA_MTU */ + nla_total_size(4) /* IFLA_LINK */ + + nla_total_size(4) /* IFLA_LINK_NETNSID */ + nla_total_size(1) /* IFLA_OPERSTATE */ + nla_total_size(inet6_ifla6_size()); /* IFLA_PROTINFO */ } @@ -5840,6 +5841,14 @@ static int inet6_fill_ifinfo(struct sk_buff *skb, struct inet6_dev *idev, nla_put_u8(skb, IFLA_OPERSTATE, netif_running(dev) ? dev->operstate : IF_OPER_DOWN)) goto nla_put_failure; + + rcu_read_lock(); + if (rtnl_fill_link_netnsid(skb, dev, dev_net(dev), GFP_ATOMIC)) { + rcu_read_unlock(); + goto nla_put_failure; + } + rcu_read_unlock(); + protoinfo = nla_nest_start_noflag(skb, IFLA_PROTINFO); if (!protoinfo) goto nla_put_failure; -- 2.28.0