Skip to content

Commit bc6c6b0

Browse files
idoschdavem330
authored andcommitted
vxlan: mdb: Add an internal flag to indicate MDB usage
Add an internal flag to indicate whether MDB entries are configured or not. Set the flag after installing the first MDB entry and clear it before deleting the last one. The flag will be consulted by the data path which will only perform an MDB lookup if the flag is set, thereby keeping the MDB overhead to a minimum when the MDB is not used. Another option would have been to use a static key, but it is global and not per-device, unlike the current approach. Signed-off-by: Ido Schimmel <[email protected]> Reviewed-by: Nikolay Aleksandrov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a3a48de commit bc6c6b0

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

drivers/net/vxlan/vxlan_mdb.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,6 +1185,9 @@ vxlan_mdb_entry_get(struct vxlan_dev *vxlan,
11851185
if (err)
11861186
goto err_free_entry;
11871187

1188+
if (hlist_is_singular_node(&mdb_entry->mdb_node, &vxlan->mdb_list))
1189+
vxlan->cfg.flags |= VXLAN_F_MDB;
1190+
11881191
return mdb_entry;
11891192

11901193
err_free_entry:
@@ -1199,6 +1202,9 @@ static void vxlan_mdb_entry_put(struct vxlan_dev *vxlan,
11991202
if (!list_empty(&mdb_entry->remotes))
12001203
return;
12011204

1205+
if (hlist_is_singular_node(&mdb_entry->mdb_node, &vxlan->mdb_list))
1206+
vxlan->cfg.flags &= ~VXLAN_F_MDB;
1207+
12021208
rhashtable_remove_fast(&vxlan->mdb_tbl, &mdb_entry->rhnode,
12031209
vxlan_mdb_rht_params);
12041210
hlist_del(&mdb_entry->mdb_node);
@@ -1336,6 +1342,7 @@ int vxlan_mdb_init(struct vxlan_dev *vxlan)
13361342
void vxlan_mdb_fini(struct vxlan_dev *vxlan)
13371343
{
13381344
vxlan_mdb_entries_flush(vxlan);
1345+
WARN_ON_ONCE(vxlan->cfg.flags & VXLAN_F_MDB);
13391346
rhashtable_free_and_destroy(&vxlan->mdb_tbl, vxlan_mdb_check_empty,
13401347
NULL);
13411348
}

include/net/vxlan.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ struct vxlan_dev {
327327
#define VXLAN_F_IPV6_LINKLOCAL 0x8000
328328
#define VXLAN_F_TTL_INHERIT 0x10000
329329
#define VXLAN_F_VNIFILTER 0x20000
330+
#define VXLAN_F_MDB 0x40000
330331

331332
/* Flags that are used in the receive path. These flags must match in
332333
* order for a socket to be shareable

0 commit comments

Comments
 (0)