diff options
author | Sabrina Dubroca <sd@queasysnail.net> | 2021-04-25 21:47:12 +0200 |
---|---|---|
committer | Steffen Klassert <steffen.klassert@secunet.com> | 2021-05-14 13:52:01 +0200 |
commit | fe9f1d8779cb47046e76ea209b6eece7ec56d1b4 (patch) | |
tree | 489289550003383fbb8c5d82b031ce9761643315 /net/xfrm/xfrm_hash.h | |
parent | esp: drop unneeded assignment in esp4_gro_receive() (diff) | |
download | linux-fe9f1d8779cb47046e76ea209b6eece7ec56d1b4.tar.xz linux-fe9f1d8779cb47046e76ea209b6eece7ec56d1b4.zip |
xfrm: add state hashtable keyed by seq
When creating new states with seq set in xfrm_usersa_info, we walk
through all the states already installed in that netns to find a
matching ACQUIRE state (__xfrm_find_acq_byseq, called from
xfrm_state_add). This causes severe slowdowns on systems with a large
number of states.
This patch introduces a hashtable using x->km.seq as key, so that the
corresponding state can be found in a reasonable time.
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Diffstat (limited to 'net/xfrm/xfrm_hash.h')
-rw-r--r-- | net/xfrm/xfrm_hash.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/net/xfrm/xfrm_hash.h b/net/xfrm/xfrm_hash.h index ce66323102f9..d12bb906c9c9 100644 --- a/net/xfrm/xfrm_hash.h +++ b/net/xfrm/xfrm_hash.h @@ -131,6 +131,13 @@ __xfrm_spi_hash(const xfrm_address_t *daddr, __be32 spi, u8 proto, return (h ^ (h >> 10) ^ (h >> 20)) & hmask; } +static inline unsigned int +__xfrm_seq_hash(u32 seq, unsigned int hmask) +{ + unsigned int h = seq; + return (h ^ (h >> 10) ^ (h >> 20)) & hmask; +} + static inline unsigned int __idx_hash(u32 index, unsigned int hmask) { return (index ^ (index >> 8)) & hmask; |