]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
tests: extend dtype test case to cover expression with integer type
authorFlorian Westphal <fw@strlen.de>
Wed, 3 Feb 2021 16:57:05 +0000 (17:57 +0100)
committerFlorian Westphal <fw@strlen.de>
Tue, 16 Feb 2021 14:10:39 +0000 (15:10 +0100)
... nft doesn't handle this correctly at the moment: they are added
as network byte order (invalid byte order).

ct zone has integer_type, the byte order has to be taken from the expression.

Signed-off-by: Florian Westphal <fw@strlen.de>
tests/shell/testcases/sets/0029named_ifname_dtype_0
tests/shell/testcases/sets/dumps/0029named_ifname_dtype_0.nft

index 39b3c90cf8dc5baf39fb845b39151769c0b2b92f..2dbcd22bb2ce1e7c1ee109cb150a892880ca5ed7 100755 (executable)
@@ -13,12 +13,53 @@ EXPECTED="table inet t {
                elements = { \"ssh\" . \"eth0\" }
        }
 
+       set nv {
+               type ifname . mark
+       }
+
+       set z {
+               typeof ct zone
+               elements = { 1 }
+       }
+
+       set m {
+               typeof meta mark
+               elements = { 1 }
+       }
+
+       map cz {
+               typeof meta iifname : ct zone
+               elements = { \"veth4\" : 1 }
+       }
+
+       map cm {
+               typeof meta iifname : ct mark
+               elements = { \"veth4\" : 1 }
+       }
+
        chain c {
                iifname @s accept
                oifname @s accept
                tcp dport . meta iifname @sc accept
+               meta iifname . meta mark @nv accept
        }
 }"
 
 set -e
 $NFT -f - <<< "$EXPECTED"
+$NFT add element inet t s '{ "eth1" }'
+$NFT add element inet t s '{ "eth2", "eth3", "veth1" }'
+
+$NFT add element inet t sc '{ 80 . "eth0" }'
+$NFT add element inet t sc '{ 80 . "eth0" }' || true
+$NFT add element inet t sc '{ 80 . "eth1" }'
+$NFT add element inet t sc '{ 81 . "eth0" }'
+
+$NFT add element inet t nv '{ "eth0" . 1 }'
+$NFT add element inet t nv '{ "eth0" . 2 }'
+
+$NFT add element inet t z '{ 2, 3, 4, 5, 6 }'
+$NFT add element inet t cz '{ "eth0" : 1,  "eth1" : 2 }'
+
+$NFT add element inet t m '{ 2, 3, 4, 5, 6 }'
+$NFT add element inet t cm '{ "eth0" : 1,  "eth1" : 2 }'
index 23ff89bb90e4567f08ec5d412abca0c5a59b31a3..55cd4f262b3502f29f440ba9c4815090c416701b 100644 (file)
@@ -1,17 +1,57 @@
 table inet t {
        set s {
                type ifname
-               elements = { "eth0" }
+               elements = { "eth0",
+                            "eth1",
+                            "eth2",
+                            "eth3",
+                            "veth1" }
        }
 
        set sc {
                type inet_service . ifname
-               elements = { 22 . "eth0" }
+               elements = { 22 . "eth0",
+                            80 . "eth0",
+                            81 . "eth0",
+                            80 . "eth1" }
+       }
+
+       set nv {
+               type ifname . mark
+               elements = { "eth0" . 0x00000001,
+                            "eth0" . 0x00000002 }
+       }
+
+       set z {
+               typeof ct zone
+               elements = { 1, 2, 3, 4, 5,
+                            6 }
+       }
+
+       set m {
+               typeof meta mark
+               elements = { 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005,
+                            0x00000006 }
+       }
+
+       map cz {
+               typeof iifname : ct zone
+               elements = { "eth0" : 1,
+                            "eth1" : 2,
+                            "veth4" : 1 }
+       }
+
+       map cm {
+               typeof iifname : ct mark
+               elements = { "eth0" : 0x00000001,
+                            "eth1" : 0x00000002,
+                            "veth4" : 0x00000001 }
        }
 
        chain c {
                iifname @s accept
                oifname @s accept
                tcp dport . iifname @sc accept
+               iifname . meta mark @nv accept
        }
 }