diff options
author | Elise Lennion <elise.lennion@gmail.com> | 2017-03-24 12:31:31 -0300 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2017-03-24 19:30:21 +0100 |
commit | 2cc9f4e38b895add3f51facc47be34114fe954a9 (patch) | |
tree | 37630172d23daf8a32d45066f3d26f7e60c71852 | |
parent | e7d3210974e3c091ea11c1c9a94b07d3b5b6abd1 (diff) |
tests: Add test for flush command selectiveness on sets
This tests the selectiveness of flush command on structures that use the
generic set infrastructure (sets, maps and flow tables).
Signed-off-by: Elise Lennion <elise.lennion@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rwxr-xr-x | tests/shell/testcases/sets/0022type_selective_flush_0 | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/shell/testcases/sets/0022type_selective_flush_0 b/tests/shell/testcases/sets/0022type_selective_flush_0 new file mode 100755 index 00000000..f8878f70 --- /dev/null +++ b/tests/shell/testcases/sets/0022type_selective_flush_0 @@ -0,0 +1,41 @@ +#!/bin/bash + +# This tests the selectiveness of flush command on structures that use the +# generic set infrastructure (sets, maps and flow tables). + +tmpfile=$(mktemp) +if [ ! -w $tmpfile ] ; then + echo "Failed to create tmp file" >&2 + exit 0 +fi + +trap "rm -rf $tmpfile" EXIT # cleanup if aborted + +echo " +add table t +add chain t c +add set t s {type ipv4_addr;} +add map t m {type ipv4_addr : inet_service;} +add rule t c tcp dport 80 flow table f {ip saddr limit rate 10/second} +" >$tmpfile + +$NFT -f $tmpfile + +# Commands that should be invalid + +declare -a cmds=( + "flush set t m" "flush set t f" + "flush map t s" "flush map t f" + "flush flow table t s" "flush flow table t m" + ) + +for i in "${cmds[@]}" +do + echo "$i" >$tmpfile + $NFT -f $tmpfile &>/dev/null + ret=$? + + if [ $ret -eq 0 ]; then + exit 1 + fi +done |