Skip to contentSkip to conversation

Revert "evaluate: relax type-checking for integer arguments in mark statements"

PATCH New Pablo Neira Ayuso 1 participant 1 message Mar 14, 2023 netfilter

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 Revert "evaluate: relax type-checking for integer arguments in mark statements"

This patch reverts eab3eb7f146c ("evaluate: relax type-checking for integer arguments in mark statements") since it might cause ruleset portability issues when moving a ruleset from little to big endian host (and vice-versa).

Let's revert this until we agree on what to do in this case.

---
 src/evaluate.c             |  8 ++------
 tests/py/ip/meta.t         |  2 --
 tests/py/ip/meta.t.json    | 20 --------------------
 tests/py/ip/meta.t.payload |  8 --------
 4 files changed, 2 insertions(+), 36 deletions(-)
src/evaluate.c +2 -6
index 47caf3b0d716..edc3c5cb04f3 100644
@@ -2733,12 +2733,8 @@ static int __stmt_evaluate_arg(struct eval_ctx *ctx, struct stmt *stmt,
 					 "expression has type %s with length %d",
 					 dtype->desc, (*expr)->dtype->desc,
 					 (*expr)->len);
-
-	if ((dtype->type == TYPE_MARK &&
-	     !datatype_equal(datatype_basetype(dtype), datatype_basetype((*expr)->dtype))) ||
-	    (dtype->type != TYPE_MARK &&
-	     (*expr)->dtype->type != TYPE_INTEGER &&
-	     !datatype_equal((*expr)->dtype, dtype)))
+	else if ((*expr)->dtype->type != TYPE_INTEGER &&
+		 !datatype_equal((*expr)->dtype, dtype))
 		return stmt_binary_error(ctx, *expr, stmt,		/* verdict vs invalid? */
 					 "datatype mismatch: expected %s, "
 					 "expression has type %s",
tests/py/ip/meta.t +0 -2
index 85eaf54ce723..5a05923a1ce1 100644
@@ -15,5 +15,3 @@ meta obrname "br0";fail
 
 meta sdif "lo" accept;ok
 meta sdifname != "vrf1" accept;ok
-
-meta mark set ip dscp;ok
tests/py/ip/meta.t.json +0 -20
index a93d7e781ce1..3df31ce381fc 100644
@@ -156,23 +156,3 @@
         }
     }
 ]
-
-# meta mark set ip dscp
-[
-    {
-        "mangle": {
-            "key": {
-                "meta": {
-                    "key": "mark"
-                }
-            },
-            "value": {
-                "payload": {
-                    "field": "dscp",
-                    "protocol": "ip"
-                }
-            }
-        }
-    }
-]
-
tests/py/ip/meta.t.payload +0 -8
index 1aa8d003b1d4..afde5cc13ac5 100644
@@ -51,11 +51,3 @@ ip test-ip4 input
   [ cmp eq reg 1 0x00000011 ]
   [ payload load 2b @ transport header + 2 => reg 1 ]
   [ cmp eq reg 1 0x00004300 ]
-
-# meta mark set ip dscp
-ip test-ip4 input
-  [ payload load 1b @ network header + 1 => reg 1 ]
-  [ bitwise reg 1 = ( reg 1 & 0x000000fc ) ^ 0x00000000 ]
-  [ bitwise reg 1 = ( reg 1 >> 0x00000002 ) ]
-  [ meta set mark with reg 1 ]
-
Signature · 1 line
2.30.2