ipset: more hash:iface test cases
Florian Westphal
maintainercover ipset: more hash:iface test cases
1) Add maxelem upper-bound test for hash:net and hash:iface. Verify forceadd flag behavior.
2) Add tests for hash:net,iface wildcard coverage. Verify that adding an interface already matched by a wildcard fails with EXIST, and that -exist refreshes the wildcard entry instead of duplicating it.
Both tests pass on unpatched nf:main.
rhashtable patchset failed the 2nd test.
Florian Westphal (2):
tests: hash:net,iface: add test for maxelem setting
tests: hash:net,iface: add of an interface covered by a wildcard
tests/hash:net,iface.t | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)
Signature · 1 line
2.56.1
Florian Westphal
maintainerPATCH 1/2 tests: hash:net,iface: add test for maxelem setting
check maxelem provides the desired upper bound.
Check forceadd flag.
Forceadd is not guaranteed to work, so we can't fail in case no replacement happened, but we can print an informal message.
--- tests/hash:net,iface.t | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
tests/hash:net,iface.t +32 -0
@@ -338,4 +338,36 @@ 1 ipset test test 10.0.0.1,eth0 # Wildcard refresh ordering: destroy set 0 ipset destroy test +# Full set: create a set with small maxelem parameter +0 ipset create test hash:net,iface maxelem 2 +# Full set: add first element +0 ipset add test 10.0.0.0/24,eth0 +# Full set: add second element, different key +0 ipset add test 10.1.0.0/24,eth0 +# Full set: add third element with a new key, must fail +1 ipset add test 10.2.0.0/24,eth0 +# Full set: third element must not be in the set +1 ipset test test 10.2.0.1,eth0 +# Full set: add element sharing the key of an existing one, must fail too +1 ipset add test 10.0.0.0/24,eth1 +# Full set: refresh an existing element with -exist, must still work +0 ipset -! add test 10.0.0.0/24,eth0 +# Full set: delete one element +0 ipset del test 10.1.0.0/24,eth0 +# Full set: adding a new key works again +0 ipset add test 10.2.0.0/24,eth0 +# Full set: destroy set +0 ipset destroy test +# Full set with forceadd: create a set with small maxelem parameter +0 ipset create test hash:net,iface maxelem 2 forceadd +# Full set with forceadd: add elements with different keys. +0 ipset add test 10.0.0.0/24,eth0 +0 ipset add test 10.0.1.0/24,eth0 +0 (for i in `seq 1 254`; do ipset add test 192.0.$i.0/24,eth0; done) || true +# Set contains two elements +0 n=`ipset list test|grep 'eth0'|wc -l` && test $n -eq 2 +# Soft-check for forceadd eviction +0 ipset list test | grep -q -F '192.0.' || echo -n "Notice: expected at least one 192 element in the set " +# Full set with forceadd: destroy set +0 ipset destroy test # eof
Signature · 1 line
2.56.1
Florian Westphal
maintainerPATCH 2/2 tests: hash:net,iface: add of an interface covered by a wildcard
In reply to Florian WestphalWith a wildcard element in place, adding an interface it covers must fail with EXIST, as in the array based implementation. With -exist it must refresh the wildcard element instead of creating a second one.
--- tests/hash:net,iface.t | 10 ++++++++++ 1 file changed, 10 insertions(+)
tests/hash:net,iface.t +10 -0
@@ -338,6 +338,16 @@ 1 ipset test test 10.0.0.1,eth0 # Wildcard refresh ordering: destroy set 0 ipset destroy test +# Add vs. wildcard: wildcard element first +0 ipset create test hash:net,iface +0 ipset add test 10.0.0.0/24,eth wildcard +# Add vs. wildcard: an interface covered by the wildcard is a duplicate +1 ipset add test 10.0.0.0/24,eth0 +# Add vs. wildcard: with -exist the wildcard element is refreshed, not duplicated +0 ipset -! add test 10.0.0.0/24,eth0 nomatch +# Add vs. wildcard: the refreshed wildcard element is now nomatch for eth1 too +1 ipset test test 10.0.0.1,eth1 +0 ipset destroy test # Full set: create a set with small maxelem parameter 0 ipset create test hash:net,iface maxelem 2 # Full set: add first element
Signature · 1 line
2.56.1