Skip to content

Commit bf38524

Browse files
author
Guillaume Nault
committed
vxlan: Add RCU read-side critical sections in the Tx path
JIRA: https://issues.redhat.com/browse/RHEL-115591 Upstream Status: linux.git commit 804b09b Author: Ido Schimmel <[email protected]> Date: Tue Apr 15 15:11:29 2025 +0300 vxlan: Add RCU read-side critical sections in the Tx path The Tx path does not run from an RCU read-side critical section which makes the current lockless accesses to FDB entries invalid. As far as I am aware, this has not been a problem in practice, but traces will be generated once we transition the FDB lookup to rhashtable_lookup(). Add rcu_read_{lock,unlock}() around the handling of FDB entries in the Tx path. Remove the RCU read-side critical section from vxlan_xmit_nh() as now the function is always called from an RCU read-side critical section. Reviewed-by: Petr Machata <[email protected]> Signed-off-by: Ido Schimmel <[email protected]> Link: https://patch.msgid.link/[email protected] Reviewed-by: Nikolay Aleksandrov <[email protected]> Signed-off-by: Paolo Abeni <[email protected]> Signed-off-by: Guillaume Nault <[email protected]>
1 parent 14c3cf9 commit bf38524

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

drivers/net/vxlan/vxlan_core.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1921,12 +1921,15 @@ static int arp_reduce(struct net_device *dev, struct sk_buff *skb, __be32 vni)
19211921
goto out;
19221922
}
19231923

1924+
rcu_read_lock();
19241925
f = vxlan_find_mac(vxlan, n->ha, vni);
19251926
if (f && vxlan_addr_any(&(first_remote_rcu(f)->remote_ip))) {
19261927
/* bridge-local neighbor */
19271928
neigh_release(n);
1929+
rcu_read_unlock();
19281930
goto out;
19291931
}
1932+
rcu_read_unlock();
19301933

19311934
reply = arp_create(ARPOP_REPLY, ETH_P_ARP, sip, dev, tip, sha,
19321935
n->ha, sha);
@@ -2653,14 +2656,10 @@ static void vxlan_xmit_nh(struct sk_buff *skb, struct net_device *dev,
26532656
memset(&nh_rdst, 0, sizeof(struct vxlan_rdst));
26542657
hash = skb_get_hash(skb);
26552658

2656-
rcu_read_lock();
26572659
nh = rcu_dereference(f->nh);
2658-
if (!nh) {
2659-
rcu_read_unlock();
2660+
if (!nh)
26602661
goto drop;
2661-
}
26622662
do_xmit = vxlan_fdb_nh_path_select(nh, hash, &nh_rdst);
2663-
rcu_read_unlock();
26642663

26652664
if (likely(do_xmit))
26662665
vxlan_xmit_one(skb, dev, vni, &nh_rdst, did_rsc);
@@ -2787,6 +2786,7 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev)
27872786
}
27882787

27892788
eth = eth_hdr(skb);
2789+
rcu_read_lock();
27902790
f = vxlan_find_mac(vxlan, eth->h_dest, vni);
27912791
did_rsc = false;
27922792

@@ -2809,7 +2809,7 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev)
28092809
vxlan_vnifilter_count(vxlan, vni, NULL,
28102810
VXLAN_VNI_STATS_TX_DROPS, 0);
28112811
kfree_skb_reason(skb, SKB_DROP_REASON_NO_TX_TARGET);
2812-
return NETDEV_TX_OK;
2812+
goto out;
28132813
}
28142814
}
28152815

@@ -2834,6 +2834,8 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev)
28342834
kfree_skb_reason(skb, SKB_DROP_REASON_NO_TX_TARGET);
28352835
}
28362836

2837+
out:
2838+
rcu_read_unlock();
28372839
return NETDEV_TX_OK;
28382840
}
28392841

0 commit comments

Comments
 (0)