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. Signed-off-by: Florian Westphal --- tests/hash:net,iface.t | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/hash:net,iface.t b/tests/hash:net,iface.t index f0c54734c580..f509630f9fb5 100644 --- a/tests/hash:net,iface.t +++ b/tests/hash:net,iface.t @@ -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 -- 2.56.1