From a2a7fbdfdd7f8dc5baa4cc8a23753b96bbc8a433 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Thu, 21 Mar 2024 12:40:53 +0100 Subject: [PATCH] datatype: use DTYPE_F_PREFIX only for IP address datatype 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 --- src/datatype.c | 1 - src/meta.c | 1 - src/rt.c | 1 - tests/py/any/meta.t | 2 +- tests/py/any/meta.t.json | 18 +++++++++--------- 5 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/datatype.c b/src/datatype.c index 3205b214..b368ea91 100644 --- a/src/datatype.c +++ b/src/datatype.c @@ -1015,7 +1015,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 = { diff --git a/src/meta.c b/src/meta.c index eca8dac7..a17bacf0 100644 --- a/src/meta.c +++ b/src/meta.c @@ -363,7 +363,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 = { diff --git a/src/rt.c b/src/rt.c index d8f3352f..9320b832 100644 --- a/src/rt.c +++ b/src/rt.c @@ -61,7 +61,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[] = { diff --git a/tests/py/any/meta.t b/tests/py/any/meta.t index 718c7ad9..bd10c56d 100644 --- a/tests/py/any/meta.t +++ b/tests/py/any/meta.t @@ -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 diff --git a/tests/py/any/meta.t.json b/tests/py/any/meta.t.json index d50272de..2af3f623 100644 --- a/tests/py/any/meta.t.json +++ b/tests/py/any/meta.t.json @@ -667,17 +667,17 @@ { "match": { "left": { - "meta": { - "key": "mark" - } + "&": [ + { + "meta": { + "key": "mark" + } + }, + 4294967040 + ] }, "op": "==", - "right": { - "prefix": { - "addr": 4294967040, - "len": 24 - } - } + "right": 4294967040 } } ]