test updates
Florian Westphal
maintainercover test updates
Hi Jozsef,
This contains various enhancments for the ipsets tests/runtest.sh.
The largest enhancement is the removal of the sendip dependency, in the last patch -- this adds a sendip emulation via scapy. Note that 'sendip' will be used if present and the bundled scapy sendip.py otherwise.
Main motivation was to make runtest.sh work with my CI pipeline. This uses nipa (https://github.com/linux-netdev/nipa.git).
Test scripts spawn kernels via virtme-ng.
1) resolve the above. Add a temporary directory, export IPSET_TMPDIR to all scripts and use that in the tests to write files there instead of cwd.
2) make test setup simpler: re-exec runtest.sh in a new namespace if IPSET_UNSHARED is unset (the default). A dummy eth0 device for tests is added in the new namespace. This makes ./runtest.sh self-contained, no extra work needed. Also avoids clashes with the test network addresses used by test scripts.
3) diff.sh: preserve file names in diff output: use the new temporary directory to store the postprocessed dump files before compare. This isn't needed but it helps to spot the cause of failures more easily, as the failing dump name is preserved in the diff output.
4) check_klog.sh: Enable direct fallback to dmesg without error messages. Not needed either, but it un-clutters stderr in my environment.
5) Use the local ipset binary instead of host binary. Allow fallback to plain "unshare -n" if user namespaces are not supported. Parallelize the test and increase iteration count to 124. 'unshare -Unr' doesn't work in my setup but 'unshare -n' does and it should be good enough. Note the script will still unse unshare -Unr by default, it only falls back once the first try fails.
6) Make setlist_resize.sh more verbose on error:
Capture command output to a temporary file, then dump log on failure. This also fixes a spurious error, the script uses 'set -e' and occasionally the first 'rmmod' try fails here which made the script exit too early.
7) Add scapy-based sendip emulation to runtest.sh. Fall bacl to a scapy-based alternative if sendip isn't found in PATH.
Florian Westphal (7):
tests: make runtest.sh work with readonly-cwd
tests: runtest.sh: run inside namespace
tests: diff.sh: preserve file name
tests: check_klog.sh: unclutter stderr
tests: setlist_ns.sh: use local ipset binary and don't rely on userns
tests: make setlist_resize.sh more verbose on error
tests: runtest.sh: add sendip emulation via scapy
README | 13 +-- tests/big_sort.sh | 8 +- tests/bitmap:ip.t | 30 +++---- tests/check_klog.sh | 11 ++- tests/check_sendip_packets | 2 +- tests/comment.t | 32 ++++---- tests/diff.sh | 13 ++- tests/hash:ip,mark.t | 8 +- tests/hash:ip,port,ip.t | 8 +- tests/hash:ip,port,net.t | 4 +- tests/hash:ip,port.t | 32 ++++---- tests/hash:ip.t | 30 +++---- tests/hash:ip6,mark.t | 8 +- tests/hash:ip6,port,ip6.t | 8 +- tests/hash:ip6,port,net6.t | 4 +- tests/hash:ip6,port.t | 8 +- tests/hash:ip6.t | 32 ++++---- tests/hash:mac.t | 16 ++-- tests/hash:net,iface.t | 12 +-- tests/hash:net,net.t | 32 ++++---- tests/hash:net,port,net.t | 4 +- tests/hash:net,port.t | 8 +- tests/hash:net.t | 16 ++-- tests/hash:net6,net6.t | 8 +- tests/hash:net6,port,net6.t | 4 +- tests/hash:net6,port.t | 16 ++-- tests/hash:net6.t | 8 +- tests/ignore.sh | 2 +- tests/iphash.t | 20 ++--- tests/ipmap.t | 28 +++---- tests/ipmarkhash.t | 8 +- tests/ipporthash.t | 8 +- tests/ipportiphash.t | 8 +- tests/ipportnethash.t | 8 +- tests/iptables.sh | 8 +- tests/iptree.t | 4 +- tests/iptreemap.t | 4 +- tests/macipmap.t | 16 ++-- tests/match_target.t | 2 +- tests/nethash.t | 4 +- tests/portmap.t | 16 ++-- tests/restore.t | 2 +- tests/runtest.sh | 52 +++++++++++- tests/sendip.py | 154 ++++++++++++++++++++++++++++++++++++ tests/sendip.sh | 8 +- tests/setlist.t | 28 +++---- tests/setlist_ns.sh | 29 ++++++- tests/setlist_resize.sh | 34 ++++++-- tests/sort.sh | 6 +- 49 files changed, 541 insertions(+), 283 deletions(-) create mode 100755 tests/sendip.py
Signature · 1 line
2.54.0
Florian Westphal
maintainerPATCH 1/7 tests: make runtest.sh work with readonly-cwd
My local test setup spawns qemu instances via virtme-ng. The host file system is a readonly export, only /tmp is writeable.
Make runtest.sh create a temporary dir, then export IPSET_TMPDIR to all other scripts and use that location to load/store temporary data.
--- tests/big_sort.sh | 8 ++++---- tests/bitmap:ip.t | 28 ++++++++++++++-------------- tests/check_klog.sh | 4 ++-- tests/comment.t | 32 ++++++++++++++++---------------- tests/hash:ip,mark.t | 8 ++++---- tests/hash:ip,port,ip.t | 8 ++++---- tests/hash:ip,port,net.t | 4 ++-- tests/hash:ip,port.t | 32 ++++++++++++++++---------------- tests/hash:ip.t | 28 ++++++++++++++-------------- tests/hash:ip6,mark.t | 8 ++++---- tests/hash:ip6,port,ip6.t | 8 ++++---- tests/hash:ip6,port,net6.t | 4 ++-- tests/hash:ip6,port.t | 8 ++++---- tests/hash:ip6.t | 32 ++++++++++++++++---------------- tests/hash:mac.t | 16 ++++++++-------- tests/hash:net,iface.t | 12 ++++++------ tests/hash:net,net.t | 32 ++++++++++++++++---------------- tests/hash:net,port,net.t | 4 ++-- tests/hash:net,port.t | 8 ++++---- tests/hash:net.t | 16 ++++++++-------- tests/hash:net6,net6.t | 8 ++++---- tests/hash:net6,port,net6.t | 4 ++-- tests/hash:net6,port.t | 16 ++++++++-------- tests/hash:net6.t | 8 ++++---- tests/ignore.sh | 2 +- tests/iphash.t | 20 ++++++++++---------- tests/ipmap.t | 28 ++++++++++++++-------------- tests/ipmarkhash.t | 8 ++++---- tests/ipporthash.t | 8 ++++---- tests/ipportiphash.t | 8 ++++---- tests/ipportnethash.t | 8 ++++---- tests/iptables.sh | 8 ++++---- tests/iptree.t | 4 ++-- tests/iptreemap.t | 4 ++-- tests/macipmap.t | 16 ++++++++-------- tests/match_target.t | 2 +- tests/nethash.t | 4 ++-- tests/portmap.t | 16 ++++++++-------- tests/restore.t | 2 +- tests/runtest.sh | 14 +++++++++++--- tests/sendip.sh | 2 +- tests/setlist.t | 26 +++++++++++++------------- tests/sort.sh | 6 +++--- 43 files changed, 265 insertions(+), 257 deletions(-)
tests/big_sort.sh +4 -4
@@ -7,8 +7,8 @@ for x in `seq 0 255`; do echo "a test 10.10.$x.$y" done done | ipset r -ipset -t list > .foo -diff .foo big_sort.terse -ipset -s save > .foo -diff .foo big_sort.saved +ipset -t list > "$IPSET_TMP/.foo" +diff "$IPSET_TMP/.foo" big_sort.terse +ipset -s save > "$IPSET_TMP/.foo" +diff "$IPSET_TMP/.foo" big_sort.saved ipset x test
tests/bitmap:ip.t +14 -14
@@ -35,15 +35,15 @@ # Range: Add a range of elements 0 ipset -A test 2.0.0.128-2.0.0.131 timeout 4 # Range: List set -0 ipset list test > .foo +0 ipset list test > "$IPSET_TMP/.foo" # Range: Check listing -0 ./diff.sh .foo bitmap:ip.t.list4 +0 ./diff.sh "$IPSET_TMP/.foo" bitmap:ip.t.list4 # Sleep 5s so that entries can time out 0 sleep 5s # Range: List set after timeout -0 ipset list test > .foo +0 ipset list test > "$IPSET_TMP/.foo" # Range: Check listing -0 ./diff.sh .foo bitmap:ip.t.list0 +0 ./diff.sh "$IPSET_TMP/.foo" bitmap:ip.t.list0 # Range: Flush test set 0 ipset flush test # Range: Delete test set
@@ -77,15 +77,15 @@ # Network: Delete the same element 0 ipset -D test 2.0.0.128 # Network: List set -0 ipset list test > .foo +0 ipset list test > "$IPSET_TMP/.foo" # Network: Check listing -0 ./diff.sh .foo bitmap:ip.t.list5 +0 ./diff.sh "$IPSET_TMP/.foo" bitmap:ip.t.list5 # Sleep 5s so that entries can time out 0 sleep 5s # Network: List set -0 ipset list test > .foo +0 ipset list test > "$IPSET_TMP/.foo" # Network: Check listing -0 ./diff.sh .foo bitmap:ip.t.list1 +0 ./diff.sh "$IPSET_TMP/.foo" bitmap:ip.t.list1 # Network: Flush test set 0 ipset flush test # Network: Delete test set
@@ -119,15 +119,15 @@ # Subnets: Add a subnet of subnets 0 ipset -A test 10.8.0.0/16 timeout 4 # Subnets: List set -0 ipset list test > .foo +0 ipset list test > "$IPSET_TMP/.foo" # Subnets: Check listing -0 ./diff.sh .foo bitmap:ip.t.list6 +0 ./diff.sh "$IPSET_TMP/.foo" bitmap:ip.t.list6 # Sleep 5s so that entries can time out 0 sleep 5s # Subnets: List set -0 ipset list test > .foo +0 ipset list test > "$IPSET_TMP/.foo" # Subnets: Check listing -0 ./diff.sh .foo bitmap:ip.t.list2 +0 ./diff.sh "$IPSET_TMP/.foo" bitmap:ip.t.list2 # Subnets: Flush test set 0 ipset flush test # Subnets: Delete test set
@@ -145,9 +145,9 @@ # Full: Test element not added to the set 1 ipset test test 0.1.0.0 # Full: List set -0 ipset list test > .foo +0 ipset list test > "$IPSET_TMP/.foo" # Full: Check listing -0 ./diff.sh .foo bitmap:ip.t.list3 +0 ./diff.sh "$IPSET_TMP/.foo" bitmap:ip.t.list3 # Full: flush set 0 ipset flush test # Full: add element with 1s timeout
tests/check_klog.sh +2 -2
@@ -5,8 +5,8 @@ set -e # arguments: ipaddr proto port setname ... -test -f .loglines || exit 1 -loglines=$(<.loglines) +test -f "$IPSET_TMP/.loglines" || exit 1 +loglines=$(<"$IPSET_TMP/.loglines") if [ $loglines -ne 0 ]; then loglines=$((loglines - 1)) fi
tests/comment.t +16 -16
@@ -9,9 +9,9 @@ # Bitmap comment: Test element with comment 0 ipset test test 2.0.0.1 # Bitmap comment: List set -0 ipset list test > .foo +0 ipset list test > "$IPSET_TMP/.foo" # Bitmap comment: Check listing -0 ./diff.sh .foo comment.t.list0 +0 ./diff.sh "$IPSET_TMP/.foo" comment.t.list0 # Bitmap comment: Delete element with comment 0 ipset del test 2.0.0.1 # Bitmap comment: Test deleted element
@@ -31,9 +31,9 @@ # Bitmap comment: Add multiple elements with comment 0 for x in `seq 1 255`; do echo "add test 2.0.0.$x comment \\\"text message $x\\\""; done | ipset restore # Bitmap comment: List set -0 ipset list test > .foo +0 ipset list test > "$IPSET_TMP/.foo" # Bitmap comment: Check listing -0 ./diff.sh .foo comment.t.list1 +0 ./diff.sh "$IPSET_TMP/.foo" comment.t.list1 # Bitmap comment: Delete test set 0 ipset destroy test # Bitmap comment: create set with timeout
@@ -43,15 +43,15 @@ # Bitmap comment: Add multiple elements with zero timeout 0 for x in `seq 1 255`; do echo "add test 2.0.1.$x timeout 0 comment \\\"text message $x\\\""; done | ipset restore # Bitmap comment: List set -0 ipset list test > .foo +0 ipset list test > "$IPSET_TMP/.foo" # Bitmap comment: Check listing -0 ./diff.sh .foo comment.t.list11 +0 ./diff.sh "$IPSET_TMP/.foo" comment.t.list11 # Sleep 5s so that entries can time out 0 sleep 5s # Bitmap comment: List set -0 ipset list test > .foo +0 ipset list test > "$IPSET_TMP/.foo" # Bitmap comment: Check listing -0 ./diff.sh .foo comment.t.list12 +0 ./diff.sh "$IPSET_TMP/.foo" comment.t.list12 # Bitmap comment: Flush set 0 ipset flush test # Bitmap comment: Delete test set
@@ -87,9 +87,9 @@ # Hash comment: Try to add IP address 0 ipset add test 2.0.0.1,2.0.0.2 # Hash comment: List set -0 ipset list test > .foo0 && ./sort.sh .foo0 +0 ipset list test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Hash comment: Check listing -0 ./diff.sh .foo comment.t.list2 +0 ./diff.sh "$IPSET_TMP/.foo" comment.t.list2 # Hash comment: Update element with comment 0 ipset -! add test 2.0.0.1,2.0.0.2 comment "text 2.0.0.1,2.0.0.2" # Hash comment: Check updated element
@@ -123,15 +123,15 @@ # Hash comment: Add multiple elements with zero timeout 0 for x in `seq 0 255`; do echo "add test 2.0.1.$x timeout 0 comment \\\"text message $x\\\""; done | ipset restore # Hash comment: List set -0 ipset list test > .foo0 && ./sort.sh .foo0 +0 ipset list test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Hash comment: Check listing -0 ./diff.sh .foo comment.t.list21 +0 ./diff.sh "$IPSET_TMP/.foo" comment.t.list21 # Sleep 5s so that entries can time out 0 sleep 5s # Hash comment: List set -0 ipset list test > .foo0 && ./sort.sh .foo0 +0 ipset list test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Hash comment: Check listing -0 ./diff.sh .foo comment.t.list22 +0 ./diff.sh "$IPSET_TMP/.foo" comment.t.list22 # Hash comment: Flush set 0 ipset flush test # Hash comment: Delete test set
@@ -147,9 +147,9 @@ # List comment: Add b set with comment 0 ipset a test b after a comment "b set comment" # List comment: List sets -0 ipset list > .foo +0 ipset list > "$IPSET_TMP/.foo" # List comment: Check listing -0 ./diff.sh .foo comment.t.list3 +0 ./diff.sh "$IPSET_TMP/.foo" comment.t.list3 # Flush sets 0 ipset f # Destroy sets
tests/hash:ip,mark.t +4 -4
@@ -27,15 +27,15 @@ # Try to add value after second random value 0 ipset add test 2.1.0.1,0x80 # List set -0 ipset list test > .foo0 && ./sort.sh .foo0 +0 ipset list test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Check listing -0 ./diff.sh .foo hash:ip,mark.t.list0 +0 ./diff.sh "$IPSET_TMP/.foo" hash:ip,mark.t.list0 # Sleep 5s so that elements can time out 0 sleep 5 # List set -0 ipset list test > .foo0 && ./sort.sh .foo0 +0 ipset list test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Check listing -0 ./diff.sh .foo hash:ip,mark.t.list1 +0 ./diff.sh "$IPSET_TMP/.foo" hash:ip,mark.t.list1 # Flush test set 0 ipset flush test # Add multiple elements in one step
tests/hash:ip,port,ip.t +4 -4
@@ -35,15 +35,15 @@ # Try to add value after second random value 0 ipset add test 2.1.0.1,128,2.2.2.2 # List set -0 ipset list test > .foo0 && ./sort.sh .foo0 +0 ipset list test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Check listing -0 ./diff.sh .foo hash:ip,port,ip.t.list0 +0 ./diff.sh "$IPSET_TMP/.foo" hash:ip,port,ip.t.list0 # Sleep 5s so that elements can time out 0 sleep 5 # List set -0 ipset list test > .foo0 && ./sort.sh .foo0 +0 ipset list test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Check listing -0 ./diff.sh .foo hash:ip,port,ip.t.list1 +0 ./diff.sh "$IPSET_TMP/.foo" hash:ip,port,ip.t.list1 # Flush test set 0 ipset flush test # Add multiple elements in one step
tests/hash:ip,port,net.t +2 -2
@@ -27,9 +27,9 @@ # Try to add value after second random value 0 ipset add test 2.1.0.1,128,10.0.0.0/17 # List set -0 ipset list test > .foo0 && ./sort.sh .foo0 +0 ipset list test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Check listing -0 ./diff.sh .foo hash:ip,port,net.t.list0 +0 ./diff.sh "$IPSET_TMP/.foo" hash:ip,port,net.t.list0 # Sleep 5s so that elements can time out 0 sleep 5 # List set
tests/hash:ip,port.t +16 -16
@@ -31,15 +31,15 @@ # Delete port by number 0 ipset del test 2.1.0.3,25 # List set -0 ipset list test > .foo0 && ./sort.sh .foo0 +0 ipset list test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Check listing -0 ./diff.sh .foo hash:ip,port.t.list0 +0 ./diff.sh "$IPSET_TMP/.foo" hash:ip,port.t.list0 # Sleep 5s so that elements can time out 0 sleep 5 # List set -0 ipset list test > .foo0 && ./sort.sh .foo0 +0 ipset list test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Check listing -0 ./diff.sh .foo hash:ip,port.t.list1 +0 ./diff.sh "$IPSET_TMP/.foo" hash:ip,port.t.list1 # Flush test set 0 ipset flush test # Add multiple elements in one step
@@ -73,9 +73,9 @@ # Delete element with sctp 0 ipset del test 2.0.0.1,sctp:80 # List set -0 ipset list test > .foo0 && ./sort.sh .foo0 +0 ipset list test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Check listing -0 ./diff.sh .foo hash:ip,port.t.list2 +0 ./diff.sh "$IPSET_TMP/.foo" hash:ip,port.t.list2 # Delete set 0 ipset destroy test # Create set to add a range
@@ -195,15 +195,15 @@ # Network: Delete the same network 0 ipset -D test 200.100.0.12,22 # Network: List set -0 ipset -L test > .foo0 && ./sort.sh .foo0 +0 ipset -L test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Network: Check listing -0 ./diff.sh .foo hash:ip,port.t.list3 +0 ./diff.sh "$IPSET_TMP/.foo" hash:ip,port.t.list3 # Sleep 5s so that elements can time out 0 sleep 5 # Network: List set -0 ipset -L test > .foo +0 ipset -L test > "$IPSET_TMP/.foo" # Network: Check listing -0 ./diff.sh .foo hash:ip,port.t.list4 +0 ./diff.sh "$IPSET_TMP/.foo" hash:ip,port.t.list4 # Network: Flush test set 0 ipset -F test # Network: add element with 1s timeout
@@ -241,15 +241,15 @@ # Network: Delete the same network 0 ipset -D test 200.100.0.12,22 # Network: List set -0 ipset -L test > .foo0 && ./sort.sh .foo0 +0 ipset -L test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Network: Check listing -0 ./diff.sh .foo hash:ip,port.t.list5 +0 ./diff.sh "$IPSET_TMP/.foo" hash:ip,port.t.list5 # Sleep 5s so that elements can time out 0 sleep 5 # Network: List set -0 ipset -L test > .foo +0 ipset -L test > "$IPSET_TMP/.foo" # Network: Check listing -0 ./diff.sh .foo hash:ip,port.t.list6 +0 ./diff.sh "$IPSET_TMP/.foo" hash:ip,port.t.list6 # Network: Flush test set 0 ipset -F test # Network: add element with 1s timeout
@@ -283,9 +283,9 @@ # Network: Test delete value 0 ipset -D test 1.168.0.124,22 # Network: List set -0 ipset -L test > .foo +0 ipset -L test > "$IPSET_TMP/.foo" # Network: Check listing -0 ./diff.sh .foo hash:ip,port.t.list7 +0 ./diff.sh "$IPSET_TMP/.foo" hash:ip,port.t.list7 # Network: Delete test set 0 ipset -X test # eof
tests/hash:ip.t +14 -14
@@ -19,15 +19,15 @@ # IP: Delete the same value 0 ipset -D test 200.100.0.12 # IP: List set -0 ipset -L test > .foo0 && ./sort.sh .foo0 +0 ipset -L test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # IP: Check listing -0 ./diff.sh .foo hash:ip.t.list2 +0 ./diff.sh "$IPSET_TMP/.foo" hash:ip.t.list2 # Sleep 5s so that element can time out 0 sleep 5 # IP: List set -0 ipset -L test > .foo0 && ./sort.sh .foo0 +0 ipset -L test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # IP: Check listing -0 ./diff.sh .foo hash:ip.t.list0 +0 ./diff.sh "$IPSET_TMP/.foo" hash:ip.t.list0 # IP: Flush test set 0 ipset -F test # IP: Add multiple elements in one step
@@ -97,15 +97,15 @@ # Network: Delete the same network 0 ipset -D test 200.100.0.12 # Network: List set -0 ipset -L test > .foo0 && ./sort.sh .foo0 +0 ipset -L test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Network: Check listing -0 ./diff.sh .foo hash:ip.t.list3 +0 ./diff.sh "$IPSET_TMP/.foo" hash:ip.t.list3 # Sleep 5s so that elements can time out 0 sleep 5 # Network: List set -0 ipset -L test > .foo +0 ipset -L test > "$IPSET_TMP/.foo" # Network: Check listing -0 ./diff.sh .foo hash:ip.t.list1 +0 ./diff.sh "$IPSET_TMP/.foo" hash:ip.t.list1 # Network: Flush test set 0 ipset -F test # Network: add element with 1s timeout
@@ -241,15 +241,15 @@ skip which sendip # Network: Delete the same network 0 ipset -D test 200.100.0.12 # Network: List set -0 ipset -L test > .foo0 && ./sort.sh .foo0 +0 ipset -L test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Network: Check listing -0 ./diff.sh .foo hash:ip.t.list4 +0 ./diff.sh "$IPSET_TMP/.foo" hash:ip.t.list4 # Sleep 5s so that elements can time out 0 sleep 5 # Network: List set -0 ipset -L test > .foo +0 ipset -L test > "$IPSET_TMP/.foo" # Network: Check listing -0 ./diff.sh .foo hash:ip.t.list5 +0 ./diff.sh "$IPSET_TMP/.foo" hash:ip.t.list5 # Network: Flush test set 0 ipset -F test # Network: add element with 1s timeout
@@ -285,9 +285,9 @@ skip which sendip # Network: Test delete value 0 ipset -D test 1.2.0.5 # Network: List set -0 ipset -L test > .foo +0 ipset -L test > "$IPSET_TMP/.foo" # Network: Check listing -0 ./diff.sh .foo hash:ip.t.list6 +0 ./diff.sh "$IPSET_TMP/.foo" hash:ip.t.list6 # Network: Delete test set 0 ipset -X test # eof
tests/hash:ip6,mark.t +4 -4
@@ -27,15 +27,15 @@ # Try to add value after second random value 0 ipset add test 2:1:0::1,0x80 # List set -0 ipset list test > .foo0 && ./sort.sh .foo0 +0 ipset list test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Check listing -0 ./diff.sh .foo hash:ip6,mark.t.list0 +0 ./diff.sh "$IPSET_TMP/.foo" hash:ip6,mark.t.list0 # Sleep 5s so that elements can time out 0 sleep 5 # List set -0 ipset list test > .foo0 && ./sort.sh .foo0 +0 ipset list test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Check listing -0 ./diff.sh .foo hash:ip6,mark.t.list1 +0 ./diff.sh "$IPSET_TMP/.foo" hash:ip6,mark.t.list1 # Delete test set 0 ipset destroy test # Create set to add a range
tests/hash:ip6,port,ip6.t +4 -4
@@ -35,15 +35,15 @@ # Try to add value after second random value 0 ipset add test 2:1:0::1,128,2:2:2::2 # List set -0 ipset list test > .foo0 && ./sort.sh .foo0 +0 ipset list test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Check listing -0 ./diff.sh .foo hash:ip6,port,ip6.t.list0 +0 ./diff.sh "$IPSET_TMP/.foo" hash:ip6,port,ip6.t.list0 # Sleep 5s so that elements can time out 0 sleep 5 # List set -0 ipset list test > .foo0 && ./sort.sh .foo0 +0 ipset list test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Check listing -0 ./diff.sh .foo hash:ip6,port,ip6.t.list1 +0 ./diff.sh "$IPSET_TMP/.foo" hash:ip6,port,ip6.t.list1 # Flush test set 0 ipset flush test # Add multiple elements in one step
tests/hash:ip6,port,net6.t +2 -2
@@ -35,9 +35,9 @@ # Range: Try to add value after second random value 0 ipset -A test 2:1:0::1,128,2:2:2::2/12 # Range: List set -0 ipset -L test > .foo0 && ./sort.sh .foo0 +0 ipset -L test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Range: Check listing -0 ./diff.sh .foo hash:ip6,port,net6.t.list0 +0 ./diff.sh "$IPSET_TMP/.foo" hash:ip6,port,net6.t.list0 # Range: Flush test set 0 ipset -F test # Range: Delete test set
tests/hash:ip6,port.t +4 -4
@@ -27,15 +27,15 @@ # Try to add value after second random value 0 ipset add test 2:1:0::1,128 # List set -0 ipset list test > .foo0 && ./sort.sh .foo0 +0 ipset list test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Check listing -0 ./diff.sh .foo hash:ip6,port.t.list0 +0 ./diff.sh "$IPSET_TMP/.foo" hash:ip6,port.t.list0 # Sleep 5s so that elements can time out 0 sleep 5 # List set -0 ipset list test > .foo0 && ./sort.sh .foo0 +0 ipset list test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Check listing -0 ./diff.sh .foo hash:ip6,port.t.list1 +0 ./diff.sh "$IPSET_TMP/.foo" hash:ip6,port.t.list1 # Flush test set 0 ipset flush test # Add multiple elements in one step
tests/hash:ip6.t +16 -16
@@ -21,25 +21,25 @@ # IP: Delete the same value 0 ipset -D test 200:100:0::12 # IP: List set -0 ipset -L test > .foo0 && ./sort.sh .foo0 +0 ipset -L test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # IP: Check listing -0 ./diff.sh .foo hash:ip6.t.list2 +0 ./diff.sh "$IPSET_TMP/.foo" hash:ip6.t.list2 # IP: Save set -0 ipset save test > hash:ip6.t.restore +0 ipset save test > "$IPSET_TMP/hash:ip6.t.restore" # Sleep 5s so that element can time out 0 sleep 5 # IP: List set -0 ipset -L test > .foo0 && ./sort.sh .foo0 +0 ipset -L test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # IP: Check listing -0 ./diff.sh .foo hash:ip6.t.list0 +0 ./diff.sh "$IPSET_TMP/.foo" hash:ip6.t.list0 # IP: Destroy set 0 ipset x test # IP: Restore saved set -0 ipset restore < hash:ip6.t.restore && rm hash:ip6.t.restore +0 ipset restore < "$IPSET_TMP/hash:ip6.t.restore" && rm "$IPSET_TMP/hash:ip6.t.restore" # IP: List set -0 ipset -L test > .foo0 && ./sort.sh .foo0 +0 ipset -L test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # IP: Check listing -0 ./diff.sh .foo hash:ip6.t.list2 +0 ./diff.sh "$IPSET_TMP/.foo" hash:ip6.t.list2 # IP: Flush test set 0 ipset -F test # IP: Try to add multiple elements in one step
@@ -73,15 +73,15 @@ # Network: Test the deleted network 1 ipset -T test 200:101:0::12 # Network: List set -0 ipset -L test > .foo0 && ./sort.sh .foo0 +0 ipset -L test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Network: Check listing -0 ./diff.sh .foo hash:ip6.t.list3 +0 ./diff.sh "$IPSET_TMP/.foo" hash:ip6.t.list3 # Sleep 5s so that elements can time out 0 sleep 5 # Network: List set -0 ipset -L test > .foo +0 ipset -L test > "$IPSET_TMP/.foo" # Network: Check listing -0 ./diff.sh .foo hash:ip6.t.list1 +0 ./diff.sh "$IPSET_TMP/.foo" hash:ip6.t.list1 # Network: Flush test set 0 ipset -F test # Network: Delete test set
@@ -89,13 +89,13 @@ # Check more complex restore commands 0 ipset restore < restore.t.restore # List restored set a -0 ipset l a > .foo0 && ./sort.sh .foo0 +0 ipset l a > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Check listing of set a -0 ./diff.sh .foo restore.t.list0 +0 ./diff.sh "$IPSET_TMP/.foo" restore.t.list0 # List restored set b -0 ipset l b > .foo0 && ./sort.sh .foo0 +0 ipset l b > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Check listing of set b -0 ./diff.sh .foo restore.t.list1 +0 ./diff.sh "$IPSET_TMP/.foo" restore.t.list1 # Destroy by restore 0 ipset restore < restore.t.destroy # Timeout: Check that resizing keeps timeout values
tests/hash:mac.t +8 -8
@@ -19,15 +19,15 @@ # MAC: Delete the same value 0 ipset -D test 1:2:3:4:a:b # MAC: List set -0 ipset -L test > .foo0 && ./sort.sh .foo0 +0 ipset -L test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # MAC: Check listing -0 ./diff.sh .foo hash:mac.t.list2 +0 ./diff.sh "$IPSET_TMP/.foo" hash:mac.t.list2 # Sleep 5s so that element can time out 0 sleep 5 # MAC: List set -0 ipset -L test > .foo0 && ./sort.sh .foo0 +0 ipset -L test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # MAC: Check listing -0 ./diff.sh .foo hash:mac.t.list0 +0 ./diff.sh "$IPSET_TMP/.foo" hash:mac.t.list0 # MAC: Destroy test set 0 ipset -X test # MAC: Create a set with skbinfo extension
@@ -45,9 +45,9 @@ # MAC: Add element with mark, skbprio and skbqueue 0 ipset a test 1:2:3:4:5:11 skbmark 0x11223344/0xffff0000 skbprio 2:1 skbqueue 8 # MAC: List set -0 ipset -L test > .foo0 && ./sort.sh .foo0 +0 ipset -L test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # MAC: Check listing -0 ./diff.sh .foo hash:mac.t.list1 +0 ./diff.sh "$IPSET_TMP/.foo" hash:mac.t.list1 # MAC: Destroy test set 0 ipset -X test # MAC: Create a set with small maxelem parameter
@@ -63,9 +63,9 @@ # MAC: Add second element with another extension value 0 ipset -! a test 1:2:3:4:5:7 skbprio 1:12 skbqueue 8 # MAC: List set -0 ipset -L test > .foo0 && ./sort.sh .foo0 +0 ipset -L test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # MAC: Check listing -0 ./diff.sh .foo hash:mac.t.list3 +0 ./diff.sh "$IPSET_TMP/.foo" hash:mac.t.list3 # MAC: Destroy test set 0 ipset x test # eof
tests/hash:net,iface.t +6 -6
@@ -41,9 +41,9 @@ # Try to add IP address 0 ipset add test 2.0.0.1,eth0 # List set -0 ipset list test > .foo0 && ./sort.sh .foo0 +0 ipset list test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Check listing -0 ./diff.sh .foo hash:net,iface.t.list0 +0 ./diff.sh "$IPSET_TMP/.foo" hash:net,iface.t.list0 # Flush test set 0 ipset flush test # Delete test set
@@ -53,9 +53,9 @@ # Add networks in range notation 0 ipset add test 10.2.0.0-10.2.1.12,eth0 # List set -0 ipset -L test > .foo0 && ./sort.sh .foo0 +0 ipset -L test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Check listing -0 ./diff.sh .foo hash:net,iface.t.list2 +0 ./diff.sh "$IPSET_TMP/.foo" hash:net,iface.t.list2 # Flush test set 0 ipset flush test # Add 0/0,eth0
@@ -117,9 +117,9 @@ # Add overlapping networks from /4 to /30 0 (set -e; for x in `seq 4 30`; do ipset add test 192.0.0.0/$x,eth$x; done) # List test set -0 ipset -L test > .foo0 && ./sort.sh .foo0 +0 ipset -L test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Check listing -0 ./diff.sh .foo hash:net,iface.t.list1 +0 ./diff.sh "$IPSET_TMP/.foo" hash:net,iface.t.list1 # Test matching elements in all added networks from /30 to /24 0 (set -e; y=2; for x in `seq 24 30 | tac`; do ipset test test 192.0.0.$y,eth$x; y=$((y*2)); done) # Test non-matching elements in all added networks from /30 to /24
tests/hash:net,net.t +16 -16
@@ -33,15 +33,15 @@ # Try to add IP address 0 ipset add test 2.0.0.1,2.0.0.2 # List set -0 ipset list test > .foo0 && ./sort.sh .foo0 +0 ipset list test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Check listing -0 ./diff.sh .foo hash:net,net.t.list0 +0 ./diff.sh "$IPSET_TMP/.foo" hash:net,net.t.list0 # Sleep 5s so that element can time out 0 sleep 5 # List set -0 ipset -L test > .foo0 && ./sort.sh .foo0 +0 ipset -L test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Check listing -0 ./diff.sh .foo hash:net,net.t.list1 +0 ./diff.sh "$IPSET_TMP/.foo" hash:net,net.t.list1 # Flush test set 0 ipset flush test # Delete test set
@@ -51,9 +51,9 @@ # Add networks in range notation 0 ipset add test 10.2.0.0-10.2.1.12,10.3.0.0-10.3.1.12 # List set -0 ipset -L test > .foo0 && ./sort.sh .foo0 +0 ipset -L test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Check listing -0 ./diff.sh .foo hash:net,net.t.list2 +0 ./diff.sh "$IPSET_TMP/.foo" hash:net,net.t.list2 # Delete test set 0 ipset destroy test # Stress test with range notation
@@ -185,15 +185,15 @@ # Network: Delete the same network 0 ipset -D test 200.100.0.12,200.100.0.13 # Network: List set -0 ipset -L test > .foo0 && ./sort.sh .foo0 +0 ipset -L test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Network: Check listing -0 ./diff.sh .foo hash:net,net.t.list3 +0 ./diff.sh "$IPSET_TMP/.foo" hash:net,net.t.list3 # Sleep 5s so that elements can time out 0 sleep 5 # Network: List set -0 ipset -L test > .foo +0 ipset -L test > "$IPSET_TMP/.foo" # Network: Check listing -0 ./diff.sh .foo hash:net,net.t.list4 +0 ./diff.sh "$IPSET_TMP/.foo" hash:net,net.t.list4 # Network: Flush test set 0 ipset -F test # Network: add element with 1s timeout
@@ -225,15 +225,15 @@ # Network: Delete the same network 0 ipset -D test 200.100.0.12,200.100.0.13 # Network: List set -0 ipset -L test > .foo0 && ./sort.sh .foo0 +0 ipset -L test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Network: Check listing -0 ./diff.sh .foo hash:net,net.t.list5 +0 ./diff.sh "$IPSET_TMP/.foo" hash:net,net.t.list5 # Sleep 5s so that elements can time out 0 sleep 5 # Network: List set -0 ipset -L test > .foo +0 ipset -L test > "$IPSET_TMP/.foo" # Network: Check listing -0 ./diff.sh .foo hash:net,net.t.list6 +0 ./diff.sh "$IPSET_TMP/.foo" hash:net,net.t.list6 # Network: Flush test set 0 ipset -F test # Network: add element with 1s timeout
@@ -267,9 +267,9 @@ # Network: Test delete value 0 ipset -D test 1.168.12.124,122.23.0.50 # Network: List set -0 ipset -L test > .foo +0 ipset -L test > "$IPSET_TMP/.foo" # Network: Check listing -0 ./diff.sh .foo hash:net,net.t.list7 +0 ./diff.sh "$IPSET_TMP/.foo" hash:net,net.t.list7 # Network: Delete test set 0 ipset -X test # eof
tests/hash:net,port,net.t +2 -2
@@ -27,9 +27,9 @@ # Try to add value after second random value 0 ipset add test 2.1.0.1,128,10.0.0.0/17 # List set -0 ipset list test > .foo0 && ./sort.sh .foo0 +0 ipset list test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Check listing -0 ./diff.sh .foo hash:net,port,net.t.list0 +0 ./diff.sh "$IPSET_TMP/.foo" hash:net,port,net.t.list0 # Sleep 5s so that elements can time out 0 sleep 5 # List set
tests/hash:net,port.t +4 -4
@@ -41,15 +41,15 @@ # Test ICMP by name 0 ipset test test 2.0.0.255,icmp:host-prohibited # List set -0 ipset list test > .foo0 && ./sort.sh .foo0 +0 ipset list test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Check listing -0 ./diff.sh .foo hash:net,port.t.list0 +0 ./diff.sh "$IPSET_TMP/.foo" hash:net,port.t.list0 # Sleep 5s so that element can time out 0 sleep 5 # IP: List set -0 ipset -L test > .foo0 && ./sort.sh .foo0 +0 ipset -L test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # IP: Check listing -0 ./diff.sh .foo hash:net,port.t.list1 +0 ./diff.sh "$IPSET_TMP/.foo" hash:net,port.t.list1 # Flush test set 0 ipset flush test # Add multiple elements in one step
tests/hash:net.t +8 -8
@@ -33,15 +33,15 @@ # Try to add IP address 0 ipset add test 2.0.0.1 # List set -0 ipset list test > .foo0 && ./sort.sh .foo0 +0 ipset list test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Check listing -0 ./diff.sh .foo hash:net.t.list0 +0 ./diff.sh "$IPSET_TMP/.foo" hash:net.t.list0 # Sleep 5s so that element can time out 0 sleep 5 # List set -0 ipset -L test > .foo0 && ./sort.sh .foo0 +0 ipset -L test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Check listing -0 ./diff.sh .foo hash:net.t.list1 +0 ./diff.sh "$IPSET_TMP/.foo" hash:net.t.list1 # Flush test set 0 ipset flush test # Delete test set
@@ -51,9 +51,9 @@ # Add networks in range notation 0 ipset add test 10.2.0.0-10.2.1.12 # List set -0 ipset -L test > .foo0 && ./sort.sh .foo0 +0 ipset -L test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Check listing -0 ./diff.sh .foo hash:net.t.list2 +0 ./diff.sh "$IPSET_TMP/.foo" hash:net.t.list2 # Delete test set 0 ipset destroy test # Stress test with range notation
@@ -127,9 +127,9 @@ # Add more than 2^31 elements in a range 0 ipset a test 0.0.0.0-128.0.0.1 # List set -0 ipset -L test > .foo0 && ./sort.sh .foo0 +0 ipset -L test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Check listing -0 ./diff.sh .foo hash:net.t.list3 +0 ./diff.sh "$IPSET_TMP/.foo" hash:net.t.list3 # Delete test set 0 ipset destroy test # Counters: create set
tests/hash:net6,net6.t +4 -4
@@ -33,15 +33,15 @@ # Try to add IP address 0 ipset add test 3:0:0::1,8:0:0::1 # List set -0 ipset list test > .foo0 && ./sort.sh .foo0 +0 ipset list test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Check listing -0 ./diff.sh .foo hash:net6,net6.t.list0 +0 ./diff.sh "$IPSET_TMP/.foo" hash:net6,net6.t.list0 # Sleep 5s so that element can time out 0 sleep 5 # IP: List set -0 ipset -L test > .foo0 && ./sort.sh .foo0 +0 ipset -L test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # IP: Check listing -0 ./diff.sh .foo hash:net6,net6.t.list1 +0 ./diff.sh "$IPSET_TMP/.foo" hash:net6,net6.t.list1 # Flush test set 0 ipset flush test # Add matching IP address entry
tests/hash:net6,port,net6.t +2 -2
@@ -41,9 +41,9 @@ # Range: Try to add value after second random value 0 ipset -A test 2:1:0::1,128,2:2:2::2/12 # Range: List set -0 ipset -L test > .foo0 && ./sort.sh .foo0 +0 ipset -L test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Range: Check listing -0 ./diff.sh .foo hash:net6,port,net6.t.list0 +0 ./diff.sh "$IPSET_TMP/.foo" hash:net6,port,net6.t.list0 # Range: Flush test set 0 ipset -F test # Range: Delete test set
tests/hash:net6,port.t +8 -8
@@ -41,25 +41,25 @@ # Test ICMPv6 by name 0 ipset test test 192:168:68::95,icmpv6:port-unreachable # List set -0 ipset list test > .foo0 && ./sort.sh .foo0 +0 ipset list test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Save set -0 ipset save test > hash:net6,port.t.restore +0 ipset save test > "$IPSET_TMP/hash:net6,port.t.restore" # Check listing -0 ./diff.sh .foo hash:net6,port.t.list0 +0 ./diff.sh "$IPSET_TMP/.foo" hash:net6,port.t.list0 # Sleep 5s so that element can time out 0 sleep 5 # IP: List set -0 ipset -L test > .foo0 && ./sort.sh .foo0 +0 ipset -L test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # IP: Check listing -0 ./diff.sh .foo hash:net6,port.t.list1 +0 ./diff.sh "$IPSET_TMP/.foo" hash:net6,port.t.list1 # Destroy set 0 ipset x test # Restore set -0 ipset restore < hash:net6,port.t.restore && rm hash:net6,port.t.restore +0 ipset restore < "$IPSET_TMP/hash:net6,port.t.restore" && rm "$IPSET_TMP/hash:net6,port.t.restore" # List set -0 ipset list test > .foo0 && ./sort.sh .foo0 +0 ipset list test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Check listing -0 ./diff.sh .foo hash:net6,port.t.list0 +0 ./diff.sh "$IPSET_TMP/.foo" hash:net6,port.t.list0 # Flush test set 0 ipset flush test # Add multiple elements in one step
tests/hash:net6.t +4 -4
@@ -33,15 +33,15 @@ # Try to add IP address 0 ipset add test 3:0:0::1 # List set -0 ipset list test > .foo0 && ./sort.sh .foo0 +0 ipset list test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Check listing -0 ./diff.sh .foo hash:net6.t.list0 +0 ./diff.sh "$IPSET_TMP/.foo" hash:net6.t.list0 # Sleep 5s so that element can time out 0 sleep 5 # IP: List set -0 ipset -L test > .foo0 && ./sort.sh .foo0 +0 ipset -L test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # IP: Check listing -0 ./diff.sh .foo hash:net6.t.list1 +0 ./diff.sh "$IPSET_TMP/.foo" hash:net6.t.list1 # Flush test set 0 ipset flush test # Delete test set
tests/ignore.sh +1 -1
@@ -1,4 +1,4 @@ #!/bin/sh -grep -v Revision: $1 | sed 's/initval 0x[0-9a-fA-F]\{8\}/initval 0x00000000/' > .foo +grep -v Revision: $1 | sed 's/initval 0x[0-9a-fA-F]\{8\}/initval 0x00000000/' > "$IPSET_TMP/.foo" rm $1
tests/iphash.t +10 -10
@@ -23,9 +23,9 @@ # IP: Delete element not added to the set, ignoring error 0 ipset -! -D test 200.100.0.12 # IP: List set -0 ipset -L test > .foo0 && ./sort.sh .foo0 +0 ipset -L test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # IP: Check listing -0 ./diff.sh .foo iphash.t.list0 +0 ./diff.sh "$IPSET_TMP/.foo" iphash.t.list0 # IP: Flush test set 0 ipset -F test # IP: Delete test set
@@ -33,13 +33,13 @@ # IP: Restore values so that rehashing is triggered, old format 0 ipset -R < iphash.t.restore.old # IP: Check that all values are restored -0 (grep add iphash.t.restore | sort > .foo.1) && (ipset -S test | grep add | sort > .foo.2) && cmp .foo.1 .foo.2 +0 (grep add iphash.t.restore | sort > "$IPSET_TMP/.foo.1") && (ipset -S test | grep add | sort > "$IPSET_TMP/.foo.2") && cmp "$IPSET_TMP/"{.foo.1,.foo.2} # IP: Delete test set 0 ipset -X test # IP: Restore values so that rehashing is triggered 0 ipset -R < iphash.t.restore # IP: Check that all values are restored -0 (grep add iphash.t.restore | sort > .foo.1) && (ipset -S test | grep add | sort > .foo.2) && cmp .foo.1 .foo.2 +0 (grep add iphash.t.restore | sort > "$IPSET_TMP/.foo.1") && (ipset -S test | grep add | sort > "$IPSET_TMP/.foo.2") && cmp "$IPSET_TMP/"{.foo.1,.foo.2} # IP: Flush test set 0 ipset -F test # IP: Delete test set
@@ -53,9 +53,9 @@ # IP: Add more entries to the second set 0 tail -n +2 iphash.t.restore | sed -e 's/test/test2/' -e 's/ 10/ 30/' | ipset r # IP: Save sets -0 ipset -s -f .foo0 save && ./ignore.sh .foo0 +0 ipset -s -f "$IPSET_TMP/.foo0" save && ./ignore.sh "$IPSET_TMP/.foo0" # IP: Compare sorted save and restore -0 cmp .foo iphash.t.restore.sorted +0 cmp "$IPSET_TMP/.foo" iphash.t.restore.sorted # IP: Delete test set 0 ipset x test # IP: Delete test2 set
@@ -63,9 +63,9 @@ # IP: Restore, which requires multiple messages 0 ipset restore < iphash.t.large # IP: Save the restored set -0 (ipset save test | sort > .foo.1) && ./ignore.sh .foo.1 +0 (ipset save test | sort > "$IPSET_TMP/.foo.1") && ./ignore.sh "$IPSET_TMP/.foo.1" # IP: Compare save and restore -0 (sort iphash.t.large > .foo.2) && (cmp .foo .foo.2) +0 (sort iphash.t.large > "$IPSET_TMP/.foo.2") && (cmp "$IPSET_TMP/.foo" "$IPSET_TMP/.foo.2") # IP: Delete all elements, one by one 0 ipset list test | sed '1,/Members/d' | xargs -n1 ipset del test # IP: Delete test set
@@ -95,9 +95,9 @@ # Network: Delete element not added to the set 1 ipset -D test 200.100.0.12 # Network: List set -0 ipset -L test > .foo0 && ./sort.sh .foo0 +0 ipset -L test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Network: Check listing -0 ./diff.sh .foo iphash.t.list1 +0 ./diff.sh "$IPSET_TMP/.foo" iphash.t.list1 # Network: Flush test set 0 ipset -F test # Network: Delete test set
tests/ipmap.t +14 -14
@@ -37,27 +37,27 @@ # Range: Add a range of elements 0 ipset -A test 2.0.0.128-2.0.0.131 # Range: Save set -0 ipset -S test > ipmap.t.restore +0 ipset -S test > "$IPSET_TMP/ipmap.t.restore" # Range: Destroy set 0 ipset -X test # Range: Restore set and catch error -1 sed 's/2.0.0.131/222.0.0.131/' < ipmap.t.restore | ipset -R +1 sed 's/2.0.0.131/222.0.0.131/' < "$IPSET_TMP/ipmap.t.restore" | ipset -R # Range: Check returned error line number -0 num=`grep 'in line' < .foo.err | sed 's/.* in line //' | cut -d : -f 1` && test $num -eq 6 +0 num=`grep 'in line' < "$IPSET_TMP/.foo.err" | sed 's/.* in line //' | cut -d : -f 1` && test $num -eq 6 # Range: Destroy set 0 ipset -X test # Range: Restore set -0 ipset -R < ipmap.t.restore && rm ipmap.t.restore +0 ipset -R < "$IPSET_TMP/ipmap.t.restore" && rm "$IPSET_TMP/ipmap.t.restore" # Range: List set -0 ipset -L test > .foo +0 ipset -L test > "$IPSET_TMP/.foo" # Range: Check listing -0 ./diff.sh .foo ipmap.t.list0 +0 ./diff.sh "$IPSET_TMP/.foo" ipmap.t.list0 # Range: Delete a range of elements 0 ipset -! -D test 2.0.0.128-2.0.0.132 # Range: List set -0 ipset -L test > .foo +0 ipset -L test > "$IPSET_TMP/.foo" # Range: Check listing -0 ./diff.sh .foo ipmap.t.list1 +0 ./diff.sh "$IPSET_TMP/.foo" ipmap.t.list1 # Range: Flush test set 0 ipset -F test # Range: Delete test set
@@ -91,9 +91,9 @@ # Network: Delete the same element 0 ipset -D test 2.0.0.128 # Network: List set -0 ipset -L test > .foo +0 ipset -L test > "$IPSET_TMP/.foo" # Network: Check listing -0 ./diff.sh .foo ipmap.t.list2 +0 ./diff.sh "$IPSET_TMP/.foo" ipmap.t.list2 # Network: Flush test set 0 ipset -F test # Network: Delete test set
@@ -127,9 +127,9 @@ # Subnets: Add a subnet of subnets 0 ipset -A test 10.8.0.0/16 # Subnets: List set -0 ipset -L test > .foo +0 ipset -L test > "$IPSET_TMP/.foo" # Subnets: Check listing -0 ./diff.sh .foo ipmap.t.list3 +0 ./diff.sh "$IPSET_TMP/.foo" ipmap.t.list3 # Subnets: FLush test set 0 ipset -F test # Subnets: Delete test set
@@ -153,9 +153,9 @@ # Full: Delete same element 0 ipset -D test 0.1.0.0 # Full: List set -0 ipset -L test > .foo +0 ipset -L test > "$IPSET_TMP/.foo" # Full: Check listing -0 ./diff.sh .foo ipmap.t.list4 +0 ./diff.sh "$IPSET_TMP/.foo" ipmap.t.list4 # Full: Delete test set 0 ipset -X test # eof
tests/ipmarkhash.t +4 -4
@@ -31,9 +31,9 @@ # Try to add value after second random value 0 ipset -A test 2.1.0.1,0x80 # List set -0 ipset -L test > .foo0 && ./sort.sh .foo0 +0 ipset -L test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Check listing -0 ./diff.sh .foo ipmarkhash.t.list0 +0 ./diff.sh "$IPSET_TMP/.foo" ipmarkhash.t.list0 # Flush test set 0 ipset -F test # Delete test set
@@ -61,9 +61,9 @@ # Try to add value after second random value 0 ipset -A test 2.1.0.0,0x80 # List set -0 ipset -L test > .foo0 && ./sort.sh .foo0 +0 ipset -L test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Check listing -0 ./diff.sh .foo ipmarkhash.t.list1 +0 ./diff.sh "$IPSET_TMP/.foo" ipmarkhash.t.list1 # Flush test set 0 ipset -F test # Delete test set
tests/ipporthash.t +4 -4
@@ -31,9 +31,9 @@ # Try to add value after second random value 0 ipset -A test 2.1.0.1,128 # List set -0 ipset -L test > .foo0 && ./sort.sh .foo0 +0 ipset -L test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Check listing -0 ./diff.sh .foo ipporthash.t.list0 +0 ./diff.sh "$IPSET_TMP/.foo" ipporthash.t.list0 # Flush test set 0 ipset -F test # Delete test set
@@ -61,9 +61,9 @@ # Try to add value after second random value 0 ipset -A test 2.1.0.0,128 # List set -0 ipset -L test > .foo0 && ./sort.sh .foo0 +0 ipset -L test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Check listing -0 ./diff.sh .foo ipporthash.t.list1 +0 ./diff.sh "$IPSET_TMP/.foo" ipporthash.t.list1 # Flush test set 0 ipset -F test # Delete test set
tests/ipportiphash.t +4 -4
@@ -39,9 +39,9 @@ # Try to add value after second random value 0 ipset -A test 2.1.0.1,128,2.2.2.2 # List set -0 ipset -L test > .foo0 && ./sort.sh .foo0 +0 ipset -L test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Check listing -0 ./diff.sh .foo ipportiphash.t.list0 +0 ./diff.sh "$IPSET_TMP/.foo" ipportiphash.t.list0 # Flush test set 0 ipset -F test # Delete test set
@@ -71,9 +71,9 @@ # Try to del value before first random value 0 ipset -D test 1.255.255.255,5,1.1.1.1 # List set -0 ipset -L test > .foo0 && ./sort.sh .foo0 +0 ipset -L test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Check listing -0 ./diff.sh .foo ipportiphash.t.list1 +0 ./diff.sh "$IPSET_TMP/.foo" ipportiphash.t.list1 # Flush test set 0 ipset -F test # Delete test set
tests/ipportnethash.t +4 -4
@@ -35,9 +35,9 @@ # Range: Try to add value after second random value 0 ipset -A test 2.1.0.1,128,2.2.2.2/12 # Range: List set -0 ipset -L test | grep -v Revision: > .foo0 && ./sort.sh .foo0 +0 ipset -L test | grep -v Revision: > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Range: Check listing -0 diff -u -I 'Size in memory.*' .foo ipportnethash.t.list0 +0 diff -u -I 'Size in memory.*' "$IPSET_TMP/.foo" ipportnethash.t.list0 # Range: Flush test set 0 ipset -F test # Range: Delete test set
@@ -65,9 +65,9 @@ # Network: Try to add value after second random value 0 ipset -A test 2.1.0.0,128,2.2.2.2/12 # Network: List set -0 ipset -L test | grep -v Revision: > .foo0 && ./sort.sh .foo0 +0 ipset -L test | grep -v Revision: > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Network: Check listing -0 diff -u -I 'Size in memory.*' .foo ipportnethash.t.list1 +0 diff -u -I 'Size in memory.*' "$IPSET_TMP/.foo" ipportnethash.t.list1 # Network: Flush test set 0 ipset -F test # Add a non-matching IP address entry
tests/iptables.sh +4 -4
@@ -58,8 +58,8 @@ start) -j LOG --log-prefix "in set ipport: " $cmd -A INPUT -m set --match-set list src,src \ -j LOG --log-prefix "in set list: " - $cmd -A OUTPUT -d $NET -j DROP - cat /dev/null > .foo.err +# $cmd -A OUTPUT -d $NET -j DROP + cat /dev/null > "$IPSET_TMP/.foo.err" cat /dev/null > /var/log/kern.log ;; start_flags)
@@ -73,7 +73,7 @@ start_flags) $cmd -A INPUT -m set --match-set test src --return-nomatch \ -j LOG --log-prefix "in set test-nomatch: " $cmd -A INPUT -s 10.0.0.0/16 -j DROP - cat /dev/null > .foo.err + cat /dev/null > "$IPSET_TMP/.foo.err" cat /dev/null > /var/log/kern.log ;; start_flags_reversed)
@@ -87,7 +87,7 @@ start_flags_reversed) $cmd -A INPUT -m set --match-set test src \ -j LOG --log-prefix "in set test: " $cmd -A INPUT -s 10.0.0.0/16 -j DROP - cat /dev/null > .foo.err + cat /dev/null > "$IPSET_TMP/.foo.err" cat /dev/null > /var/log/kern.log ;; del)
tests/iptree.t +2 -2
@@ -13,9 +13,9 @@ # Static: Test value not added to the set 1 ipset -T test 192.168.68.70 # Static: List set -0 ipset -L test | grep -v Revision: > .foo0 && ./sort.sh .foo0 +0 ipset -L test | grep -v Revision: > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Static: Check listing -0 diff -u -I 'Size in memory.*' .foo iptree.t.list0 +0 diff -u -I 'Size in memory.*' "$IPSET_TMP/.foo" iptree.t.list0 # Static: Flush test set 0 ipset -F test # Static: Delete test set
tests/iptreemap.t +2 -2
@@ -49,9 +49,9 @@ # Test element after upper bound of deleted network 0 ipset -T test 192.168.68.72 # List set -0 ipset -L test | grep -v Revision: > .foo0 && ./sort.sh .foo0 +0 ipset -L test | grep -v Revision: > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Check listing -0 diff -u -I 'Size in memory.*' .foo iptreemap.t.list0 +0 diff -u -I 'Size in memory.*' "$IPSET_TMP/.foo" iptreemap.t.list0 # Flush test set 0 ipset -F test # Delete test set
tests/macipmap.t +8 -8
@@ -39,9 +39,9 @@ # Range: Delete the same element 0 ipset -D test 2.0.200.214 # Range: List set -0 ipset -L test > .foo +0 ipset -L test > "$IPSET_TMP/.foo" # Range: Check listing -0 ./diff.sh .foo macipmap.t.list0 +0 ./diff.sh "$IPSET_TMP/.foo" macipmap.t.list0 # Range: Flush test set 0 ipset -F test # Range: Catch invalid (too long) MAC
@@ -87,9 +87,9 @@ # Network: Add MAC to already added element 0 ipset -A test 2.0.255.255,00:11:22:33:44:56 # Network: List set -0 ipset -L test > .foo +0 ipset -L test > "$IPSET_TMP/.foo" # Network: Check listing -0 ./diff.sh .foo macipmap.t.list1 +0 ./diff.sh "$IPSET_TMP/.foo" macipmap.t.list1 # Network: Flush test set 0 ipset -F test # Network: Delete test set
@@ -127,15 +127,15 @@ # Range: Delete the same element 0 ipset -D test 2.0.200.214 # Range: List set -0 ipset -L test > .foo +0 ipset -L test > "$IPSET_TMP/.foo" # Range: Check listing -0 ./diff.sh .foo macipmap.t.list3 +0 ./diff.sh "$IPSET_TMP/.foo" macipmap.t.list3 # Range: sleep 5s so that elements can timeout 0 sleep 5 # Range: List set -0 ipset -L test > .foo +0 ipset -L test > "$IPSET_TMP/.foo" # Range: Check listing -0 ./diff.sh .foo macipmap.t.list2 +0 ./diff.sh "$IPSET_TMP/.foo" macipmap.t.list2 # Range: Flush test set 0 ipset -F test # Range: add element with 1s timeout
tests/match_target.t +1 -1
@@ -107,7 +107,7 @@ # Create set and rules for 0.0.0.0/0 check in hash:net,iface 0 ./iptables.sh inet netiface # Send probe packet -0 ./sendip.sh -p ipv4 -id 10.255.255.254 -is 10.255.255.64 -p udp -ud 80 -us 1025 10.255.255.254 >/dev/null 2>&1 +0 ./sendip.sh -p ipv4 -id 10.255.255.254 -is 10.255.255.64 -p udp -ud 80 -us 1025 10.255.255.254 # Check kernel log that the packet matched the set 0 ./check_klog.sh 10.255.255.64 udp 1025 netiface # Destroy sets and rules
tests/nethash.t +2 -2
@@ -33,9 +33,9 @@ # Try to add IP address 0 ipset -A test 2.0.0.1 # List set -0 ipset -L test > .foo0 && ./sort.sh .foo0 +0 ipset -L test > "$IPSET_TMP/.foo0" && ./sort.sh "$IPSET_TMP/.foo0" # Check listing -0 ./diff.sh .foo nethash.t.list0 +0 ./diff.sh "$IPSET_TMP/.foo" nethash.t.list0 # Flush test set 0 ipset -F test # Add a non-matching IP address entry
tests/portmap.t +8 -8
@@ -25,9 +25,9 @@ # Range: Delete the same element 0 ipset -D test 567 # Range: List set -0 ipset -L test > .foo +0 ipset -L test > "$IPSET_TMP/.foo" # Range: Check listing -0 ./diff.sh .foo portmap.t.list0 +0 ./diff.sh "$IPSET_TMP/.foo" portmap.t.list0 # Range: Flush test set 0 ipset -F test # Range: Delete test set
@@ -45,9 +45,9 @@ # Full: Test value not added to the set 1 ipset -T test 1 # Full: List set -0 ipset -L test > .foo +0 ipset -L test > "$IPSET_TMP/.foo" # Full: Check listing -0 ./diff.sh .foo portmap.t.list1 +0 ./diff.sh "$IPSET_TMP/.foo" portmap.t.list1 # Full: Flush test set 0 ipset -F test # Full: Delete test set
@@ -69,15 +69,15 @@ # Full: Delete the same element 0 ipset -D test 567 # Full: List set -0 ipset -L test > .foo +0 ipset -L test > "$IPSET_TMP/.foo" # Full: Check listing -0 ./diff.sh .foo portmap.t.list3 +0 ./diff.sh "$IPSET_TMP/.foo" portmap.t.list3 # Full: sleep 5s so that elements can timeout 0 sleep 5 # Full: List set -0 ipset -L test > .foo +0 ipset -L test > "$IPSET_TMP/.foo" # Full: Check listing -# 0 ./diff.sh .foo portmap.t.list2 +# 0 ./diff.sh "$IPSET_TMP/.foo" portmap.t.list2 # Full: Flush test set 0 ipset -F test # Full: add element with 1s timeout
tests/restore.t +1 -1
@@ -1,7 +1,7 @@ # Check multi-set restore 0 ipset restore < restore.t.multi # Save sets and compare -0 ipset save > .foo && diff restore.t.multi.saved .foo +0 ipset save > "$IPSET_TMP/.foo" && diff restore.t.multi.saved "$IPSET_TMP/.foo" # Delete all sets 0 ipset x # Check auto-increasing maximal number of sets
tests/runtest.sh +11 -3
@@ -3,6 +3,7 @@ # set -x ipset=${IPSET_BIN:-../src/ipset} +tmpdir="" tests="init" tests="$tests ipmap bitmap:ip"
@@ -17,10 +18,18 @@ tests="$tests hash:net,port,net hash:net6,port,net6" tests="$tests hash:net,iface.t hash:mac.t" tests="$tests comment setlist restore" # tests="$tests iptree iptreemap" +cleanup() { + rm -f "$tmpdir"/.foo* + rm -f "$tmpdir/.loglines" + rmdir "$tmpdir" +} +trap cleanup EXIT +tmpdir=$(mktemp -t -d ipset-XXXXXXXX) # For correct sorting: LC_ALL=C export LC_ALL +export IPSET_TMP="$tmpdir" add_tests() { # inet|inet6 network
@@ -105,7 +114,7 @@ for types in $tests; do ;; esac echo -ne "$types: $what: " - cmd=`echo $cmd | sed "s|ipset|$ipset 2>.foo.err|"` + cmd=`echo $cmd | sed "s|ipset|$ipset 2>"$tmpdir"/.foo.err|"` # For the case: ipset list | ... | xargs -n1 ipset cmd=`echo $cmd | sed "s|ipset|$ipset|2g"` eval $cmd
@@ -116,7 +125,7 @@ for types in $tests; do else echo "FAILED" echo "Failed test: $cmd" - cat .foo.err + cat "$tmpdir"/.foo.err let "failcount++" break fi
@@ -137,7 +146,6 @@ for x in $tests; do esac done rmmod ip_set >/dev/null 2>&1 -rm -f .foo* if [ "$failcount" -eq 0 ]; then echo "All tests are passed" else
tests/sendip.sh +1 -1
@@ -1,6 +1,6 @@ #!/bin/bash # Save lineno for checking -wc -l /var/log/kern.log | cut -d ' ' -f 1 > .loglines +wc -l /var/log/kern.log | cut -d ' ' -f 1 > "$IPSET_TMP/.loglines" sendip "$@"
tests/setlist.t +13 -13
@@ -29,7 +29,7 @@ # Test foo,after,bar 1 ipset -T test foo,after,bar # Save sets -0 ipset -S > setlist.t.r +0 ipset -S > "$IPSET_TMP/setlist.t.r" # Delete bar,before,foo 1 ipset -D test bar,before,foo # Delete foo,after,bar
@@ -43,15 +43,15 @@ # Delete all sets 0 ipset -X # Restore saved sets -0 ipset -R < setlist.t.r +0 ipset -R < "$IPSET_TMP/setlist.t.r" # List set -0 ipset -L test > .foo +0 ipset -L test > "$IPSET_TMP/.foo" # Check listing -0 ./diff.sh .foo setlist.t.list0 +0 ./diff.sh "$IPSET_TMP/.foo" setlist.t.list0 # Flush all sets 0 ipset -F # Delete all sets -0 ipset -X && rm setlist.t.r +0 ipset -X && rm "$IPSET_TMP/setlist.t.r" # Create sets a, b, c to check before/after in all combinations 0 ipset restore < setlist.t.before # Add set b to test set
@@ -61,9 +61,9 @@ # Add set a before b 0 ipset add test a before b # List test set -0 ipset list test > .foo +0 ipset list test > "$IPSET_TMP/.foo" # Check listing -0 ./diff.sh .foo setlist.t.list1 +0 ./diff.sh "$IPSET_TMP/.foo" setlist.t.list1 # Test a set before b 0 ipset test test a before b # Test c set after b
@@ -71,19 +71,19 @@ # Delete b set before c 0 ipset del test b before c # List test set -0 ipset list test > .foo +0 ipset list test > "$IPSET_TMP/.foo" # Check listing -0 ./diff.sh .foo setlist.t.list2 +0 ./diff.sh "$IPSET_TMP/.foo" setlist.t.list2 # Delete c set after a 0 ipset del test c after a # List test set -0 ipset list test > .foo +0 ipset list test > "$IPSET_TMP/.foo" # Check listing -0 ./diff.sh .foo setlist.t.list3 +0 ./diff.sh "$IPSET_TMP/.foo" setlist.t.list3 # List all sets -0 sleep .1s; ipset list > .foo +0 sleep .1s; ipset list > "$IPSET_TMP/.foo" # Check listing -0 ./diff.sh .foo setlist.t.list4 +0 ./diff.sh "$IPSET_TMP/.foo" setlist.t.list4 # Flush sets 0 ipset flush # Destroy sets
tests/sort.sh +3 -3
@@ -1,5 +1,5 @@ #!/bin/sh -sed '/Members:/q' $1 > .foo -awk '/Members:/,EOF' $1 | grep -v 'Members:' | sort >> .foo -rm -f $1 +sed '/Members:/q' "$1" > "$IPSET_TMP/.foo" +awk '/Members:/,EOF' "$1" | grep -v 'Members:' | sort >> "$IPSET_TMP/.foo" +rm -f "$1"
Signature · 1 line
2.54.0
Florian Westphal
maintainerPATCH 2/7 tests: runtest.sh: run inside namespace
In reply to Florian Westphalre-exec the script in case IPSET_UNSHARED environment variable isn't set yet.
Add a dummy device named 'eth0' as thats what tests expect to be present.
--- tests/runtest.sh | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-)
tests/runtest.sh +20 -1
@@ -18,13 +18,32 @@ tests="$tests hash:net,port,net hash:net6,port,net6" tests="$tests hash:net,iface.t hash:mac.t" tests="$tests comment setlist restore" # tests="$tests iptree iptreemap" + +if [ "$IPSET_UNSHARED" = "" ]; then + # Re-execute in new network namespace + export IPSET_UNSHARED="yes" + sysctl net.netfilter.nf_log_all_netns=1 + exec unshare -n -- "$0" "$@" +fi + +sysctl net.ipv4.conf.all.rp_filter=0 + cleanup() { rm -f "$tmpdir"/.foo* rm -f "$tmpdir/.loglines" rmdir "$tmpdir" + ip link del eth0 } trap cleanup EXIT -tmpdir=$(mktemp -t -d ipset-XXXXXXXX) +tmpdir=$(mktemp -t -d ip-set-XXXXXXXX) + +ip link set lo up + +# test cases send and expect packets on eth0. +ip link add dev eth0 type dummy +ip link set eth0 up +ip addr add 10.255.255.64/8 dev eth0 +sysctl net.ipv4.conf.eth0.rp_filter=0 # For correct sorting: LC_ALL=C
Signature · 1 line
2.54.0
Florian Westphal
maintainerPATCH 3/7 tests: diff.sh: preserve file name
In reply to Florian WestphalAs-is, in case of error, its not easy to see which diff file has failed, because diff gets fed via <(sed...), so diff shows something like
--- /dev/fd/63
+++ /dev/ ..
Take advantage of the temporary directory and output a file that has keeps part of the original name.
--- tests/diff.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
tests/diff.sh +10 -3
@@ -1,7 +1,14 @@ #!/bin/bash -diff -u -I 'Revision: .*' -I 'Size in memory.*' \ - <(sed -e 's/timeout [0-9]*/timeout x/' -e 's/initval 0x[0-9a-fA-F]\{8\}/initval 0x00000000/' $1) \ - <(sed -e 's/timeout [0-9]*/timeout x/' -e 's/initval 0x[0-9a-fA-F]\{8\}/initval 0x00000000/' $2) +NEW_DUMP="$IPSET_TMP/kernel-dump.sed" +STORED_DUMP="$IPSET_TMP/$2.sed" +sed -e 's/timeout [0-9]*/timeout x/' -e 's/initval 0x[0-9a-fA-F]\{8\}/initval 0x00000000/' "$1" > "$NEW_DUMP" +sed -e 's/timeout [0-9]*/timeout x/' -e 's/initval 0x[0-9a-fA-F]\{8\}/initval 0x00000000/' "$2" > "$STORED_DUMP" +diff -u -I 'Revision: .*' -I 'Size in memory.*' "$STORED_DUMP" "$NEW_DUMP" +ret=$? + +rm -f "$STORED_DUMP" "$NEW_DUMP" + +exit $ret
Signature · 1 line
2.54.0
Florian Westphal
maintainerPATCH 4/7 tests: check_klog.sh: unclutter stderr
In reply to Florian WestphalMy test vm doesn't have a kern.log file, but the existing script will fall back to dmesg which is good enough for me.
Suppress the 'no such file' error from tail and go straight to the dmesg fallback.
--- tests/check_klog.sh | 7 ++++++- tests/sendip.sh | 3 +-- 2 files changed, 7 insertions(+), 3 deletions(-)
tests/check_klog.sh +6 -1
@@ -44,7 +44,12 @@ port=$1; shift set +e for setname in $@; do - match=`tail -n +$loglines /var/log/kern.log | grep -e "in set $setname: .* SRC=$ipaddr .* PROTO=$proto SPT=$port .*"` + if [ -r /var/log/kern.log ]; then + match=`tail -n +$loglines /var/log/kern.log | grep -e "in set $setname: .* SRC=$ipaddr .* PROTO=$proto SPT=$port .*"` + else + match="" + fi + if [ -z "$match" ]; then match=`dmesg | tail -n +$loglines | grep -e "in set $setname: .* SRC=$ipaddr .* PROTO=$proto SPT=$port .*"` fi
tests/sendip.sh +1 -2
@@ -1,6 +1,5 @@ #!/bin/bash # Save lineno for checking -wc -l /var/log/kern.log | cut -d ' ' -f 1 > "$IPSET_TMP/.loglines" +wc -l /var/log/kern.log 2>/dev/null | cut -d ' ' -f 1 > "$IPSET_TMP/.loglines" sendip "$@" -
Signature · 1 line
2.54.0
Florian Westphal
maintainerPATCH 5/7 tests: setlist_ns.sh: use local ipset binary and don't rely on userns
In reply to Florian WestphalThe script runs command in network+user namespace with remapped uid0.
In case this fails (e.g. because user namespaces are disabled), we should re-try with plain "-n" before giving up and returning an error.
Also, in case 'ipset' isn't in $PATH, this fails.
Let runtest.sh export the ipset binary to use and refer to that.
While at it, parallelize the test and also run it 124 times, not just 4 times - missing $() resulted in 'for x in a b c d ..'.
x
--- tests/runtest.sh | 1 + tests/setlist_ns.sh | 29 +++++++++++++++++++++++++---- 2 files changed, 26 insertions(+), 4 deletions(-)
tests/runtest.sh +1 -0
@@ -22,6 +22,7 @@ tests="$tests comment setlist restore" if [ "$IPSET_UNSHARED" = "" ]; then # Re-execute in new network namespace export IPSET_UNSHARED="yes" + export IPSET_BIN="$ipset" sysctl net.netfilter.nf_log_all_netns=1 exec unshare -n -- "$0" "$@" fi
tests/setlist_ns.sh +25 -4
@@ -2,21 +2,42 @@ set -e +[ -z "$IPSET_BIN" ] && IPSET_BIN=ipset + CMD=$(cat <<EOF for x in \$(seq 0 127); do echo "create h\$x hash:ip" echo "create l\$x list:set timeout 10 comment" -done | ipset restore +done | $IPSET_BIN restore for x in \$(seq 0 127); do for y in \$(seq 0 127); do echo "add l\$x h\$y timeout 1000 comment \"l\$x h\$y\"" done -done | ipset restore +done | $IPSET_BIN restore # Wait for GC sleep 15 EOF ) -for x in seq 0 123; do - unshare -Urn bash -c "$CMD" +# First try with user namespaces and remapped-root. +options="-Urn" +if ! unshare "$options" bash -c "$CMD"; then + # Doesn't work - try with plain network namespaces. + if unshare -n bash -c "$CMD"; then + # "-Ur" unsupported + options="-n" + else + # Either network namespaces are not + # supported at all or $CMD is failing. + exit 1 + fi +fi + +parallel=16 +for x in $(seq 1 123); do + unshare "$options" bash -c "$CMD" & + + [ $((x % $parallel)) -eq 0 ] && wait done + +wait
Signature · 1 line
2.54.0
Florian Westphal
maintainerPATCH 6/7 tests: make setlist_resize.sh more verbose on error
In reply to Florian WestphalInstead of just existing, tell where we failed. Use -x and take advantage of $IPSET_TMP to capture the full output.
On success, remove the file.
cleanup handler will dump the content in case we failed somewhere.
--- tests/setlist_resize.sh | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-)
tests/setlist_resize.sh +28 -6
@@ -1,22 +1,41 @@ #!/bin/sh set -e -# set -x -# exec > setlist.res -# exec 2>&1 + +cleanup() { + exec 1>&3 + exec 2>&4 + if [ -r "$IPSET_TMP/setlist.res" ]; then + cat "$IPSET_TMP/setlist.res" + rm -f "$IPSET_TMP/setlist.res" + fi +} +trap cleanup EXIT + +exec 3>&1 +exec 4>&2 +exec > "$IPSET_TMP/setlist.res" 2>&1 + +set -x ipset=${IPSET_BIN:-../src/ipset} loop=8 +fail() { + echo "FAILED: $0 $@" + exit 1 +} + n=0 while [ $n -le 9 ]; do egrep '^(ip_set_|xt_set)' /proc/modules | while read x y; do - rmmod $x >/dev/null 2>&1 + rmmod $x || : done if [ "`egrep '^(ip_set_|xt_set)' /proc/modules`" ]; then sleep 1s else + echo "Modules unloaded after $n attempts." n=10 fi done
@@ -35,7 +54,7 @@ for x in `seq 1 $loop`; do create 1 & create 2 & wait - test `$ipset l -n | wc -l` -eq 1024 || exit 1 + test `$ipset l -n | wc -l` -eq 1024 || fail "expected 1024 sets" $ipset x # Wait for destroy to be finished and reference counts releases n=0
@@ -53,7 +72,10 @@ for x in `seq 1 $loop`; do lsmod echo $ref fi - test "$ref" -eq 0 || exit 1 + test "$ref" -eq 0 || fail "ref was $ref" rmmod ip_set_hash_ip >/dev/null 2>&1 rmmod ip_set >/dev/null 2>&1 done + +rm -f "$IPSET_TMP/setlist.res" +cleanup
Signature · 1 line
2.54.0
Florian Westphal
maintainerPATCH 7/7 tests: runtest.sh: add sendip emulation via scapy
In reply to Florian Westphalsendip tool is ancient and not packaged on fedora (or i'm blind). Add a scapy-based replacement.
--- README | 13 ++-- tests/bitmap:ip.t | 2 +- tests/check_sendip_packets | 2 +- tests/hash:ip.t | 2 +- tests/runtest.sh | 18 ++++- tests/sendip.py | 154 +++++++++++++++++++++++++++++++++++++ tests/sendip.sh | 7 +- tests/setlist.t | 2 +- 8 files changed, 188 insertions(+), 12 deletions(-) create mode 100755 tests/sendip.py
README +7 -6
@@ -41,12 +41,13 @@ instructions too. After installing the modules, you can run the testsuite as well. Please note, several assumptions must be met for the testsuite: - - no sets defined - - iptables/ip6tables rules are not set up - - the destination for kernel logs is /var/log/kern.log - - the networks 10.255.255.0/24 and 1002:1002:1002:1002::/64 - are not in use - - sendip utility is installed + - the destination for kernel logs is /var/log/kern.log, OR, + if running from a network namespace, iptables -j LOG can + write to the kernel ring buffer (dmesg). + - by default tests run in a extra namespace to avoid + conflicts with the networks used by the tests: + 10.255.255.0/24 and 1002:1002:1002:1002::/64. + - sendip utility OR scapy is installed # make tests
tests/bitmap:ip.t +1 -1
@@ -209,7 +209,7 @@ # Counters and timeout: destroy set 0 ipset x test # Counters: require sendip -skip which sendip +require_sendip # Counters: create set 0 ipset n test bitmap:ip range 10.255.0.0/16 counters # Counters: add elemet with zero counters
tests/check_sendip_packets +1 -1
@@ -18,7 +18,7 @@ fi $cmd -A INPUT -m set --match-set test $2 -j DROP for x in `seq 1 $3`; do - sendip -p $proto -id $dst -is $src -p tcp -td 80 -ts 1025 $dst + ./sendip.sh -p $proto -id $dst -is $src -p tcp -td 80 -ts 1025 $dst done $cmd -D INPUT -m set --match-set test $2 -j DROP
tests/hash:ip.t +1 -1
@@ -195,7 +195,7 @@ # Counters and timeout: destroy set 0 ipset x test # Counters: require sendip -skip which sendip +require_sendip # Counters: create set 0 ipset n test hash:ip counters # Counters: add elemet with zero counters
tests/runtest.sh +17 -1
@@ -51,6 +51,14 @@ LC_ALL=C export LC_ALL export IPSET_TMP="$tmpdir" +HAVE_SENDIP=n +[ -z "`which sendip`" ] && HAVE_SENDIP=y +if [ $HAVE_SENDIP = "n" ]; then + if python -c 'from scapy.all import ( IPv6 )'; then + HAVE_SENDIP=y + fi +fi + add_tests() { # inet|inet6 network if [ $1 = "inet" ]; then
@@ -72,7 +80,7 @@ add_tests() { fi if [ `$cmd -t filter | wc -l` -eq 7 -a \ `$cmd -t filter | grep ACCEPT | wc -l` -eq 3 ]; then - if [ -z "`which sendip`" ]; then + if [ "$HAVE_SENDIP" = "n" ]; then echo "sendip utility is missig: skipping $1 match and target tests" return elif [ -n "`which ss`" ]; then
@@ -130,6 +138,14 @@ for types in $tests; do fi continue ;; + require_sendip) + if [ "$HAVE_SENDIP" = "y" ]; then + continue + else + echo "Skipping, sendip (scapy) not available" + break + fi + ;; *) ;; esac
tests/sendip.py new file +154 -0
154 lines not on this page · raw message
tests/sendip.sh +6 -1
@@ -2,4 +2,9 @@ # Save lineno for checking wc -l /var/log/kern.log 2>/dev/null | cut -d ' ' -f 1 > "$IPSET_TMP/.loglines" -sendip "$@" + +if [ -n "`which sendip 2>/dev/null`" ]; then + exec sendip "$@" +fi + +exec ./sendip.py "$@"
tests/setlist.t +1 -1
@@ -174,7 +174,7 @@ # Counters and timeout: destroy sets 0 ipset x # Counters: require sendip -skip which sendip >/dev/null +require_sendip # Counters: create set 0 ipset n a hash:ip counters # Counters: create list set
Signature · 1 line
2.54.0
Hi Pablo,
I have committed Florian's patches but it seems my old rsa key is still valid at git.netfilter.org. Could you replace it with my attached ed25519 key? Thank you!
Best regards,
Jozsef
Quoted 111 lines · Florian Westphal
Hi Jozsef,
This contains various enhancments for the ipsets
tests/runtest.sh.The largest enhancement is the removal of the sendip dependency, in the last patch -- this adds a sendip emulation via scapy. Note that 'sendip' will be used if present and the bundled scapy
sendip.pyotherwise.Main motivation was to make
runtest.shwork with my CI pipeline. This uses nipa (https://github.com/linux-netdev/nipa.git).
Test scripts spawn kernels via virtme-ng.1) resolve the above. Add a temporary directory, export
IPSET_TMPDIRto all scripts and use that in the tests to write files there instead of cwd.2) make test setup simpler: re-exec
runtest.shin a new namespace ifIPSET_UNSHAREDis unset (the default). A dummy eth0 device for tests is added in the new namespace. This makes ./runtest.sh self-contained, no extra work needed. Also avoids clashes with the test network addresses used by test scripts.3)
diff.sh: preserve file names in diff output: use the new temporary directory to store the postprocessed dump files before compare. This isn't needed but it helps to spot the cause of failures more easily, as the failing dump name is preserved in the diff output.4)
check_klog.sh: Enable direct fallback to dmesg without error messages. Not needed either, but it un-clutters stderr in my environment.5) Use the local ipset binary instead of host binary. Allow fallback to plain "unshare -n" if user namespaces are not supported. Parallelize the test and increase iteration count to 124. 'unshare -Unr' doesn't work in my setup but 'unshare -n' does and it should be good enough. Note the script will still unse unshare -Unr by default, it only falls back once the first try fails.
6) Make
setlist_resize.shmore verbose on error:
Capture command output to a temporary file, then dump log on failure. This also fixes a spurious error, the script uses 'set -e' and occasionally the first 'rmmod' try fails here which made the script exit too early.7) Add scapy-based sendip emulation to
runtest.sh. Fall bacl to a scapy-based alternative if sendip isn't found in PATH.Florian Westphal (7):
tests: makeruntest.shwork with readonly-cwd
tests:runtest.sh: run inside namespace
tests:diff.sh: preserve file name
tests:check_klog.sh: unclutter stderr
tests:setlist_ns.sh: use local ipset binary and don't rely on userns
tests: makesetlist_resize.shmore verbose on error
tests:runtest.sh: add sendip emulation via scapyREADME | 13 +-- tests/big_sort.sh | 8 +- tests/bitmap:ip.t | 30 +++---- tests/check_klog.sh | 11 ++- tests/check_sendip_packets | 2 +- tests/comment.t | 32 ++++---- tests/diff.sh | 13 ++- tests/hash:ip,mark.t | 8 +- tests/hash:ip,port,ip.t | 8 +- tests/hash:ip,port,net.t | 4 +- tests/hash:ip,port.t | 32 ++++---- tests/hash:ip.t | 30 +++---- tests/hash:ip6,mark.t | 8 +- tests/hash:ip6,port,ip6.t | 8 +- tests/hash:ip6,port,net6.t | 4 +- tests/hash:ip6,port.t | 8 +- tests/hash:ip6.t | 32 ++++---- tests/hash:mac.t | 16 ++-- tests/hash:net,iface.t | 12 +-- tests/hash:net,net.t | 32 ++++---- tests/hash:net,port,net.t | 4 +- tests/hash:net,port.t | 8 +- tests/hash:net.t | 16 ++-- tests/hash:net6,net6.t | 8 +- tests/hash:net6,port,net6.t | 4 +- tests/hash:net6,port.t | 16 ++-- tests/hash:net6.t | 8 +- tests/ignore.sh | 2 +- tests/iphash.t | 20 ++--- tests/ipmap.t | 28 +++---- tests/ipmarkhash.t | 8 +- tests/ipporthash.t | 8 +- tests/ipportiphash.t | 8 +- tests/ipportnethash.t | 8 +- tests/iptables.sh | 8 +- tests/iptree.t | 4 +- tests/iptreemap.t | 4 +- tests/macipmap.t | 16 ++-- tests/match_target.t | 2 +- tests/nethash.t | 4 +- tests/portmap.t | 16 ++-- tests/restore.t | 2 +- tests/runtest.sh | 52 +++++++++++- tests/sendip.py | 154 ++++++++++++++++++++++++++++++++++++ tests/sendip.sh | 8 +- tests/setlist.t | 28 +++---- tests/setlist_ns.sh | 29 ++++++- tests/setlist_resize.sh | 34 ++++++-- tests/sort.sh | 6 +- 49 files changed, 541 insertions(+), 283 deletions(-)create mode 100755
tests/sendip.pySignature · 1 line
2.54.0
Pablo Neira Ayuso
maintainerQuoted 5 lines · Jozsef Kadlecsik
Hi Pablo,
I have committed Florian's patches but it seems my old rsa key is still valid at git.netfilter.org. Could you replace it with my attached ed25519 key? Thank you!
Done, please give it a try. Thanks.
Hi Pablo,
Quoted 7 lines · Pablo Neira Ayuso
Quoted 4 lines · Jozsef Kadlecsik
I have committed Florian's patches but it seems my old rsa key is still valid at git.netfilter.org. Could you replace it with my attached ed25519 key? Thank you!
Done, please give it a try. Thanks.
Thanks indeed, it works just fine.
Best regards,
Jozsef