From: Florian Westphal <fw@strlen.de>
To: kadlec@netfilter.org
Cc: <netfilter-devel@vger.kernel.org>, Florian Westphal <fw@strlen.de>
Subject: [PATCH ipset 5/5] tests: match_target.t check for proper cidr matching
Date: Thu, 23 Jul 2026 12:35:04 +0200 [thread overview]
Message-ID: <20260723103504.3175-6-fw@strlen.de> (raw)
In-Reply-To: <20260723103504.3175-1-fw@strlen.de>
Add a test that covers CIDR matching ("multi" flag).
In ipsets CIDR-prefix loop, the multi-flag is re-set so the loop can
continue to less-specific prefixes when an element matched key+iface but
failed the counter constraint. Without the reset, the loop stops at the
first prefix that has any non-expired element.
(The kernel patch that removed this reset was never
merged, but add test coverage for this).
Assisted-by: Claude:claude-opus-4-6
Signed-off-by: Florian Westphal <fw@strlen.de>
---
tests/match_target.t | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/tests/match_target.t b/tests/match_target.t
index c3ead171dd00..c4fc777ffdd9 100644
--- a/tests/match_target.t
+++ b/tests/match_target.t
@@ -54,7 +54,7 @@
0 ./iptables.sh inet del
# Send probe packet 10.255.255.64,icmp:host-prohibited
0 ./sendip.sh -d r10 -p ipv4 -id 127.0.0.1 -is 10.255.255.64 -p icmp -ct 3 -cd 10 127.0.0.1
-# Check that 10.255.255.64,icmp:3/10 isn't in ipport
+# Check that 10.255.255.64,icmp:3/10 is not in ipport
1 ipset test ipport 10.255.255.64,icmp:host-prohibited
# Destroy sets and rules
0 ./iptables.sh inet stop
@@ -118,4 +118,16 @@
0 ipset l test |grep -q '^10.255.255.64 packets 2'
# Destroy sets and rules
0 ./iptables.sh inet stop
+# hash:net,iface set with counters.
+# /24 entry: low counter -> will fail --packets-gt 50
+# /16 entry: high counter -> would pass --packets-gt 50
+0 ipset create test hash:net,iface counters
+0 ipset add test 127.0.0.0/24,lo packets 5 bytes 500
+0 ipset add test 127.0.0.0/16,lo packets 100 bytes 10000
+# Match the set with a counter threshold of 50.
+0 iptables -A INPUT -i lo -p icmp -m set --match-set test src,src --packets-gt 50 -j ACCEPT
+0 ping -c 1 -W 1 127.0.0.1 > /dev/null 2>&1
+# Check whether the iptables rule matched.
+0 (set -e; pkts=$(iptables -v -n -L INPUT | grep test | awk '{print $1}') ; [ "${pkts:-0}" -ge 1 ] && exit 0 )
+0 ./iptables.sh inet stop
# eof
--
2.54.0
prev parent reply other threads:[~2026-07-23 10:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-23 10:34 [PATCH ipset 0/5] ipset test updates Florian Westphal
2026-07-23 10:35 ` [PATCH ipset 1/5] tests: check_extensions: introduce and use IPSET_MACHINE_SLOW Florian Westphal
2026-07-23 10:35 ` [PATCH ipset 2/5] tests: hash:net.t: prefer tail -n Florian Westphal
2026-07-23 10:35 ` [PATCH ipset 3/5] tests: prefer diff -u to cmp Florian Westphal
2026-07-23 10:35 ` [PATCH ipset 4/5] tests: hash:net,iface.t: add reproducer for UaF Florian Westphal
2026-07-23 10:35 ` 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=20260723103504.3175-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.