]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
tests: shell: add testcase for reject expr
authorLiping Zhang <liping.zhang@spreadtrum.com>
Mon, 22 Aug 2016 15:43:53 +0000 (23:43 +0800)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 22 Aug 2016 16:27:43 +0000 (18:27 +0200)
Reject expr is only valid in input/forward/output chain,
and if user can add reject expr in prerouting chain, kernel
panic will happen.

So add a simple test case to cover this situation.

Signed-off-by: Liping Zhang <liping.zhang@spreadtrum.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
tests/shell/testcases/chains/0012reject_in_prerouting_1 [new file with mode: 0755]

diff --git a/tests/shell/testcases/chains/0012reject_in_prerouting_1 b/tests/shell/testcases/chains/0012reject_in_prerouting_1
new file mode 100755 (executable)
index 0000000..81cda0c
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+set -e
+
+$NFT add table t
+$NFT add chain t prerouting {type filter hook prerouting priority 0 \; }
+# wrong hook prerouting, only input/forward/output is valid
+$NFT add rule t prerouting reject 2>/dev/null
+echo "E: accepted reject in prerouting hook" >&2