]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
tests/shell: cover long interface name in "0042chain_variable_0" test
authorThomas Haller <thaller@redhat.com>
Mon, 23 Oct 2023 17:00:46 +0000 (19:00 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 24 Oct 2023 09:31:02 +0000 (11:31 +0200)
IFNAMSIZ is 16. Adjust "0042chain_variable_0" to use an interface name
with the maximum allowed bytes length.

Instead of adding an entirely different test, adjust an existing one to
use another interface name. The aspect for testing for a long interface
name is not special enough, to warrant a separate test. We can cover it
by extending an existing test.

Note that the length check in "parser_bison.y" is wrong. The test checks
still for the wrong behavior and that "d23456789012345x" is accepted.

Signed-off-by: Thomas Haller <thaller@redhat.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
tests/shell/testcases/chains/0042chain_variable_0
tests/shell/testcases/chains/dumps/0042chain_variable_0.nft

index 1ea44e85c71f70f7fe193ea1f920eeeda8a45232..739dc05a1777dfaa40fbc8d70c9ef5133524d54c 100755 (executable)
@@ -2,7 +2,8 @@
 
 set -e
 
-ip link add name dummy0 type dummy
+ip link add name d23456789012345 type dummy
+
 
 EXPECTED="define if_main = \"lo\"
 
@@ -14,22 +15,50 @@ table netdev filter1 {
 
 $NFT -f - <<< $EXPECTED
 
+
+EXPECTED="define if_main = \"lo\"
+
+table netdev filter2 {
+       chain Main_Ingress2 {
+               type filter hook ingress devices = { \$if_main, d23456789012345x } priority -500; policy accept;
+       }
+}"
+
+rc=0
+$NFT -f - <<< $EXPECTED || rc=$?
+test "$rc" = 0
+cat <<EOF | $DIFF -u <($NFT list ruleset) -
+table netdev filter1 {
+       chain Main_Ingress1 {
+               type filter hook ingress device "lo" priority -500; policy accept;
+       }
+}
+table netdev filter2 {
+       chain Main_Ingress2 {
+               type filter hook ingress devices = { d23456789012345, lo } priority -500; policy accept;
+       }
+}
+EOF
+
+
 EXPECTED="define if_main = \"lo\"
 
 table netdev filter2 {
        chain Main_Ingress2 {
-               type filter hook ingress devices = { \$if_main, dummy0 } priority -500; policy accept;
+               type filter hook ingress devices = { \$if_main, d23456789012345 } priority -500; policy accept;
        }
 }"
 
 $NFT -f - <<< $EXPECTED
 
+
 if [ "$NFT_TEST_HAVE_netdev_egress" = n ] ; then
        echo "Skip parts of the test due to NFT_TEST_HAVE_netdev_egress=n"
        exit 77
 fi
 
-EXPECTED="define if_main = { lo, dummy0 }
+
+EXPECTED="define if_main = { lo, d23456789012345 }
 define lan_interfaces = { lo }
 
 table netdev filter3 {
@@ -43,4 +72,3 @@ table netdev filter3 {
 
 $NFT -f - <<< $EXPECTED
 
-
index 5ec230d0bcfa8277c277c78ef0e34d9338b25b55..84a908d33dee1dbee1760f56b02515f8556eead6 100644 (file)
@@ -5,12 +5,12 @@ table netdev filter1 {
 }
 table netdev filter2 {
        chain Main_Ingress2 {
-               type filter hook ingress devices = { dummy0, lo } priority -500; policy accept;
+               type filter hook ingress devices = { d23456789012345, lo } priority -500; policy accept;
        }
 }
 table netdev filter3 {
        chain Main_Ingress3 {
-               type filter hook ingress devices = { dummy0, lo } priority -500; policy accept;
+               type filter hook ingress devices = { d23456789012345, lo } priority -500; policy accept;
        }
 
        chain Main_Egress3 {