tests: hash:net,iface.t: add test case for wildcard matching behaviour
Florian Westphal
maintainerPATCH 1/1 tests: hash:net,iface.t: add test case for wildcard matching behaviour
Document the existing behaviour of wildcard matching.
---
LLM generated. Passes on nf, fails with
rhashtable conversion patches.
tests/hash:net,iface.t | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
tests/hash:net,iface.t +26 -0
@@ -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
Signature · 1 line
2.55.0
Hi Florian,
Quoted 17 lines · Florian Westphal
Document the existing behaviour of wildcard matching.
Signed-off-by Florian Westphal <[email protected]>---
LLM generated. Passes on nf, fails with
rhashtable conversion patches.tests/hash:net,iface.t | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)tests/hash:net,iface.t +0
-0@@ -235,4 +235,30 @@ 0 ipset list # Counters and timeout: destroy set
tests/hash:net,iface.t line 246
Quoted 10 lines
tests/hash:net,iface.t +9
-00 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.
Quoted 7 lines
tests/hash:net,iface.t +7
-0+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.
tests/hash:net,iface.t line 263
Quoted 10 lines
tests/hash:net,iface.t +10
-0+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
Signature · 3 lines
E-mail : [email protected], [email protected], [email protected] Address: Wigner Research Centre for Physics H-1525 Budapest 114, POB. 49, Hungary
Florian Westphal
maintainerQuoted 8 lines · Jozsef Kadlecsik
tests/hash:net,iface.t line 246
Quoted 4 lines
tests/hash:net,iface.t +4
-0+# 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,eth1The 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.
Quoted 7 lines
Quoted 3 lines
+# 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 testThis 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?
Hi Florian,
Quoted 9 lines · Florian Westphal
Quoted 6 lines · Jozsef Kadlecsik
tests/hash:net,iface.t line 246
Quoted 4 lines
tests/hash:net,iface.t +4
-0+# 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,eth1The 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.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
+# 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 testThis 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 :-).
Best regards,
Jozsef
Signature · 3 lines
E-mail : [email protected], [email protected], [email protected] Address: Wigner Research Centre for Physics H-1525 Budapest 114, POB. 49, Hungary
Florian Westphal
maintainerQuoted 8 lines · Jozsef Kadlecsik
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 <[email protected]>Acked-by Jozsef Kadlecsik <[email protected]>
Thanks Jozsef, I pushed them out.
Hi Florian,
Quoted 17 lines · Florian Westphal
Document the existing behaviour of wildcard matching.
Signed-off-by Florian Westphal <[email protected]>---
LLM generated. Passes on nf, fails with
rhashtable conversion patches.tests/hash:net,iface.t | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)tests/hash:net,iface.t +0
-0@@ -235,4 +235,30 @@ 0 ipset list # Counters and timeout: destroy set
tests/hash:net,iface.t line 246
Quoted 10 lines
tests/hash:net,iface.t +9
-00 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
Quoted 23 lines
tests/hash:net,iface.t +17
-0+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 # eofSignature · 1 line
2.55.0
Signature · 3 lines
E-mail : [email protected], [email protected], [email protected] Address: Wigner Research Centre for Physics H-1525 Budapest 114, POB. 49, Hungary