All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH nft] expression: typeof verdict needs verdict datatype
@ 2022-03-28 11:41 Pablo Neira Ayuso
  0 siblings, 0 replies; only message in thread
From: Pablo Neira Ayuso @ 2022-03-28 11:41 UTC (permalink / raw)
  To: netfilter-devel

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                                   | 1 +
 tests/shell/testcases/maps/dumps/typeof_maps_0.nft | 2 ++
 tests/shell/testcases/maps/typeof_maps_0           | 2 ++
 3 files changed, 5 insertions(+)

diff --git a/src/expression.c b/src/expression.c
index ea999f2e546c..612f2c06d1b1 100644
--- a/src/expression.c
+++ b/src/expression.c
@@ -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;
 }
diff --git a/tests/shell/testcases/maps/dumps/typeof_maps_0.nft b/tests/shell/testcases/maps/dumps/typeof_maps_0.nft
index 438b9829db90..7315b0731d6d 100644
--- a/tests/shell/testcases/maps/dumps/typeof_maps_0.nft
+++ b/tests/shell/testcases/maps/dumps/typeof_maps_0.nft
@@ -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
 	}
 }
diff --git a/tests/shell/testcases/maps/typeof_maps_0 b/tests/shell/testcases/maps/typeof_maps_0
index f024ebe0f9f6..9e36c02f514f 100755
--- a/tests/shell/testcases/maps/typeof_maps_0
+++ b/tests/shell/testcases/maps/typeof_maps_0
@@ -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
 	}
 }"
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-03-28 11:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-28 11:41 [PATCH nft] expression: typeof verdict needs verdict datatype Pablo Neira Ayuso

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.