From: Florian Westphal <fw@strlen.de>
To: <netfilter-devel@vger.kernel.org>
Cc: kadlec@netfilter.org, Florian Westphal <fw@strlen.de>
Subject: [PATCH RFC nf-next 06/12] netfilter: ipset: add and use ip_set_ext_destroy_slow
Date: Tue, 14 Jul 2026 15:18:22 +0200 [thread overview]
Message-ID: <20260714131828.10685-7-fw@strlen.de> (raw)
In-Reply-To: <20260714131828.10685-1-fw@strlen.de>
same rationale as previous patch, however, this time we cannot
add lockdep assertion in ip_set_ext_destroy().
At this time the function has too many call sites where set->lock
is held (e.g. during set destruction).
Signed-off-by: Florian Westphal <fw@strlen.de>
---
include/linux/netfilter/ipset/ip_set.h | 24 ++++++++++++++++++++----
net/netfilter/ipset/ip_set_bitmap_gen.h | 2 ++
net/netfilter/ipset/ip_set_hash_gen.h | 8 ++++----
3 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
index 50cd719bc270..f9003ec21259 100644
--- a/include/linux/netfilter/ipset/ip_set.h
+++ b/include/linux/netfilter/ipset/ip_set.h
@@ -282,17 +282,33 @@ struct ip_set {
void *data;
};
+static inline void
+__ip_set_destroy_comment(struct ip_set *set, void *data)
+{
+ struct ip_set_comment *c = ext_comment(data, set);
+
+ ip_set_extensions[IPSET_EXT_ID_COMMENT].destroy(set, c);
+}
+
static inline void
ip_set_ext_destroy(struct ip_set *set, void *data)
{
/* Check that the extension is enabled for the set and
* call it's destroy function for its extension part in data.
*/
- if (SET_WITH_COMMENT(set)) {
- struct ip_set_comment *c = ext_comment(data, set);
+ if (SET_WITH_COMMENT(set))
+ __ip_set_destroy_comment(set, data);
+}
- ip_set_extensions[IPSET_EXT_ID_COMMENT].destroy(set, c);
- }
+static inline void
+ip_set_ext_destroy_slow(struct ip_set *set, void *data)
+{
+ if (!SET_WITH_COMMENT(set))
+ return;
+
+ spin_lock_bh(&set->lock);
+ __ip_set_destroy_comment(set, data);
+ spin_unlock_bh(&set->lock);
}
int ip_set_put_flags(struct sk_buff *skb, struct ip_set *set);
diff --git a/net/netfilter/ipset/ip_set_bitmap_gen.h b/net/netfilter/ipset/ip_set_bitmap_gen.h
index b13cde902c17..ca68b6e51214 100644
--- a/net/netfilter/ipset/ip_set_bitmap_gen.h
+++ b/net/netfilter/ipset/ip_set_bitmap_gen.h
@@ -182,6 +182,8 @@ mtype_del(struct ip_set *set, void *value, const struct ip_set_ext *ext,
const struct mtype_adt_elem *e = value;
void *x = get_ext(set, map, e->id);
+ lockdep_assert_held(&set->lock);
+
if (mtype_do_del(e, map))
return -IPSET_ERR_EXIST;
diff --git a/net/netfilter/ipset/ip_set_hash_gen.h b/net/netfilter/ipset/ip_set_hash_gen.h
index c3dda56d786c..1eff2c065bb3 100644
--- a/net/netfilter/ipset/ip_set_hash_gen.h
+++ b/net/netfilter/ipset/ip_set_hash_gen.h
@@ -443,7 +443,7 @@ mtype_ext_cleanup(struct ip_set *set, struct hbucket *n)
for (i = 0; i < pos; i++)
if (test_bit(i, n->used))
- ip_set_ext_destroy(set, ahash_data(n, i, set->dsize));
+ ip_set_ext_destroy_slow(set, ahash_data(n, i, set->dsize));
}
/* Flush a hash type of set: destroy all elements */
@@ -587,7 +587,7 @@ mtype_gc_do(struct ip_set *set, struct htype *h, struct htable *t, u32 r)
smp_mb__after_atomic();
mtype_del_cidr_all(set, h, data);
t->hregion[r].elements--;
- ip_set_ext_destroy(set, data);
+ ip_set_ext_destroy_slow(set, data);
d++;
}
if (d >= AHASH_INIT_SIZE) {
@@ -1012,7 +1012,7 @@ mtype_add(struct ip_set *set, void *value, const struct ip_set_ext *ext,
data = ahash_data(n, j, set->dsize);
if (!deleted) {
mtype_del_cidr_all(set, h, data);
- ip_set_ext_destroy(set, data);
+ ip_set_ext_destroy_slow(set, data);
t->hregion[r].elements--;
}
goto copy_data;
@@ -1167,7 +1167,7 @@ mtype_del(struct ip_set *set, void *value, const struct ip_set_ext *ext,
smp_store_release(&n->pos, --pos);
t->hregion[r].elements--;
mtype_del_cidr_all(set, h, d);
- ip_set_ext_destroy(set, data);
+ ip_set_ext_destroy_slow(set, data);
if (t->resizing && ext && ext->target) {
/* Resize is in process and kernel side del,
--
2.54.0
next prev parent reply other threads:[~2026-07-14 13:19 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-14 13:18 [PATCH RFC nf-next 00/12] netfilter: ipset: convert to rhashtable Florian Westphal
2026-07-14 13:18 ` [PATCH RFC nf-next 01/12] netfilter: ipset: rework cidr bookkeeping Florian Westphal
2026-07-14 13:18 ` [PATCH RFC nf-next 02/12] netfilter: ipset: rework cidr bookkeeping fixups Florian Westphal
2026-07-14 13:18 ` [PATCH RFC nf-next 03/12] netfilter: ipset: add small wrappers for hash and bucket sizes Florian Westphal
2026-07-14 13:18 ` [PATCH RFC nf-next 04/12] netfilter: ipset: add and use mtype_del_cidr_all helper Florian Westphal
2026-07-14 13:18 ` [PATCH RFC nf-next 05/12] netfilter: ipset: add and use ip_set_init_comment_slow Florian Westphal
2026-07-14 13:18 ` Florian Westphal [this message]
2026-07-14 13:18 ` [PATCH RFC nf-next 07/12] netfilter: ipset: add rhashtable boilerplate stubs Florian Westphal
2026-07-16 12:53 ` Jozsef Kadlecsik
2026-07-16 13:00 ` Florian Westphal
2026-07-14 13:18 ` [PATCH RFC nf-next 08/12] netfilter: ipset: replace internal hash table with rhashtable Florian Westphal
2026-07-16 13:22 ` Jozsef Kadlecsik
2026-07-16 14:04 ` Florian Westphal
2026-07-14 13:18 ` [PATCH RFC nf-next 09/12] netfilter: ipset: use plain rcu_read_lock Florian Westphal
2026-07-16 13:41 ` Jozsef Kadlecsik
2026-07-16 14:05 ` Florian Westphal
2026-07-14 13:18 ` [PATCH RFC nf-next 10/12] netfilter: ipset: use correct lockdep annotation in ipset_dereference Florian Westphal
2026-07-16 13:56 ` Jozsef Kadlecsik
2026-07-16 14:07 ` Florian Westphal
2026-07-14 13:18 ` [PATCH RFC nf-next 11/12] netfilter: ipset: remove last region lock usage Florian Westphal
2026-07-16 14:01 ` Jozsef Kadlecsik
2026-07-16 14:08 ` Florian Westphal
2026-07-16 14:17 ` Jozsef Kadlecsik
2026-07-16 14:52 ` Florian Westphal
2026-07-14 13:18 ` [PATCH RFC nf-next 12/12] netfilter: ipset: re-add forceadd support for rhashtable Florian Westphal
2026-07-16 14:06 ` Jozsef Kadlecsik
2026-07-14 15:52 ` [PATCH RFC nf-next 00/12] netfilter: ipset: convert to rhashtable Jozsef Kadlecsik
2026-07-15 5:54 ` [syzbot ci] " syzbot ci
2026-07-16 13:02 ` Florian Westphal
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=20260714131828.10685-7-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.