]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
expression: typeof verdict needs verdict datatype
authorPablo Neira Ayuso <pablo@netfilter.org>
Mon, 28 Mar 2022 11:25:42 +0000 (13:25 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 29 Mar 2022 08:32:10 +0000 (10:32 +0200)
Otherwise listing breaks showing [invalid type] notice.

 # nft list ruleset
 table inet x {
        map y {
                typeof ip saddr : verdict
                elements = { 1.1.1.1 : 0x1010101 [invalid type] }
        }
 }

Update tests to cover this usecase.

Fixes: 4ab1e5e60779 ("src: allow use of 'verdict' in typeof definitions")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/expression.c
tests/shell/testcases/maps/dumps/typeof_maps_0.nft
tests/shell/testcases/maps/typeof_maps_0

index ea999f2e546c48f4f3da5fe1dd4aad1d2f4f5589..612f2c06d1b10797a549853370cc426ca7284590 100644 (file)
@@ -268,6 +268,7 @@ static struct expr *verdict_expr_parse_udata(const struct nftnl_udata *attr)
        struct expr *e;
 
        e = symbol_expr_alloc(&internal_location, SYMBOL_VALUE, NULL, "verdict");
+       e->dtype = &verdict_type;
        e->len = NFT_REG_SIZE * BITS_PER_BYTE;
        return e;
 }
index 438b9829db907a0246d68567f92db66e193aa578..ea411335cbd47b0d3c46f2105557a417eb5e34a8 100644 (file)
@@ -17,11 +17,14 @@ table inet t {
 
        map m4 {
                typeof iifname . ip protocol . th dport : verdict
+               elements = { "eth0" . tcp . 22 : accept }
        }
 
        chain c {
                ct mark set osf name map @m1
                meta mark set vlan id map @m2
                meta mark set ip saddr . ip daddr map @m3
+               iifname . ip protocol . th dport vmap @m4
+               iifname . ip protocol . th dport vmap { "eth0" . tcp . 22 : accept, "eth1" . udp . 67 : drop }
        }
 }
index f024ebe0f9f64c0658bddc2dacffe4e529494754..1014d8115fd9308e9b9aac26a1ef8ac0cee1ada2 100755 (executable)
@@ -24,12 +24,15 @@ EXPECTED="table inet t {
 
        map m4 {
                typeof        iifname . ip protocol . th dport : verdict
+               elements = { eth0 . tcp . 22 : accept }
        }
 
        chain c {
                ct mark set osf name map @m1
                ether type vlan meta mark set vlan id map @m2
                meta mark set ip saddr . ip daddr map @m3
+               iifname . ip protocol . th dport vmap @m4
+               iifname . ip protocol . th dport vmap { \"eth0\" . tcp . 22 : accept, \"eth1\" . udp . 67 : drop }
        }
 }"