]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
tests: shell: cover cache flush on flush ruleset
authorPablo Neira Ayuso <pablo@netfilter.org>
Wed, 4 Jan 2017 13:28:02 +0000 (14:28 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 10 Jan 2017 21:31:12 +0000 (22:31 +0100)
This tests covers 530a82a72d15 ("evaluate: Update cache on flush
ruleset"). Make sure loading twice including an upfront ruleset flush
leaves us with an empty cache.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
tests/shell/testcases/sets/0015rulesetflush_0 [new file with mode: 0755]

diff --git a/tests/shell/testcases/sets/0015rulesetflush_0 b/tests/shell/testcases/sets/0015rulesetflush_0
new file mode 100755 (executable)
index 0000000..27242b3
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+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 "flush ruleset
+add table t
+add chain t c
+
+table inet filter {
+  set blacklist_v4 { type ipv4_addr; flags interval; }
+}
+
+add element inet filter blacklist_v4 {
+192.168.0.1/24,
+}" >$tmpfile
+
+$NFT -f $tmpfile
+
+# make sure flush ruleset works right
+$NFT -f $tmpfile