summaryrefslogtreecommitdiffstats
path: root/tests/shell/testcases/flowtable
diff options
context:
space:
mode:
Diffstat (limited to 'tests/shell/testcases/flowtable')
-rwxr-xr-xtests/shell/testcases/flowtable/0001flowtable_033
-rwxr-xr-xtests/shell/testcases/flowtable/0002create_flowtable_012
-rwxr-xr-xtests/shell/testcases/flowtable/0003add_after_flush_08
-rwxr-xr-xtests/shell/testcases/flowtable/0004delete_after_add06
-rwxr-xr-xtests/shell/testcases/flowtable/0005delete_in_use_19
5 files changed, 68 insertions, 0 deletions
diff --git a/tests/shell/testcases/flowtable/0001flowtable_0 b/tests/shell/testcases/flowtable/0001flowtable_0
new file mode 100755
index 00000000..307f06f6
--- /dev/null
+++ b/tests/shell/testcases/flowtable/0001flowtable_0
@@ -0,0 +1,33 @@
+#!/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
+
+
+EXPECTED='table inet t {
+ flowtable f {
+ hook ingress priority 10
+ devices = { eth0, wlan0 }
+ }
+
+ chain c {
+ flow offload @f
+ }
+}'
+
+echo "$EXPECTED" > $tmpfile
+set -e
+$NFT -f $tmpfile
+
+GET="$($NFT list ruleset)"
+
+if [ "$EXPECTED" != "$GET" ] ; then
+ DIFF="$(which diff)"
+ [ -x $DIFF ] && $DIFF -u <(echo "$EXPECTED") <(echo "$GET")
+ exit 1
+fi
diff --git a/tests/shell/testcases/flowtable/0002create_flowtable_0 b/tests/shell/testcases/flowtable/0002create_flowtable_0
new file mode 100755
index 00000000..b6941c58
--- /dev/null
+++ b/tests/shell/testcases/flowtable/0002create_flowtable_0
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+set -e
+$NFT add table t
+$NFT add flowtable t f { hook ingress priority 10 \; devices = { eth0, wlan0 }\; }
+if $NFT create flowtable t f { hook ingress priority 10 \; devices = { eth0, wlan0 }\; } 2>/dev/null ; then
+ echo "E: flowtable creation not failing on existing set" >&2
+ exit 1
+fi
+$NFT add flowtable t f { hook ingress priority 10 \; devices = { eth0, wlan0 }\; }
+
+exit 0
diff --git a/tests/shell/testcases/flowtable/0003add_after_flush_0 b/tests/shell/testcases/flowtable/0003add_after_flush_0
new file mode 100755
index 00000000..1f3cb18a
--- /dev/null
+++ b/tests/shell/testcases/flowtable/0003add_after_flush_0
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+set -e
+$NFT add table x
+$NFT add flowtable x y { hook ingress priority 0\; devices = { eth0, wlan0 }\;}
+$NFT flush ruleset
+$NFT add table x
+$NFT add flowtable x y { hook ingress priority 0\; devices = { eth0, wlan0 }\;}
diff --git a/tests/shell/testcases/flowtable/0004delete_after_add0 b/tests/shell/testcases/flowtable/0004delete_after_add0
new file mode 100755
index 00000000..b72977b3
--- /dev/null
+++ b/tests/shell/testcases/flowtable/0004delete_after_add0
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+set -e
+$NFT add table x
+$NFT add flowtable x y { hook ingress priority 0\; devices = { eth0, wlan0 }\;}
+$NFT delete flowtable x y
diff --git a/tests/shell/testcases/flowtable/0005delete_in_use_1 b/tests/shell/testcases/flowtable/0005delete_in_use_1
new file mode 100755
index 00000000..ce39e24e
--- /dev/null
+++ b/tests/shell/testcases/flowtable/0005delete_in_use_1
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+set -e
+$NFT add table x
+$NFT add chain x x
+$NFT add flowtable x y { hook ingress priority 0\; devices = { eth0, wlan0 }\;}
+$NFT add rule x x flow offload @y
+$NFT delete flowtable x y
+echo "E: delete flowtable in use"