All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH ipset] tests: hash:net,iface.t: add test case for wildcard matching behaviour
@ 2026-10-28 13:02 Florian Westphal
  2026-11-15 16:39 ` Jozsef Kadlecsik
  2026-11-15 16:45 ` Jozsef Kadlecsik
  0 siblings, 2 replies; 6+ messages in thread
From: Florian Westphal @ 2026-10-28 13:02 UTC (permalink / raw)
  To: netfilter-devel; +Cc: Jozsef Kadlecsik, Florian Westphal

Document the existing behaviour of wildcard matching.

Signed-off-by: Florian Westphal <fw@strlen.de>
---
 LLM generated.  Passes on nf, fails with
 rhashtable conversion patches.

 tests/hash:net,iface.t | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/tests/hash:net,iface.t b/tests/hash:net,iface.t
index 556d56df5c4b..b1d92bef26f8 100644
--- a/tests/hash:net,iface.t
+++ b/tests/hash:net,iface.t
@@ -235,4 +235,30 @@
 0 ipset list
 # Counters and timeout: destroy set
 0 ipset x test
+# Re-Create the set for wildcard tests.
+0 ipset create test hash:net,iface hashsize 128
+# Add a specific entry first, a wildcard entry for the same net second.
+0 ipset add test 10.0.1.0/24,eth0
+0 ipset add test 10.0.1.0/24,eth wildcard
+# Delete the specific entry.
+0 ipset del test 10.0.1.0/24,eth0
+# The wildcard entry should still be there and match eth1 via its prefix.
+0 ipset test test 10.0.1.0/24,eth1
+0 ipset flush test
+# Same layout: specific entry first, wildcard entry second.
+0 ipset add test 10.0.2.0/24,eth0
+0 ipset add test 10.0.2.0/24,eth wildcard
+# Re-add the specific entry with -exist, expecting a no-op refresh.
+0 ipset -exist add test 10.0.2.0/24,eth0
+# The wildcard entry should have survived the refresh and still match eth1.
+0 ipset test test 10.0.2.0/24,eth1
+0 ipset flush test
+# Add a nomatch exception first, a wildcard entry for the same net second.
+0 ipset add test 10.0.3.0/24,eth0 nomatch
+0 ipset add test 10.0.3.0/24,eth wildcard
+# eth1 isn't excluded, so the wildcard should match it.
+0 ipset test test 10.0.3.0/24,eth1
+# eth0 is excluded by the nomatch entry; it must not match via the wildcard.
+1 ipset test test 10.0.3.0/24,eth0
+0 ipset destroy test
 # eof
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH ipset] tests: hash:net,iface.t: add test case for wildcard matching behaviour
  2026-10-28 13:02 [PATCH ipset] tests: hash:net,iface.t: add test case for wildcard matching behaviour Florian Westphal
@ 2026-11-15 16:39 ` Jozsef Kadlecsik
  2026-11-15 18:21   ` Florian Westphal
  2026-11-15 16:45 ` Jozsef Kadlecsik
  1 sibling, 1 reply; 6+ messages in thread
From: Jozsef Kadlecsik @ 2026-11-15 16:39 UTC (permalink / raw)
  To: Florian Westphal; +Cc: netfilter-devel

Hi Florian,

On Wed, 28 Oct 2026, Florian Westphal wrote:

> Document the existing behaviour of wildcard matching.
> 
> Signed-off-by: Florian Westphal <fw@strlen.de>
> ---
>  LLM generated.  Passes on nf, fails with
>  rhashtable conversion patches.
> 
>  tests/hash:net,iface.t | 26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
> 
> diff --git a/tests/hash:net,iface.t b/tests/hash:net,iface.t
> index 556d56df5c4b..b1d92bef26f8 100644
> --- a/tests/hash:net,iface.t
> +++ b/tests/hash:net,iface.t
> @@ -235,4 +235,30 @@
>  0 ipset list
>  # Counters and timeout: destroy set
>  0 ipset x test
> +# Re-Create the set for wildcard tests.
> +0 ipset create test hash:net,iface hashsize 128
> +# Add a specific entry first, a wildcard entry for the same net second.
> +0 ipset add test 10.0.1.0/24,eth0
> +0 ipset add test 10.0.1.0/24,eth wildcard
> +# Delete the specific entry.
> +0 ipset del test 10.0.1.0/24,eth0
> +# The wildcard entry should still be there and match eth1 via its prefix.
> +0 ipset test test 10.0.1.0/24,eth1

The original code does not handle the case properly and the wildcard entry 
can be deleted instead the specific one. If it passes for you then it's 
just lucky ordering.

> +0 ipset flush test
> +# Same layout: specific entry first, wildcard entry second.
> +0 ipset add test 10.0.2.0/24,eth0
> +0 ipset add test 10.0.2.0/24,eth wildcard
> +# Re-add the specific entry with -exist, expecting a no-op refresh.
> +0 ipset -exist add test 10.0.2.0/24,eth0
> +# The wildcard entry should have survived the refresh and still match eth1.
> +0 ipset test test 10.0.2.0/24,eth1
> +0 ipset flush test
> +# Add a nomatch exception first, a wildcard entry for the same net second.
> +0 ipset add test 10.0.3.0/24,eth0 nomatch
> +0 ipset add test 10.0.3.0/24,eth wildcard
> +# eth1 isn't excluded, so the wildcard should match it.
> +0 ipset test test 10.0.3.0/24,eth1
> +# eth0 is excluded by the nomatch entry; it must not match via the wildcard.
> +1 ipset test test 10.0.3.0/24,eth0
> +0 ipset destroy test

This part also does not handled properly with the current code: it lacks 
the ordering to match/delete first the specific and then the wildcard 
records.

Best regards,
Jozsef
-- 
E-mail : kadlec@netfilter.org, kadlec@blackhole.kfki.hu, kadlecsik.jozsef@wigner.hu
Address: Wigner Research Centre for Physics
         H-1525 Budapest 114, POB. 49, Hungary

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH ipset] tests: hash:net,iface.t: add test case for wildcard matching behaviour
  2026-10-28 13:02 [PATCH ipset] tests: hash:net,iface.t: add test case for wildcard matching behaviour Florian Westphal
  2026-11-15 16:39 ` Jozsef Kadlecsik
@ 2026-11-15 16:45 ` Jozsef Kadlecsik
  1 sibling, 0 replies; 6+ messages in thread
From: Jozsef Kadlecsik @ 2026-11-15 16:45 UTC (permalink / raw)
  To: Florian Westphal; +Cc: netfilter-devel

Hi Florian,

On Wed, 28 Oct 2026, Florian Westphal wrote:

> Document the existing behaviour of wildcard matching.
> 
> Signed-off-by: Florian Westphal <fw@strlen.de>
> ---
>  LLM generated.  Passes on nf, fails with
>  rhashtable conversion patches.
> 
>  tests/hash:net,iface.t | 26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
> 
> diff --git a/tests/hash:net,iface.t b/tests/hash:net,iface.t
> index 556d56df5c4b..b1d92bef26f8 100644
> --- a/tests/hash:net,iface.t
> +++ b/tests/hash:net,iface.t
> @@ -235,4 +235,30 @@
>  0 ipset list
>  # Counters and timeout: destroy set
>  0 ipset x test
> +# Re-Create the set for wildcard tests.
> +0 ipset create test hash:net,iface hashsize 128
> +# Add a specific entry first, a wildcard entry for the same net second.
> +0 ipset add test 10.0.1.0/24,eth0
> +0 ipset add test 10.0.1.0/24,eth wildcard
> +# Delete the specific entry.
> +0 ipset del test 10.0.1.0/24,eth0
> +# The wildcard entry should still be there and match eth1 via its prefix.
> +0 ipset test test 10.0.1.0/24,eth1

Just for the record: this is a variant of specific entry/overlapping 
wildcard matching and it fails in the original code, which is of 
course wrong.

Best regards,
Jozsef

> +0 ipset flush test
> +# Same layout: specific entry first, wildcard entry second.
> +0 ipset add test 10.0.2.0/24,eth0
> +0 ipset add test 10.0.2.0/24,eth wildcard
> +# Re-add the specific entry with -exist, expecting a no-op refresh.
> +0 ipset -exist add test 10.0.2.0/24,eth0
> +# The wildcard entry should have survived the refresh and still match eth1.
> +0 ipset test test 10.0.2.0/24,eth1
> +0 ipset flush test
> +# Add a nomatch exception first, a wildcard entry for the same net second.
> +0 ipset add test 10.0.3.0/24,eth0 nomatch
> +0 ipset add test 10.0.3.0/24,eth wildcard
> +# eth1 isn't excluded, so the wildcard should match it.
> +0 ipset test test 10.0.3.0/24,eth1
> +# eth0 is excluded by the nomatch entry; it must not match via the wildcard.
> +1 ipset test test 10.0.3.0/24,eth0
> +0 ipset destroy test
>  # eof
> -- 
> 2.55.0
> 
> 
> 

-- 
E-mail : kadlec@netfilter.org, kadlec@blackhole.kfki.hu, kadlecsik.jozsef@wigner.hu
Address: Wigner Research Centre for Physics
         H-1525 Budapest 114, POB. 49, Hungary

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH ipset] tests: hash:net,iface.t: add test case for wildcard matching behaviour
  2026-11-15 16:39 ` Jozsef Kadlecsik
@ 2026-11-15 18:21   ` Florian Westphal
  2026-11-17 16:26     ` Jozsef Kadlecsik
  0 siblings, 1 reply; 6+ messages in thread
From: Florian Westphal @ 2026-11-15 18:21 UTC (permalink / raw)
  To: Jozsef Kadlecsik; +Cc: netfilter-devel

Jozsef Kadlecsik <kadlec@netfilter.org> wrote:
> > +# Delete the specific entry.
> > +0 ipset del test 10.0.1.0/24,eth0
> > +# The wildcard entry should still be there and match eth1 via its prefix.
> > +0 ipset test test 10.0.1.0/24,eth1
> 
> The original code does not handle the case properly and the wildcard entry 
> can be deleted instead the specific one. If it passes for you then it's 
> just lucky ordering.

Yes, it passes both on main and rhashtable_v10.

> > +# eth0 is excluded by the nomatch entry; it must not match via the wildcard.
> > +1 ipset test test 10.0.3.0/24,eth0
> > +0 ipset destroy test
> 
> This part also does not handled properly with the current code: it lacks 
> the ordering to match/delete first the specific and then the wildcard 
> records.

Lucky coincidence, then?
What do we do now?  Will you make test cases that demonstrate the
expected behaviour and I respin a v11 that passes those tests?


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH ipset] tests: hash:net,iface.t: add test case for wildcard matching behaviour
  2026-11-15 18:21   ` Florian Westphal
@ 2026-11-17 16:26     ` Jozsef Kadlecsik
  2026-11-17 17:10       ` Florian Westphal
  0 siblings, 1 reply; 6+ messages in thread
From: Jozsef Kadlecsik @ 2026-11-17 16:26 UTC (permalink / raw)
  To: Florian Westphal; +Cc: netfilter-devel

Hi Florian,

On Sun, 15 Nov 2026, Florian Westphal wrote:

> Jozsef Kadlecsik <kadlec@netfilter.org> wrote:
> > > +# Delete the specific entry.
> > > +0 ipset del test 10.0.1.0/24,eth0
> > > +# The wildcard entry should still be there and match eth1 via its prefix.
> > > +0 ipset test test 10.0.1.0/24,eth1
> > 
> > The original code does not handle the case properly and the wildcard entry 
> > can be deleted instead the specific one. If it passes for you then it's 
> > just lucky ordering.
> 
> Yes, it passes both on main and rhashtable_v10.

I don't quite understand why does it passes for you in the case of the 
original code.

> > > +# eth0 is excluded by the nomatch entry; it must not match via the wildcard.
> > > +1 ipset test test 10.0.3.0/24,eth0
> > > +0 ipset destroy test
> > 
> > This part also does not handled properly with the current code: it lacks 
> > the ordering to match/delete first the specific and then the wildcard 
> > records.
> 
> Lucky coincidence, then? What do we do now?  Will you make test cases 
> that demonstrate the expected behaviour and I respin a v11 that passes 
> those tests?

The tests you added verify the expected behaviour and v10 passes all 
tests. I'd not add bug-compatibility even when that means the experienced 
behaviour changes.

Please apply your patches :-).

Tested-by: Jozsef Kadlecsik <kadlec@netfilter.org>
Acked-by: Jozsef Kadlecsik <kadlec@netfilter.org>

Best regards,
Jozsef
-- 
E-mail : kadlec@netfilter.org, kadlec@blackhole.kfki.hu, kadlecsik.jozsef@wigner.hu
Address: Wigner Research Centre for Physics
          H-1525 Budapest 114, POB. 49, Hungary

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH ipset] tests: hash:net,iface.t: add test case for wildcard matching behaviour
  2026-11-17 16:26     ` Jozsef Kadlecsik
@ 2026-11-17 17:10       ` Florian Westphal
  0 siblings, 0 replies; 6+ messages in thread
From: Florian Westphal @ 2026-11-17 17:10 UTC (permalink / raw)
  To: Jozsef Kadlecsik; +Cc: netfilter-devel

Jozsef Kadlecsik <kadlec@netfilter.org> wrote:
> The tests you added verify the expected behaviour and v10 passes all 
> tests. I'd not add bug-compatibility even when that means the experienced 
> behaviour changes.
> 
> Please apply your patches :-).
> 
> Tested-by: Jozsef Kadlecsik <kadlec@netfilter.org>
> Acked-by: Jozsef Kadlecsik <kadlec@netfilter.org>

Thanks Jozsef, I pushed them out.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-11-17 17:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-28 13:02 [PATCH ipset] tests: hash:net,iface.t: add test case for wildcard matching behaviour Florian Westphal
2026-11-15 16:39 ` Jozsef Kadlecsik
2026-11-15 18:21   ` Florian Westphal
2026-11-17 16:26     ` Jozsef Kadlecsik
2026-11-17 17:10       ` Florian Westphal
2026-11-15 16:45 ` Jozsef Kadlecsik

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.