Skip to contentSkip to conversation

expression: typeof verdict needs verdict datatype

PATCH Superseded Pablo Neira Ayuso 1 participant 1 message Mar 28, 2022 netfilter

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 expression: typeof verdict needs verdict datatype

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")
---
 src/expression.c                                   | 1 +
 tests/shell/testcases/maps/dumps/typeof_maps_0.nft | 2 ++
 tests/shell/testcases/maps/typeof_maps_0           | 2 ++
 3 files changed, 5 insertions(+)
src/expression.c +1 -0
index ea999f2e546c..612f2c06d1b1 100644
@@ -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;
 }
tests/shell/testcases/maps/dumps/typeof_maps_0.nft +2 -0
index 438b9829db90..7315b0731d6d 100644
@@ -17,11 +17,13 @@ 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
 	}
 }
tests/shell/testcases/maps/typeof_maps_0 +2 -0
index f024ebe0f9f6..9e36c02f514f 100755
@@ -24,12 +24,14 @@ 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
 	}
 }"
 
Signature · 1 line
2.30.2