Skip to content

Commit 54f4518

Browse files
idoschPaolo Abeni
authored andcommitted
vxlan: Convert FDB flushing to RCU
Instead of holding the FDB hash lock when traversing the FDB linked list during flushing, use RCU and only acquire the lock for entries that need to be flushed. Reviewed-by: Petr Machata <petrm@nvidia.com> Signed-off-by: Ido Schimmel <idosch@nvidia.com> Link: https://patch.msgid.link/20250415121143.345227-11-idosch@nvidia.com Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent a6d04f8 commit 54f4518

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

drivers/net/vxlan/vxlan_core.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3037,27 +3037,32 @@ static void vxlan_flush(struct vxlan_dev *vxlan,
30373037
const struct vxlan_fdb_flush_desc *desc)
30383038
{
30393039
bool match_remotes = vxlan_fdb_flush_should_match_remotes(desc);
3040-
struct hlist_node *n;
30413040
struct vxlan_fdb *f;
30423041

3043-
spin_lock_bh(&vxlan->hash_lock);
3044-
hlist_for_each_entry_safe(f, n, &vxlan->fdb_list, fdb_node) {
3042+
rcu_read_lock();
3043+
hlist_for_each_entry_rcu(f, &vxlan->fdb_list, fdb_node) {
30453044
if (!vxlan_fdb_flush_matches(f, vxlan, desc))
30463045
continue;
30473046

3047+
spin_lock_bh(&vxlan->hash_lock);
3048+
if (hlist_unhashed(&f->fdb_node))
3049+
goto unlock;
3050+
30483051
if (match_remotes) {
30493052
bool destroy_fdb = false;
30503053

30513054
vxlan_fdb_flush_match_remotes(f, vxlan, desc,
30523055
&destroy_fdb);
30533056

30543057
if (!destroy_fdb)
3055-
continue;
3058+
goto unlock;
30563059
}
30573060

30583061
vxlan_fdb_destroy(vxlan, f, true, true);
3062+
unlock:
3063+
spin_unlock_bh(&vxlan->hash_lock);
30593064
}
3060-
spin_unlock_bh(&vxlan->hash_lock);
3065+
rcu_read_unlock();
30613066
}
30623067

30633068
static const struct nla_policy vxlan_del_bulk_policy[NDA_MAX + 1] = {

0 commit comments

Comments
 (0)