diff mbox series

tests: shell: add testcases for named limits

Message ID 20171014104603.16365-1-harshasharmaiitr@gmail.com
State Accepted
Delegated to: Pablo Neira
Headers show
Series tests: shell: add testcases for named limits | expand

Commit Message

Harsha Sharma Oct. 14, 2017, 10:46 a.m. UTC
Add testcases for creating named limits and referencing them
from rule

Signed-off-by: Harsha Sharma <harshasharmaiitr@gmail.com>
---
 tests/shell/testcases/sets/0025named_limit_0 | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100755 tests/shell/testcases/sets/0025named_limit_0

Comments

Pablo Neira Ayuso Oct. 17, 2017, 12:02 p.m. UTC | #1
On Sat, Oct 14, 2017 at 04:16:03PM +0530, Harsha Sharma wrote:
> Add testcases for creating named limits and referencing them
> from rule

Applied, thanks Harsha.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox series

Patch

diff --git a/tests/shell/testcases/sets/0025named_limit_0 b/tests/shell/testcases/sets/0025named_limit_0
new file mode 100755
index 0000000..91553f3
--- /dev/null
+++ b/tests/shell/testcases/sets/0025named_limit_0
@@ -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