blob: 1dbac0b7cdbd541eb04f24da2cb53f4cf0e5f230 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
#!/bin/bash
# NFT_TEST_SKIP(NFT_TEST_SKIP_slow)
set -e
RULESET="table inet x {
set y {
type inet_service
flags interval
auto-merge
}
}"
HOWMANY=65535
if [ "$NFT_TEST_HAS_SOCKET_LIMITS" = y ] ; then
# The socket limit /proc/sys/net/core/wmem_max may be unsuitable for
# the test.
#
# Run only a subset of the test and mark as skipped at the end.
HOWMANY=5000
fi
$NFT -f - <<< $RULESET
tmpfile=$(mktemp)
echo -n "add element inet x y { " > $tmpfile
for ((i=0;i<$HOWMANY;i+=2))
do
echo -n "$i, " >> $tmpfile
if [ $i -eq $((HOWMANY-1)) ]
then
echo -n "$i" >> $tmpfile
fi
done
echo "}" >> $tmpfile
$NFT -f $tmpfile
tmpfile2=$(mktemp)
for ((i=1;i<$HOWMANY;i+=2))
do
echo "$i" >> $tmpfile2
done
tmpfile3=$(mktemp)
shuf "$tmpfile2" --random-source=<("$NFT_TEST_BASEDIR/helpers/random-source.sh" "automerge-shuf-tmpfile2" "$NFT_TEST_RANDOM_SEED") > "$tmpfile3"
i=0
cat $tmpfile3 | while read line && [ $i -lt 10 ]
do
$NFT add element inet x y { $line }
if [ $? -ne 0 ]
then
echo "failed to add $line"
exit 1
fi
i=$((i+1))
done
for ((i=0;i<10;i++))
do
from=$(($RANDOM%$HOWMANY))
to=$(($from+100))
$NFT add element inet x y { $from-$to }
if [ $? -ne 0 ]
then
echo "failed to add $from-$to"
exit 1
fi
$NFT get element inet x y { $from-$to } 1>/dev/null
if [ $? -ne 0 ]
then
echo "failed to get $from-$to"
exit 1
fi
# partial removals in the previous random range
from2=$(($from+10))
to2=$(($to-10))
$NFT delete element inet x y { $from, $to, $from2-$to2 }
if [ $? -ne 0 ]
then
echo "failed to delete $from, $to, $from2-$to2"
exit 1
fi
# check deletions are correct
from=$(($from+1))
$NFT get element inet x y { $from } 1>/dev/null
if [ $? -ne 0 ]
then
echo "failed to get $from"
exit 1
fi
to=$(($to-1))
$NFT get element inet x y { $to } 1>/dev/null
if [ $? -ne 0 ]
then
echo "failed to get $to"
exit 1
fi
from2=$(($from2-1))
$NFT get element inet x y { $from2 } 1>/dev/null
if [ $? -ne 0 ]
then
echo "failed to get $from2"
exit 1
fi
to2=$(($to2+1))
$NFT get element inet x y { $to2 } 1>/dev/null
if [ $? -ne 0 ]
then
echo "failed to get $to2"
exit 1
fi
done
rm -f $tmpfile
rm -f $tmpfile2
rm -f $tmpfile3
if [ "$HOWMANY" != 65535 ] ; then
echo "NFT_TEST_HAS_SOCKET_LIMITS indicates that the socket limit for"
echo "/proc/sys/net/core/wmem_max is too small for this test. Mark as SKIPPED"
echo "You may bump the limit and rerun with \`NFT_TEST_HAS_SOCKET_LIMITS=n\`."
exit 77
fi
|