netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tests: shell: add testcases for named objects
@ 2017-10-05 10:15 Harsha Sharma
  2017-10-06 12:38 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 6+ messages in thread
From: Harsha Sharma @ 2017-10-05 10:15 UTC (permalink / raw)
  To: pablo; +Cc: netfilter-devel, outreachy-kernel, Harsha Sharma

Add testcases for creating named objects with unique name, defined
by user and referencing them from rule.

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

diff --git a/tests/shell/testcases/sets/0024named_objects_0 b/tests/shell/testcases/sets/0024named_objects_0
new file mode 100755
index 0000000..de02d65
--- /dev/null
+++ b/tests/shell/testcases/sets/0024named_objects_0
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+# This is the testscase:
+# * creating valid named objects
+# * 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 inet x {
+	counter user123 {
+		packets 12 bytes 1433
+	}
+	quota user123 {
+		over 2000 bytes
+	}
+	quota user124 {
+		over 2000 bytes
+	}
+	set y {
+		type ipv4_addr
+	}
+	map test {
+		type ipv4_addr : quota
+		elements = { 192.168.2.2 : "user124", 192.168.2.3 : "user124"}
+	}
+	chain y {
+		type filter hook input priority 0; policy accept;
+		counter name ip saddr map { 192.168.2.2 : "user123", 1.1.1.1 : "user123", 2.2.2.2 : "user123"}
+		quota name ip saddr map @test drop
+	}
+}" > $tmpfile
+
+set -e
+$NFT -f $tmpfile
--
2.11.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-10-10 20:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-05 10:15 [PATCH] tests: shell: add testcases for named objects Harsha Sharma
2017-10-06 12:38 ` Pablo Neira Ayuso
2017-10-07  7:41   ` Harsha Sharma
2017-10-09 12:02     ` Pablo Neira Ayuso
2017-10-09 12:33       ` Harsha Sharma
2017-10-10 20:40       ` Harsha Sharma

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).