1 From: Pablo Neira Ayuso <pablo@netfilter.org>
2 Date: Mon, 22 Jan 2018 19:54:36 +0100
3 Subject: [PATCH] tests: shell: add flowtable tests
5 Add basic flowtable tests.
7 Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
9 create mode 100755 tests/shell/testcases/flowtable/0001flowtable_0
10 create mode 100755 tests/shell/testcases/flowtable/0002create_flowtable_0
11 create mode 100755 tests/shell/testcases/flowtable/0003add_after_flush_0
12 create mode 100755 tests/shell/testcases/flowtable/0004delete_after_add0
13 create mode 100755 tests/shell/testcases/flowtable/0005delete_in_use_1
15 --- a/tests/shell/run-tests.sh
16 +++ b/tests/shell/run-tests.sh
17 @@ -68,7 +68,9 @@ kernel_cleanup() {
18 nft_set_hash nft_set_rbtree nft_set_bitmap \
19 nft_chain_nat_ipv4 nft_chain_nat_ipv6 \
20 nf_tables_inet nf_tables_bridge nf_tables_arp \
21 - nf_tables_ipv4 nf_tables_ipv6 nf_tables
22 + nf_tables_ipv4 nf_tables_ipv6 nf_tables \
23 + nf_flow_table nf_flow_table_ipv4 nf_flow_tables_ipv6 \
24 + nf_flow_table_inet nft_flow_offload
29 +++ b/tests/shell/testcases/flowtable/0001flowtable_0
34 +if [ ! -w $tmpfile ] ; then
35 + echo "Failed to create tmp file" >&2
39 +trap "rm -rf $tmpfile" EXIT # cleanup if aborted
42 +EXPECTED='table inet t {
44 + hook ingress priority 10
45 + devices = { eth0, wlan0 }
53 +echo "$EXPECTED" > $tmpfile
57 +GET="$($NFT list ruleset)"
59 +if [ "$EXPECTED" != "$GET" ] ; then
60 + DIFF="$(which diff)"
61 + [ -x $DIFF ] && $DIFF -u <(echo "$EXPECTED") <(echo "$GET")
65 +++ b/tests/shell/testcases/flowtable/0002create_flowtable_0
71 +$NFT add flowtable t f { hook ingress priority 10 \; devices = { eth0, wlan0 }\; }
72 +if $NFT create flowtable t f { hook ingress priority 10 \; devices = { eth0, wlan0 }\; } 2>/dev/null ; then
73 + echo "E: flowtable creation not failing on existing set" >&2
76 +$NFT add flowtable t f { hook ingress priority 10 \; devices = { eth0, wlan0 }\; }
80 +++ b/tests/shell/testcases/flowtable/0003add_after_flush_0
86 +$NFT add flowtable x y { hook ingress priority 0\; devices = { eth0, wlan0 }\;}
89 +$NFT add flowtable x y { hook ingress priority 0\; devices = { eth0, wlan0 }\;}
91 +++ b/tests/shell/testcases/flowtable/0004delete_after_add0
97 +$NFT add flowtable x y { hook ingress priority 0\; devices = { eth0, wlan0 }\;}
98 +$NFT delete flowtable x y
100 +++ b/tests/shell/testcases/flowtable/0005delete_in_use_1
107 +$NFT add flowtable x y { hook ingress priority 0\; devices = { eth0, wlan0 }\;}
108 +$NFT add rule x x flow offload @y
109 +$NFT delete flowtable x y
110 +echo "E: delete flowtable in use"