summaryrefslogtreecommitdiffstats
path: root/tests/conntrack/load-stress.sh
blob: 597c4c6189fdf08b12bfe4d94c1d797bdb58a2c5 (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
#!/bin/bash

SPORT_COUNT=128
DPORT_COUNT=128

function ct_data_gen()
{
	for (( d = 1; d <= $DPORT_COUNT; d++ )) do
		for (( s = 1; s <= $SPORT_COUNT; s++ )) do
			ip netns exec ct-ns-test conntrack -I -s 1.1.1.1 -d 2.2.2.2 -p tcp --sport ${s} --dport ${d} --state LISTEN -u SEEN_REPLY -t 300 &> /dev/null
			if [ $? -ne 0 ]
			then
				echo "[FAILED] cannot insert conntrack entries"
				exit 1
			fi
		done
	done
}

ip netns add ct-ns-test

if [ $UID -ne 0 ]
then
	echo "Run this test as root"
	exit 1
fi

echo "Creating conntrack entries, please wait..."
ct_data_gen
ip netns exec ct-ns-test conntrack -U -p tcp -m 1
if [ $? -ne 0 ]
then
	echo "[FAILED] cannot update conntrack entries"
	exit 1
fi

COUNT=`ip netns exec ct-ns-test conntrack -L | wc -l`
if [ $COUNT -ne 16384 ]
then
	echo "$COUNT entries, expecting 131072"
	exit 1
fi

ip netns exec ct-ns-test conntrack -F
if [ $? -ne 0 ]
then
	echo "[FAILED] faild to flush conntrack entries"
	exit 1
fi

COUNT=`ip netns exec ct-ns-test conntrack -L | wc -l`
if [ $COUNT -ne 0 ]
then
	echo "$COUNT entries, expecting 0"
	exit 1
fi

ip netns del ct-ns-test

echo "[OK] test successful"

exit 0