ipv6: add IPV6_CALL() helper
Subsystems (20)
PATCH 1/1 ipv6: add IPV6_CALL() helper
ipv6_stub use is racy, we should add READ_ONCE() and WRITE_ONCE(), even if this pointer can only change once.
Add IPV6_CALL() macro to factorize the READ_ONCE(), and perform direct calls when CONFIG_IPV6=y.
ipv6_stub->nd_tbl will need a separate patch.
$ size vmlinux.old vmlinux.new text data bss dec hex filename 37705007 23152761 4747540 65605308 3e90ebc vmlinux.0 37702861 23152665 4747540 65603066 3e905fa vmlinux
$ scripts/bloat-o-meter -t vmlinux.old vmlinux.new add/remove: 0/22 grow/shrink: 0/25 up/down: 0/-1025 (-1025) Function old new delta nexthop_select_path 832 828 -4 ipv4_confirm_neigh 426 422 -4 fib_detect_death 348 344 -4 br_do_suppress_nd 671 667 -4 udp_lib_setsockopt 893 888 -5 set_xfrm_gro_udp_encap_rcv 117 112 -5 __ipv6_neigh_lookup_noref_stub 336 328 -8 udp_tunnel_encap_enable 57 45 -12 udp_tunnel6_dst_lookup 465 453 -12 setup_udp_tunnel_sock 251 239 -12 nexthop_free_rcu 254 242 -12 bpf_xmit 1203 1191 -12 bpf_input 500 488 -12 __remove_nexthop 1705 1693 -12 xfrm6_tunnel_check_size 631 616 -15 sch_frag_xmit_hook 1233 1218 -15 icmp_build_probe 922 907 -15 eafnosupport_fib6_select_path 15 - -15 ip_neigh_gw6 708 692 -16 __pfx_eafnosupport_ipv6_route_input 16 - -16 __pfx_eafnosupport_ipv6_fragment 16 - -16 __pfx_eafnosupport_ipv6_dst_lookup_flow 16 - -16 __pfx_eafnosupport_ipv6_dev_find 16 - -16 __pfx_eafnosupport_ip6_mtu_from_fib6 16 - -16 __pfx_eafnosupport_ip6_del_rt 16 - -16 __pfx_eafnosupport_fib6_table_lookup 16 - -16 __pfx_eafnosupport_fib6_select_path 16 - -16 __pfx_eafnosupport_fib6_nh_init 16 - -16 __pfx_eafnosupport_fib6_lookup 16 - -16 __pfx_eafnosupport_fib6_get_table 16 - -16 eafnosupport_ip6_mtu_from_fib6 17 - -17 eafnosupport_fib6_get_table 17 - -17 skb_do_redirect 2878 2858 -20 eafnosupport_ipv6_route_input 20 - -20 eafnosupport_ip6_del_rt 20 - -20 eafnosupport_fib6_table_lookup 20 - -20 eafnosupport_fib6_lookup 20 - -20 eafnosupport_ipv6_dst_lookup_flow 22 - -22 eafnosupport_ipv6_dev_find 22 - -22 nh_rt_cache_flush 191 167 -24 fib_check_nh 1580 1556 -24 nat_keepalive_work_single 1319 1292 -27 eafnosupport_ipv6_fragment 35 - -35 eafnosupport_fib6_nh_init 49 - -49 rtm_new_nexthop 8495 8441 -54 bpf_ipv6_fib_lookup 1107 1043 -64 .compoundliteral 5792 5592 -200 Total: Before=25219423, After=25218398, chg -0.00%
---
CC: Ido Schimmel <[email protected]>
--- drivers/infiniband/core/addr.c | 2 +- drivers/infiniband/sw/rxe/rxe_net.c | 6 ++--- .../ethernet/mellanox/mlx5/core/en/tc_tun.c | 4 ++-- .../ethernet/netronome/nfp/flower/action.c | 2 +- .../netronome/nfp/flower/tunnel_conf.c | 6 ++--- drivers/net/ethernet/sfc/tc_encap_actions.c | 4 ++-- drivers/net/gtp.c | 2 +- drivers/net/ovpn/peer.c | 4 ++-- drivers/net/ovpn/udp.c | 2 +- drivers/net/usb/cdc_mbim.c | 2 +- drivers/net/vxlan/vxlan_multicast.c | 4 ++-- drivers/net/wireguard/socket.c | 4 ++-- include/net/ipv6_stubs.h | 24 +++++++++++++------ include/net/udp_tunnel.h | 2 +- net/core/filter.c | 12 +++++----- net/core/lwt_bpf.c | 4 ++-- net/ipv4/fib_semantics.c | 4 ++-- net/ipv4/icmp.c | 5 +++- net/ipv4/nexthop.c | 15 ++++++------ net/ipv4/udp.c | 4 ++-- net/ipv6/addrconf_core.c | 10 +++++--- net/ipv6/af_inet6.c | 12 ++++++---- net/ipv6/ip6_output.c | 1 + net/ipv6/ip6_udp_tunnel.c | 3 +-- net/ipv6/ndisc.c | 1 + net/mpls/af_mpls.c | 2 +- net/openvswitch/actions.c | 2 +- net/sched/sch_frag.c | 5 ++-- net/tipc/udp_media.c | 8 +++---- net/xfrm/espintcp.c | 2 +- net/xfrm/xfrm_nat_keepalive.c | 4 ++-- net/xfrm/xfrm_output.c | 2 +- 32 files changed, 93 insertions(+), 71 deletions(-)
drivers/infiniband/core/addr.c +1 -1
@@ -411,7 +411,7 @@ static int addr6_resolve(struct sockaddr *src_sock, fl6.saddr = src_in->sin6_addr; fl6.flowi6_oif = addr->bound_dev_if; - dst = ipv6_stub->ipv6_dst_lookup_flow (addr->net,NULL , &fl6,NULL ); + dst =IPV6_CALL (ip6_dst_lookup_flow)(addr->net,NULL , &fl6,NULL );if (IS_ERR (dst))return PTR_ERR (dst);
drivers/infiniband/sw/rxe/rxe_net.c +3 -3
@@ -138,9 +138,9 @@ static struct dst_entry *rxe_find_route6(struct rxe_qp *qp,memcpy (&fl6.daddr, daddr,sizeof (*daddr)); fl6.flowi6_proto =IPPROTO_UDP ; - ndst = ipv6_stub->ipv6_dst_lookup_flow (sock_net (recv_sockets.sk6->sk), - recv_sockets.sk6->sk, &fl6, -NULL ); + ndst =IPV6_CALL (ip6_dst_lookup_flow)(sock_net (recv_sockets.sk6->sk), + recv_sockets.sk6->sk, &fl6, +NULL );if (IS_ERR (ndst)) {rxe_dbg_qp (qp,"no route to %pI6\n" , daddr);return NULL ;
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c +2 -2
@@ -453,8 +453,8 @@ static int mlx5e_route_lookup_ipv6_get(struct mlx5e_priv *priv,if (tunnel && tunnel->get_remote_ifindex) attr->fl.fl6.flowi6_oif = tunnel->get_remote_ifindex (dev); - dst = ipv6_stub->ipv6_dst_lookup_flow (dev_net (dev),NULL , &attr->fl.fl6, -NULL ); + dst =IPV6_CALL (ip6_dst_lookup_flow)(dev_net (dev),NULL , &attr->fl.fl6, +NULL );if (IS_ERR (dst))return PTR_ERR (dst);
drivers/net/ethernet/netronome/nfp/flower/action.c +1 -1
@@ -470,7 +470,7 @@ nfp_fl_set_tun(struct nfp_app *app, struct nfp_fl_set_tun *set_tun, flow.daddr = ip_tun->key.u.ipv6.dst; flow.flowi4_proto =IPPROTO_UDP ; - dst = ipv6_stub->ipv6_dst_lookup_flow (net,NULL , &flow,NULL ); + dst =IPV6_CALL (ip6_dst_lookup_flow)(net,NULL , &flow,NULL );if (!IS_ERR (dst)) { set_tun->ttl =ip6_dst_hoplimit (dst);dst_release (dst);
drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c +3 -3
@@ -650,7 +650,7 @@ static void nfp_tun_neigh_update(struct work_struct *work) flow6.daddr = *(struct in6_addr *)n->primary_key;if (!neigh_invalid) {struct dst_entry *dst; -/* Use ipv6_dst_lookup_flow to populate flow6->saddr +/* Use ip6_dst_lookup_flow to populate flow6->saddr * and other fields. This information is only needed * for new entries, lookup can be skipped when an entry * gets invalidated - as only the daddr is needed for
@@ -815,8 +815,8 @@ void nfp_tunnel_request_route_v6(struct nfp_app *app, struct sk_buff *skb) flow.flowi6_proto =IPPROTO_UDP ;#if IS_ENABLED (CONFIG_INET ) &&IS_ENABLED (CONFIG_IPV6 ) - dst = ipv6_stub->ipv6_dst_lookup_flow (dev_net (netdev),NULL , &flow, -NULL ); + dst =IPV6_CALL (ip6_dst_lookup_flow)(dev_net (netdev),NULL , &flow, +NULL );if (IS_ERR (dst)) goto fail_rcu_unlock;#else
drivers/net/ethernet/sfc/tc_encap_actions.c +2 -2
@@ -149,8 +149,8 @@ static int efx_bind_neigh(struct efx_nic *efx,#if IS_ENABLED (CONFIG_IPV6 )struct dst_entry *dst; - dst = ipv6_stub->ipv6_dst_lookup_flow (net,NULL , &flow6, -NULL ); + dst =IPV6_CALL (ip6_dst_lookup_flow)(net,NULL , &flow6, +NULL ); rc =PTR_ERR_OR_ZERO (dst);if (rc) {NL_SET_ERR_MSG_MOD (extack,"Failed to lookup route for IPv6 encap" );
drivers/net/gtp.c +1 -1
@@ -374,7 +374,7 @@ static struct rt6_info *ip6_route_output_gtp(struct net *net, fl6->saddr = *saddr; fl6->flowi6_proto = sk->sk_protocol; - dst = ipv6_stub->ipv6_dst_lookup_flow (net, sk, fl6,NULL ); + dst =IPV6_CALL (ip6_dst_lookup_flow)(net, sk, fl6,NULL );if (IS_ERR (dst))return ERR_PTR (-ENETUNREACH );
drivers/net/ovpn/peer.c +2 -2
@@ -821,8 +821,8 @@ static struct in6_addr ovpn_nexthop_from_rt6(struct ovpn_priv *ovpn, .daddr = dest, }; - entry = ipv6_stub->ipv6_dst_lookup_flow (dev_net (ovpn->dev),NULL , &fl, -NULL ); + entry =IPV6_CALL (ip6_dst_lookup_flow)(dev_net (ovpn->dev),NULL , &fl, +NULL );if (IS_ERR (entry)) {net_dbg_ratelimited ("%s: no route to host %pI6c\n" ,netdev_name (ovpn->dev), &dest);
drivers/net/ovpn/udp.c +1 -1
@@ -251,7 +251,7 @@ static int ovpn_udp6_output(struct ovpn_peer *peer, struct ovpn_bind *bind,dst_cache_reset (cache); } - dst = ipv6_stub->ipv6_dst_lookup_flow (sock_net (sk), sk, &fl,NULL ); + dst =IPV6_CALL (ip6_dst_lookup_flow)(sock_net (sk), sk, &fl,NULL );if (IS_ERR (dst)) { ret =PTR_ERR (dst); net_dbg_ratelimited("%s: no route to host %pISpc: %d\n",
drivers/net/usb/cdc_mbim.c +1 -1
@@ -343,7 +343,7 @@ static void do_neigh_solicit(struct usbnet *dev, u8 *buf, u16 tci)in6_dev_put (in6_dev);/* ipv6_stub != NULL if in6_dev_get returned an inet6_dev */ - ipv6_stub->ndisc_send_na(netdev, &iph->saddr, &msg->target, + IPV6_CALL(ndisc_send_na)(netdev, &iph->saddr, &msg->target, is_router /* router */, true /* solicited */, false /* override */,
drivers/net/vxlan/vxlan_multicast.c +2 -2
@@ -39,7 +39,7 @@ int vxlan_igmp_join(struct vxlan_dev *vxlan, union vxlan_addr *rip, sk = sock6->sock->sk;lock_sock (sk); - ret = ipv6_stub->ipv6_sock_mc_join (sk, ifindex, + ret =IPV6_CALL (ipv6_sock_mc_join)(sk, ifindex, &ip->sin6.sin6_addr);release_sock (sk);#endif
@@ -73,7 +73,7 @@ int vxlan_igmp_leave(struct vxlan_dev *vxlan, union vxlan_addr *rip, sk = sock6->sock->sk;lock_sock (sk); - ret = ipv6_stub->ipv6_sock_mc_drop (sk, ifindex, + ret =IPV6_CALL (ipv6_sock_mc_drop)(sk, ifindex, &ip->sin6.sin6_addr);release_sock (sk);#endif
drivers/net/wireguard/socket.c +2 -2
@@ -136,8 +136,8 @@ static int send6(struct wg_device *wg, struct sk_buff *skb,if (cache)dst_cache_reset (cache); } - dst = ipv6_stub->ipv6_dst_lookup_flow (sock_net (sock), sock, &fl, -NULL ); + dst =IPV6_CALL (ip6_dst_lookup_flow)(sock_net (sock), sock, &fl, +NULL );if (IS_ERR (dst)) { ret =PTR_ERR (dst); net_dbg_ratelimited("%s: No route to %pISpfsc, error %d\n",
include/net/ipv6_stubs.h +17 -7
@@ -17,18 +17,22 @@ struct fib6_nh;struct fib6_config ;struct fib6_result ; +int ipv6_route_input (struct sk_buff *skb); +/* This is ugly, ideally these symbols should be built * into the core kernel. */ struct ipv6_stub { +struct neigh_table *nd_tbl; +#if !defined(CONFIG_IPV6 )int (*ipv6_sock_mc_join)(struct sock *sk,int ifindex,const struct in6_addr *addr);int (*ipv6_sock_mc_drop)(struct sock *sk,int ifindex,const struct in6_addr *addr); -struct dst_entry *(*ipv6_dst_lookup_flow)(struct net *net, -const struct sock *sk, -struct flowi6 *fl6, -const struct in6_addr *final_dst); +struct dst_entry *(*ip6_dst_lookup_flow)(struct net *net, +const struct sock *sk, +struct flowi6 *fl6, +const struct in6_addr *final_dst);int (*ipv6_route_input)(struct sk_buff *skb);struct fib6_table *(*fib6_get_table)(struct net *net,u32 id);
@@ -67,14 +71,14 @@ struct ipv6_stub {int (*xfrm6_rcv_encap)(struct sk_buff *skb,int nexthdr,__be32 spi,int encap_type);#endif -struct neigh_table *nd_tbl; -int (*ipv6_fragment)(struct net *net,struct sock *sk,struct sk_buff *skb, -int (*output)(struct net *,struct sock *,struct sk_buff *)); +int (*ip6_fragment)(struct net *net,struct sock *sk,struct sk_buff *skb, +int (*output)(struct net *,struct sock *,struct sk_buff *));struct net_device *(*ipv6_dev_find)(struct net *net,const struct in6_addr *addr,struct net_device *dev);int (*ip6_xmit)(const struct sock *sk,struct sk_buff *skb,struct flowi6 *fl6,__u32 mark,struct ipv6_txoptions *opt,int tclass,u32 priority); +#endif };extern const struct ipv6_stub *ipv6_stub__read_mostly ;
@@ -99,4 +103,10 @@ struct ipv6_bpf_stub { };extern const struct ipv6_bpf_stub *ipv6_bpf_stub__read_mostly ; +#if defined(CONFIG_IPV6 ) +#define IPV6_CALL (X ) (X) +#else +#define IPV6_CALL (X ) (READ_ONCE(ipv6_stub)->X) +#endif +#endif
include/net/udp_tunnel.h +1 -1
@@ -230,7 +230,7 @@ static inline void udp_tunnel_encap_enable(struct sock *sk)#if IS_ENABLED (CONFIG_IPV6 )if (READ_ONCE (sk->sk_family) ==PF_INET6 ) - ipv6_stub->udpv6_encap_enable (); +IPV6_CALL (udpv6_encap_enable)();#endif udp_encap_enable (); }
net/core/filter.c +6 -6
@@ -2276,7 +2276,7 @@ static int __bpf_redirect_neigh_v6(struct sk_buff *skb, struct net_device *dev, .saddr = ip6h->saddr, }; - dst = ipv6_stub->ipv6_dst_lookup_flow (net,NULL , &fl6,NULL ); + dst =IPV6_CALL (ip6_dst_lookup_flow)(net,NULL , &fl6,NULL );if (IS_ERR (dst)) goto out_drop;
@@ -6281,11 +6281,11 @@ static int bpf_ipv6_fib_lookup(struct net *net, struct bpf_fib_lookup *params, params->tbid =0 ; } - tb = ipv6_stub->fib6_get_table (net, tbid); + tb =IPV6_CALL (fib6_get_table)(net, tbid);if (unlikely (!tb))return BPF_FIB_LKUP_RET_NOT_FWDED ; - err = ipv6_stub->fib6_table_lookup (net, tb, oif, &fl6, &res, + err =IPV6_CALL (fib6_table_lookup)(net, tb, oif, &fl6, &res, strict); }else {if (flags &BPF_FIB_LOOKUP_MARK )
@@ -6296,7 +6296,7 @@ static int bpf_ipv6_fib_lookup(struct net *net, struct bpf_fib_lookup *params, fl6.flowi6_tun_key.tun_id =0 ; fl6.flowi6_uid =sock_net_uid (net,NULL ); - err = ipv6_stub->fib6_lookup (net, oif, &fl6, &res, strict); + err =IPV6_CALL (fib6_lookup)(net, oif, &fl6, &res, strict); } if (unlikely(err || IS_ERR_OR_NULL(res.f6i) ||
@@ -6317,11 +6317,11 @@ static int bpf_ipv6_fib_lookup(struct net *net, struct bpf_fib_lookup *params,return BPF_FIB_LKUP_RET_NOT_FWDED ; } - ipv6_stub->fib6_select_path (net, &res, &fl6, fl6.flowi6_oif, +IPV6_CALL (fib6_select_path)(net, &res, &fl6, fl6.flowi6_oif, fl6.flowi6_oif !=0 ,NULL , strict);if (check_mtu) { - mtu = ipv6_stub->ip6_mtu_from_fib6 (&res, dst, src); + mtu =IPV6_CALL (ip6_mtu_from_fib6)(&res, dst, src);if (params->tot_len > mtu) { params->mtu_result = mtu;/* union with tot_len */ return BPF_FIB_LKUP_RET_FRAG_NEEDED ;
net/core/lwt_bpf.c +2 -2
@@ -103,7 +103,7 @@ static int bpf_lwt_input_reroute(struct sk_buff *skb)dev_put (dev); }else if (skb->protocol ==htons (ETH_P_IPV6 )) {skb_dst_drop (skb); - err = ipv6_stub->ipv6_route_input (skb); + err =IPV6_CALL (ipv6_route_input)(skb); }else { err = -EAFNOSUPPORT ; }
@@ -233,7 +233,7 @@ static int bpf_lwt_xmit_reroute(struct sk_buff *skb) fl6.daddr = iph6->daddr; fl6.saddr = iph6->saddr; - dst = ipv6_stub->ipv6_dst_lookup_flow (net, skb->sk, &fl6,NULL ); + dst =IPV6_CALL (ip6_dst_lookup_flow)(net, skb->sk, &fl6,NULL );if (IS_ERR (dst)) { err =PTR_ERR (dst); goto err;
net/ipv4/fib_semantics.c +2 -2
@@ -1083,7 +1083,7 @@ static int fib_check_nh_v6_gw(struct net *net, struct fib_nh *nh,struct fib6_nh fib6_nh = {};int err; - err = ipv6_stub->fib6_nh_init (net, &fib6_nh, &cfg,GFP_KERNEL , extack); + err =IPV6_CALL (fib6_nh_init)(net, &fib6_nh, &cfg,GFP_KERNEL , extack);if (!err) { nh->fib_nh_dev = fib6_nh.fib_nh_dev; netdev_hold(nh->fib_nh_dev, &nh->fib_nh_dev_tracker,
@@ -1091,7 +1091,7 @@ static int fib_check_nh_v6_gw(struct net *net, struct fib_nh *nh, nh->fib_nh_oif = nh->fib_nh_dev->ifindex; nh->fib_nh_scope =RT_SCOPE_LINK ; - ipv6_stub->fib6_nh_release (&fib6_nh); +IPV6_CALL (fib6_nh_release)(&fib6_nh); }return err;
net/ipv4/icmp.c +4 -1
@@ -1342,7 +1342,10 @@ bool icmp_build_probe(struct sk_buff *skb, struct icmphdr *icmphdr)case ICMP_AFI_IP6 :if (iio->ident.addr.ctype3_hdr.addrlen !=sizeof (struct in6_addr )) goto send_mal_query; - dev = ipv6_stub->ipv6_dev_find (net, &iio->ident.addr.ip_addr.ipv6_addr, dev); + dev =IPV6_CALL (ipv6_dev_find)( + net, + &iio->ident.addr.ip_addr.ipv6_addr, + dev);dev_hold (dev);break ;#endif
net/ipv4/nexthop.c +8 -7
@@ -16,6 +16,7 @@#include <net/nexthop.h> #include <net/route.h> #include <net/sock.h> +#include <net/ip6_route.h> #define NH_RES_DEFAULT_IDLE_TIMER (120 * HZ)#define NH_RES_DEFAULT_UNBALANCED_TIMER 0/* No forced rebalancing. */
@@ -510,7 +511,7 @@ static void nexthop_free_single(struct nexthop *nh)fib_nh_release (nh->net, &nhi->fib_nh);break ;case AF_INET6 : - ipv6_stub->fib6_nh_release (&nhi->fib6_nh); +IPV6_CALL (fib6_nh_release)(&nhi->fib6_nh);break ; }kfree (nhi);
@@ -2143,7 +2144,7 @@ static void __remove_nexthop_fib(struct net *net, struct nexthop *nh)fib6_info_hold (f6i);spin_unlock_bh (&nh->lock); - ipv6_stub->ip6_del_rt (net, f6i, +IPV6_CALL (ip6_del_rt)(net, f6i, !READ_ONCE (net->ipv4.sysctl_nexthop_compat_mode));spin_lock_bh (&nh->lock);
@@ -2201,7 +2202,7 @@ static void nh_rt_cache_flush(struct net *net, struct nexthop *nh,rt_cache_flush (net);list_for_each_entry (f6i, &nh->f6i_list, nh_list) - ipv6_stub->fib6_update_sernum (net, f6i); +IPV6_CALL (fib6_update_sernum)(net, f6i);/* if an IPv6 group was replaced, we have to release all old * dsts to make sure all refcounts are released
@@ -2215,7 +2216,7 @@ static void nh_rt_cache_flush(struct net *net, struct nexthop *nh,struct nh_info *nhi =rtnl_dereference (nhge->nh->nh_info);if (nhi->family ==AF_INET6 ) - ipv6_stub->fib6_nh_release_dsts (&nhi->fib6_nh); +IPV6_CALL (fib6_nh_release_dsts)(&nhi->fib6_nh); } }
@@ -2496,7 +2497,7 @@ static void __nexthop_replace_notify(struct net *net, struct nexthop *nh, }list_for_each_entry (f6i, &nh->f6i_list, nh_list) - ipv6_stub->fib6_rt_update (net, f6i, info); +IPV6_CALL (fib6_rt_update)(net, f6i, info); }/* send RTM_NEWROUTE with REPLACE flag set for all FIB entries
@@ -2869,13 +2870,13 @@ static int nh_create_ipv6(struct net *net, struct nexthop *nh, fib6_cfg.fc_flags |=RTF_GATEWAY ;/* sets nh_dev if successful */ - err = ipv6_stub->fib6_nh_init (net, fib6_nh, &fib6_cfg,GFP_KERNEL , + err =IPV6_CALL (fib6_nh_init)(net, fib6_nh, &fib6_cfg,GFP_KERNEL , extack);if (err) {/* IPv6 is not enabled, don't call fib6_nh_release */ if (err == -EAFNOSUPPORT ) goto out; - ipv6_stub->fib6_nh_release (fib6_nh); +IPV6_CALL (fib6_nh_release)(fib6_nh); }else { nh->nh_flags = fib6_nh->fib_nh_flags; }
net/ipv4/udp.c +2 -2
@@ -2966,7 +2966,7 @@ static void set_xfrm_gro_udp_encap_rcv(__u16 encap_type, unsigned short family,if (udp_test_bit (GRO_ENABLED , sk) && encap_type ==UDP_ENCAP_ESPINUDP ) {if (IS_ENABLED (CONFIG_IPV6 ) && family ==AF_INET6 ) - new_gro_receive = ipv6_stub->xfrm6_gro_udp_encap_rcv; + new_gro_receive =IPV6_CALL (xfrm6_gro_udp_encap_rcv);else new_gro_receive = xfrm4_gro_udp_encap_rcv;
@@ -3039,7 +3039,7 @@ int udp_lib_setsockopt(struct sock *sk, int level, int optname,#if IS_ENABLED (CONFIG_IPV6 )if (sk->sk_family ==AF_INET6 )WRITE_ONCE (up->encap_rcv, - ipv6_stub->xfrm6_udp_encap_rcv); +IPV6_CALL (xfrm6_udp_encap_rcv)); else#endif WRITE_ONCE(up->encap_rcv,
net/ipv6/addrconf_core.c +7 -3
@@ -129,7 +129,8 @@ int inet6addr_validator_notifier_call_chain(unsigned long val, void *v) }EXPORT_SYMBOL (inet6addr_validator_notifier_call_chain); -static struct dst_entry *eafnosupport_ipv6_dst_lookup_flow (struct net *net, +#if !defined(CONFIG_IPV6 ) +static struct dst_entry *eafnosupport_ip6_dst_lookup_flow (struct net *net,const struct sock *sk,struct flowi6 *fl6,const struct in6_addr *final_dst)
@@ -203,9 +204,11 @@ static struct net_device *eafnosupport_ipv6_dev_find(struct net *net, const stru {return ERR_PTR (-EAFNOSUPPORT ); } +#endif const struct ipv6_stub *ipv6_stub__read_mostly = &(struct ipv6_stub ) { - .ipv6_dst_lookup_flow = eafnosupport_ipv6_dst_lookup_flow, +#if !defined(CONFIG_IPV6) + .ip6_dst_lookup_flow = eafnosupport_ip6_dst_lookup_flow, .ipv6_route_input = eafnosupport_ipv6_route_input, .fib6_get_table = eafnosupport_fib6_get_table, .fib6_table_lookup = eafnosupport_fib6_table_lookup,
@@ -214,8 +217,9 @@ const struct ipv6_stub *ipv6_stub __read_mostly = &(struct ipv6_stub) { .ip6_mtu_from_fib6 = eafnosupport_ip6_mtu_from_fib6, .fib6_nh_init = eafnosupport_fib6_nh_init, .ip6_del_rt = eafnosupport_ip6_del_rt, - .ipv6_fragment = eafnosupport_ipv6_fragment, + .ip6_fragment = eafnosupport_ipv6_fragment, .ipv6_dev_find = eafnosupport_ipv6_dev_find, +#endif };EXPORT_SYMBOL_GPL (ipv6_stub);
net/ipv6/af_inet6.c +7 -5
@@ -1023,16 +1023,18 @@ static struct pernet_operations inet6_net_ops = { .exit = inet6_net_exit, }; -static int ipv6_route_input (struct sk_buff *skb) +int ipv6_route_input (struct sk_buff *skb) {ip6_route_input (skb);return skb_dst (skb)->error; }static const struct ipv6_stub ipv6_stub_impl = { + .nd_tbl = &nd_tbl, +#if !defined(CONFIG_IPV6) .ipv6_sock_mc_join = ipv6_sock_mc_join, .ipv6_sock_mc_drop = ipv6_sock_mc_drop, - .ipv6_dst_lookup_flow = ip6_dst_lookup_flow, + .ip6_dst_lookup_flow = ip6_dst_lookup_flow, .ipv6_route_input = ipv6_route_input, .fib6_get_table = fib6_get_table, .fib6_table_lookup = fib6_table_lookup,
@@ -1053,10 +1055,10 @@ static const struct ipv6_stub ipv6_stub_impl = { .xfrm6_gro_udp_encap_rcv = xfrm6_gro_udp_encap_rcv, .xfrm6_rcv_encap = xfrm6_rcv_encap, #endif - .nd_tbl = &nd_tbl, - .ipv6_fragment = ip6_fragment, + .ip6_fragment = ip6_fragment, .ipv6_dev_find = ipv6_dev_find, .ip6_xmit = ip6_xmit, +#endif }; static const struct ipv6_bpf_stub ipv6_bpf_stub_impl = {
@@ -1235,7 +1237,7 @@ static int __init inet6_init(void)/* ensure that ipv6 stubs are visible only after ipv6 is ready */ wmb (); - ipv6_stub = &ipv6_stub_impl; +WRITE_ONCE (ipv6_stub, &ipv6_stub_impl); ipv6_bpf_stub = &ipv6_bpf_stub_impl; out:return err;
net/ipv6/ip6_output.c +1 -0
@@ -1045,6 +1045,7 @@ int ip6_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,kfree_skb (skb);return err; } +EXPORT_SYMBOL_GPL (ip6_fragment); static inline int ip6_rt_check(const struct rt6key *rt_key, const struct in6_addr *fl_addr,
net/ipv6/ip6_udp_tunnel.c +1 -2
@@ -162,8 +162,7 @@ struct dst_entry *udp_tunnel6_dst_lookup(struct sk_buff *skb, fl6.fl6_dport = dport; fl6.flowlabel =ip6_make_flowinfo (dsfield, key->label); - dst = ipv6_stub->ipv6_dst_lookup_flow (net, sock->sk, &fl6, -NULL ); + dst =IPV6_CALL (ip6_dst_lookup_flow)(net, sock->sk, &fl6,NULL );if (IS_ERR (dst)) {netdev_dbg (dev,"no route to %pI6\n" , &fl6.daddr);return ERR_PTR (-ENETUNREACH );
net/ipv6/ndisc.c +1 -0
@@ -576,6 +576,7 @@ void ndisc_send_na(struct net_device *dev, const struct in6_addr *daddr,ndisc_send_skb (skb, daddr, src_addr); } +EXPORT_SYMBOL (ndisc_send_na);static void ndisc_send_unsol_na (struct net_device *dev) {
net/mpls/af_mpls.c +1 -1
@@ -642,7 +642,7 @@ static struct net_device *inet6_fib_lookup_dev(struct net *net,memset (&fl6,0 ,sizeof (fl6));memcpy (&fl6.daddr, addr,sizeof (struct in6_addr )); - dst = ipv6_stub->ipv6_dst_lookup_flow (net,NULL , &fl6,NULL ); + dst =IPV6_CALL (ip6_dst_lookup_flow)(net,NULL , &fl6,NULL );if (IS_ERR (dst))return ERR_CAST (dst);
net/openvswitch/actions.c +1 -1
@@ -810,7 +810,7 @@ static void ovs_fragment(struct net *net, struct vport *vport,skb_dst_set_noref (skb, &ovs_rt.dst);IP6CB (skb)->frag_max_size = mru; - ipv6_stub->ipv6_fragment (net, skb->sk, skb, ovs_vport_output); +IPV6_CALL (ip6_fragment)(net, skb->sk, skb, ovs_vport_output);refdst_drop (orig_dst); }else { WARN_ONCE(1, "Failed fragment ->%s: eth=%04x, MRU=%d, MTU=%d.",
net/sched/sch_frag.c +3 -2
@@ -6,6 +6,7 @@#include <net/dst.h> #include <net/ip.h> #include <net/ip6_fib.h> +#include <net/ip6_route.h> struct sch_frag_data {unsigned long dst;
@@ -127,8 +128,8 @@ static int sch_fragment(struct net *net, struct sk_buff *skb,skb_dst_set_noref (skb, &sch_frag_rt.dst);IP6CB (skb)->frag_max_size = mru; - ret = ipv6_stub->ipv6_fragment (net, skb->sk, skb, - sch_frag_xmit); + ret =IPV6_CALL (ip6_fragment)(net, skb->sk, skb, + sch_frag_xmit);local_unlock_nested_bh (&sch_frag_data_storage.bh_lock);refdst_drop (orig_dst); }else {
net/tipc/udp_media.c +4 -4
@@ -207,9 +207,9 @@ static int tipc_udp_xmit(struct net *net, struct sk_buff *skb, .saddr = src->ipv6, .flowi6_proto = IPPROTO_UDP }; - ndst = ipv6_stub->ipv6_dst_lookup_flow (net, - ub->ubsock->sk, - &fl6,NULL ); + ndst =IPV6_CALL (ip6_dst_lookup_flow)(net, + ub->ubsock->sk, + &fl6,NULL );if (IS_ERR (ndst)) { err =PTR_ERR (ndst); goto tx_error;
@@ -418,7 +418,7 @@ static int enable_mcast(struct udp_bearer *ub, struct udp_media_addr *remote)#if IS_ENABLED (CONFIG_IPV6 ) } else {lock_sock (sk); - err = ipv6_stub->ipv6_sock_mc_join (sk, ub->ifindex, + err =IPV6_CALL (ipv6_sock_mc_join)(sk, ub->ifindex, &remote->ipv6);release_sock (sk);#endif
net/xfrm/espintcp.c +1 -1
@@ -43,7 +43,7 @@ static void handle_esp(struct sk_buff *skb, struct sock *sk)local_bh_disable ();#if IS_ENABLED (CONFIG_IPV6 )if (sk->sk_family ==AF_INET6 ) - ipv6_stub->xfrm6_rcv_encap (skb,IPPROTO_ESP ,0 ,TCP_ENCAP_ESPINTCP ); +IPV6_CALL (xfrm6_rcv_encap)(skb,IPPROTO_ESP ,0 ,TCP_ENCAP_ESPINTCP ); else#endif xfrm4_rcv_encap (skb,IPPROTO_ESP ,0 ,TCP_ENCAP_ESPINTCP );
net/xfrm/xfrm_nat_keepalive.c +2 -2
@@ -98,14 +98,14 @@ static int nat_keepalive_send_ipv6(struct sk_buff *skb,local_lock_nested_bh (&nat_keepalive_sk_ipv6.bh_lock); sk =this_cpu_read (nat_keepalive_sk_ipv6.sock);sock_net_set (sk, net); - dst = ipv6_stub->ipv6_dst_lookup_flow (net, sk, &fl6,NULL ); + dst =IPV6_CALL (ip6_dst_lookup_flow)(net, sk, &fl6,NULL );if (IS_ERR (dst)) {local_unlock_nested_bh (&nat_keepalive_sk_ipv6.bh_lock);return PTR_ERR (dst); }skb_dst_set (skb, dst); - err = ipv6_stub->ip6_xmit (sk, skb, &fl6, skb->mark,NULL ,0 ,0 ); + err =IPV6_CALL (ip6_xmit)(sk, skb, &fl6, skb->mark,NULL ,0 ,0 );sock_net_set (sk, &init_net);local_unlock_nested_bh (&nat_keepalive_sk_ipv6.bh_lock);return err;
net/xfrm/xfrm_output.c +1 -1
@@ -900,7 +900,7 @@ int xfrm6_tunnel_check_size(struct sk_buff *skb) skb->protocol =htons (ETH_P_IPV6 );if (xfrm6_local_dontfrag (sk)) - ipv6_stub->xfrm6_local_rxpmtu (skb, mtu); +IPV6_CALL (xfrm6_local_rxpmtu)(skb, mtu);else if (sk)xfrm_local_error (skb, mtu);else
Signature · 1 line
2.53.0.473.g4a7958ca14-goog
Jakub Kicinski
maintainerQuoted 5 lines · On Sun, 1 Mar 2026 16:25:14 +0000 Eric Dumazet wrote:
ipv6_stubuse is racy, we should addREAD_ONCE()andWRITE_ONCE(), even if this pointer can only change once.Add
IPV6_CALL()macro to factorize theREAD_ONCE(), and perform direct calls whenCONFIG_IPV6=y.
Some crashiness detected here, I think
pw-bot: cr
[ 1831.476440][ T4627] =============================
[ 1831.476614][ T4627] WARNING: suspicious RCU usage
[ 1831.476776][ T4627] 7.0.0-rc1-virtme #1 Not tainted
[ 1831.476955][ T4627] -----------------------------
[ 1831.477119][ T4627] net/ipv6/ip6_fib.c:111 suspicious rcu_dereference_protected() usage!
[ 1831.477338][ T4627]
[ 1831.477338][ T4627] other info that might help us debug this:
[ 1831.477338][ T4627]
[ 1831.477613][ T4627]
[ 1831.477613][ T4627] rcu_scheduler_active = 2, debug_locks = 1
[ 1831.477831][ T4627] 1 lock held by ip/4627:
[ 1831.477975][ T4627] #0: ffffffff950a1d28 (rtnl_mutex){+.+.}-{4:4}, at: rtm_new_nexthop+0x1a6/0x8c0
[ 1831.478234][ T4627]
[ 1831.478234][ T4627] stack backtrace:
[ 1831.478423][ T4627] CPU: 2 UID: 0 PID: 4627 Comm: ip Not tainted 7.0.0-rc1-virtme #1 PREEMPT(full)
[ 1831.478427][ T4627] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
[ 1831.478429][ T4627] Call Trace:
[ 1831.478431][ T4627] <TASK>
[ 1831.478433][ T4627] dump_stack_lvl+0x6f/0xa0
[ 1831.478440][ T4627] lockdep_rcu_suspicious.cold+0x4f/0xad
[ 1831.478445][ T4627] fib6_update_sernum+0xfb/0x130
[ 1831.478450][ T4627] nh_rt_cache_flush+0x8d/0x380
[ 1831.478454][ T4627] replace_nexthop+0x347/0x6e0
[ 1831.478458][ T4627] insert_nexthop+0x41e/0x7a0
[ 1831.478460][ T4627] ? nexthop_create+0x307/0x770
[ 1831.478463][ T4627] rtm_new_nexthop+0x3a0/0x8c0
[ 1831.478467][ T4627] ? insert_nexthop+0x7a0/0x7a0
[ 1831.478468][ T4627] ? lock_acquire.part.0+0xbc/0x260
[ 1831.478471][ T4627] ? find_held_lock+0x2b/0x80
[ 1831.478478][ T4627] ? lock_acquire.part.0+0xbc/0x260
[ 1831.478479][ T4627] ? find_held_lock+0x2b/0x80
[ 1831.478485][ T4627] ? find_held_lock+0x2b/0x80
[ 1831.478487][ T4627] ? insert_nexthop+0x7a0/0x7a0
[ 1831.478489][ T4627] ? __lock_release.isra.0+0x59/0x170
[ 1831.478492][ T4627] ? insert_nexthop+0x7a0/0x7a0
[ 1831.478494][ T4627] rtnetlink_rcv_msg+0x6fe/0xb90
[ 1831.478499][ T4627] ? rtnl_fdb_dump+0x620/0x620
[ 1831.478501][ T4627] ? __lock_acquire+0x577/0xc10
[ 1831.478511][ T4627] ? lock_acquire.part.0+0xbc/0x260
[ 1831.478513][ T4627] ? find_held_lock+0x2b/0x80
[ 1831.478516][ T4627] netlink_rcv_skb+0x123/0x380
[ 1831.478519][ T4627] ? rtnl_fdb_dump+0x620/0x620
[ 1831.478522][ T4627] ? netlink_ack+0xce0/0xce0
[ 1831.478527][ T4627] ? netlink_deliver_tap+0xc5/0x330
[ 1831.478529][ T4627] ? netlink_deliver_tap+0x13f/0x330
[ 1831.478533][ T4627] netlink_unicast+0x4a3/0x770
[ 1831.478536][ T4627] ? netlink_attachskb+0x810/0x810
[ 1831.478537][ T4627] ? __alloc_skb+0x4c4/0x5f0
[ 1831.478540][ T4627] ? napi_skb_cache_get+0x7a0/0x7a0
[ 1831.478542][ T4627] ? lock_acquire.part.0+0xbc/0x260
[ 1831.478544][ T4627] ? __lock_acquire+0x577/0xc10
[ 1831.478547][ T4627] netlink_sendmsg+0x735/0xc60
[ 1831.478550][ T4627] ? netlink_unicast+0x770/0x770
[ 1831.478553][ T4627] ? __might_fault+0x97/0x140
[ 1831.478559][ T4627] ____sys_sendmsg+0x419/0x850
[ 1831.478561][ T4627] ? copy_msghdr_from_user+0x270/0x430
[ 1831.478563][ T4627] ? get_timestamp.constprop.0+0x390/0x390
[ 1831.478564][ T4627] ? move_addr_to_kernel+0x40/0x40
[ 1831.478567][ T4627] ? stack_depot_save_flags+0x30d/0x6e0
[ 1831.478571][ T4627] ? rcu_read_lock_any_held+0x3c/0x90
[ 1831.478576][ T4627] ___sys_sendmsg+0xfd/0x180
[ 1831.478578][ T4627] ? __call_rcu_common.constprop.0+0xa6/0xa00
[ 1831.478581][ T4627] ? copy_msghdr_from_user+0x430/0x430
[ 1831.478595][ T4627] __sys_sendmsg+0x124/0x1c0
[ 1831.478597][ T4627] ? __sys_sendmsg_sock+0x20/0x20
[ 1831.478599][ T4627] ? lockdep_hardirqs_on+0x84/0x130
[ 1831.478603][ T4627] ? __call_rcu_common.constprop.0+0x3bd/0xa00
[ 1831.478608][ T4627] ? do_raw_spin_unlock+0x59/0x250
[ 1831.478610][ T4627] ? rcu_is_watching+0x15/0xd0
[ 1831.478613][ T4627] do_syscall_64+0x117/0xfc0
[ 1831.478615][ T4627] ? exc_page_fault+0xaf/0xd0
[ 1831.478617][ T4627] entry_SYSCALL_64_after_hwframe+0x4b/0x53Jakub Kicinski
maintainerQuoted 8 lines · On Sun, 1 Mar 2026 11:24:13 -0800 Jakub Kicinski wrote:
Quoted 5 lines · On Sun, 1 Mar 2026 16:25:14 +0000 Eric Dumazet wrote:
ipv6_stubuse is racy, we should addREAD_ONCE()andWRITE_ONCE(), even if this pointer can only change once.Add
IPV6_CALL()macro to factorize theREAD_ONCE(), and perform direct calls whenCONFIG_IPV6=y.Some crashiness detected here, I think
Took me a minute to grok it but its obvious in hindsight so to possibly save you time: fib6_update_sernum_stub() vs fib6_update_sernum() We now call the wrong function due to the funny naming.
Quoted 6 lines · Jakub Kicinski
Quoted 4 lines · On Sun, 1 Mar 2026 11:24:13 -0800 Jakub Kicinski wrote:
Quoted 3 lines · On Sun, 1 Mar 2026 16:25:14 +0000 Eric Dumazet wrote:
ipv6_stubuse is racy, we should addREAD_ONCE()andWRITE_ONCE(), even if this pointer can only change once.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Add
IPV6_CALL()macro to factorize theREAD_ONCE(), and perform direct calls whenCONFIG_IPV6=y.Some crashiness detected here, I think
Took me a minute to grok it but its obvious in hindsight so to possibly save you time:
fib6_update_sernum_stub()vsfib6_update_sernum()We now call the wrong function due to the funny naming.
Thanks, I will take a look