From: Rosen Penev <rosenp@gmail.com>
To: netfilter-devel@vger.kernel.org
Cc: Simon Horman <horms@verge.net.au>, Julian Anastasov <ja@ssi.bg>,
Pablo Neira Ayuso <pablo@netfilter.org>,
Florian Westphal <fw@strlen.de>, Phil Sutter <phil@nwl.cc>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org (open list:IPVS),
lvs-devel@vger.kernel.org (open list:IPVS),
coreteam@netfilter.org (open list:NETFILTER),
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH] ipvs: Use flexible array for MH lookup table
Date: Mon, 18 May 2026 18:55:06 -0700 [thread overview]
Message-ID: <20260519015506.634185-1-rosenp@gmail.com> (raw)
Store the Maglev hash lookup table in the scheduler state
allocation instead of allocating it separately.
This keeps the lookup table tied to the RCU-freed state lifetime and
simplifies the allocation and cleanup paths.
Assisted-by: Codex:GPT-5.5
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
net/netfilter/ipvs/ip_vs_mh.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/net/netfilter/ipvs/ip_vs_mh.c b/net/netfilter/ipvs/ip_vs_mh.c
index 020863047562..d31d3c6d4216 100644
--- a/net/netfilter/ipvs/ip_vs_mh.c
+++ b/net/netfilter/ipvs/ip_vs_mh.c
@@ -59,11 +59,11 @@ static int primes[] = {251, 509, 1021, 2039, 4093,
struct ip_vs_mh_state {
struct rcu_head rcu_head;
- struct ip_vs_mh_lookup *lookup;
struct ip_vs_mh_dest_setup *dest_setup;
hsiphash_key_t hash1, hash2;
int gcd;
int rshift;
+ struct ip_vs_mh_lookup lookup[];
};
static inline void generate_hash_secret(hsiphash_key_t *hash1,
@@ -372,7 +372,6 @@ static void ip_vs_mh_state_free(struct rcu_head *head)
struct ip_vs_mh_state *s;
s = container_of(head, struct ip_vs_mh_state, rcu_head);
- kfree(s->lookup);
kfree(s);
}
@@ -382,16 +381,10 @@ static int ip_vs_mh_init_svc(struct ip_vs_service *svc)
struct ip_vs_mh_state *s;
/* Allocate the MH table for this service */
- s = kzalloc_obj(*s);
+ s = kzalloc_flex(*s, lookup, IP_VS_MH_TAB_SIZE);
if (!s)
return -ENOMEM;
- s->lookup = kzalloc_objs(struct ip_vs_mh_lookup, IP_VS_MH_TAB_SIZE);
- if (!s->lookup) {
- kfree(s);
- return -ENOMEM;
- }
-
generate_hash_secret(&s->hash1, &s->hash2);
s->gcd = ip_vs_mh_gcd_weight(svc);
s->rshift = ip_vs_mh_shift_weight(svc, s->gcd);
--
2.54.0
next reply other threads:[~2026-05-19 1:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-19 1:55 Rosen Penev [this message]
2026-05-19 17:08 ` [PATCH] ipvs: Use flexible array for MH lookup table Julian Anastasov
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=20260519015506.634185-1-rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=coreteam@netfilter.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=horms@verge.net.au \
--cc=ja@ssi.bg \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lvs-devel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pablo@netfilter.org \
--cc=phil@nwl.cc \
/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