Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rtnetlink: allow rtnl_fill_link_netnsid() to run under RCU protection

We want to be able to run rtnl_fill_ifinfo() under RCU protection
instead of RTNL in the future.

All rtnl_link_ops->get_link_net() methods already using dev_net()
are ready. I added READ_ONCE() annotations on others.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Eric Dumazet and committed by
Paolo Abeni
9cf621bd 979aad40

+7 -8
+1 -1
drivers/net/ppp/ppp_generic.c
··· 1357 1357 { 1358 1358 struct ppp *ppp = netdev_priv(dev); 1359 1359 1360 - return ppp->ppp_net; 1360 + return READ_ONCE(ppp->ppp_net); 1361 1361 } 1362 1362 1363 1363 static struct rtnl_link_ops ppp_link_ops __read_mostly = {
+1 -1
drivers/net/vxlan/vxlan_core.c
··· 4569 4569 { 4570 4570 struct vxlan_dev *vxlan = netdev_priv(dev); 4571 4571 4572 - return vxlan->net; 4572 + return READ_ONCE(vxlan->net); 4573 4573 } 4574 4574 4575 4575 static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
+2 -3
net/core/rtnetlink.c
··· 1923 1923 goto nla_put_failure; 1924 1924 } 1925 1925 1926 - if (rtnl_fill_link_netnsid(skb, dev, src_net, gfp)) 1927 - goto nla_put_failure; 1928 - 1929 1926 if (new_nsid && 1930 1927 nla_put_s32(skb, IFLA_NEW_NETNSID, *new_nsid) < 0) 1931 1928 goto nla_put_failure; ··· 1935 1938 goto nla_put_failure; 1936 1939 1937 1940 rcu_read_lock(); 1941 + if (rtnl_fill_link_netnsid(skb, dev, src_net, GFP_ATOMIC)) 1942 + goto nla_put_failure_rcu; 1938 1943 qdisc = rcu_dereference(dev->qdisc); 1939 1944 if (qdisc && nla_put_string(skb, IFLA_QDISC, qdisc->ops->id)) 1940 1945 goto nla_put_failure_rcu;
+1 -1
net/ipv4/ip_tunnel.c
··· 1120 1120 { 1121 1121 struct ip_tunnel *tunnel = netdev_priv(dev); 1122 1122 1123 - return tunnel->net; 1123 + return READ_ONCE(tunnel->net); 1124 1124 } 1125 1125 EXPORT_SYMBOL(ip_tunnel_get_link_net); 1126 1126
+1 -1
net/ipv6/ip6_tunnel.c
··· 2146 2146 { 2147 2147 struct ip6_tnl *tunnel = netdev_priv(dev); 2148 2148 2149 - return tunnel->net; 2149 + return READ_ONCE(tunnel->net); 2150 2150 } 2151 2151 EXPORT_SYMBOL(ip6_tnl_get_link_net); 2152 2152
+1 -1
net/xfrm/xfrm_interface_core.c
··· 926 926 { 927 927 struct xfrm_if *xi = netdev_priv(dev); 928 928 929 - return xi->net; 929 + return READ_ONCE(xi->net); 930 930 } 931 931 932 932 static const struct nla_policy xfrmi_policy[IFLA_XFRM_MAX + 1] = {