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.
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Jozsef Kadlecsik <kadlec@netfilter.org>
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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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 add with range notation
# 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
# 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
# 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
# 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
# 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
#!/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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
-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)
$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)
$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)
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# set -x
ipset=${IPSET_BIN:-../src/ipset}
+tmpdir=""
tests="init"
tests="$tests ipmap bitmap:ip"
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
;;
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
else
echo "FAILED"
echo "Failed test: $cmd"
- cat .foo.err
+ cat "$tmpdir"/.foo.err
let "failcount++"
break
fi
esac
done
rmmod ip_set >/dev/null 2>&1
-rm -f .foo*
if [ "$failcount" -eq 0 ]; then
echo "All tests are passed"
else
#!/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 "$@"
# 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
# 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
# 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
# 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
#!/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"