tests: shell: Test odd netdev hook updates
Phil Sutter
reviewerPATCH 1/1 tests: shell: Test odd netdev hook updates
These should cover what Fernando fixes in his kernel patch "netfilter:nf_tables: fix device name and prefix match in hook lookup" as well as some bonus cases I came up with.
--- .../chains/netdev_chain_update_wildcard_hook | 45 +++++++++++++++++++ .../testcases/flowtable/update_wildcard_hook | 45 +++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100755 tests/shell/testcases/chains/netdev_chain_update_wildcard_hook create mode 100755 tests/shell/testcases/flowtable/update_wildcard_hook
tests/shell/testcases/chains/netdev_chain_update_wildcard_hook new file +45 -0
@@ -0,0 +1,45 @@ +#!/bin/bash + +# NFT_TEST_REQUIRES(NFT_TEST_HAVE_ifname_based_hooks) + +RC=0 + +die() { + echo "FAIL: $@" + ((RC++)) + $NFT list ruleset +} + +$NFT add table netdev t || die "add table failed" + +do_chain() { # (cmd, devspec, thp) + $NFT $1 chain netdev t c "{ $3 devices = { $2 }; }" +} + +thp='type filter hook ingress priority 0;' + +do_chain add foo* "$thp" || die "initial add chain failed" +do_chain create foo* "$thp" && die "duplicated create initial chain allowed" +do_chain add foo* || die "duplicated hook add failed" + +do_chain add "bar*, bar*" && die "duplicate wildcard add allowed" +do_chain add "bar, bar" && die "duplicate device add allowed" + +do_chain add foo && die "update with non-wildcard allowed" +do_chain add fo* && die "update with shorter wildcard allowed" +do_chain add fooo* && die "update with longer wildcard allowed" + +# add after testing delete in case deletion is allowed when it should not + +do_chain delete foo && die "delete non-wildcard hook allowed" +do_chain add foo* || die "duplicated hook add failed" + +do_chain delete fo* && die "delete shorter wildcard allowed" +do_chain add foo* || die "duplicated hook add failed" + +do_chain delete fooo* && die "delete longer wildcard allowed" +do_chain add foo* || die "duplicated hook add failed" + +do_chain delete foo* || die "delete initial chain hook failed" + +exit $RC
tests/shell/testcases/flowtable/update_wildcard_hook new file +45 -0
45 lines not on this page · raw message
Signature · 1 line
2.54.0
Quoted 5 lines · Phil Sutter
These should cover what Fernando fixes in his kernel patch "netfilter:
nf_tables: fix device name and prefix match in hook lookup" as well as some bonus cases I came up with.Signed-off-by Phil Sutter <[email protected]>
Thanks Phil! These tests cover a lot of different cases.
Quoted 108 lines
.../chains/netdev_chain_update_wildcard_hook | 45 +++++++++++++++++++ .../testcases/flowtable/update_wildcard_hook | 45 +++++++++++++++++++ 2 files changed, 90 insertions(+)create mode 100755 tests/shell/testcases/chains/netdev_chain_update_wildcard_hook create mode 100755 tests/shell/testcases/flowtable/update_wildcard_hook
tests/shell/testcases/chains/netdev_chain_update_wildcard_hook new file +45
-0@@ -0,0 +1,45 @@ +#!/bin/bash + +# NFT_TEST_REQUIRES(NFT_TEST_HAVE_ifname_based_hooks) + +RC=0 + +die() { + echo "FAIL: $@" + ((RC++)) + $NFT list ruleset +} + +$NFT add table netdev t || die "add table failed" + +do_chain() { # (cmd, devspec, thp) + $NFT $1 chain netdev t c "{ $3 devices = { $2 }; }" +} + +thp='type filter hook ingress priority 0;' + +do_chain add foo* "$thp" || die "initial add chain failed" +do_chain create foo* "$thp" && die "duplicated create initial chain allowed" +do_chain add foo* || die "duplicated hook add failed" + +do_chain add "bar*, bar*" && die "duplicate wildcard add allowed" +do_chain add "bar, bar" && die "duplicate device add allowed" + +do_chain add foo && die "update with non-wildcard allowed" +do_chain add fo* && die "update with shorter wildcard allowed" +do_chain add fooo* && die "update with longer wildcard allowed" + +# add after testing delete in case deletion is allowed when it should not + +do_chain delete foo && die "delete non-wildcard hook allowed" +do_chain add foo* || die "duplicated hook add failed" + +do_chain delete fo* && die "delete shorter wildcard allowed" +do_chain add foo* || die "duplicated hook add failed" + +do_chain delete fooo* && die "delete longer wildcard allowed" +do_chain add foo* || die "duplicated hook add failed" + +do_chain delete foo* || die "delete initial chain hook failed" + +exit $RCtests/shell/testcases/flowtable/update_wildcard_hook new file +45
-0@@ -0,0 +1,45 @@ +#!/bin/bash + +# NFT_TEST_REQUIRES(NFT_TEST_HAVE_ifname_based_hooks) + +RC=0 + +die() { + echo "FAIL: $@" + ((RC++)) + $NFT list ruleset +} + +$NFT add table t || die "add table failed" + +do_ft() { # (cmd, devspec, thp) + $NFT $1 flowtable t ft "{ $3 devices = { $2 }; }" +} + +thp='hook ingress priority 0;' + +do_ft add foo* "$thp" || die "initial add flowtable failed" +do_ft create foo* "$thp" && die "duplicated create initial flowtable allowed" +do_ft add foo* || die "duplicated hook add failed" + +do_ft add "bar*, bar*" && die "duplicate wildcard add allowed" +do_ft add "bar, bar" && die "duplicate device add allowed" + +do_ft add foo && die "update with non-wildcard allowed" +do_ft add fo* && die "update with shorter wildcard allowed" +do_ft add fooo* && die "update with longer wildcard allowed" + +# add after testing delete in case deletion is allowed when it should not + +do_ft delete foo && die "delete non-wildcard hook allowed" +do_ft add foo* || die "duplicated hook add failed" + +do_ft delete fo* && die "delete shorter wildcard allowed" +do_ft add foo* || die "duplicated hook add failed" + +do_ft delete fooo* && die "delete longer wildcard allowed" +do_ft add foo* || die "duplicated hook add failed" + +do_ft delete foo* || die "delete initial flowtable hook failed" + +exit $RC
Phil Sutter
reviewerQuoted 10 lines · Fernando Fernandez Mancera
Quoted 5 lines · Phil Sutter
These should cover what Fernando fixes in his kernel patch "netfilter:
nf_tables: fix device name and prefix match in hook lookup" as well as some bonus cases I came up with.Signed-off-by Phil Sutter <[email protected]>Thanks Phil! These tests cover a lot of different cases.
Reviewed-by Fernando Fernandez Mancera <[email protected]>
Thanks for your review, Fernando!
Pablo, I'll push this out now, which means we'll get two failing test cases until kernel fixes are ready and deployed. Fine with you?
Cheers, Phil
Pablo Neira Ayuso
maintainerQuoted 8 lines · Phil Sutter
Quoted 7 lines · Fernando Fernandez Mancera
Quoted 5 lines · Phil Sutter
These should cover what Fernando fixes in his kernel patch "netfilter:
nf_tables: fix device name and prefix match in hook lookup" as well as some bonus cases I came up with.Signed-off-by Phil Sutter <[email protected]>
Quoted 8 lines
Quoted 3 lines
Thanks Phil! These tests cover a lot of different cases.
Reviewed-by Fernando Fernandez Mancera <[email protected]>Thanks for your review, Fernando!
Pablo, I'll push this out now, which means we'll get two failing test cases until kernel fixes are ready and deployed. Fine with you?
We usually wait for fixes to propagate upstream before applying tests to userspace.
Phil Sutter
reviewerQuoted 13 lines · Pablo Neira Ayuso
Quoted 12 lines · Phil Sutter
Quoted 10 lines · Fernando Fernandez Mancera
Quoted 5 lines · Phil Sutter
These should cover what Fernando fixes in his kernel patch "netfilter:
nf_tables: fix device name and prefix match in hook lookup" as well as some bonus cases I came up with.Signed-off-by Phil Sutter <[email protected]>Thanks Phil! These tests cover a lot of different cases.
Reviewed-by Fernando Fernandez Mancera <[email protected]>
Quoted 7 lines
Quoted 4 lines
Thanks for your review, Fernando!
Pablo, I'll push this out now, which means we'll get two failing test cases until kernel fixes are ready and deployed. Fine with you?
We usually wait for fixes to propagate upstream before applying tests to userspace.
ACK, will do.