]> git.baikalelectronics.ru Git - kernel.git/commit
ipv4: avoid quadratic behavior in netns dismantle
authorEric Dumazet <edumazet@google.com>
Wed, 19 Jan 2022 10:04:12 +0000 (02:04 -0800)
committerJakub Kicinski <kuba@kernel.org>
Wed, 19 Jan 2022 16:14:40 +0000 (08:14 -0800)
commit1c5a1a00fa220555088e00a13874c4fac8951bdb
tree99556371ae6bd0963505ee19ba41f2b4641395ae
parente32ee1eb4cf622c9485f5aadf37d60dc98c9b0af
ipv4: avoid quadratic behavior in netns dismantle

net/ipv4/fib_semantics.c uses an hash table of 256 slots,
keyed by device ifindexes: fib_info_devhash[DEVINDEX_HASHSIZE]

Problem is that with network namespaces, devices tend
to use the same ifindex.

lo device for instance has a fixed ifindex of one,
for all network namespaces.

This means that hosts with thousands of netns spend
a lot of time looking at some hash buckets with thousands
of elements, notably at netns dismantle.

Simply add a per netns perturbation (net_hash_mix())
to spread elements more uniformely.

Also change fib_devindex_hashfn() to use more entropy.

Fixes: bb138aa120b5 ("net: Make ifindex generation per-net namespace")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/ipv4/fib_semantics.c