From: hawk@kernel.org
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, dsahern@kernel.org, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
shuah@kernel.org, linux-kselftest@vger.kernel.org,
hawk@kernel.org, ivan@cloudflare.com, kernel-team@cloudflare.com
Subject: [RFC PATCH net-next 2/4] ipv6: make inet6_addr_lst hash table size configurable
Date: Tue, 31 Mar 2026 23:07:37 +0200 [thread overview]
Message-ID: <20260331210739.3998753-3-hawk@kernel.org> (raw)
In-Reply-To: <20260331210739.3998753-1-hawk@kernel.org>
From: Jesper Dangaard Brouer <hawk@kernel.org>
Similar to the IPv4 inet_addr_lst hash table, IPv6 also uses a fixed
256-bucket hash table for address lookups. On hosts with many IPv6
addresses, this results in long hash chains walked under RCU.
The inet6_addr_lst table is used in the route lookup path when no
output interface is specified (oif == 0):
udpv6_sendmsg
ip6_sk_dst_lookup_flow
ip6_dst_lookup_tail
ip6_route_output -> fib6 lookup
__rt6_device_match
ipv6_chk_addr <-- walks inet6_addr_lst
Add CONFIG_INET6_ADDR_HASH_BUCKETS (default 256, range 64-16384, EXPERT)
so hosts with many addresses can size the table appropriately. The value
is rounded up to the nearest power of 2 at compile time via
order_base_2(). Memory cost is one hlist_head pointer per bucket per net
namespace.
Reported-by: Ivan Babrou <ivan@cloudflare.com>
Signed-off-by: Jesper Dangaard Brouer <hawk@kernel.org>
---
net/ipv6/Kconfig | 15 +++++++++++++++
net/ipv6/addrconf.c | 2 +-
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/net/ipv6/Kconfig b/net/ipv6/Kconfig
index b8f9a8c0302e..963fa0e1a014 100644
--- a/net/ipv6/Kconfig
+++ b/net/ipv6/Kconfig
@@ -238,6 +238,21 @@ config IPV6_FOU_TUNNEL
default NET_FOU_IP_TUNNELS && IPV6_FOU
select IPV6_TUNNEL
+config INET6_ADDR_HASH_BUCKETS
+ int "IPv6 address hash table size" if EXPERT
+ range 64 16384
+ default 256
+ help
+ Number of hash buckets for looking up local IPv6 addresses,
+ e.g. in ipv6_chk_addr() and related callers. Rounded up to
+ the nearest power of 2.
+
+ Hosts with many IPv6 addresses benefit from a larger table to
+ reduce hash chain lengths.
+
+ The default of 256 is fine for most systems. A value of 1024
+ suits hosts with ~500+ addresses.
+
config IPV6_MULTIPLE_TABLES
bool "IPv6: Multiple Routing Tables"
select FIB_RULES
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 0e55f139e05d..dad08f0733ef 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -144,7 +144,7 @@ static int ipv6_generate_stable_address(struct in6_addr *addr,
u8 dad_count,
const struct inet6_dev *idev);
-#define IN6_ADDR_HSIZE_SHIFT 8
+#define IN6_ADDR_HSIZE_SHIFT order_base_2(CONFIG_INET6_ADDR_HASH_BUCKETS)
#define IN6_ADDR_HSIZE (1 << IN6_ADDR_HSIZE_SHIFT)
static void addrconf_verify(struct net *net);
--
2.43.0
next prev parent reply other threads:[~2026-03-31 21:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-31 21:07 [RFC PATCH net-next 0/4] ipv4/ipv6: local address lookup scaling hawk
2026-03-31 21:07 ` [RFC PATCH net-next 1/4] ipv4: make inet_addr_lst hash table size configurable hawk
2026-03-31 21:07 ` hawk [this message]
2026-03-31 21:07 ` [RFC PATCH net-next 3/4] ipv4: convert inet_addr_lst to rhltable for dynamic resizing hawk
2026-03-31 21:07 ` [RFC PATCH net-next 4/4] selftests: net: add IPv4 address lookup stress test hawk
2026-04-03 22:35 ` [RFC PATCH net-next 0/4] ipv4/ipv6: local address lookup scaling David Ahern
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260331210739.3998753-3-hawk@kernel.org \
--to=hawk@kernel.org \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=ivan@cloudflare.com \
--cc=kernel-team@cloudflare.com \
--cc=kuba@kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox