diff options
author | Arturo Borrero Gonzalez <arturo@debian.org> | 2016-11-16 13:53:21 +0100 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2016-11-24 13:01:16 +0100 |
commit | 1f0cc74d09333930133d1dfd64a8c73bc3beb7c8 (patch) | |
tree | 640a91cdc4cdea5109131aa1fcefc55c532ef979 | |
parent | a65f2647903c3ba1c27e893c2cafc1c078ca958e (diff) |
tests: shell: testcase for deleting many set elements
This testcase adds and deletes many elements in a set.
We add and delete 65.536 elements in a same batch of netlink messages,
(single nft -f run).
Signed-off-by: Arturo Borrero Gonzalez <arturo@debian.org>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rwxr-xr-x | tests/shell/testcases/sets/0012add_delete_many_elements_0 | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/shell/testcases/sets/0012add_delete_many_elements_0 b/tests/shell/testcases/sets/0012add_delete_many_elements_0 new file mode 100755 index 00000000..7a5f8c69 --- /dev/null +++ b/tests/shell/testcases/sets/0012add_delete_many_elements_0 @@ -0,0 +1,46 @@ +#!/bin/bash + +# test adding and deleting many sets elements + +HOWMANY=255 + +tmpfile=$(mktemp) +if [ ! -w $tmpfile ] ; then + echo "Failed to create tmp file" >&2 + exit 0 +fi + +trap "rm -rf $tmpfile" EXIT # cleanup if aborted + +generate() { + echo -n "{" + for ((i=1; i<=HOWMANY; i++)) ; do + for ((j=1; j<=HOWMANY; j++)) ; do + echo -n "10.0.${i}.${j}" + [ "$i" == "$HOWMANY" ] && [ "$j" == "$HOWMANY" ] && break + echo -n ", " + done + done + echo -n "}" +} + +echo "add table x +add set x y { type ipv4_addr; } +add element x y $(generate) +delete element x y $(generate)" > $tmpfile + +set -e +$NFT -f $tmpfile + +EXPECTED="table ip x { + set y { + type ipv4_addr + } +}" +GET=$($NFT list ruleset) +if [ "$EXPECTED" != "$GET" ] ; then + DIFF="$(which diff)" + [ -x $DIFF ] && $DIFF -u <(echo "$EXPECTED") <(echo "$GET") + exit 1 +fi + |