Skip to content

Commit 804b09b

Browse files
idoschPaolo Abeni
authored andcommitted
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]>
1 parent 07e3223 commit 804b09b

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
@@ -1916,12 +1916,15 @@ static int arp_reduce(struct net_device *dev, struct sk_buff *skb, __be32 vni)
19161916
goto out;
19171917
}
19181918

1919+
rcu_read_lock();
19191920
f = vxlan_find_mac(vxlan, n->ha, vni);
19201921
if (f && vxlan_addr_any(&(first_remote_rcu(f)->remote_ip))) {
19211922
/* bridge-local neighbor */
19221923
neigh_release(n);
1924+
rcu_read_unlock();
19231925
goto out;
19241926
}
1927+
rcu_read_unlock();
19251928

19261929
reply = arp_create(ARPOP_REPLY, ETH_P_ARP, sip, dev, tip, sha,
19271930
n->ha, sha);
@@ -2648,14 +2651,10 @@ static void vxlan_xmit_nh(struct sk_buff *skb, struct net_device *dev,
26482651
memset(&nh_rdst, 0, sizeof(struct vxlan_rdst));
26492652
hash = skb_get_hash(skb);
26502653

2651-
rcu_read_lock();
26522654
nh = rcu_dereference(f->nh);
2653-
if (!nh) {
2654-
rcu_read_unlock();
2655+
if (!nh)
26552656
goto drop;
2656-
}
26572657
do_xmit = vxlan_fdb_nh_path_select(nh, hash, &nh_rdst);
2658-
rcu_read_unlock();
26592658

26602659
if (likely(do_xmit))
26612660
vxlan_xmit_one(skb, dev, vni, &nh_rdst, did_rsc);
@@ -2782,6 +2781,7 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev)
27822781
}
27832782

27842783
eth = eth_hdr(skb);
2784+
rcu_read_lock();
27852785
f = vxlan_find_mac(vxlan, eth->h_dest, vni);
27862786
did_rsc = false;
27872787

@@ -2804,7 +2804,7 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev)
28042804
vxlan_vnifilter_count(vxlan, vni, NULL,
28052805
VXLAN_VNI_STATS_TX_DROPS, 0);
28062806
kfree_skb_reason(skb, SKB_DROP_REASON_NO_TX_TARGET);
2807-
return NETDEV_TX_OK;
2807+
goto out;
28082808
}
28092809
}
28102810

@@ -2829,6 +2829,8 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev)
28292829
kfree_skb_reason(skb, SKB_DROP_REASON_NO_TX_TARGET);
28302830
}
28312831

2832+
out:
2833+
rcu_read_unlock();
28322834
return NETDEV_TX_OK;
28332835
}
28342836

0 commit comments

Comments
 (0)