All of lore.kernel.org
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: <netfilter-devel@vger.kernel.org>
Cc: Jozsef Kadlecsik <kadlec@netfilter.org>, Florian Westphal <fw@strlen.de>
Subject: [PATCH nf v3 5/5] netfilter: ipset: also report mem size for cidr storage to userspace
Date: Fri, 28 Aug 2026 17:22:56 +0200	[thread overview]
Message-ID: <20260828152256.8759-6-fw@strlen.de> (raw)
In-Reply-To: <20260828152256.8759-1-fw@strlen.de>

After the 'Fixes' commit, the storage is allocated dynamically.
Include this when reporting the mem usage.

Fixes: 8e5fd2a55e24 ("netfilter: ipset: rework cidr bookkeeping")
Signed-off-by: Florian Westphal <fw@strlen.de>
---
 v3: no change.
 net/netfilter/ipset/ip_set_hash_gen.h | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/net/netfilter/ipset/ip_set_hash_gen.h b/net/netfilter/ipset/ip_set_hash_gen.h
index e156ea725f3c..245a5dbd7d5b 100644
--- a/net/netfilter/ipset/ip_set_hash_gen.h
+++ b/net/netfilter/ipset/ip_set_hash_gen.h
@@ -668,6 +668,23 @@ mtype_rht_size(struct ip_set *set, u32 *elements, size_t *ext_size)
 	*elements = ipset_hash_nelems(h);
 	*ext_size = *elements *
 		    (offsetof(struct mtype_rht_elem, elem) + set->dsize);
+
+#ifdef IP_SET_HASH_WITH_NETS
+	{
+		const struct net_prefixes *nets;
+		int i;
+
+		rcu_read_lock();
+
+		for (i = 0; i < IPSET_NET_COUNT; i++) {
+			nets = rcu_dereference(h->rnets[i]);
+			if (nets)
+				*ext_size += ksize(nets);
+		}
+
+		rcu_read_unlock();
+	}
+#endif
 }
 
 static u32 mtype_remove_key(const void *data, u32 len, u32 seed)
@@ -721,11 +738,8 @@ mtype_remove_random(struct ip_set *set, struct htype *h)
 	if (e && !ipset_hash_remove(h, e))
 		removed = true;
 
-	if (removed) {
-		mtype_del_cidr_all(set, h, &e->elem);
-		ip_set_ext_destroy(set, &e->elem);
-		kfree_rcu(e, rcu);
-	}
+	if (removed)
+		ipset_hash_elem_destroy_free(set, h, e);
 
 	return removed;
 }
-- 
2.54.0


      parent reply	other threads:[~2026-08-28 15:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-28 15:22 [PATCH nf v3 0/5] netfilter: ipset: rhashtable conversion Florian Westphal
2026-08-28 15:22 ` [PATCH nf v3 1/5] netfilter: ipset: add rhashtable boilerplate stubs Florian Westphal
2026-08-28 15:22 ` [PATCH nf v3 2/5] netfilter: ipset: add rhltable " Florian Westphal
2026-08-28 15:22 ` [PATCH nf v3 3/5] netfilter: ipset: replace internal hash table with rhashtable Florian Westphal
2026-09-02  4:32   ` Florian Westphal
2026-09-02  7:35     ` Jozsef Kadlecsik
2026-09-02  7:42     ` Jozsef Kadlecsik
2026-08-28 15:22 ` [PATCH nf v3 4/5] netfilter: ipset: re-add forceadd support Florian Westphal
2026-08-28 15:22 ` Florian Westphal [this message]

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=20260828152256.8759-6-fw@strlen.de \
    --to=fw@strlen.de \
    --cc=kadlec@netfilter.org \
    --cc=netfilter-devel@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.