summaryrefslogtreecommitdiffstats
path: root/tests/shell/testcases/transactions/0049huge_0
blob: f029ee3c54d78ac469a742dd231e273e129af9e6 (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
#!/bin/bash

# let's try to exceed transaction buffer space

$NFT flush ruleset
$NFT add table inet test
$NFT add chain inet test c

RULE_COUNT=3000
RULESET=$(
for ((i = 0; i < ${RULE_COUNT}; i++)); do
	echo "add rule inet test c accept comment rule$i"
done
)
test $($NFT -e -a -f - <<< "$RULESET" |grep "#[ ]\+handle[ ]\+[0-9]\+" |wc -l) -eq ${RULE_COUNT} || exit 1

# same thing, but with JSON rules
#
$NFT flush ruleset
$NFT add table inet test
$NFT add chain inet test c

RULESET=$(
echo '{"nftables": ['
for ((i = 0; i < $((${RULE_COUNT} - 1)); i++)); do
	echo '{"add": {"rule": {"family": "inet", "table": "test", "chain": "c", "expr": [{"accept": null}], "comment": "rule'$i'"}}},'
done
	echo '{"add": {"rule": {"family": "inet", "table": "test", "chain": "c", "expr": [{"accept": null}], "comment": "rule'$((${RULE_COUNT} - 1))'"}}}'
echo ']}'
)
test $($NFT -j -e -a -f - <<< "$RULESET" |sed 's/\({"add":\)/\n\1/g' |grep '"handle"' |wc -l) -eq ${RULE_COUNT} || exit 1