summaryrefslogtreecommitdiffstats
path: root/tests/shell/testcases/chains
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2024-10-28 23:17:14 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2024-11-05 21:57:18 +0100
commit0373ca62be3c11a58bd462ee0689718ad25142b6 (patch)
tree3f6a7cbfd5fe9eafec5cacbab90a5d0e0ec3b981 /tests/shell/testcases/chains
parentbe4b61c05a2491aad596aa9243b17b13c937b347 (diff)
tests: shell: move device to different namespace
This actually triggers a UNREGISTER event, it is similar to existing tests, but add this test to improve coverage for this scenario. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'tests/shell/testcases/chains')
-rwxr-xr-xtests/shell/testcases/chains/netdev_move_device39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/shell/testcases/chains/netdev_move_device b/tests/shell/testcases/chains/netdev_move_device
new file mode 100755
index 00000000..762ca598
--- /dev/null
+++ b/tests/shell/testcases/chains/netdev_move_device
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+set -e
+
+rnd=$(mktemp -u XXXXXXXX)
+ns1="nft1-$rnd"
+
+cleanup() {
+ ip netns del "$ns1"
+ ip link del d0 &>/dev/null || :
+}
+trap 'cleanup' EXIT
+
+RULESET="table netdev x {
+ chain x {}
+ chain w {
+ ip daddr 8.7.6.0/24 counter
+ }
+ chain y {
+ type filter hook ingress device d0 priority 0;
+ ip saddr { 1.2.3.4, 2.3.4.5 } counter
+ ip daddr vmap { 5.4.3.0/24 : jump w, 8.9.0.0/24 : jump x }
+ }
+}"
+
+ip link add d0 type dummy
+$NFT -f - <<< $RULESET
+
+ip netns add $ns1
+# move device to $ns1 triggers UNREGISTER event
+ip link set d0 netns $ns1
+
+cleanup
+$NFT delete table netdev x
+
+# a simple test that also triggers UNREGISTER event
+ip netns add $ns1
+ip -netns $ns1 link add d0 type dummy
+ip netns exec $ns1 $NFT -f - <<< $RULESET