diff options
author | Gabriel Oginski <gabrielx.oginski@intel.com> | 2022-10-21 07:05:56 +0000 |
---|---|---|
committer | Fan Zhang <royzhang1980@hotmail.com> | 2022-10-25 08:30:02 +0000 |
commit | 813c1bd257ddcc573422083bd66cc8b8ed79d5b2 (patch) | |
tree | 9fe49f620cb410b8a9d293bbee8fe28d940a35a2 /src/vppinfra | |
parent | c9d916c7cc312d2396985f5cb83bcfdb98c98a1f (diff) |
hash: add local variable
The current implmentation of the hash table is not thread-safe.
This design leads to a segfault when VPP handling a lot of tunnels for
Wireguard, where one thread modify the hash table and other threads
starting to lookup at the same time.
The fix add a local variable to store how many bits are used by a user
object.
Type: fix
Signed-off-by: Gabriel Oginski <gabrielx.oginski@intel.com>
Change-Id: Iecf6b3ef9f308b61015c66277cc459a6d019c9c1
Diffstat (limited to 'src/vppinfra')
-rw-r--r-- | src/vppinfra/hash.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/vppinfra/hash.h b/src/vppinfra/hash.h index 968c7781c36..3c754c8e29f 100644 --- a/src/vppinfra/hash.h +++ b/src/vppinfra/hash.h @@ -123,8 +123,9 @@ always_inline uword hash_is_user (void *v, uword i) { hash_t *h = hash_header (v); - uword i0 = i / BITS (h->is_user[0]); - uword i1 = i % BITS (h->is_user[0]); + uword bits = BITS (h->is_user[0]); + uword i0 = i / bits; + uword i1 = i % bits; return (h->is_user[i0] & ((uword) 1 << i1)) != 0; } |