Blame tests/hash:net.t

Packit 99347c
# Create a set with timeout
Packit 99347c
0 ipset create test nethash hashsize 128 timeout 4
Packit 99347c
# Add zero valued element
Packit 99347c
1 ipset add test 0.0.0.0/0
Packit 99347c
# Test zero valued element
Packit 99347c
1 ipset test test 0.0.0.0/0
Packit 99347c
# Delete zero valued element
Packit 99347c
1 ipset del test 0.0.0.0/0
Packit 99347c
# Try to add /0
Packit 99347c
1 ipset add test 1.1.1.1/0
Packit 99347c
# Try to add /32
Packit 99347c
0 ipset add test 1.1.1.1/32
Packit 99347c
# Add almost zero valued element
Packit 99347c
0 ipset add test 0.0.0.0/1
Packit 99347c
# Test almost zero valued element
Packit 99347c
0 ipset test test 0.0.0.0/1
Packit 99347c
# Delete almost zero valued element
Packit 99347c
0 ipset del test 0.0.0.0/1
Packit 99347c
# Test deleted element
Packit 99347c
1 ipset test test 0.0.0.0/1
Packit 99347c
# Delete element not added to the set
Packit 99347c
1 ipset del test 0.0.0.0/1
Packit 99347c
# Add first random network
Packit 99347c
0 ipset add test 2.0.0.1/24
Packit 99347c
# Add second random network
Packit 99347c
0 ipset add test 192.168.68.69/27
Packit 99347c
# Test first random value
Packit 99347c
0 ipset test test 2.0.0.255
Packit 99347c
# Test second random value
Packit 99347c
0 ipset test test 192.168.68.95
Packit 99347c
# Test value not added to the set
Packit 99347c
1 ipset test test 2.0.1.0
Packit 99347c
# Try to add IP address
Packit 99347c
0 ipset add test 2.0.0.1
Packit 99347c
# List set
Packit 99347c
0 ipset list test | grep -v Revision: | sed 's/timeout ./timeout x/' > .foo0 && ./sort.sh .foo0
Packit 99347c
# Check listing
Packit 99347c
0 diff -u -I 'Size in memory.*' .foo hash:net.t.list0
Packit 99347c
# Sleep 5s so that element can time out
Packit 99347c
0 sleep 5
Packit 99347c
# List set
Packit 99347c
0 ipset -L test 2>/dev/null | grep -v Revision: > .foo0 && ./sort.sh .foo0
Packit 99347c
# Check listing
Packit 99347c
0 diff -u -I 'Size in memory.*' .foo hash:net.t.list1
Packit 99347c
# Flush test set
Packit 99347c
0 ipset flush test
Packit 99347c
# Delete test set
Packit 99347c
0 ipset destroy test
Packit 99347c
# Create test set
Packit 99347c
0 ipset new test hash:net
Packit 99347c
# Add networks in range notation
Packit 99347c
0 ipset add test 10.2.0.0-10.2.1.12
Packit 99347c
# List set
Packit 99347c
0 ipset -L test 2>/dev/null | grep -v Revision: > .foo0 && ./sort.sh .foo0
Packit 99347c
# Check listing
Packit 99347c
0 diff -u -I 'Size in memory.*' .foo hash:net.t.list2
Packit 99347c
# Delete test set
Packit 99347c
0 ipset destroy test
Packit 99347c
# Stress test with range notation
Packit 99347c
0 ./netgen.sh | ipset restore
Packit 99347c
# List set and check the number of elements
Packit 99347c
0 n=`ipset -L test|grep '^10.'|wc -l` && test $n -eq 43520
Packit 99347c
# Destroy test set
Packit 99347c
0 ipset destroy test
Packit 99347c
# Verify keeping track cidrs: create set
Packit 99347c
0 ipset n test hash:net
Packit 99347c
# Verify keeping track cidrs: add /16 net
Packit 99347c
0 ipset a test 1.1.0.0/16
Packit 99347c
# Verify keeping track cidrs: add /24 net
Packit 99347c
0 ipset a test 2.2.2.0/24
Packit 99347c
# Verify keeping track cidrs: del /24 net
Packit 99347c
0 ipset d test 2.2.2.0/24
Packit 99347c
# Verify keeping track cidrs: check address in /16
Packit 99347c
0 ipset t test 1.1.1.1
Packit 99347c
# Destroy test set
Packit 99347c
0 ipset x test
Packit 99347c
# Create test set with timeout support
Packit 99347c
0 ipset create test hash:net timeout 30
Packit 99347c
# Add a non-matching IP address entry
Packit 99347c
0 ipset -A test 1.1.1.1 nomatch
Packit 99347c
# Add an overlapping matching small net
Packit 99347c
0 ipset -A test 1.1.1.0/30
Packit 99347c
# Add an overlapping non-matching larger net
Packit 99347c
0 ipset -A test 1.1.1.0/28 nomatch
Packit 99347c
# Add an even larger matching net
Packit 99347c
0 ipset -A test 1.1.1.0/26
Packit 99347c
# Check non-matching IP
Packit 99347c
1 ipset -T test 1.1.1.1
Packit 99347c
# Check non-matching IP with nomatch flag
Packit 99347c
0 ipset -T test 1.1.1.1 nomatch
Packit 99347c
# Check matching IP from non-matchin small net
Packit 99347c
0 ipset -T test 1.1.1.3
Packit 99347c
# Check non-matching IP from larger net
Packit 99347c
1 ipset -T test 1.1.1.4
Packit 99347c
# Check matching IP from even larger net
Packit 99347c
0 ipset -T test 1.1.1.16
Packit 99347c
# Update non-matching IP to matching one
Packit 99347c
0 ipset -! -A test 1.1.1.1
Packit 99347c
# Delete overlapping small net
Packit 99347c
0 ipset -D test 1.1.1.0/30
Packit 99347c
# Check matching IP
Packit 99347c
0 ipset -T test 1.1.1.1
Packit 99347c
# Add overlapping small net
Packit 99347c
0 ipset -A test 1.1.1.0/30
Packit 99347c
# Update matching IP as a non-matching one, with shorter timeout
Packit 99347c
0 ipset -! -A test 1.1.1.1 nomatch timeout 2
Packit 99347c
# Check non-matching IP
Packit 99347c
1 ipset -T test 1.1.1.1
Packit 99347c
# Sleep 3s so that element can time out
Packit 99347c
0 sleep 3
Packit 99347c
# Check non-matching IP
Packit 99347c
0 ipset -T test 1.1.1.1
Packit 99347c
# Check matching IP
Packit 99347c
0 ipset -T test 1.1.1.3
Packit 99347c
# Delete test set
Packit 99347c
0 ipset destroy test
Packit 99347c
# Check CIDR book-keeping
Packit 99347c
0 ./check_cidrs.sh
Packit 99347c
# Check all possible CIDR values
Packit 99347c
0 ./cidr.sh net
Packit 99347c
# Timeout: Check that resizing keeps timeout values
Packit 99347c
0 ./resizet.sh -4 net
Packit 99347c
# Nomatch: Check that resizing keeps the nomatch flag
Packit 99347c
0 ./resizen.sh -4 net
Packit 99347c
# Create set without timeout support
Packit 99347c
0 ipset n test hash:net
Packit 99347c
# Add more than 2^31 elements in a range
Packit 99347c
0 ipset a test 0.0.0.0-128.0.0.1
Packit 99347c
# List set
Packit 99347c
0 ipset -L test 2>/dev/null | grep -v Revision: > .foo0 && ./sort.sh .foo0
Packit 99347c
# Check listing
Packit 99347c
0 diff -u -I 'Size in memory.*' .foo hash:net.t.list3
Packit 99347c
# Delete test set
Packit 99347c
0 ipset destroy test
Packit 99347c
# Counters: create set
Packit 99347c
0 ipset n test hash:net counters
Packit 99347c
# Counters: add element with packet, byte counters
Packit 99347c
0 ipset a test 2.0.0.1/24 packets 5 bytes 3456
Packit 99347c
# Counters: check element
Packit 99347c
0 ipset t test 2.0.0.1/24
Packit 99347c
# Counters: check counters
Packit 99347c
0 ./check_counters test 2.0.0.0/24 5 3456
Packit 99347c
# Counters: delete element
Packit 99347c
0 ipset d test 2.0.0.1/24
Packit 99347c
# Counters: test deleted element
Packit 99347c
1 ipset t test 2.0.0.1/24
Packit 99347c
# Counters: add element with packet, byte counters
Packit 99347c
0 ipset a test 2.0.0.20/25 packets 12 bytes 9876
Packit 99347c
# Counters: check counters
Packit 99347c
0 ./check_counters test 2.0.0.0/25 12 9876
Packit 99347c
# Counters: update counters
Packit 99347c
0 ipset -! a test 2.0.0.20/25 packets 13 bytes 12479
Packit 99347c
# Counters: check counters
Packit 99347c
0 ./check_counters test 2.0.0.0/25 13 12479
Packit 99347c
# Counters: destroy set
Packit 99347c
0 ipset x test
Packit 99347c
# Counters and timeout: create set
Packit 99347c
0 ipset n test hash:net counters timeout 600
Packit 99347c
# Counters and timeout: add element with packet, byte counters
Packit 99347c
0 ipset a test 2.0.0.1/24 packets 5 bytes 3456
Packit 99347c
# Counters and timeout: check element
Packit 99347c
0 ipset t test 2.0.0.1/24
Packit 99347c
# Counters and timeout: check counters
Packit 99347c
0 ./check_extensions test 2.0.0.0/24 600 5 3456
Packit 99347c
# Counters and timeout: delete element
Packit 99347c
0 ipset d test 2.0.0.1/24
Packit 99347c
# Counters and timeout: test deleted element
Packit 99347c
1 ipset t test 2.0.0.1/24
Packit 99347c
# Counters and timeout: add element with packet, byte counters
Packit 99347c
0 ipset a test 2.0.0.20/25 packets 12 bytes 9876
Packit 99347c
# Counters and timeout: check counters
Packit 99347c
0 ./check_extensions test 2.0.0.0/25 600 12 9876
Packit 99347c
# Counters and timeout: update counters
Packit 99347c
0 ipset -! a test 2.0.0.20/25 packets 13 bytes 12479
Packit 99347c
# Counters and timeout: check counters
Packit 99347c
0 ./check_extensions test 2.0.0.0/25 600 13 12479
Packit 99347c
# Counters and timeout: update timeout
Packit 99347c
0 ipset -! a test 2.0.0.20/25 timeout 700
Packit 99347c
# Counters and timeout: check counters
Packit 99347c
0 ./check_extensions test 2.0.0.0/25 700 13 12479
Packit 99347c
# Counters and timeout: destroy set
Packit 99347c
0 ipset x test
Packit 99347c
# eof