netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH nft] evaluate: incorrect byteorder with typeof and integer_datatype
@ 2020-04-29 10:38 Pablo Neira Ayuso
  0 siblings, 0 replies; only message in thread
From: Pablo Neira Ayuso @ 2020-04-29 10:38 UTC (permalink / raw)
  To: netfilter-devel

 table bridge t {
         set s3 {
                 typeof meta ibrpvid
                 elements = { 2, 3, 103 }
         }
 }

 # nft --debug=netlink -f test.nft
 s3 t 0
 s3 t 0
        element 00000100  : 0 [end]     element 00000200  : 0 [end]     element 00000300  : 0 [end]
                ^^^^^^^^

The integer_type uses BYTEORDER_INVALID byteorder (which is implicitly
handled as BYTEORDER_BIG_ENDIAN).

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 src/evaluate.c                                     | 3 ++-
 tests/shell/testcases/sets/dumps/typeof_sets_0.nft | 5 +++++
 tests/shell/testcases/sets/typeof_sets_0           | 5 +++++
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/evaluate.c b/src/evaluate.c
index 8c227eb11402..597141317000 100644
--- a/src/evaluate.c
+++ b/src/evaluate.c
@@ -3544,7 +3544,8 @@ static int set_evaluate(struct eval_ctx *ctx, struct set *set)
 
 	ctx->set = set;
 	if (set->init != NULL) {
-		expr_set_context(&ctx->ectx, set->key->dtype, set->key->len);
+		__expr_set_context(&ctx->ectx, set->key->dtype,
+				   set->key->byteorder, set->key->len, 0);
 		if (expr_evaluate(ctx, &set->init) < 0)
 			return -1;
 	}
diff --git a/tests/shell/testcases/sets/dumps/typeof_sets_0.nft b/tests/shell/testcases/sets/dumps/typeof_sets_0.nft
index 44e11202d299..565369fb7be5 100644
--- a/tests/shell/testcases/sets/dumps/typeof_sets_0.nft
+++ b/tests/shell/testcases/sets/dumps/typeof_sets_0.nft
@@ -9,6 +9,11 @@ table inet t {
 		elements = { 2, 3, 103 }
 	}
 
+	set s3 {
+		typeof meta ibrpvid
+		elements = { 2, 3, 103 }
+	}
+
 	chain c1 {
 		osf name @s1 accept
 	}
diff --git a/tests/shell/testcases/sets/typeof_sets_0 b/tests/shell/testcases/sets/typeof_sets_0
index 2a8b21c725c6..9b2712e56177 100755
--- a/tests/shell/testcases/sets/typeof_sets_0
+++ b/tests/shell/testcases/sets/typeof_sets_0
@@ -15,6 +15,11 @@ EXPECTED="table inet t {
 		elements = { 2, 3, 103 }
 	}
 
+	set s3 {
+		typeof meta ibrpvid
+		elements = { 2, 3, 103 }
+	}
+
 	chain c1 {
 		osf name @s1 accept
 	}
-- 
2.20.1


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

only message in thread, other threads:[~2020-04-29 10:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-29 10:38 [PATCH nft] evaluate: incorrect byteorder with typeof and integer_datatype Pablo Neira Ayuso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).