]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
datatype: use DTYPE_F_PREFIX only for IP address datatype
authorPablo Neira Ayuso <pablo@netfilter.org>
Thu, 21 Mar 2024 11:40:53 +0000 (12:40 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 23 Jan 2025 00:35:35 +0000 (01:35 +0100)
commit a2a7fbdfdd7f8dc5baa4cc8a23753b96bbc8a433 upstream.

DTYPE_F_PREFIX flag provides a hint to the netlink delinearize path to
use prefix notation.

It seems use of prefix notation in meta mark causes confusion, users
expect to see prefix in the listing only in IP address datatypes.

Untoggle this flag so (more lengthy) binop output such as:

  meta mark & 0xffffff00 == 0xffffff00

is used instead.

Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1739
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/datatype.c
src/meta.c
src/rt.c
tests/py/any/meta.t
tests/py/any/meta.t.json

index ac0221a8d30406a2d848285d68f82176cd48b9ba..e5df3d3d2dc08093234e263a0361f07c18870519 100644 (file)
@@ -843,7 +843,6 @@ const struct datatype mark_type = {
        .print          = mark_type_print,
        .json           = mark_type_json,
        .parse          = mark_type_parse,
-       .flags          = DTYPE_F_PREFIX,
 };
 
 static const struct symbol_table icmp_code_tbl = {
index 62546397a968ccb53f70118e415d9c37d4746a75..71ed1033361663c03c62d7755c92d64d000e6bbd 100644 (file)
@@ -371,7 +371,6 @@ const struct datatype devgroup_type = {
        .print          = devgroup_type_print,
        .json           = devgroup_type_json,
        .parse          = devgroup_type_parse,
-       .flags          = DTYPE_F_PREFIX,
 };
 
 const struct datatype ifname_type = {
index d7aa5edd93a3c6312da31a94826f8533e5e1f8ff..48cc5fe61a93c76e8cf7cca6b9f0c305c911dd3f 100644 (file)
--- a/src/rt.c
+++ b/src/rt.c
@@ -55,7 +55,6 @@ const struct datatype realm_type = {
        .basetype       = &integer_type,
        .print          = realm_type_print,
        .parse          = realm_type_parse,
-       .flags          = DTYPE_F_PREFIX,
 };
 
 const struct rt_template rt_templates[] = {
index 12fabb79f5f997e104aec3bae6c2dbd2588d6ce5..05eb44d37b0f5138ee98b14941428c3476957dca 100644 (file)
@@ -56,7 +56,7 @@ meta mark and 0x03 == 0x01;ok;meta mark & 0x00000003 == 0x00000001
 meta mark and 0x03 != 0x01;ok;meta mark & 0x00000003 != 0x00000001
 meta mark 0x10;ok;meta mark 0x00000010
 meta mark != 0x10;ok;meta mark != 0x00000010
-meta mark 0xffffff00/24;ok
+meta mark 0xffffff00/24;ok;meta mark & 0xffffff00 == 0xffffff00
 
 meta mark or 0x03 == 0x01;ok;meta mark | 0x00000003 == 0x00000001
 meta mark or 0x03 != 0x01;ok;meta mark | 0x00000003 != 0x00000001
index 4734bbf90d41aa30166438fce134c7ed40b668a6..f3717f2672e4be097b6b7508963bdb083364e81f 100644 (file)
     {
         "match": {
             "left": {
-                "meta": {
-                    "key": "mark"
-                }
+                "&": [
+                    {
+                        "meta": {
+                            "key": "mark"
+                        }
+                    },
+                    4294967040
+                ]
             },
             "op": "==",
-            "right": {
-                "prefix": {
-                    "addr": 4294967040,
-                    "len": 24
-                }
-            }
+            "right": 4294967040
         }
     }
 ]