]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
tests: shell: add testcases for named limits
authorHarsha Sharma <harshasharmaiitr@gmail.com>
Sat, 14 Oct 2017 10:46:03 +0000 (16:16 +0530)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 17 Oct 2017 12:01:42 +0000 (14:01 +0200)
Add testcases for creating named limits and referencing them
from rule

Signed-off-by: Harsha Sharma <harshasharmaiitr@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
tests/shell/testcases/sets/0025named_limit_0 [new file with mode: 0755]

diff --git a/tests/shell/testcases/sets/0025named_limit_0 b/tests/shell/testcases/sets/0025named_limit_0
new file mode 100755 (executable)
index 0000000..91553f3
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+# This is the testscase:
+# * creating valid named limits
+# * referencing them from a valid rule
+
+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 "
+table ip filter {
+       limit http-traffic {
+               rate 1/second
+       }
+       chain input {
+               type filter hook input priority 0; policy accept;
+               limit name tcp dport map { 80 : "http-traffic", 443 : "http-traffic"}
+       }
+}" > $tmpfile
+
+set -e
+$NFT -f $tmpfile