vxlan: RCU protect vxlan_config and enable RTNL-less fill_info
Subsystems (4)
cover vxlan: RCU protect vxlan_config and enable RTNL-less fill_info
This patch series converts VXLAN configuration (struct vxlan_config) to be RCU-protected, allowing lockless readers and enabling RTNL-less vxlan_fill_info() netlink link info dumping.
Work has been split into three distinct parts:
1. Refactor helper functions in RX, TX, MDB, VNIFILTER, and OVS paths to accept a const struct vxlan_config *cfg pointer (or pass specific fields such as flags/saddr_family) rather than accessing vxlan->cfg directly.
2. Convert vxlan->cfg from an embedded struct into an RCU-protected pointer (struct vxlan_config __rcu *cfg), dynamically allocated on device creation or changelink, and freed via kfree_rcu(). Update offload drivers (mlxsw) and OVS (vport-vxlan.c) accordingly.
3. Update vxlan_fill_info() to run under rcu_read_lock() instead of relying on RTNL lock, completing the transition to lockless link info dumping for VXLAN devices.
Eric Dumazet (3):
vxlan: pass vxlan_config pointer to helper functions
vxlan: convert configuration to RCU protection
vxlan: no longer rely on RTNL in vxlan_fill_info()
.../mellanox/mlxsw/spectrum_nve_vxlan.c | 14 +- .../mellanox/mlxsw/spectrum_switchdev.c | 57 +- drivers/net/vxlan/vxlan_core.c | 566 +++++++++++------- drivers/net/vxlan/vxlan_mdb.c | 37 +- drivers/net/vxlan/vxlan_multicast.c | 12 +- drivers/net/vxlan/vxlan_private.h | 6 +- drivers/net/vxlan/vxlan_vnifilter.c | 24 +- include/net/vxlan.h | 3 +- net/openvswitch/vport-vxlan.c | 34 +- 9 files changed, 475 insertions(+), 278 deletions(-)
Signature · 1 line
2.55.0.795.g602f6c329a-goog
PATCH 1/3 vxlan: pass vxlan_config pointer to helper functions
In preparation for converting vxlan->cfg to an RCU-protected pointer, refactor internal helper functions in the RX, TX, MDB, VNIFILTER, and OVS paths to accept a pointer to struct vxlan_config (or pass flags/ saddr_family where appropriate) rather than directly accessing vxlan->cfg.
--- drivers/net/vxlan/vxlan_core.c | 249 +++++++++++++++------------- drivers/net/vxlan/vxlan_mdb.c | 20 ++- drivers/net/vxlan/vxlan_private.h | 6 +- drivers/net/vxlan/vxlan_vnifilter.c | 5 +- net/openvswitch/vport-vxlan.c | 7 +- 5 files changed, 158 insertions(+), 129 deletions(-)
drivers/net/vxlan/vxlan_core.c +135 -114
@@ -377,14 +377,15 @@ static void vxlan_fdb_miss(struct vxlan_dev *vxlan, const u8 eth_addr[ETH_ALEN])/* Look up Ethernet address in forwarding table */ static struct vxlan_fdb *vxlan_find_mac_rcu (struct vxlan_dev *vxlan, +const struct vxlan_config *cfg,const u8 *mac,__be32 vni) {struct vxlan_fdb_key key;memset (&key,0 ,sizeof (key));memcpy (key.eth_addr, mac,sizeof (key.eth_addr)); -if (!(vxlan->cfg.flags &VXLAN_F_COLLECT_METADATA )) - key.vni = vxlan->default_dst.remote_vni; +if (!(cfg->flags &VXLAN_F_COLLECT_METADATA )) + key.vni = cfg->vni;else key.vni = vni;
@@ -393,11 +394,12 @@ static struct vxlan_fdb *vxlan_find_mac_rcu(struct vxlan_dev *vxlan, }static struct vxlan_fdb *vxlan_find_mac_tx (struct vxlan_dev *vxlan, +const struct vxlan_config *cfg,const u8 *mac,__be32 vni) {struct vxlan_fdb *f; - f =vxlan_find_mac_rcu (vxlan, mac, vni); + f =vxlan_find_mac_rcu (vxlan, cfg, mac, vni);if (f) {unsigned long now = jiffies;
@@ -416,7 +418,7 @@ static struct vxlan_fdb *vxlan_find_mac(struct vxlan_dev *vxlan,lockdep_assert_held_once (&vxlan->hash_lock);rcu_read_lock (); - f =vxlan_find_mac_rcu (vxlan, mac, vni); + f =vxlan_find_mac_rcu (vxlan, &vxlan->cfg, mac, vni);rcu_read_unlock ();return f;
@@ -457,7 +459,7 @@ int vxlan_fdb_find_uc(struct net_device *dev, const u8 *mac, __be32 vni,rcu_read_lock (); - f =vxlan_find_mac_rcu (vxlan, eth_addr, vni); + f =vxlan_find_mac_rcu (vxlan, &vxlan->cfg, eth_addr, vni);if (f) rdst =first_remote_rcu (f);if (!rdst) {
@@ -1405,7 +1407,7 @@ static int vxlan_fdb_get(struct sk_buff *skb,rcu_read_lock (); - f =vxlan_find_mac_rcu (vxlan, addr, vni); + f =vxlan_find_mac_rcu (vxlan, &vxlan->cfg, addr, vni);if (!f) {NL_SET_ERR_MSG (extack,"Fdb entry not found" ); err = -ENOENT ;
@@ -1423,6 +1425,7 @@ static int vxlan_fdb_get(struct sk_buff *skb,* and Tunnel endpoint. */ static enum skb_drop_reason vxlan_snoop (struct net_device *dev, +const struct vxlan_config *cfg,union vxlan_addr *src_ip,const u8 *src_mac,u32 src_ifindex,__be32 vni)
@@ -1441,7 +1444,7 @@ static enum skb_drop_reason vxlan_snoop(struct net_device *dev, ifindex = src_ifindex;#endif - f =vxlan_find_mac_rcu (vxlan, src_mac, vni); + f =vxlan_find_mac_rcu (vxlan, cfg, src_mac, vni);if (likely (f)) {struct vxlan_rdst *rdst =first_remote_rcu (f);unsigned long now = jiffies;
@@ -1477,9 +1480,9 @@ static enum skb_drop_reason vxlan_snoop(struct net_device *dev,vxlan_fdb_update (vxlan, src_mac, src_ip,NUD_REACHABLE ,NLM_F_EXCL |NLM_F_CREATE , - vxlan->cfg.dst_port, + cfg->dst_port, vni, - vxlan->default_dst.remote_vni, + cfg->vni, ifindex,NTF_SELF ,0 , true,NULL );spin_unlock (&vxlan->hash_lock); }
@@ -1587,6 +1590,7 @@ static void vxlan_parse_gbp_hdr(struct sk_buff *skb, u32 vxflags, }static enum skb_drop_reason vxlan_set_mac (struct vxlan_dev *vxlan, +const struct vxlan_config *cfg,struct vxlan_sock *vs,struct sk_buff *skb,__be32 vni) {
@@ -1612,10 +1616,10 @@ static enum skb_drop_reason vxlan_set_mac(struct vxlan_dev *vxlan,#endif } -if (!(vxlan->cfg.flags &VXLAN_F_LEARN )) +if (!(cfg->flags &VXLAN_F_LEARN ))return SKB_NOT_DROPPED_YET ; -return vxlan_snoop (skb->dev, &saddr,eth_hdr (skb)->h_source, +return vxlan_snoop (skb->dev, cfg, &saddr,eth_hdr (skb)->h_source, ifindex, vni); }
@@ -1646,18 +1650,20 @@ static bool vxlan_ecn_decapsulate(struct vxlan_sock *vs, void *oiph,static int vxlan_rcv (struct sock *sk,struct sk_buff *skb) {struct vxlan_vni_node *vninode =NULL ; -const struct vxlanhdr *vh; -struct vxlan_dev *vxlan; -struct vxlan_sock *vs; -struct vxlan_metadata _md; -struct vxlan_metadata *md = &_md;__be16 protocol =htons (ETH_P_TEB );enum skb_drop_reason reason; +const struct vxlanhdr *vh; +struct vxlan_metadata *md; +struct vxlan_metadata _md; +struct vxlan_dev *vxlan;bool raw_proto = false; -void *oiph; +struct vxlan_sock *vs;__be32 vni =0 ; +void *oiph;int nh; + md = &_md; +/* Need UDP and VXLAN header to be present */ reason =pskb_may_pull_reason (skb,VXLAN_HLEN );if (reason)
@@ -1698,7 +1704,7 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) reason =SKB_DROP_REASON_VXLAN_INVALID_HDR ;DEV_STATS_INC (vxlan->dev, rx_frame_errors);DEV_STATS_INC (vxlan->dev, rx_errors); -vxlan_vnifilter_count (vxlan, vni, vninode, +vxlan_vnifilter_count (vxlan, &vxlan->cfg, vni, vninode,VXLAN_VNI_STATS_RX_ERRORS ,0 ); goto drop; }
@@ -1748,7 +1754,7 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)*/ if (!raw_proto) { - reason =vxlan_set_mac (vxlan, vs, skb, vni); + reason =vxlan_set_mac (vxlan, &vxlan->cfg, vs, skb, vni);if (reason) goto drop; }else {
@@ -1769,7 +1775,7 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)if (reason) {DEV_STATS_INC (vxlan->dev, rx_length_errors);DEV_STATS_INC (vxlan->dev, rx_errors); -vxlan_vnifilter_count (vxlan, vni, vninode, +vxlan_vnifilter_count (vxlan, &vxlan->cfg, vni, vninode,VXLAN_VNI_STATS_RX_ERRORS ,0 ); goto drop; }
@@ -1781,7 +1787,7 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) reason =SKB_DROP_REASON_IP_TUNNEL_ECN ;DEV_STATS_INC (vxlan->dev, rx_frame_errors);DEV_STATS_INC (vxlan->dev, rx_errors); -vxlan_vnifilter_count (vxlan, vni, vninode, +vxlan_vnifilter_count (vxlan, &vxlan->cfg, vni, vninode,VXLAN_VNI_STATS_RX_ERRORS ,0 ); goto drop; }
@@ -1791,14 +1797,14 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)if (unlikely (!(vxlan->dev->flags &IFF_UP ))) {rcu_read_unlock ();dev_dstats_rx_dropped (vxlan->dev); -vxlan_vnifilter_count (vxlan, vni, vninode, +vxlan_vnifilter_count (vxlan, &vxlan->cfg, vni, vninode,VXLAN_VNI_STATS_RX_DROPS ,0 ); reason =SKB_DROP_REASON_DEV_READY ; goto drop; }dev_dstats_rx_add (vxlan->dev, skb->len); -vxlan_vnifilter_count (vxlan, vni, vninode,VXLAN_VNI_STATS_RX , skb->len); +vxlan_vnifilter_count (vxlan, &vxlan->cfg, vni, vninode,VXLAN_VNI_STATS_RX , skb->len);gro_cells_receive (&vxlan->gro_cells, skb);rcu_read_unlock ();
@@ -1839,7 +1845,7 @@ static int vxlan_err_lookup(struct sock *sk, struct sk_buff *skb)return 0 ; } -static int arp_reduce (struct net_device *dev,struct sk_buff *skb,__be32 vni) +static int arp_reduce (struct net_device *dev,struct sk_buff *skb,__be32 vni,u32 flags) {struct vxlan_dev *vxlan =netdev_priv (dev);struct arphdr *parp;
@@ -1852,7 +1858,7 @@ static int arp_reduce(struct net_device *dev, struct sk_buff *skb, __be32 vni)if (!pskb_may_pull (skb,arp_hdr_len (dev))) {dev_dstats_tx_dropped (dev); -vxlan_vnifilter_count (vxlan, vni,NULL , +vxlan_vnifilter_count (vxlan, &vxlan->cfg, vni,NULL ,VXLAN_VNI_STATS_TX_DROPS ,0 ); goto out; }
@@ -1890,7 +1896,7 @@ static int arp_reduce(struct net_device *dev, struct sk_buff *skb, __be32 vni) }rcu_read_lock (); - f =vxlan_find_mac_tx (vxlan, n->ha, vni); + f =vxlan_find_mac_tx (vxlan, &vxlan->cfg, n->ha, vni);if (f) rdst =first_remote_rcu (f);if (rdst &&vxlan_addr_any (&rdst->remote_ip)) {
@@ -1916,11 +1922,11 @@ static int arp_reduce(struct net_device *dev, struct sk_buff *skb, __be32 vni)if (netif_rx (reply) ==NET_RX_DROP ) {dev_dstats_rx_dropped (dev); -vxlan_vnifilter_count (vxlan, vni,NULL , +vxlan_vnifilter_count (vxlan, &vxlan->cfg, vni,NULL ,VXLAN_VNI_STATS_RX_DROPS ,0 ); } - }else if (vxlan->cfg.flags &VXLAN_F_L3MISS ) { + }else if (flags &VXLAN_F_L3MISS ) {union vxlan_addr ipa = { .sin.sin_addr.s_addr = tip, .sin.sin_family = AF_INET,
@@ -2027,7 +2033,7 @@ static struct sk_buff *vxlan_na_create(struct sk_buff *request,return reply; } -static int neigh_reduce (struct net_device *dev,struct sk_buff *skb,__be32 vni) +static int neigh_reduce (struct net_device *dev,struct sk_buff *skb,__be32 vni,u32 flags) {struct vxlan_dev *vxlan =netdev_priv (dev);const struct in6_addr *daddr;
@@ -2059,7 +2065,7 @@ static int neigh_reduce(struct net_device *dev, struct sk_buff *skb, __be32 vni) goto out; } - f =vxlan_find_mac_tx (vxlan, n->ha, vni); + f =vxlan_find_mac_tx (vxlan, &vxlan->cfg, n->ha, vni);if (f) rdst =first_remote_rcu (f);if (rdst &&vxlan_addr_any (&rdst->remote_ip)) {
@@ -2078,10 +2084,10 @@ static int neigh_reduce(struct net_device *dev, struct sk_buff *skb, __be32 vni)if (netif_rx (reply) ==NET_RX_DROP ) {dev_dstats_rx_dropped (dev); -vxlan_vnifilter_count (vxlan, vni,NULL , +vxlan_vnifilter_count (vxlan, &vxlan->cfg, vni,NULL ,VXLAN_VNI_STATS_RX_DROPS ,0 ); } - }else if (vxlan->cfg.flags &VXLAN_F_L3MISS ) { + }else if (flags &VXLAN_F_L3MISS ) {union vxlan_addr ipa = { .sin6.sin6_addr = msg->target, .sin6.sin6_family = AF_INET6,
@@ -2097,9 +2103,9 @@ static int neigh_reduce(struct net_device *dev, struct sk_buff *skb, __be32 vni) }#endif -static bool route_shortcircuit (struct net_device *dev,struct sk_buff *skb) +static bool route_shortcircuit (struct net_device *dev,struct sk_buff *skb, +const struct vxlan_config *cfg) { -struct vxlan_dev *vxlan =netdev_priv (dev);struct neighbour *n;if (is_multicast_ether_addr (eth_hdr (skb)->h_dest))
@@ -2115,7 +2121,7 @@ static bool route_shortcircuit(struct net_device *dev, struct sk_buff *skb)return false; pip =ip_hdr (skb); n =neigh_lookup (&arp_tbl, &pip->daddr, dev); -if (!n && (vxlan->cfg.flags &VXLAN_F_L3MISS )) { +if (!n && (cfg->flags &VXLAN_F_L3MISS )) {union vxlan_addr ipa = { .sin.sin_addr.s_addr = pip->daddr, .sin.sin_family =AF_INET ,
@@ -2141,7 +2147,7 @@ static bool route_shortcircuit(struct net_device *dev, struct sk_buff *skb)return false; pip6 =ipv6_hdr (skb); n =neigh_lookup (&nd_tbl, &pip6->daddr, dev); -if (!n && (vxlan->cfg.flags &VXLAN_F_L3MISS )) { +if (!n && (cfg->flags &VXLAN_F_L3MISS )) {union vxlan_addr ipa = { .sin6.sin6_addr = pip6->daddr, .sin6.sin6_family =AF_INET6 ,
@@ -2253,20 +2259,20 @@ static int vxlan_build_skb(struct sk_buff *skb, struct dst_entry *dst,/* Bypass encapsulation if the destination is local */ static void vxlan_encap_bypass (struct sk_buff *skb,struct vxlan_dev *src_vxlan, -struct vxlan_dev *dst_vxlan,__be32 vni, -bool snoop) +struct vxlan_dev *dst_vxlan, +const struct vxlan_config *cfg, +__be32 vni,bool snoop) {union vxlan_addr loopback; -union vxlan_addr *remote_ip = &dst_vxlan->default_dst.remote_ip;unsigned int len = skb->len; -struct net_device *dev; +struct net_device *dev = dst_vxlan->dev; skb->pkt_type =PACKET_HOST ; skb->encapsulation =0 ; - skb->dev = dst_vxlan->dev; + skb->dev = dev;__skb_pull (skb,skb_network_offset (skb)); -if (remote_ip->sa.sa_family ==AF_INET ) { +if (cfg->remote_ip.sa.sa_family ==AF_INET ) { loopback.sin.sin_addr.s_addr =htonl (INADDR_LOOPBACK ); loopback.sa.sa_family =AF_INET ;#if IS_ENABLED (CONFIG_IPV6 )
@@ -2277,26 +2283,25 @@ static void vxlan_encap_bypass(struct sk_buff *skb, struct vxlan_dev *src_vxlan, }rcu_read_lock (); - dev = skb->dev;if (unlikely (!(dev->flags &IFF_UP ))) {kfree_skb_reason (skb,SKB_DROP_REASON_DEV_READY ); goto drop; } -if ((dst_vxlan->cfg.flags &VXLAN_F_LEARN ) && snoop) -vxlan_snoop (dev, &loopback,eth_hdr (skb)->h_source,0 , vni); +if ((cfg->flags &VXLAN_F_LEARN ) && snoop) +vxlan_snoop (dev, cfg, &loopback,eth_hdr (skb)->h_source,0 , vni);dev_dstats_tx_add (src_vxlan->dev, len); -vxlan_vnifilter_count (src_vxlan, vni,NULL ,VXLAN_VNI_STATS_TX , len); +vxlan_vnifilter_count (src_vxlan, cfg, vni,NULL ,VXLAN_VNI_STATS_TX , len);if (__netif_rx (skb) ==NET_RX_SUCCESS ) {dev_dstats_rx_add (dst_vxlan->dev, len); -vxlan_vnifilter_count (dst_vxlan, vni,NULL ,VXLAN_VNI_STATS_RX , +vxlan_vnifilter_count (dst_vxlan, cfg, vni,NULL ,VXLAN_VNI_STATS_RX , len); }else { drop:dev_dstats_rx_dropped (dev); -vxlan_vnifilter_count (dst_vxlan, vni,NULL , +vxlan_vnifilter_count (dst_vxlan, cfg, vni,NULL ,VXLAN_VNI_STATS_RX_DROPS ,0 ); }rcu_read_unlock ();
@@ -2304,6 +2309,7 @@ static void vxlan_encap_bypass(struct sk_buff *skb, struct vxlan_dev *src_vxlan, static int encap_bypass_if_local(struct sk_buff *skb, struct net_device *dev, struct vxlan_dev *vxlan, + const struct vxlan_config *cfg, int addr_family, __be16 dst_port, int dst_ifindex, __be32 vni, struct dst_entry *dst,
@@ -2319,22 +2325,22 @@ static int encap_bypass_if_local(struct sk_buff *skb, struct net_device *dev,/* Bypass encapsulation if the destination is local */ if (rt_flags &RTCF_LOCAL && !(rt_flags & (RTCF_BROADCAST |RTCF_MULTICAST )) && - vxlan->cfg.flags &VXLAN_F_LOCALBYPASS ) { + cfg->flags &VXLAN_F_LOCALBYPASS ) {struct vxlan_dev *dst_vxlan;dst_release (dst); dst_vxlan =vxlan_find_vni (vxlan->net, dst_ifindex, vni, addr_family, dst_port, - vxlan->cfg.flags); + cfg->flags);if (!dst_vxlan) {DEV_STATS_INC (dev, tx_errors); -vxlan_vnifilter_count (vxlan, vni,NULL , +vxlan_vnifilter_count (vxlan, cfg, vni,NULL ,VXLAN_VNI_STATS_TX_ERRORS ,0 );kfree_skb_reason (skb,SKB_DROP_REASON_VXLAN_VNI_NOT_FOUND );return -ENOENT ; } -vxlan_encap_bypass (skb, vxlan, dst_vxlan, vni, true); +vxlan_encap_bypass (skb, vxlan, dst_vxlan, cfg, vni, true);return 1 ; }
@@ -2342,30 +2348,35 @@ static int encap_bypass_if_local(struct sk_buff *skb, struct net_device *dev, }void vxlan_xmit_one (struct sk_buff *skb,struct net_device *dev, +const struct vxlan_config *cfg,__be32 default_vni,struct vxlan_rdst *rdst,bool did_rsc) { +unsigned int pkt_len = skb->len; +__be16 src_port =0 , dst_port; +struct dst_entry *ndst =NULL ; +enum skb_drop_reason reason; +struct vxlan_dev *vxlan;struct dst_cache *dst_cache; +const struct iphdr *old_iph;struct ip_tunnel_info *info;struct ip_tunnel_key *pkey; -struct ip_tunnel_key key; -struct vxlan_dev *vxlan =netdev_priv (dev); -const struct iphdr *old_iph; +struct vxlan_metadata *md;struct vxlan_metadata _md; -struct vxlan_metadata *md = &_md; -unsigned int pkt_len = skb->len; -__be16 src_port =0 , dst_port; -struct dst_entry *ndst =NULL ; +struct ip_tunnel_key key; +u32 flags = cfg->flags; +bool udp_sum = false; +bool no_eth_encap;int addr_family; +bool use_cache; +__be32 vni =0 ; +bool xnet;__u8 tos, ttl;int ifindex;int err =0 ; -u32 flags = vxlan->cfg.flags; -bool use_cache; -bool udp_sum = false; -bool xnet = !net_eq (vxlan->net,dev_net (vxlan->dev)); -enum skb_drop_reason reason; -bool no_eth_encap; -__be32 vni =0 ; + + vxlan =netdev_priv (dev); + xnet = !net_eq (vxlan->net,dev_net (vxlan->dev)); + md = &_md; no_eth_encap = flags &VXLAN_F_GPE && skb->protocol !=htons (ETH_P_TEB ); reason =skb_vlan_inet_prepare (skb, no_eth_encap);
@@ -2385,23 +2396,23 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,if (vxlan_addr_any (&rdst->remote_ip)) {if (did_rsc) {/* short-circuited back to local bridge */ -vxlan_encap_bypass (skb, vxlan, vxlan, +vxlan_encap_bypass (skb, vxlan, vxlan, cfg, default_vni, true);return ; } goto drop; } - addr_family = vxlan->cfg.saddr.sa.sa_family; - dst_port = rdst->remote_port ? rdst->remote_port : vxlan->cfg.dst_port; + addr_family = cfg->saddr.sa.sa_family; + dst_port = rdst->remote_port ? rdst->remote_port : cfg->dst_port; vni = (rdst->remote_vni) ? : default_vni; ifindex = rdst->remote_ifindex;if (addr_family ==AF_INET ) { - key.u.ipv4.src = vxlan->cfg.saddr.sin.sin_addr.s_addr; + key.u.ipv4.src = cfg->saddr.sin.sin_addr.s_addr; key.u.ipv4.dst = rdst->remote_ip.sin.sin_addr.s_addr; }else { - key.u.ipv6.src = vxlan->cfg.saddr.sin6.sin6_addr; + key.u.ipv6.src = cfg->saddr.sin6.sin6_addr; key.u.ipv6.dst = rdst->remote_ip.sin6.sin6_addr; }
@@ -2410,11 +2421,11 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,if (flags &VXLAN_F_TTL_INHERIT ) { ttl =ip_tunnel_get_ttl (old_iph, skb); }else { - ttl = vxlan->cfg.ttl; + ttl = cfg->ttl;if (!ttl &&vxlan_addr_multicast (&rdst->remote_ip)) ttl =1 ; } - tos = vxlan->cfg.tos; + tos = cfg->tos;if (tos ==1 ) tos =ip_tunnel_get_dsfield (old_iph, skb);if (tos && !info)
@@ -2425,9 +2436,9 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,else udp_sum = !(flags &VXLAN_F_UDP_ZERO_CSUM6_TX );#if IS_ENABLED (CONFIG_IPV6 ) -switch (vxlan->cfg.label_policy) { +switch (cfg->label_policy) {case VXLAN_LABEL_FIXED : - key.label = vxlan->cfg.label; + key.label = cfg->label;break ;case VXLAN_LABEL_INHERIT : key.label =ip_tunnel_get_flowlabel (old_iph, skb);
@@ -2445,7 +2456,7 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, } pkey = &info->key; addr_family =ip_tunnel_info_af (info); - dst_port = info->key.tp_dst ? : vxlan->cfg.dst_port; + dst_port = info->key.tp_dst ? : cfg->dst_port; vni =tunnel_id_to_key32 (info->key.tun_id); ifindex =0 ; dst_cache = &info->dst_cache;
@@ -2458,8 +2469,8 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, tos = info->key.tos; udp_sum =test_bit (IP_TUNNEL_CSUM_BIT , info->key.tun_flags); } - src_port =udp_flow_src_port (dev_net (dev), skb, vxlan->cfg.port_min, - vxlan->cfg.port_max, true); + src_port =udp_flow_src_port (dev_net (dev), skb, cfg->port_min, + cfg->port_max, true);rcu_read_lock ();if (addr_family ==AF_INET ) {
@@ -2492,15 +2503,15 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,if (!info) {/* Bypass encapsulation if the destination is local */ - err =encap_bypass_if_local (skb, dev, vxlan,AF_INET , + err =encap_bypass_if_local (skb, dev, vxlan, cfg,AF_INET , dst_port, ifindex, vni, &rt->dst, rt->rt_flags);if (err) goto out_unlock; -if (vxlan->cfg.df ==VXLAN_DF_SET ) { +if (cfg->df ==VXLAN_DF_SET ) { df =htons (IP_DF ); - }else if (vxlan->cfg.df ==VXLAN_DF_INHERIT ) { + }else if (cfg->df ==VXLAN_DF_INHERIT ) {struct ethhdr *eth =eth_hdr (skb); if (ntohs(eth->h_proto) == ETH_P_IPV6 ||
@@ -2529,7 +2540,7 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, unclone->key.u.ipv4.src = pkey->u.ipv4.dst; unclone->key.u.ipv4.dst = saddr; } -vxlan_encap_bypass (skb, vxlan, vxlan, vni, false); +vxlan_encap_bypass (skb, vxlan, vxlan, cfg, vni, false);dst_release (ndst); goto out_unlock; }
@@ -2579,7 +2590,7 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,if (!info) {u32 rt6i_flags =dst_rt6_info (ndst)->rt6i_flags; - err =encap_bypass_if_local (skb, dev, vxlan,AF_INET6 , + err =encap_bypass_if_local (skb, dev, vxlan, cfg,AF_INET6 , dst_port, ifindex, vni, ndst, rt6i_flags);if (err)
@@ -2603,7 +2614,7 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, unclone->key.u.ipv6.dst = saddr; } -vxlan_encap_bypass (skb, vxlan, vxlan, vni, false); +vxlan_encap_bypass (skb, vxlan, vxlan, cfg, vni, false);dst_release (ndst); goto out_unlock; }
@@ -2624,14 +2635,14 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, ip6cb_flags);#endif } -vxlan_vnifilter_count (vxlan, vni,NULL ,VXLAN_VNI_STATS_TX , pkt_len); +vxlan_vnifilter_count (vxlan, cfg, vni,NULL ,VXLAN_VNI_STATS_TX , pkt_len); out_unlock:rcu_read_unlock ();return ; drop:dev_dstats_tx_dropped (dev); -vxlan_vnifilter_count (vxlan, vni,NULL ,VXLAN_VNI_STATS_TX_DROPS ,0 ); +vxlan_vnifilter_count (vxlan, cfg, vni,NULL ,VXLAN_VNI_STATS_TX_DROPS ,0 );kfree_skb_reason (skb, reason);return ;
@@ -2643,11 +2654,12 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,DEV_STATS_INC (dev, tx_carrier_errors);dst_release (ndst);DEV_STATS_INC (dev, tx_errors); -vxlan_vnifilter_count (vxlan, vni,NULL ,VXLAN_VNI_STATS_TX_ERRORS ,0 ); +vxlan_vnifilter_count (vxlan, cfg, vni,NULL ,VXLAN_VNI_STATS_TX_ERRORS ,0 );kfree_skb_reason (skb, reason); }static void vxlan_xmit_nh (struct sk_buff *skb,struct net_device *dev, +const struct vxlan_config *cfg,struct vxlan_fdb *f,__be32 vni,bool did_rsc) {struct vxlan_rdst nh_rdst;
@@ -2664,7 +2676,7 @@ static void vxlan_xmit_nh(struct sk_buff *skb, struct net_device *dev, do_xmit =vxlan_fdb_nh_path_select (nh, hash, &nh_rdst);if (likely (do_xmit)) -vxlan_xmit_one (skb, dev, vni, &nh_rdst, did_rsc); +vxlan_xmit_one (skb, dev, cfg, vni, &nh_rdst, did_rsc);else goto drop;
@@ -2672,15 +2684,15 @@ static void vxlan_xmit_nh(struct sk_buff *skb, struct net_device *dev, drop:dev_dstats_tx_dropped (dev); -vxlan_vnifilter_count (netdev_priv (dev), vni,NULL , +vxlan_vnifilter_count (netdev_priv (dev), cfg, vni,NULL ,VXLAN_VNI_STATS_TX_DROPS ,0 );dev_kfree_skb (skb); }static netdev_tx_t vxlan_xmit_nhid (struct sk_buff *skb,struct net_device *dev, -u32 nhid,__be32 vni) +u32 nhid,__be32 vni,int saddr_family, +const struct vxlan_config *cfg) { -struct vxlan_dev *vxlan =netdev_priv (dev);struct vxlan_rdst nh_rdst;struct nexthop *nh;bool do_xmit;
@@ -2698,11 +2710,11 @@ static netdev_tx_t vxlan_xmit_nhid(struct sk_buff *skb, struct net_device *dev, do_xmit =vxlan_fdb_nh_path_select (nh, hash, &nh_rdst);rcu_read_unlock (); -if (vxlan->cfg.saddr.sa.sa_family != nh_rdst.remote_ip.sa.sa_family) +if (saddr_family != nh_rdst.remote_ip.sa.sa_family) goto drop;if (likely (do_xmit)) -vxlan_xmit_one (skb, dev, vni, &nh_rdst, false); +vxlan_xmit_one (skb, dev, cfg, vni, &nh_rdst, false);else goto drop;
@@ -2710,7 +2722,7 @@ static netdev_tx_t vxlan_xmit_nhid(struct sk_buff *skb, struct net_device *dev, drop:dev_dstats_tx_dropped (dev); -vxlan_vnifilter_count (netdev_priv (dev), vni,NULL , +vxlan_vnifilter_count (netdev_priv (dev), cfg, vni,NULL ,VXLAN_VNI_STATS_TX_DROPS ,0 );dev_kfree_skb (skb);return NETDEV_TX_OK ;
@@ -2727,34 +2739,43 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev)struct vxlan_dev *vxlan =netdev_priv (dev);struct vxlan_rdst *rdst, *fdst =NULL ;const struct ip_tunnel_info *info; +const struct vxlan_config *cfg; +__be32 default_vni;struct vxlan_fdb *f;struct ethhdr *eth; +int saddr_family;__be32 vni =0 ; -u32 nhid =0 ;bool did_rsc; +u32 nhid =0 ; +u32 flags; + + cfg = &vxlan->cfg; + flags = cfg->flags; + default_vni = cfg->vni; + saddr_family = cfg->saddr.sa.sa_family; info =skb_tunnel_info (skb);skb_reset_mac_header (skb); -if (vxlan->cfg.flags &VXLAN_F_COLLECT_METADATA ) { +if (flags &VXLAN_F_COLLECT_METADATA ) {if (info && info->mode &IP_TUNNEL_INFO_BRIDGE && info->mode &IP_TUNNEL_INFO_TX ) { vni =tunnel_id_to_key32 (info->key.tun_id); nhid = info->key.nhid; }else {if (info && info->mode &IP_TUNNEL_INFO_TX ) -vxlan_xmit_one (skb, dev, vni,NULL , false); +vxlan_xmit_one (skb, dev, cfg, vni,NULL , false);else kfree_skb_reason (skb,SKB_DROP_REASON_TUNNEL_TXINFO );return NETDEV_TX_OK ; } } -if (vxlan->cfg.flags &VXLAN_F_PROXY ) { +if (flags &VXLAN_F_PROXY ) { eth =eth_hdr (skb);if (ntohs (eth->h_proto) ==ETH_P_ARP ) -return arp_reduce (dev, skb, vni); +return arp_reduce (dev, skb, vni, flags); #if IS_ENABLED(CONFIG_IPV6) else if (ntohs(eth->h_proto) == ETH_P_IPV6 && pskb_may_pull(skb, sizeof(struct ipv6hdr) +
@@ -2764,15 +2785,15 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev)if (m->icmph.icmp6_code ==0 && m->icmph.icmp6_type ==NDISC_NEIGHBOUR_SOLICITATION ) - return neigh_reduce(dev, skb, vni); + return neigh_reduce(dev, skb, vni, flags); }#endif }if (nhid) -return vxlan_xmit_nhid (skb, dev, nhid, vni); +return vxlan_xmit_nhid (skb, dev, nhid, vni, saddr_family, cfg); -if (vxlan->cfg.flags &VXLAN_F_MDB ) { +if (flags &VXLAN_F_MDB ) {struct vxlan_mdb_entry *mdb_entry;rcu_read_lock ();
@@ -2789,26 +2810,26 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev) eth =eth_hdr (skb);rcu_read_lock (); - f =vxlan_find_mac_tx (vxlan, eth->h_dest, vni); + f =vxlan_find_mac_tx (vxlan, cfg, eth->h_dest, vni); did_rsc = false; -if (f && (f->flags &NTF_ROUTER ) && (vxlan->cfg.flags &VXLAN_F_RSC ) && +if (f && (f->flags &NTF_ROUTER ) && (flags &VXLAN_F_RSC ) && (ntohs (eth->h_proto) ==ETH_P_IP ||ntohs (eth->h_proto) ==ETH_P_IPV6 )) { - did_rsc =route_shortcircuit (dev, skb); + did_rsc =route_shortcircuit (dev, skb, cfg);if (did_rsc) - f =vxlan_find_mac_tx (vxlan, eth->h_dest, vni); + f =vxlan_find_mac_tx (vxlan, cfg, eth->h_dest, vni); }if (f ==NULL ) { - f =vxlan_find_mac_tx (vxlan, all_zeros_mac, vni); + f =vxlan_find_mac_tx (vxlan, cfg, all_zeros_mac, vni);if (f ==NULL ) { -if ((vxlan->cfg.flags &VXLAN_F_L2MISS ) && +if ((flags &VXLAN_F_L2MISS ) && !is_multicast_ether_addr (eth->h_dest))vxlan_fdb_miss (vxlan, eth->h_dest);dev_dstats_tx_dropped (dev); -vxlan_vnifilter_count (vxlan, vni,NULL , +vxlan_vnifilter_count (vxlan, cfg, vni,NULL ,VXLAN_VNI_STATS_TX_DROPS ,0 );kfree_skb_reason (skb,SKB_DROP_REASON_NO_TX_TARGET ); goto out;
@@ -2816,8 +2837,8 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev) }if (rcu_access_pointer (f->nh)) { -vxlan_xmit_nh (skb, dev, f, - (vni ? : vxlan->default_dst.remote_vni), did_rsc); +vxlan_xmit_nh (skb, dev, cfg, f, + (vni ? : default_vni), did_rsc); }else {list_for_each_entry_rcu (rdst, &f->remotes, list) {struct sk_buff *skb1;
@@ -2828,10 +2849,10 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev) } skb1 =skb_clone (skb,GFP_ATOMIC );if (skb1) -vxlan_xmit_one (skb1, dev, vni, rdst, did_rsc); +vxlan_xmit_one (skb1, dev, cfg, vni, rdst, did_rsc); }if (fdst) -vxlan_xmit_one (skb, dev, vni, fdst, did_rsc); +vxlan_xmit_one (skb, dev, cfg, vni, fdst, did_rsc);else kfree_skb_reason (skb,SKB_DROP_REASON_NO_TX_TARGET ); }
@@ -3701,7 +3722,7 @@ static int vxlan_sock_add(struct vxlan_dev *vxlan) }int vxlan_vni_in_use (struct net *src_net,struct vxlan_dev *vxlan, -struct vxlan_config *conf,__be32 vni) +const struct vxlan_config *conf,__be32 vni) {struct vxlan_net *vn =net_generic (src_net, vxlan_net_id);struct vxlan_dev *tmp;
drivers/net/vxlan/vxlan_mdb.c +12 -8
@@ -164,6 +164,7 @@ static int vxlan_mdb_entry_info_fill(const struct vxlan_dev *vxlan,const struct vxlan_mdb_entry *mdb_entry, const struct vxlan_mdb_remote *remote) { + const struct vxlan_config *cfg = &vxlan->cfg;struct vxlan_rdst *rd =rtnl_dereference (remote->rd);struct br_mdb_entry e;struct nlattr *nest;
@@ -188,7 +189,7 @@ static int vxlan_mdb_entry_info_fill(const struct vxlan_dev *vxlan, vxlan_nla_put_addr(skb, MDBA_MDB_EATTR_DST, &rd->remote_ip)) goto nest_err; -if (rd->remote_port && rd->remote_port != vxlan->cfg.dst_port && +if (rd->remote_port && rd->remote_port != cfg->dst_port &&nla_put_u16 (skb,MDBA_MDB_EATTR_DST_PORT ,be16_to_cpu (rd->remote_port))) goto nest_err;
@@ -201,7 +202,7 @@ static int vxlan_mdb_entry_info_fill(const struct vxlan_dev *vxlan, nla_put_u32(skb, MDBA_MDB_EATTR_IFINDEX, rd->remote_ifindex)) goto nest_err; -if ((vxlan->cfg.flags &VXLAN_F_COLLECT_METADATA ) && +if ((cfg->flags &VXLAN_F_COLLECT_METADATA ) && mdb_entry->key.vni &&nla_put_u32 (skb,MDBA_MDB_EATTR_SRC_VNI ,be32_to_cpu (mdb_entry->key.vni))) goto nest_err;
@@ -604,6 +605,7 @@ static int vxlan_mdb_config_init(struct vxlan_mdb_config *cfg, {struct br_mdb_entry *entry =nla_data (tb[MDBA_SET_ENTRY ]);struct vxlan_dev *vxlan =netdev_priv (dev); +const struct vxlan_config *vcfg = &vxlan->cfg;memset (cfg,0 ,sizeof (*cfg)); cfg->vxlan = vxlan;
@@ -613,7 +615,7 @@ static int vxlan_mdb_config_init(struct vxlan_mdb_config *cfg, cfg->filter_mode =MCAST_EXCLUDE ; cfg->rt_protocol =RTPROT_STATIC ; cfg->remote_vni = vxlan->default_dst.remote_vni; - cfg->remote_port = vxlan->cfg.dst_port; + cfg->remote_port = vcfg->dst_port;if (entry->ifindex != dev->ifindex) {NL_SET_ERR_MSG_MOD (extack,"Port net device must be the VXLAN net device" );
@@ -938,6 +940,7 @@ vxlan_mdb_nlmsg_remote_size(const struct vxlan_dev *vxlan,const struct vxlan_mdb_entry *mdb_entry, const struct vxlan_mdb_remote *remote) { + const struct vxlan_config *cfg = &vxlan->cfg;const struct vxlan_mdb_entry_key *group = &mdb_entry->key;struct vxlan_rdst *rd =rtnl_dereference (remote->rd);size_t nlmsg_size;
@@ -959,7 +962,7 @@ vxlan_mdb_nlmsg_remote_size(const struct vxlan_dev *vxlan,/* MDBA_MDB_EATTR_DST */ nlmsg_size +=nla_total_size (vxlan_addr_size (&rd->remote_ip));/* MDBA_MDB_EATTR_DST_PORT */ -if (rd->remote_port && rd->remote_port != vxlan->cfg.dst_port) +if (rd->remote_port && rd->remote_port != cfg->dst_port) nlmsg_size +=nla_total_size (sizeof (u16));/* MDBA_MDB_EATTR_VNI */ if (rd->remote_vni != vxlan->default_dst.remote_vni)
@@ -968,7 +971,7 @@ vxlan_mdb_nlmsg_remote_size(const struct vxlan_dev *vxlan,if (rd->remote_ifindex) nlmsg_size +=nla_total_size (sizeof (u32));/* MDBA_MDB_EATTR_SRC_VNI */ -if ((vxlan->cfg.flags &VXLAN_F_COLLECT_METADATA ) && group->vni) +if ((cfg->flags &VXLAN_F_COLLECT_METADATA ) && group->vni) nlmsg_size +=nla_total_size (sizeof (u32));return nlmsg_size;
@@ -1607,6 +1610,7 @@ struct vxlan_mdb_entry *vxlan_mdb_entry_skb_get(struct vxlan_dev *vxlan, struct sk_buff *skb, __be32 src_vni) { +const struct vxlan_config *cfg = &vxlan->cfg;struct vxlan_mdb_entry *mdb_entry;struct vxlan_mdb_entry_key group;
@@ -1617,7 +1621,7 @@ struct vxlan_mdb_entry *vxlan_mdb_entry_skb_get(struct vxlan_dev *vxlan,/* When not in collect metadata mode, 'src_vni' is zero, but MDB * entries are stored with the VNI of the VXLAN device. */ -if (!(vxlan->cfg.flags &VXLAN_F_COLLECT_METADATA )) +if (!(cfg->flags &VXLAN_F_COLLECT_METADATA )) src_vni = vxlan->default_dst.remote_vni;memset (&group,0 ,sizeof (group));
@@ -1704,12 +1708,12 @@ netdev_tx_t vxlan_mdb_xmit(struct vxlan_dev *vxlan, skb1 =skb_clone (skb,GFP_ATOMIC );if (skb1) -vxlan_xmit_one (skb1, vxlan->dev, src_vni, +vxlan_xmit_one (skb1, vxlan->dev, &vxlan->cfg, src_vni,rcu_dereference (remote->rd), false); }if (fremote) -vxlan_xmit_one (skb, vxlan->dev, src_vni, +vxlan_xmit_one (skb, vxlan->dev, &vxlan->cfg, src_vni,rcu_dereference (fremote->rd), false);else kfree_skb_reason (skb,SKB_DROP_REASON_NO_TX_TARGET );
drivers/net/vxlan/vxlan_private.h +4 -2
@@ -195,9 +195,10 @@ int vxlan_fdb_update(struct vxlan_dev *vxlan, __u32 ifindex, __u16 ndm_flags, u32 nhid, bool swdev_notify, struct netlink_ext_ack *extack);void vxlan_xmit_one (struct sk_buff *skb,struct net_device *dev, +const struct vxlan_config *cfg,__be32 default_vni,struct vxlan_rdst *rdst,bool did_rsc);int vxlan_vni_in_use (struct net *src_net,struct vxlan_dev *vxlan, -struct vxlan_config *conf,__be32 vni); +const struct vxlan_config *conf,__be32 vni);/* vxlan_vnifilter.c */ int vxlan_vnigroup_init (struct vxlan_dev *vxlan);
@@ -205,7 +206,8 @@ void vxlan_vnigroup_uninit(struct vxlan_dev *vxlan);int vxlan_vnifilter_init (void );void vxlan_vnifilter_uninit (void ); -void vxlan_vnifilter_count (struct vxlan_dev *vxlan,__be32 vni, +void vxlan_vnifilter_count (struct vxlan_dev *vxlan, +const struct vxlan_config *cfg,__be32 vni,struct vxlan_vni_node *vninode,int type,unsigned int len);
drivers/net/vxlan/vxlan_vnifilter.c +3 -2
@@ -171,13 +171,14 @@ static void vxlan_vnifilter_stats_add(struct vxlan_vni_node *vninode,u64_stats_update_end (&pstats->syncp); } -void vxlan_vnifilter_count (struct vxlan_dev *vxlan,__be32 vni, +void vxlan_vnifilter_count (struct vxlan_dev *vxlan, +const struct vxlan_config *cfg,__be32 vni,struct vxlan_vni_node *vninode,int type,unsigned int len) {struct vxlan_vni_node *vnode; -if (!(vxlan->cfg.flags &VXLAN_F_VNIFILTER )) +if (!cfg || !(cfg->flags &VXLAN_F_VNIFILTER ))return ;if (vninode) {
net/openvswitch/vport-vxlan.c +4 -3
@@ -22,19 +22,20 @@ static struct vport_ops ovs_vxlan_netdev_vport_ops;static int vxlan_get_options (const struct vport *vport,struct sk_buff *skb) {struct vxlan_dev *vxlan =netdev_priv (vport->dev); -__be16 dst_port = vxlan->cfg.dst_port; +const struct vxlan_config *cfg = &vxlan->cfg; +__be16 dst_port = cfg->dst_port;if (nla_put_u16 (skb,OVS_TUNNEL_ATTR_DST_PORT ,ntohs (dst_port)))return -EMSGSIZE ; -if (vxlan->cfg.flags &VXLAN_F_GBP ) { +if (cfg->flags &VXLAN_F_GBP ) {struct nlattr *exts; exts =nla_nest_start_noflag (skb,OVS_TUNNEL_ATTR_EXTENSION );if (!exts)return -EMSGSIZE ; -if (vxlan->cfg.flags &VXLAN_F_GBP && +if (cfg->flags &VXLAN_F_GBP &&nla_put_flag (skb,OVS_VXLAN_EXT_GBP ))return -EMSGSIZE ;
Signature · 1 line
2.55.0.795.g602f6c329a-goog
Re: [PATCH net-next 1/3] vxlan: pass vxlan_config pointer to helper functions
Quoted 6 lines · Eric Dumazet
In preparation for converting
vxlan->cfgto an RCU-protected pointer, refactor internal helper functions in the RX, TX, MDB, VNIFILTER, and OVS paths to accept a pointer to structvxlan_config(or pass flags/saddr_familywhere appropriate) rather than directly accessingvxlan->cfg.
<-->
drivers/net/vxlan/vxlan_core.c static int encap_bypass_if_local(struct sk_buff *skb, struct net_device *dev, · line 2358
Quoted 9 lines
void vxlan_xmit_one(struct
sk_buff*skb, structnet_device*dev,drivers/net/vxlan/vxlan_core.c +6
-0+const struct vxlan_config *cfg, __be32 default_vni, struct vxlan_rdst *rdst, bool did_rsc) { + unsigned int pkt_len = skb->len; +__be16 src_port =0 , dst_port; +struct dst_entry *ndst =NULL ; +enum skb_drop_reason reason; +struct vxlan_dev *vxlan;
nit: Can this be pushed few lines below for the reverse xmas tree order.. otherwise LGTM.
PATCH 2/3 vxlan: convert configuration to RCU protection
In reply to Eric DumazetIn order to allow lockless readers in future patches, dynamically allocate 'struct vxlan_config' and convert 'vxlan->cfg' to an RCU protected pointer.
Updating configuration via vxlan_changelink() or __vxlan_dev_create() now allocates a new struct vxlan_config, initializes it, and uses rcu_assign_pointer() to publish it, freeing the previous config with kfree_rcu().
--- .../mellanox/mlxsw/spectrum_nve_vxlan.c | 14 +- .../mellanox/mlxsw/spectrum_switchdev.c | 57 ++- drivers/net/vxlan/vxlan_core.c | 336 +++++++++++------- drivers/net/vxlan/vxlan_mdb.c | 29 +- drivers/net/vxlan/vxlan_multicast.c | 12 +- drivers/net/vxlan/vxlan_vnifilter.c | 21 +- include/net/vxlan.h | 3 +- net/openvswitch/vport-vxlan.c | 31 +- 8 files changed, 331 insertions(+), 172 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_nve_vxlan.c +10 -4
@@ -59,8 +59,11 @@ static bool mlxsw_sp_nve_vxlan_can_offload(const struct mlxsw_sp_nve *nve,const struct mlxsw_sp_nve_params *params, struct netlink_ext_ack *extack) { - struct vxlan_dev *vxlan = netdev_priv(params->dev); -struct vxlan_config *cfg = &vxlan->cfg; + const struct vxlan_config *cfg; +struct vxlan_dev *vxlan; + + vxlan =netdev_priv (params->dev); + cfg =rtnl_dereference (vxlan->cfg);if (vxlan_addr_multicast (&cfg->remote_ip)) {NL_SET_ERR_MSG_MOD (extack,"VxLAN: Multicast destination IP is not supported" );
@@ -148,8 +151,11 @@ static void mlxsw_sp_nve_vxlan_config(const struct mlxsw_sp_nve *nve,const struct mlxsw_sp_nve_params *params, struct mlxsw_sp_nve_config *config) { - struct vxlan_dev *vxlan = netdev_priv(params->dev); -struct vxlan_config *cfg = &vxlan->cfg; + const struct vxlan_config *cfg; +struct vxlan_dev *vxlan; + + vxlan =netdev_priv (params->dev); + cfg =rtnl_dereference (vxlan->cfg); config->type =MLXSW_SP_NVE_TYPE_VXLAN ; config->ttl = cfg->ttl;
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +39 -18
130 lines not on this page · raw message
drivers/net/vxlan/vxlan_core.c +216 -120
918 lines not on this page · raw message
drivers/net/vxlan/vxlan_mdb.c +19 -10
@@ -164,7 +164,7 @@ static int vxlan_mdb_entry_info_fill(const struct vxlan_dev *vxlan,const struct vxlan_mdb_entry *mdb_entry, const struct vxlan_mdb_remote *remote) { - const struct vxlan_config *cfg = &vxlan->cfg; + const struct vxlan_config *cfg = rtnl_dereference(vxlan->cfg);struct vxlan_rdst *rd =rtnl_dereference (remote->rd);struct br_mdb_entry e;struct nlattr *nest;
@@ -605,7 +605,9 @@ static int vxlan_mdb_config_init(struct vxlan_mdb_config *cfg, {struct br_mdb_entry *entry =nla_data (tb[MDBA_SET_ENTRY ]);struct vxlan_dev *vxlan =netdev_priv (dev); -const struct vxlan_config *vcfg = &vxlan->cfg; +const struct vxlan_config *vcfg; + + vcfg =rtnl_dereference (vxlan->cfg);memset (cfg,0 ,sizeof (*cfg)); cfg->vxlan = vxlan;
@@ -940,12 +942,12 @@ vxlan_mdb_nlmsg_remote_size(const struct vxlan_dev *vxlan,const struct vxlan_mdb_entry *mdb_entry, const struct vxlan_mdb_remote *remote) { - const struct vxlan_config *cfg = &vxlan->cfg; + const struct vxlan_config *cfg = rtnl_dereference(vxlan->cfg);const struct vxlan_mdb_entry_key *group = &mdb_entry->key;struct vxlan_rdst *rd =rtnl_dereference (remote->rd);size_t nlmsg_size; -/* MDBA_MDB_ENTRY_INFO */ +/* MDBA_MDB_ENTRY_INFO */ nlmsg_size =nla_total_size (sizeof (struct br_mdb_entry )) +/* MDBA_MDB_EATTR_TIMER */ nla_total_size (sizeof (u32));
@@ -1205,7 +1207,7 @@ vxlan_mdb_entry_get(struct vxlan_dev *vxlan, goto err_free_entry;if (hlist_is_singular_node (&mdb_entry->mdb_node, &vxlan->mdb_list)) - vxlan->cfg.flags |=VXLAN_F_MDB ; +rtnl_dereference (vxlan->cfg)->flags |=VXLAN_F_MDB ;return mdb_entry;
@@ -1222,7 +1224,7 @@ static void vxlan_mdb_entry_put(struct vxlan_dev *vxlan,return ;if (hlist_is_singular_node (&mdb_entry->mdb_node, &vxlan->mdb_list)) - vxlan->cfg.flags &= ~VXLAN_F_MDB ; +rtnl_dereference (vxlan->cfg)->flags &= ~VXLAN_F_MDB ;rhashtable_remove_fast (&vxlan->mdb_tbl, &mdb_entry->rhnode, vxlan_mdb_rht_params);
@@ -1610,7 +1612,7 @@ struct vxlan_mdb_entry *vxlan_mdb_entry_skb_get(struct vxlan_dev *vxlan, struct sk_buff *skb, __be32 src_vni) { -const struct vxlan_config *cfg = &vxlan->cfg; +const struct vxlan_config *cfg;struct vxlan_mdb_entry *mdb_entry;struct vxlan_mdb_entry_key group;
@@ -1618,6 +1620,10 @@ struct vxlan_mdb_entry *vxlan_mdb_entry_skb_get(struct vxlan_dev *vxlan, is_broadcast_ether_addr(eth_hdr(skb)->h_dest))return NULL ; + cfg =rcu_dereference (vxlan->cfg); +if (!cfg) +return NULL ; +/* When not in collect metadata mode, 'src_vni' is zero, but MDB * entries are stored with the VNI of the VXLAN device. */
@@ -1691,8 +1697,11 @@ netdev_tx_t vxlan_mdb_xmit(struct vxlan_dev *vxlan, struct sk_buff *skb) {struct vxlan_mdb_remote *remote, *fremote =NULL ; +const struct vxlan_config *cfg;__be32 src_vni = mdb_entry->key.vni; + cfg =rcu_dereference (vxlan->cfg); +list_for_each_entry_rcu (remote, &mdb_entry->remotes, list) {struct sk_buff *skb1;
@@ -1708,12 +1717,12 @@ netdev_tx_t vxlan_mdb_xmit(struct vxlan_dev *vxlan, skb1 =skb_clone (skb,GFP_ATOMIC );if (skb1) -vxlan_xmit_one (skb1, vxlan->dev, &vxlan->cfg, src_vni, +vxlan_xmit_one (skb1, vxlan->dev, cfg, src_vni,rcu_dereference (remote->rd), false); }if (fremote) -vxlan_xmit_one (skb, vxlan->dev, &vxlan->cfg, src_vni, +vxlan_xmit_one (skb, vxlan->dev, cfg, src_vni,rcu_dereference (fremote->rd), false);else kfree_skb_reason (skb,SKB_DROP_REASON_NO_TX_TARGET );
@@ -1744,7 +1753,7 @@ void vxlan_mdb_fini(struct vxlan_dev *vxlan)struct vxlan_mdb_flush_desc desc = {};vxlan_mdb_flush (vxlan, &desc); -WARN_ON_ONCE (vxlan->cfg.flags &VXLAN_F_MDB ); +WARN_ON_ONCE (rtnl_dereference (vxlan->cfg)->flags &VXLAN_F_MDB );rhashtable_free_and_destroy (&vxlan->mdb_tbl, vxlan_mdb_check_empty,NULL ); }
drivers/net/vxlan/vxlan_multicast.c +9 -3
@@ -147,6 +147,8 @@ bool vxlan_group_used(struct vxlan_net *vn, struct vxlan_dev *dev,#endif list_for_each_entry (vxlan, &vn->vxlan_list, next) { +const struct vxlan_config *cfg; +if (!netif_running (vxlan->dev) || vxlan == dev)continue ;
@@ -158,7 +160,9 @@ bool vxlan_group_used(struct vxlan_net *vn, struct vxlan_dev *dev, rtnl_dereference(vxlan->vn6_sock) != sock6)continue ;#endif -if (vxlan->cfg.flags &VXLAN_F_VNIFILTER ) { + cfg =rtnl_dereference (vxlan->cfg); + +if (cfg->flags &VXLAN_F_VNIFILTER ) {if (!vxlan_group_used_by_vnifilter (vxlan, ip, ifindex))continue ; }else {
@@ -233,6 +237,7 @@ static int vxlan_multicast_leave_vnigrp(struct vxlan_dev *vxlan)int vxlan_multicast_join (struct vxlan_dev *vxlan) { +const struct vxlan_config *cfg =rtnl_dereference (vxlan->cfg);int ret =0 ;if (vxlan_addr_multicast (&vxlan->default_dst.remote_ip)) {
@@ -244,7 +249,7 @@ int vxlan_multicast_join(struct vxlan_dev *vxlan)return ret; } -if (vxlan->cfg.flags &VXLAN_F_VNIFILTER ) +if (cfg->flags &VXLAN_F_VNIFILTER )return vxlan_multicast_join_vnigrp (vxlan);return 0 ;
@@ -252,6 +257,7 @@ int vxlan_multicast_join(struct vxlan_dev *vxlan)int vxlan_multicast_leave (struct vxlan_dev *vxlan) { +const struct vxlan_config *cfg =rtnl_dereference (vxlan->cfg);struct vxlan_net *vn =net_generic (vxlan->net, vxlan_net_id);int ret =0 ;
@@ -263,7 +269,7 @@ int vxlan_multicast_leave(struct vxlan_dev *vxlan)return ret; } -if (vxlan->cfg.flags &VXLAN_F_VNIFILTER ) +if (cfg->flags &VXLAN_F_VNIFILTER )return vxlan_multicast_leave_vnigrp (vxlan);return 0 ;
drivers/net/vxlan/vxlan_vnifilter.c +14 -7
@@ -178,7 +178,7 @@ void vxlan_vnifilter_count(struct vxlan_dev *vxlan, {struct vxlan_vni_node *vnode; -if (!cfg || !(cfg->flags &VXLAN_F_VNIFILTER )) +if (!(cfg->flags &VXLAN_F_VNIFILTER ))return ;if (vninode) {
@@ -337,13 +337,15 @@ static int vxlan_vnifilter_dump_dev(const struct net_device *dev,struct vxlan_vni_node *tmp, *v, *vbegin =NULL , *vend =NULL ;struct vxlan_dev *vxlan =netdev_priv (dev);struct tunnel_msg *new_tmsg, *tmsg; +const struct vxlan_config *cfg;int idx =0 , s_idx = cb->args[1 ];struct vxlan_vni_group *vg;struct nlmsghdr *nlh;bool dump_stats;int err =0 ; -if (!(vxlan->cfg.flags &VXLAN_F_VNIFILTER )) + cfg =rcu_dereference (vxlan->cfg); +if (!(cfg->flags &VXLAN_F_VNIFILTER ))return -EINVAL ;/* RCU needed because of the vni locking rules (rcu || rtnl) */
@@ -478,6 +480,7 @@ static int vxlan_update_default_fdb_entry(struct vxlan_dev *vxlan, __be32 vni,union vxlan_addr *remote_ip, struct netlink_ext_ack *extack) { + const struct vxlan_config *cfg = rtnl_dereference(vxlan->cfg);struct vxlan_rdst *dst = &vxlan->default_dst;int err =0 ;
@@ -487,7 +490,7 @@ static int vxlan_update_default_fdb_entry(struct vxlan_dev *vxlan, __be32 vni, remote_ip,NUD_REACHABLE |NUD_PERMANENT ,NLM_F_APPEND |NLM_F_CREATE , - vxlan->cfg.dst_port, + cfg->dst_port, vni, vni, dst->remote_ifindex,
@@ -501,7 +504,7 @@ static int vxlan_update_default_fdb_entry(struct vxlan_dev *vxlan, __be32 vni,if (old_remote_ip && !vxlan_addr_any (old_remote_ip)) {__vxlan_fdb_delete (vxlan, all_zeros_mac, *old_remote_ip, - vxlan->cfg.dst_port, + cfg->dst_port, vni, vni, dst->remote_ifindex, true);
@@ -615,6 +618,7 @@ static void vxlan_vni_delete_group(struct vxlan_dev *vxlan, struct vxlan_vni_node *vninode) {struct vxlan_net *vn =net_generic (vxlan->net, vxlan_net_id); +const struct vxlan_config *cfg =rtnl_dereference (vxlan->cfg);struct vxlan_rdst *dst = &vxlan->default_dst;/* if per vni remote_ip not present, delete the
@@ -626,7 +630,7 @@ static void vxlan_vni_delete_group(struct vxlan_dev *vxlan,__vxlan_fdb_delete (vxlan, all_zeros_mac, (vxlan_addr_any (&vninode->remote_ip) ? dst->remote_ip : vninode->remote_ip), - vxlan->cfg.dst_port, + cfg->dst_port, vninode->vni, vninode->vni, dst->remote_ifindex, true);
@@ -726,6 +730,7 @@ static int vxlan_vni_add(struct vxlan_dev *vxlan, u32 vni, union vxlan_addr *group, struct netlink_ext_ack *extack) { + const struct vxlan_config *cfg = rtnl_dereference(vxlan->cfg);struct vxlan_vni_node *vninode;__be32 v =cpu_to_be32 (vni);bool changed = false;
@@ -734,7 +739,7 @@ static int vxlan_vni_add(struct vxlan_dev *vxlan,if (vxlan_vnifilter_lookup (vxlan, v))return vxlan_vni_update (vxlan, vg, v, group, &changed, extack); - err =vxlan_vni_in_use (vxlan->net, vxlan, &vxlan->cfg, v); + err =vxlan_vni_in_use (vxlan->net, vxlan, cfg, v);if (err) {NL_SET_ERR_MSG (extack,"VNI in use" );return err;
@@ -943,6 +948,7 @@ static int vxlan_vnifilter_process(struct sk_buff *skb, struct nlmsghdr *nlh, struct netlink_ext_ack *extack) {struct net *net =sock_net (skb->sk); +const struct vxlan_config *cfg;struct tunnel_msg *tmsg;struct vxlan_dev *vxlan;struct net_device *dev;
@@ -967,8 +973,9 @@ static int vxlan_vnifilter_process(struct sk_buff *skb, struct nlmsghdr *nlh, } vxlan =netdev_priv (dev); + cfg =rtnl_dereference (vxlan->cfg); -if (!(vxlan->cfg.flags &VXLAN_F_VNIFILTER )) +if (!(cfg->flags &VXLAN_F_VNIFILTER ))return -EOPNOTSUPP ; nlmsg_for_each_attr_type(attr, VXLAN_VNIFILTER_ENTRY, nlh,
include/net/vxlan.h +2 -1
@@ -229,6 +229,7 @@ struct vxlan_config {bool no_share;enum ifla_vxlan_df df;struct vxlanhdr reserved_bits; +struct rcu_head rcu; };enum {
@@ -301,7 +302,7 @@ struct vxlan_dev {unsigned int addrcnt;struct gro_cells gro_cells; -struct vxlan_config cfg; +struct vxlan_config __rcu *cfg;struct vxlan_vni_group __rcu *vnigrp;
net/openvswitch/vport-vxlan.c +22 -9
@@ -22,27 +22,40 @@ static struct vport_ops ovs_vxlan_netdev_vport_ops;static int vxlan_get_options (const struct vport *vport,struct sk_buff *skb) {struct vxlan_dev *vxlan =netdev_priv (vport->dev); -const struct vxlan_config *cfg = &vxlan->cfg; -__be16 dst_port = cfg->dst_port; +const struct vxlan_config *cfg; +__be16 dst_port; +int err =0 ; -if (nla_put_u16 (skb,OVS_TUNNEL_ATTR_DST_PORT ,ntohs (dst_port))) -return -EMSGSIZE ; +rcu_read_lock (); + cfg =rcu_dereference (vxlan->cfg); + dst_port = cfg->dst_port; + +if (nla_put_u16 (skb,OVS_TUNNEL_ATTR_DST_PORT ,ntohs (dst_port))) { + err = -EMSGSIZE ; + goto out; + }if (cfg->flags &VXLAN_F_GBP ) {struct nlattr *exts; exts =nla_nest_start_noflag (skb,OVS_TUNNEL_ATTR_EXTENSION ); -if (!exts) -return -EMSGSIZE ; +if (!exts) { + err = -EMSGSIZE ; + goto out; + }if (cfg->flags &VXLAN_F_GBP && -nla_put_flag (skb,OVS_VXLAN_EXT_GBP )) -return -EMSGSIZE ; +nla_put_flag (skb,OVS_VXLAN_EXT_GBP )) { + err = -EMSGSIZE ; + goto out; + }nla_nest_end (skb, exts); } -return 0 ; +out: +rcu_read_unlock (); +return err; }static const struct nla_policy exts_policy[OVS_VXLAN_EXT_MAX +1 ] = {
Signature · 1 line
2.55.0.795.g602f6c329a-goog
Re: [PATCH net-next 2/3] vxlan: convert configuration to RCU protection
Quoted 10 lines · Eric Dumazet
In order to allow lockless readers in future patches, dynamically allocate 'struct
vxlan_config' and convert 'vxlan->cfg' to an RCU protected pointer.Updating configuration via
vxlan_changelink()or__vxlan_dev_create()now allocates a new structvxlan_config, initializes it, and usesrcu_assign_pointer()to publish it, freeing the previous config withkfree_rcu().Signed-off-by Eric Dumazet <[email protected]>
Quoted 11 lines
--- .../mellanox/mlxsw/spectrum_nve_vxlan.c | 14 +- .../mellanox/mlxsw/spectrum_switchdev.c | 57 ++- drivers/net/vxlan/vxlan_core.c | 336 +++++++++++------- drivers/net/vxlan/vxlan_mdb.c | 29 +- drivers/net/vxlan/vxlan_multicast.c | 12 +- drivers/net/vxlan/vxlan_vnifilter.c | 21 +- include/net/vxlan.h | 3 +- net/openvswitch/vport-vxlan.c | 31 +- 8 files changed, 331 insertions(+), 172 deletions(-)
PATCH 3/3 vxlan: no longer rely on RTNL in vxlan_fill_info()
In reply to Eric DumazetNow that vxlan->cfg is RCU-protected, we can update vxlan_fill_info() to run under RCU read lock instead of relying on RTNL.
This completes the transition to RTNL-less link info dumping for VXLAN.
--- drivers/net/vxlan/vxlan_core.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/net/vxlan/vxlan_core.c +11 -2
@@ -4674,10 +4674,16 @@ static int vxlan_fill_info(struct sk_buff *skb, const struct net_device *dev)struct ifla_vxlan_port_range ports;const struct vxlan_config *cfg;const struct vxlan_rdst *dst; +int err =0 ; dst = &vxlan->default_dst; - cfg =rtnl_dereference (vxlan->cfg); +rcu_read_lock (); + cfg =rcu_dereference (vxlan->cfg); +if (!cfg) { + err = -ENODEV ; + goto out; + } ports.low =htons (cfg->port_min); ports.high =htons (cfg->port_max);
@@ -4777,9 +4783,12 @@ static int vxlan_fill_info(struct sk_buff *skb, const struct net_device *dev) &cfg->reserved_bits)) goto nla_put_failure; -return 0 ; +out: +rcu_read_unlock (); +return err; nla_put_failure: +rcu_read_unlock ();return -EMSGSIZE ; }
Signature · 1 line
2.55.0.795.g602f6c329a-goog
Re: [PATCH net-next 3/3] vxlan: no longer rely on RTNL in vxlan_fill_info()
Quoted 11 lines · Eric Dumazet
Now that
vxlan->cfgis RCU-protected, we can updatevxlan_fill_info()to run under RCU read lock instead of relying on RTNL.This completes the transition to RTNL-less link info dumping for VXLAN.
Signed-off-by Eric Dumazet <[email protected]>--- drivers/net/vxlan/vxlan_core.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
Paolo Abeni
maintainerQuoted 11 lines · Eric Dumazet
This patch series converts VXLAN configuration (
struct vxlan_config) to be RCU-protected, allowing lockless readers and enabling RTNL-lessvxlan_fill_info()netlink link info dumping.Work has been split into three distinct parts:
1. Refactor helper functions in RX, TX, MDB, VNIFILTER, and OVS paths to accept a
const struct vxlan_config *cfgpointer (or pass specific fields such asflags/saddr_family) rather than accessingvxlan->cfgdirectly.
Quoted 8 lines
2. Convert
vxlan->cfgfrom an embedded struct into an RCU-protected pointer (struct vxlan_config __rcu *cfg), dynamically allocated on device creation or changelink, and freed viakfree_rcu(). Update offload drivers (mlxsw) and OVS (vport-vxlan.c) accordingly.3. Update
vxlan_fill_info()to run underrcu_read_lock()instead of relying on RTNL lock, completing the transition to lockless link info dumping for VXLAN devices.
I *suspect* this is triggering RCU splat in forwarding self-tests:
[ 1955.481960][T11074] =============================
[ 1955.482076][T11074] WARNING: suspicious RCU usage
[ 1955.482190][T11074] 7.2.0-rc2-virtme #1 Not tainted
[ 1955.482304][T11074] -----------------------------
[ 1955.482886][T11074] drivers/net/vxlan/vxlan_core.c:1872 suspicious rcu_dereference_check() usage!
[ 1955.483087][T11074]
[ 1955.483087][T11074] other info that might help us debug this:
[ 1955.483087][T11074]
[ 1955.483312][T11074]
[ 1955.483312][T11074] rcu_scheduler_active = 2, debug_locks = 1
[ 1955.483489][T11074] 1 lock held by arping/11074:
[ 1955.483623][T11074] #0: ffffffffbad91d60 (rcu_read_lock_bh){....}-{1:3}, at: __dev_queue_xmit+0x204/0x1b90
[ 1955.483836][T11074]
[ 1955.483836][T11074] stack backtrace:
[ 1955.483977][T11074] CPU: 0 UID: 0 PID: 11074 Comm: arping Not tainted 7.2.0-rc2-virtme #1 PREEMPT(full)
[ 1955.483980][T11074] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
[ 1955.483982][T11074] Call Trace:
[ 1955.483983][T11074] <TASK>
[ 1955.483984][T11074] dump_stack_lvl+0x6f/0xa0
[ 1955.483990][T11074] lockdep_rcu_suspicious.cold+0x37/0x89
[ 1955.483995][T11074] arp_reduce.isra.0+0x9b9/0x1080 [vxlan]
[ 1955.484003][T11074] ? mark_usage+0x61/0x170
[ 1955.484007][T11074] ? __lock_acquire+0x518/0xc20
[ 1955.484010][T11074] ? vxlan_nl2conf+0x5b30/0x5b30 [vxlan]
[ 1955.484015][T11074] ? lock_acquire.part.0+0xbc/0x260
[ 1955.484017][T11074] ? find_held_lock+0x2b/0x80
[ 1955.484020][T11074] ? __lock_release.isra.0+0x6b/0x1a0
[ 1955.484025][T11074] ? vxlan_xmit+0x128b/0x1660 [vxlan]
[ 1955.484029][T11074] vxlan_xmit+0x128b/0x1660 [vxlan]
[ 1955.484034][T11074] ? rcu_lockdep_current_cpu_online+0x39/0x1b0
[ 1955.484039][T11074] dev_hard_start_xmit+0xf4/0x620
[ 1955.484042][T11074] ? validate_xmit_skb+0x72/0x9a0
[ 1955.484045][T11074] __dev_queue_xmit+0xc1a/0x1b90
[ 1955.484047][T11074] ? _copy_from_iter+0x1bb/0x1810
[ 1955.484052][T11074] ? __alloc_skb+0x342/0x5f0
[ 1955.484055][T11074] ? _copy_from_iter_flushcache+0x1970/0x1970
[ 1955.484057][T11074] ? ref_tracker_alloc+0x2e7/0x430
[ 1955.484060][T11074] ? netdev_core_pick_tx+0x2c0/0x2c0
[ 1955.484064][T11074] ? packet_parse_headers+0x325/0x830
[ 1955.484067][T11074] ? __asan_memset+0x27/0x50
[ 1955.484070][T11074] ? packet_parse_headers+0x325/0x830
[ 1955.484073][T11074] ? skb_copy_datagram_from_iter+0xf3/0x6a0
[ 1955.484075][T11074] ? packet_release+0xc70/0xc70
[ 1955.484079][T11074] packet_snd+0xfad/0x1990
[ 1955.484085][T11074] ? tpacket_snd+0x19e0/0x19e0
[ 1955.484087][T11074] ? __might_fault+0x97/0x140
[ 1955.484093][T11074] ? __might_fault+0x97/0x140
[ 1955.484095][T11074] ? __might_fault+0x97/0x140
[ 1955.484098][T11074] __sys_sendto+0x2aa/0x400
[ 1955.484101][T11074] ? __ia32_sys_getpeername+0xd0/0xd0
[ 1955.484110][T11074] ? do_user_addr_fault+0x325/0xe30
[ 1955.484116][T11074] __x64_sys_sendto+0xe4/0x1f0
[ 1955.484117][T11074] ? trace_irq_enable.constprop.0+0x9b/0x160
[ 1955.484121][T11074] ? lockdep_hardirqs_on+0x8c/0x130
[ 1955.484123][T11074] ? do_syscall_64+0x82/0x590
[ 1955.484126][T11074] do_syscall_64+0x117/0x590
[ 1955.484127][T11074] ? trace_hardirqs_off+0xd/0x30
[ 1955.484129][T11074] ? exc_page_fault+0xee/0x100
[ 1955.484132][T11074] entry_SYSCALL_64_after_hwframe+0x4b/0x53
[ 1955.484134][T11074] RIP: 0033:0x7f138c3ec54e
[ 1955.484138][T11074] Code: 4d 89 d8 e8 b4 bd 00 00 4c 8b 5d f8 41 8b 93 08 03 00 00 59 5e 48 83 f8 fc 74 11 c9 c3 0f 1f 80 00 00 00 00 48 8b 45 10 0f 05 <c9> c3 83 e2 39 83 fa 08 75 e7 e8 03 ff ff ff 0f 1f 00 f3 0f 1e fa
[ 1955.484139][T11074] RSP: 002b:00007ffc648f74e0 EFLAGS: 00000202 ORIG_RAX: 000000000000002c
[ 1955.484142][T11074] RAX: ffffffffffffffda RBX: 000000000000001c RCX: 00007f138c3ec54e
[ 1955.484143][T11074] RDX: 000000000000001c RSI: 00007ffc648f7560 RDI: 0000000000000005
[ 1955.484144][T11074] RBP: 00007ffc648f74f0 R08: 00007ffc648f79e0 R09: 0000000000000014
[ 1955.484145][T11074] R10: 0000000000000000 R11: 0000000000000202 R12: 0000000000000000
[ 1955.484146][T11074] R13: 00007ffc648f7910 R14: ffffffffffffffe8 R15: 0000000000000000full log at:
https://netdev-ctrl.bots.linux.dev/logs/vmksft/net-dbg/results/728082/83-test-vxlan-nh-sh/stderr
Tentatively setting the series to 'changes requested'
/P
Paolo Abeni
maintainerQuoted 17 lines · Paolo Abeni
Quoted 16 lines · Eric Dumazet
This patch series converts VXLAN configuration (
struct vxlan_config) to be RCU-protected, allowing lockless readers and enabling RTNL-lessvxlan_fill_info()netlink link info dumping.Work has been split into three distinct parts:
1. Refactor helper functions in RX, TX, MDB, VNIFILTER, and OVS paths to accept a
const struct vxlan_config *cfgpointer (or pass specific fields such asflags/saddr_family) rather than accessingvxlan->cfgdirectly.2. Convert
vxlan->cfgfrom an embedded struct into an RCU-protected pointer (struct vxlan_config __rcu *cfg), dynamically allocated on device creation or changelink, and freed viakfree_rcu(). Update offload drivers (mlxsw) and OVS (vport-vxlan.c) accordingly.
Quoted 7 lines
Quoted 3 lines
3. Update
vxlan_fill_info()to run underrcu_read_lock()instead of relying on RTNL lock, completing the transition to lockless link info dumping for VXLAN devices.I *suspect* this is triggering RCU splat in forwarding self-tests:
[ 1955.481960][T11074] =============================
oops, sashiko already spotted it:
https://sashiko.dev/#/patchset/20260708160411.1355008-1-edumazet%40google.com
/P
Quoted 23 lines · Paolo Abeni
Quoted 21 lines · Paolo Abeni
Quoted 19 lines · Eric Dumazet
This patch series converts VXLAN configuration (
struct vxlan_config) to be RCU-protected, allowing lockless readers and enabling RTNL-lessvxlan_fill_info()netlink link info dumping.Work has been split into three distinct parts:
1. Refactor helper functions in RX, TX, MDB, VNIFILTER, and OVS paths to accept a
const struct vxlan_config *cfgpointer (or pass specific fields such asflags/saddr_family) rather than accessingvxlan->cfgdirectly.2. Convert
vxlan->cfgfrom an embedded struct into an RCU-protected pointer (struct vxlan_config __rcu *cfg), dynamically allocated on device creation or changelink, and freed viakfree_rcu(). Update offload drivers (mlxsw) and OVS (vport-vxlan.c) accordingly.3. Update
vxlan_fill_info()to run underrcu_read_lock()instead of relying on RTNL lock, completing the transition to lockless link info dumping for VXLAN devices.
Quoted 6 lines
Quoted 3 lines
I *suspect* this is triggering RCU splat in forwarding self-tests:
[ 1955.481960][T11074] =============================oops, sashiko already spotted it:
https://sashiko.dev/#/patchset/20260708160411.1355008-1-edumazet%40google.com
LOCKDEP inablility to understand rcu_read_lock() and rcu_read_lock_bh() is quite something.
rcu_bh has disappeared a long time ago (it is kept for historical reasons only).
Perhaps we should finally replace it with standard rcu, to avoid stacking rcu_read_lock() and rcu_read_lock_bh().