Skip to contentSkip to conversation

Fix netlink debug output on Big Endian

PATCH In review Phil Sutter 2 participants 15 messages Nov 14, 2025 – Jan 28

Subsystems (2)
lore
Share & tools
lore

Phil Sutter

author reviewer
#0 lore raw

v2 cover Fix netlink debug output on Big Endian

Make use of recent changes to libnftnl to make test suites pass on both Little and Big Endian systems.

Changes since v1:
- First 12 patches accepted and pushed already, patches 27 and 28 as well
- Minimize changes to existing code: Drop patch 13 changing string-based expressions to be defined as Big Endian as well as related patches 14, 17 and 18
- Pull a fix for concatenated wildcard interface names upfront
- Follow with set element sorting changes, with improved patch descriptions and related test suite record changes folded into them for clarification of practical effect
- Review patch descriptions in general
- Add special casing to patch 5 to avoid string-based values being printed in reverse by libnftnl, also communicate any byteorder conversions from __netlink_gen_concat_key() back to caller for the same purpose

Patch 1 works around "funny" behaviour of GMP when partially exporting data and unwanted prefix-padding when exporting into an oversized buffer, all happening on Big Endian only.

Patches 2 and 3 deal with sorting of set elements. They are effective on Little Endian only, changing sort ordering to match that of Big Endian.

Patches 4 and 5 are preparation for the next two patches.

Patches 6 and 7 collect data for calls to newly introduced libnftnl API functions (in patch 8) to communicate byte order and component sizes in data regs to libnftnl.

Patch 10 contains the big payload records update, created with help from the script introduced in patch 9.

Patch 11 still contains the expr_print_debug() macro definition for use with printf-debugging.

Phil Sutter (11):
segtree: Fix range aggregation on Big Endian
mergesort: Fix sorting of string values
mergesort: Align concatenation sort order with Big Endian
intervals: Convert byte order implicitly
expression: Set range expression 'len' field
netlink: Introduce struct nft_data_linearize::byteorder
netlink: Introduce struct nft_data_linearize::sizes
netlink: Make use of nftnl_{expr,set_elem}_set_imm()
tests: py: tools: Add regen_payloads.sh
tests: py: Update payload records
utils: Introduce expr_print_debug()

 include/netlink.h                             |   2 +
 include/utils.h                               |   9 +
 src/evaluate.c                                |   1 +
 src/expression.c                              |   1 +
 src/intervals.c                               |  10 +-
 src/mergesort.c                               |  11 +-
 src/netlink.c                                 |  84 +++-
 src/netlink_linearize.c                       |  34 +-
 src/segtree.c                                 |   6 +-
 tests/py/any/ct.t.json.output                 |  20 +-
 tests/py/any/ct.t.payload                     |  89 ++--
 tests/py/any/meta.t.json.output               |  54 ---
 tests/py/any/meta.t.payload                   | 232 ++++-----
 tests/py/any/meta.t.payload.bridge            |  10 +-
 tests/py/any/queue.t.json.output              |   4 +-
 tests/py/any/queue.t.payload                  |   2 +-
 tests/py/any/rawpayload.t.payload             |  64 +--
 tests/py/any/rt.t.payload                     |   5 +-
 tests/py/any/tcpopt.t.json.output             |  77 ---
 tests/py/any/tcpopt.t.payload                 |  88 ++--
 tests/py/arp/arp.t.payload                    |  99 ++--
 tests/py/arp/arp.t.payload.netdev             | 189 ++++----
 tests/py/bridge/ether.t.payload               |  43 +-
 tests/py/bridge/icmpX.t.payload               |  25 +-
 tests/py/bridge/meta.t.payload                |  20 +-
 tests/py/bridge/redirect.t.payload            |   2 +-
 tests/py/bridge/reject.t.payload              |  43 +-
 tests/py/bridge/vlan.t.payload                | 262 +++++------
 tests/py/bridge/vlan.t.payload.netdev         | 316 ++++++-------
 tests/py/inet/ah.t.payload                    |  89 ++--
 tests/py/inet/comp.t.payload                  |  53 ++-
 tests/py/inet/ct.t.payload                    |  14 +-
 tests/py/inet/dccp.t.payload                  |  53 ++-
 tests/py/inet/dnat.t.payload                  |  47 +-
 tests/py/inet/esp.t.payload                   |  45 +-
 tests/py/inet/ether-ip.t.payload              |  22 +-
 tests/py/inet/ether-ip.t.payload.netdev       |  23 +-
 tests/py/inet/ether.t.payload                 |  37 +-
 tests/py/inet/ether.t.payload.bridge          |  29 +-
 tests/py/inet/ether.t.payload.ip              |  37 +-
 tests/py/inet/fib.t.payload                   |  12 +-
 tests/py/inet/geneve.t.payload                |  83 ++--
 tests/py/inet/gre.t.payload                   |  53 ++-
 tests/py/inet/gretap.t.payload                |  59 ++-
 tests/py/inet/icmp.t.payload                  |  37 +-
 tests/py/inet/icmpX.t.payload                 |  32 +-
 tests/py/inet/ip.t.payload                    |   4 +-
 tests/py/inet/ip.t.payload.bridge             |   4 +-
 tests/py/inet/ip.t.payload.inet               |   7 +-
 tests/py/inet/ip.t.payload.netdev             |   7 +-
 tests/py/inet/ip_tcp.t.payload                |  36 +-
 tests/py/inet/ip_tcp.t.payload.bridge         |  35 +-
 tests/py/inet/ip_tcp.t.payload.netdev         |  37 +-
 tests/py/inet/ipsec.t.payload                 |  11 +-
 tests/py/inet/map.t.payload                   |  11 +-
 tests/py/inet/map.t.payload.ip                |   7 +-
 tests/py/inet/map.t.payload.netdev            |  11 +-
 tests/py/inet/meta.t.payload                  |  83 ++--
 tests/py/inet/osf.t.json.output               |  54 +++
 tests/py/inet/osf.t.payload                   |  16 +-
 tests/py/inet/payloadmerge.t.payload          |  43 +-
 tests/py/inet/reject.t.payload.inet           |  43 +-
 tests/py/inet/rt.t.payload                    |   7 +-
 tests/py/inet/sctp.t.payload                  | 159 ++++---
 tests/py/inet/sets.t.payload.bridge           |  15 +-
 tests/py/inet/sets.t.payload.inet             |  14 +-
 tests/py/inet/sets.t.payload.netdev           |  14 +-
 tests/py/inet/snat.t.payload                  |  30 +-
 tests/py/inet/socket.t.payload                |   8 +-
 tests/py/inet/tcp.t.payload                   | 360 +++++++-------
 tests/py/inet/tproxy.t.payload                |  45 +-
 tests/py/inet/udp.t.payload                   | 112 ++---
 tests/py/inet/udplite.t.payload               |  81 ++--
 tests/py/inet/vmap.t.payload                  |  13 +-
 tests/py/inet/vmap.t.payload.netdev           |  13 +-
 tests/py/inet/vxlan.t.payload                 |  83 ++--
 tests/py/ip/ct.t.payload                      |  46 +-
 tests/py/ip/dnat.t.payload.ip                 | 117 +++--
 tests/py/ip/dup.t.payload                     |   7 +-
 tests/py/ip/ether.t.payload                   |  37 +-
 tests/py/ip/hash.t.payload                    |   2 +-
 tests/py/ip/icmp.t.payload.ip                 | 312 ++++++-------
 tests/py/ip/igmp.t.payload                    |  61 ++-
 tests/py/ip/ip.t.payload                      | 246 +++++-----
 tests/py/ip/ip.t.payload.bridge               | 440 +++++++++---------
 tests/py/ip/ip.t.payload.inet                 | 440 +++++++++---------
 tests/py/ip/ip.t.payload.netdev               | 434 ++++++++---------
 tests/py/ip/ip_tcp.t.payload                  |   9 +-
 tests/py/ip/masquerade.t.payload              |  71 ++-
 tests/py/ip/meta.t.payload                    |  32 +-
 tests/py/ip/numgen.t.payload                  |   4 +-
 tests/py/ip/objects.t.payload                 |  26 +-
 tests/py/ip/redirect.t.payload                | 121 +++--
 tests/py/ip/reject.t.payload                  |   3 +-
 tests/py/ip/rt.t.payload                      |   3 +-
 tests/py/ip/sets.t.payload.inet               |  38 +-
 tests/py/ip/sets.t.payload.ip                 |  12 +-
 tests/py/ip/sets.t.payload.netdev             |  38 +-
 tests/py/ip/snat.t.payload                    |  74 +--
 tests/py/ip/tcp.t.payload                     |  11 +-
 tests/py/ip/tproxy.t.payload                  |  29 +-
 tests/py/ip6/ct.t.payload                     |  12 +-
 tests/py/ip6/dnat.t.payload.ip6               |  38 +-
 tests/py/ip6/dst.t.payload.inet               |  60 +--
 tests/py/ip6/dst.t.payload.ip6                |  30 +-
 tests/py/ip6/dup.t.payload                    |   7 +-
 tests/py/ip6/ether.t.payload                  |  36 +-
 tests/py/ip6/exthdr.t.payload.ip6             |  25 +-
 tests/py/ip6/frag.t.payload.inet              | 131 +++---
 tests/py/ip6/frag.t.payload.ip6               |  75 ++-
 tests/py/ip6/frag.t.payload.netdev            | 131 +++---
 tests/py/ip6/hbh.t.payload.inet               |  65 ++-
 tests/py/ip6/hbh.t.payload.ip6                |  33 +-
 tests/py/ip6/icmpv6.t.payload.ip6             | 322 ++++++-------
 tests/py/ip6/ip6.t.payload.inet               | 359 +++++++-------
 tests/py/ip6/ip6.t.payload.ip6                | 191 ++++----
 tests/py/ip6/map.t.payload                    |   5 +-
 tests/py/ip6/masquerade.t.payload.ip6         |  71 ++-
 tests/py/ip6/meta.t.payload                   |  36 +-
 tests/py/ip6/mh.t.payload.inet                | 132 +++---
 tests/py/ip6/mh.t.payload.ip6                 |  66 +--
 tests/py/ip6/redirect.t.payload.ip6           | 105 +++--
 tests/py/ip6/reject.t.payload.ip6             |   3 +-
 tests/py/ip6/rt.t.payload.inet                | 121 +++--
 tests/py/ip6/rt.t.payload.ip6                 |  61 ++-
 tests/py/ip6/rt0.t.payload                    |   3 +-
 tests/py/ip6/sets.t.payload.inet              |  18 +-
 tests/py/ip6/sets.t.payload.ip6               |   4 +-
 tests/py/ip6/sets.t.payload.netdev            |  18 +-
 tests/py/ip6/snat.t.payload.ip6               |  23 +-
 tests/py/ip6/srh.t.payload                    |  23 +-
 tests/py/ip6/tproxy.t.payload                 |  29 +-
 tests/py/ip6/vmap.t.payload.inet              | 169 ++++---
 tests/py/ip6/vmap.t.payload.ip6               |  85 ++--
 tests/py/ip6/vmap.t.payload.netdev            | 169 ++++---
 tests/py/netdev/dup.t.payload                 |   3 +-
 tests/py/netdev/fwd.t.payload                 |   5 +-
 tests/py/netdev/reject.t.payload              |  41 +-
 tests/py/netdev/tunnel.t.payload              |   5 +-
 tests/py/tools/regen_payloads.sh              |  74 +++
 .../testcases/maps/dumps/0012map_0.json-nft   |  20 +-
 .../shell/testcases/maps/dumps/0012map_0.nft  |   8 +-
 .../maps/dumps/named_ct_objects.json-nft      |  12 +-
 .../testcases/maps/dumps/named_ct_objects.nft |   6 +-
 .../maps/dumps/typeof_integer_0.json-nft      |  12 +-
 .../testcases/maps/dumps/typeof_integer_0.nft |   4 +-
 .../dumps/0012different_defines_0.json-nft    |   8 +-
 .../nft-f/dumps/0012different_defines_0.nft   |   2 +-
 .../dumps/merge_nat_inet.json-nft             |  12 +-
 .../optimizations/dumps/merge_nat_inet.nft    |   2 +-
 .../optimizations/dumps/merge_reject.json-nft |  16 +-
 .../optimizations/dumps/merge_reject.nft      |   4 +-
 .../dumps/merge_stmts_concat.json-nft         |  42 +-
 .../dumps/merge_stmts_concat.nft              |   8 +-
 .../dumps/merge_stmts_concat_vmap.json-nft    |   4 +-
 .../dumps/merge_stmts_concat_vmap.nft         |   2 +-
 .../sets/dumps/0029named_ifname_dtype_0.nft   |   4 +-
 .../0037_set_with_inet_service_0.json-nft     |  12 +-
 .../dumps/0037_set_with_inet_service_0.nft    |   8 +-
 .../sets/dumps/sets_with_ifnames.json-nft     |   4 +-
 .../sets/dumps/sets_with_ifnames.nft          |   2 +-
 .../testcases/sets/dumps/typeof_sets_0.nft    |   4 +-
 tests/shell/testcases/sets/typeof_sets_0      |   4 +-
 163 files changed, 4743 insertions(+), 4744 deletions(-)
 create mode 100755 tests/py/tools/regen_payloads.sh
Signature · 1 line
2.51.0
author reviewer
#1 lore raw

PATCH v2 1/11 segtree: Fix range aggregation on Big Endian

Interface name wildcards are received as ranges from prefix with zero padding to prefix with ones padding. E.g. with "abcd*" (in hex):

61626364000000000000000000000000 - 61626364ffffffffffffffffffffffff

The faulty code tries to export the prefix from the lower boundary (r1) into a buffer, append "*" and allocate a constant expression from the resulting string. This does not work on Big Endian though:
mpz_export_data() seems to zero-pad data upon export and not necessarily respect the passed length value. Moreover, this padding appears in the first bytes of the buffer. The amount of padding seems illogical, too:
While a 6B prefix causes 2B padding and 8B prefix no padding, 10B prefix causes 4B padding and 12B prefix even 8B padding.

Work around the odd behaviour by exporting the full data into a larger buffer.

A similar issue is caused by increasing the constant expression's length to match the upper boundary data length: Data export when printing puts the padding upfront, so the resulting string starts with NUL-chars. Since this length adjustment seems not to have any effect in practice, just drop it.

Fixes 88b2345a215ef ("segtree: add pretty-print support for wildcard strings in concatenated sets")
---
 src/segtree.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
src/segtree.c +3 -3
index cf2b4f129096f..b9d6891e4b8f6 100644
@@ -409,16 +409,16 @@ void concat_range_aggregate(struct expr *set)
 			if (prefix_len >= 0 &&
 			    (prefix_len % BITS_PER_BYTE) == 0 &&
 			    string_type) {
+				unsigned int r1len = div_round_up(r1->len, BITS_PER_BYTE);
 				unsigned int str_len = prefix_len / BITS_PER_BYTE;
-				char data[str_len + 2];
+				char data[r1len + 1] = {};
 
-				mpz_export_data(data, r1->value, BYTEORDER_HOST_ENDIAN, str_len);
+				mpz_export_data(data, r1->value, BYTEORDER_HOST_ENDIAN, r1len);
 				data[str_len] = '*';
 
 				tmp = constant_expr_alloc(&r1->location, r1->dtype,
 							  BYTEORDER_HOST_ENDIAN,
 							  (str_len + 1) * BITS_PER_BYTE, data);
-				tmp->len = r2->len;
 				list_replace(&r2->list, &tmp->list);
 				r2_next = tmp->list.next;
 				expr_free(r2);
Signature · 1 line
2.51.0
author reviewer
#2 lore raw

PATCH v2 2/11 mergesort: Fix sorting of string values

In reply to Phil Sutter

Sorting order was obviously wrong, e.g. "ppp0" ordered before "eth1". Moreover, this happened on Little Endian only so sorting order actually depended on host's byteorder. By reimporting string values as Big Endian, both issues are fixed: On one hand, GMP-internal byteorder no longer depends on host's byteorder, on the other comparing strings really starts with the first character, not the last.

Fixes 14ee0a979b622 ("src: sort set elements in netlink_get_setelems()")
---
 src/mergesort.c                               |  7 +++
 tests/py/any/meta.t.json.output               | 54 -------------------
 tests/py/any/queue.t.json.output              |  4 +-
 tests/py/inet/osf.t.json.output               | 54 +++++++++++++++++++
 .../testcases/maps/dumps/0012map_0.json-nft   | 20 +++----
 .../shell/testcases/maps/dumps/0012map_0.nft  |  8 +--
 .../maps/dumps/named_ct_objects.json-nft      |  4 +-
 .../testcases/maps/dumps/named_ct_objects.nft |  4 +-
 .../sets/dumps/sets_with_ifnames.json-nft     |  4 +-
 .../sets/dumps/sets_with_ifnames.nft          |  2 +-
 10 files changed, 84 insertions(+), 77 deletions(-)
src/mergesort.c +7 -0
index a9cba614612ed..97e36917280f3 100644
@@ -37,6 +37,13 @@ static mpz_srcptr expr_msort_value(const struct expr *expr, mpz_t value)
 	case EXPR_RANGE:
 		return expr_msort_value(expr->left, value);
 	case EXPR_VALUE:
+		if (expr_basetype(expr)->type == TYPE_STRING) {
+			char buf[expr->len];
+
+			mpz_export_data(buf, expr->value, BYTEORDER_HOST_ENDIAN, expr->len);
+			mpz_import_data(value, buf, BYTEORDER_BIG_ENDIAN, expr->len);
+			return value;
+		}
 		return expr->value;
 	case EXPR_RANGE_VALUE:
 		return expr->range.low;
tests/py/any/meta.t.json.output +0 -54

60 lines not on this page · raw message

tests/py/any/queue.t.json.output +2 -2
index ea3722383f113..90670cc938866 100644
@@ -104,11 +104,11 @@
                                 0
                             ],
                             [
-                                "ppp0",
+                                "eth1",
                                 2
                             ],
                             [
-                                "eth1",
+                                "ppp0",
                                 2
                             ]
                         ]
tests/py/inet/osf.t.json.output +54 -0

63 lines not on this page · raw message

tests/shell/testcases/maps/dumps/0012map_0.json-nft +10 -10
index 2892e11d71f54..6c885703ffd6b 100644
@@ -32,21 +32,21 @@
         "map": "verdict",
         "elem": [
           [
-            "lo",
+            "eth0",
             {
-              "accept": null
+              "drop": null
             }
           ],
           [
-            "eth0",
+            "eth1",
             {
               "drop": null
             }
           ],
           [
-            "eth1",
+            "lo",
             {
-              "drop": null
+              "accept": null
             }
           ]
         ]
@@ -69,21 +69,21 @@
               "data": {
                 "set": [
                   [
-                    "lo",
+                    "eth0",
                     {
-                      "accept": null
+                      "drop": null
                     }
                   ],
                   [
-                    "eth0",
+                    "eth1",
                     {
                       "drop": null
                     }
                   ],
                   [
-                    "eth1",
+                    "lo",
                     {
-                      "drop": null
+                      "accept": null
                     }
                   ]
                 ]
tests/shell/testcases/maps/dumps/0012map_0.nft +4 -4
index e734fc1c70b93..0df329a550518 100644
@@ -1,12 +1,12 @@
 table ip x {
 	map z {
 		type ifname : verdict
-		elements = { "lo" : accept,
-			     "eth0" : drop,
-			     "eth1" : drop }
+		elements = { "eth0" : drop,
+			     "eth1" : drop,
+			     "lo" : accept }
 	}
 
 	chain y {
-		iifname vmap { "lo" : accept, "eth0" : drop, "eth1" : drop }
+		iifname vmap { "eth0" : drop, "eth1" : drop, "lo" : accept }
 	}
 }
tests/shell/testcases/maps/dumps/named_ct_objects.json-nft +2 -2
index c0f270e372b24..34c8798dee8fb 100644
@@ -195,8 +195,8 @@
         },
         "handle": 0,
         "elem": [
-          "sip",
-          "ftp"
+          "ftp",
+          "sip"
         ]
       }
     },
tests/shell/testcases/maps/dumps/named_ct_objects.nft +2 -2
index 59f18932b28ad..dab683bf5cdbd 100644
@@ -50,8 +50,8 @@ table inet t {
 
 	set helpname {
 		typeof ct helper
-		elements = { "sip",
-			     "ftp" }
+		elements = { "ftp",
+			     "sip" }
 	}
 
 	chain y {
tests/shell/testcases/sets/dumps/sets_with_ifnames.json-nft +2 -2
index ac4284293c32a..7b4849e0530d3 100644
@@ -260,8 +260,8 @@
               },
               "right": {
                 "set": [
-                  "eth0",
-                  "abcdef0"
+                  "abcdef0",
+                  "eth0"
                 ]
               }
             }
tests/shell/testcases/sets/dumps/sets_with_ifnames.nft +1 -1
index 77a8baf58cef2..8abca03a080ec 100644
@@ -39,7 +39,7 @@ table inet testifsets {
 	chain v4icmp {
 		iifname @simple counter packets 0 bytes 0
 		iifname @simple_wild counter packets 0 bytes 0
-		iifname { "eth0", "abcdef0" } counter packets 0 bytes 0
+		iifname { "abcdef0", "eth0" } counter packets 0 bytes 0
 		iifname { "abcdef*", "eth0" } counter packets 0 bytes 0
 		iifname vmap @map_wild
 	}
Signature · 1 line
2.51.0
#3 lore raw

Re: [nft PATCH v2 02/11] mergesort: Fix sorting of string values

Quoted 27 lines · Phil Sutter

Sorting order was obviously wrong, e.g. "ppp0" ordered before "eth1". Moreover, this happened on Little Endian only so sorting order actually depended on host's byteorder. By reimporting string values as Big Endian, both issues are fixed: On one hand, GMP-internal byteorder no longer depends on host's byteorder, on the other comparing strings really starts with the first character, not the last.

Fixes 14ee0a979b622 ("src: sort set elements in netlink_get_setelems()")
---
 src/mergesort.c                               |  7 +++
 tests/py/any/meta.t.json.output               | 54 -------------------
 tests/py/any/queue.t.json.output              |  4 +-
 tests/py/inet/osf.t.json.output               | 54 +++++++++++++++++++
 .../testcases/maps/dumps/0012map_0.json-nft   | 20 +++----
 .../shell/testcases/maps/dumps/0012map_0.nft  |  8 +--
 .../maps/dumps/named_ct_objects.json-nft      |  4 +-
 .../testcases/maps/dumps/named_ct_objects.nft |  4 +-
 .../sets/dumps/sets_with_ifnames.json-nft     |  4 +-
 .../sets/dumps/sets_with_ifnames.nft          |  2 +-
 10 files changed, 84 insertions(+), 77 deletions(-)
src/mergesort.c +0 -0
index a9cba614612ed..97e36917280f3 100644

src/mergesort.c static mpz_srcptr expr_msort_value(const struct expr *expr, mpz_t value) · line 46

Quoted 10 lines
src/mergesort.c +7 -0
@@ -37,6 +37,13 @@ static mpz_srcptr expr_msort_value(const struct expr *expr, mpz_t value)
 	case EXPR_RANGE:
 		return expr_msort_value(expr->left, value);
 	case EXPR_VALUE:
+		if (expr_basetype(expr)->type == TYPE_STRING) {
+			char buf[expr->len];
+
+			mpz_export_data(buf, expr->value, BYTEORDER_HOST_ENDIAN, expr->len);
+			mpz_import_data(value, buf, BYTEORDER_BIG_ENDIAN, expr->len);
+			return value;
+		}

This is also used for automerge, not only get_setelems().

Are you sure this is correct?

Quoted 295 lines
src/mergesort.c +0 -0
 		return expr->value;
 	case EXPR_RANGE_VALUE:
 		return expr->range.low;
tests/py/any/meta.t.json.output +0 -54
index 8f4d597a5034e..4454bb960385d 100644
@@ -233,60 +233,6 @@
     }
 ]
 
-# meta iifname {"dummy0", "lo"}
-[
-    {
-        "match": {
-            "left": {
-                "meta": { "key": "iifname" }
-            },
-	    "op": "==",
-            "right": {
-                "set": [
-                    "lo",
-                    "dummy0"
-                ]
-            }
-        }
-    }
-]
-
-# meta iifname != {"dummy0", "lo"}
-[
-    {
-        "match": {
-            "left": {
-                "meta": { "key": "iifname" }
-            },
-            "op": "!=",
-            "right": {
-                "set": [
-                    "lo",
-                    "dummy0"
-                ]
-            }
-        }
-    }
-]
-
-# meta oifname { "dummy0", "lo"}
-[
-    {
-        "match": {
-            "left": {
-                "meta": { "key": "oifname" }
-            },
-	    "op": "==",
-            "right": {
-                "set": [
-                    "lo",
-                    "dummy0"
-                ]
-            }
-        }
-    }
-]
-
 # meta skuid {"bin", "root", "daemon"} accept
 [
     {
tests/py/any/queue.t.json.output +2 -2
index ea3722383f113..90670cc938866 100644
@@ -104,11 +104,11 @@
                                 0
                             ],
                             [
-                                "ppp0",
+                                "eth1",
                                 2
                             ],
                             [
-                                "eth1",
+                                "ppp0",
                                 2
                             ]
                         ]
tests/py/inet/osf.t.json.output +54 -0
index 922e395f202c7..77ca7e30e0f77 100644
@@ -18,6 +18,26 @@
     }
 ]
 
+# osf version { "Windows:XP", "MacOs:Sierra" }
+[
+    {
+        "match": {
+            "left": {
+                "osf": {
+                    "key": "version"
+                }
+            },
+            "op": "==",
+            "right": {
+                "set": [
+                    "MacOs:Sierra",
+                    "Windows:XP"
+                ]
+            }
+        }
+    }
+]
+
 # ct mark set osf name map { "Windows" : 0x00000001, "MacOs" : 0x00000002 }
 [
     {
@@ -51,3 +71,37 @@
         }
     }
 ]
+
+# ct mark set osf version map { "Windows:XP" : 0x00000003, "MacOs:Sierra" : 0x00000004 }
+[
+    {
+        "mangle": {
+            "key": {
+                "ct": {
+                    "key": "mark"
+                }
+            },
+            "value": {
+                "map": {
+                    "data": {
+                        "set": [
+                            [
+                                "MacOs:Sierra",
+                                4
+                            ],
+                            [
+                                "Windows:XP",
+                                3
+                            ]
+                        ]
+                    },
+                    "key": {
+                        "osf": {
+                            "key": "version"
+                        }
+                    }
+                }
+            }
+        }
+    }
+]
tests/shell/testcases/maps/dumps/0012map_0.json-nft +10 -10
index 2892e11d71f54..6c885703ffd6b 100644
@@ -32,21 +32,21 @@
         "map": "verdict",
         "elem": [
           [
-            "lo",
+            "eth0",
             {
-              "accept": null
+              "drop": null
             }
           ],
           [
-            "eth0",
+            "eth1",
             {
               "drop": null
             }
           ],
           [
-            "eth1",
+            "lo",
             {
-              "drop": null
+              "accept": null
             }
           ]
         ]
@@ -69,21 +69,21 @@
               "data": {
                 "set": [
                   [
-                    "lo",
+                    "eth0",
                     {
-                      "accept": null
+                      "drop": null
                     }
                   ],
                   [
-                    "eth0",
+                    "eth1",
                     {
                       "drop": null
                     }
                   ],
                   [
-                    "eth1",
+                    "lo",
                     {
-                      "drop": null
+                      "accept": null
                     }
                   ]
                 ]
tests/shell/testcases/maps/dumps/0012map_0.nft +4 -4
index e734fc1c70b93..0df329a550518 100644
@@ -1,12 +1,12 @@
 table ip x {
 	map z {
 		type ifname : verdict
-		elements = { "lo" : accept,
-			     "eth0" : drop,
-			     "eth1" : drop }
+		elements = { "eth0" : drop,
+			     "eth1" : drop,
+			     "lo" : accept }
 	}
 
 	chain y {
-		iifname vmap { "lo" : accept, "eth0" : drop, "eth1" : drop }
+		iifname vmap { "eth0" : drop, "eth1" : drop, "lo" : accept }
 	}
 }
tests/shell/testcases/maps/dumps/named_ct_objects.json-nft +2 -2
index c0f270e372b24..34c8798dee8fb 100644
@@ -195,8 +195,8 @@
         },
         "handle": 0,
         "elem": [
-          "sip",
-          "ftp"
+          "ftp",
+          "sip"
         ]
       }
     },
tests/shell/testcases/maps/dumps/named_ct_objects.nft +2 -2
index 59f18932b28ad..dab683bf5cdbd 100644
@@ -50,8 +50,8 @@ table inet t {
 
 	set helpname {
 		typeof ct helper
-		elements = { "sip",
-			     "ftp" }
+		elements = { "ftp",
+			     "sip" }
 	}
 
 	chain y {
tests/shell/testcases/sets/dumps/sets_with_ifnames.json-nft +2 -2
index ac4284293c32a..7b4849e0530d3 100644
@@ -260,8 +260,8 @@
               },
               "right": {
                 "set": [
-                  "eth0",
-                  "abcdef0"
+                  "abcdef0",
+                  "eth0"
                 ]
               }
             }
tests/shell/testcases/sets/dumps/sets_with_ifnames.nft +1 -1
index 77a8baf58cef2..8abca03a080ec 100644
@@ -39,7 +39,7 @@ table inet testifsets {
 	chain v4icmp {
 		iifname @simple counter packets 0 bytes 0
 		iifname @simple_wild counter packets 0 bytes 0
-		iifname { "eth0", "abcdef0" } counter packets 0 bytes 0
+		iifname { "abcdef0", "eth0" } counter packets 0 bytes 0
 		iifname { "abcdef*", "eth0" } counter packets 0 bytes 0
 		iifname vmap @map_wild
 	}
Signature · 1 line
2.51.0
author reviewer
#4 lore raw

Re: [nft PATCH v2 02/11] mergesort: Fix sorting of string values

Quoted 41 lines · Pablo Neira Ayuso
Quoted 27 lines · Phil Sutter

Sorting order was obviously wrong, e.g. "ppp0" ordered before "eth1". Moreover, this happened on Little Endian only so sorting order actually depended on host's byteorder. By reimporting string values as Big Endian, both issues are fixed: On one hand, GMP-internal byteorder no longer depends on host's byteorder, on the other comparing strings really starts with the first character, not the last.

Fixes 14ee0a979b622 ("src: sort set elements in netlink_get_setelems()")
---
 src/mergesort.c                               |  7 +++
 tests/py/any/meta.t.json.output               | 54 -------------------
 tests/py/any/queue.t.json.output              |  4 +-
 tests/py/inet/osf.t.json.output               | 54 +++++++++++++++++++
 .../testcases/maps/dumps/0012map_0.json-nft   | 20 +++----
 .../shell/testcases/maps/dumps/0012map_0.nft  |  8 +--
 .../maps/dumps/named_ct_objects.json-nft      |  4 +-
 .../testcases/maps/dumps/named_ct_objects.nft |  4 +-
 .../sets/dumps/sets_with_ifnames.json-nft     |  4 +-
 .../sets/dumps/sets_with_ifnames.nft          |  2 +-
 10 files changed, 84 insertions(+), 77 deletions(-)
src/mergesort.c +0 -0
index a9cba614612ed..97e36917280f3 100644

src/mergesort.c static mpz_srcptr expr_msort_value(const struct expr *expr, mpz_t value) · line 46

Quoted 10 lines
src/mergesort.c +7 -0
@@ -37,6 +37,13 @@ static mpz_srcptr expr_msort_value(const struct expr *expr, mpz_t value)
 	case EXPR_RANGE:
 		return expr_msort_value(expr->left, value);
 	case EXPR_VALUE:
+		if (expr_basetype(expr)->type == TYPE_STRING) {
+			char buf[expr->len];
+
+			mpz_export_data(buf, expr->value, BYTEORDER_HOST_ENDIAN, expr->len);
+			mpz_import_data(value, buf, BYTEORDER_BIG_ENDIAN, expr->len);
+			return value;
+		}

This is also used for automerge, not only get_setelems().

Quoted 1 line

Are you sure this is correct?

If it isn't, we don't have test coverage for the broken code-path.

Cheers, Phil

author reviewer
#5 lore raw

PATCH v2 3/11 mergesort: Align concatenation sort order with Big Endian

In reply to Phil Sutter

By exporting all concat components in a way independent from host byteorder and importing that blob of data in the same way aligns sort order between hosts of different Endianness.

Fixes 741a06ac15d2b ("mergesort: find base value expression type via recursion")
---
 src/mergesort.c                               |  4 +-
 tests/py/any/ct.t.json.output                 | 20 ++---
 tests/py/any/tcpopt.t.json.output             | 77 -------------------
 .../maps/dumps/named_ct_objects.json-nft      |  8 +-
 .../testcases/maps/dumps/named_ct_objects.nft |  2 +-
 .../maps/dumps/typeof_integer_0.json-nft      | 12 +--
 .../testcases/maps/dumps/typeof_integer_0.nft |  4 +-
 .../dumps/0012different_defines_0.json-nft    |  8 +-
 .../nft-f/dumps/0012different_defines_0.nft   |  2 +-
 .../dumps/merge_nat_inet.json-nft             | 12 +--
 .../optimizations/dumps/merge_nat_inet.nft    |  2 +-
 .../optimizations/dumps/merge_reject.json-nft | 16 ++--
 .../optimizations/dumps/merge_reject.nft      |  4 +-
 .../dumps/merge_stmts_concat.json-nft         | 42 +++++-----
 .../dumps/merge_stmts_concat.nft              |  8 +-
 .../dumps/merge_stmts_concat_vmap.json-nft    |  4 +-
 .../dumps/merge_stmts_concat_vmap.nft         |  2 +-
 .../sets/dumps/0029named_ifname_dtype_0.nft   |  4 +-
 .../0037_set_with_inet_service_0.json-nft     | 12 +--
 .../dumps/0037_set_with_inet_service_0.nft    |  8 +-
 .../testcases/sets/dumps/typeof_sets_0.nft    |  4 +-
 tests/shell/testcases/sets/typeof_sets_0      |  4 +-
 22 files changed, 91 insertions(+), 168 deletions(-)
src/mergesort.c +2 -2
index 97e36917280f3..7b318423a572b 100644
@@ -20,11 +20,11 @@ static void concat_expr_msort_value(const struct expr *expr, mpz_t value)
 
 	list_for_each_entry(i, &expr_concat(expr)->expressions, list) {
 		ilen = div_round_up(i->len, BITS_PER_BYTE);
-		mpz_export_data(data + len, i->value, i->byteorder, ilen);
+		mpz_export_data(data + len, i->value, BYTEORDER_BIG_ENDIAN, ilen);
 		len += ilen;
 	}
 
-	mpz_import_data(value, data, BYTEORDER_HOST_ENDIAN, len);
+	mpz_import_data(value, data, BYTEORDER_BIG_ENDIAN, len);
 }
 
 static mpz_srcptr expr_msort_value(const struct expr *expr, mpz_t value)
tests/py/any/ct.t.json.output +10 -10
index 82634c2da6720..3f7959301354a 100644
@@ -494,14 +494,14 @@
                 "set": [
                     {
                         "concat": [
-                            "new",
-                            305419896
+                            "established",
+                            309876276
                         ]
                     },
                     {
                         "concat": [
-                            "established",
-                            309876276
+                            "new",
+                            305419896
                         ]
                     },
                     {
@@ -578,23 +578,23 @@
                     [
                         {
                             "concat": [
-                                "new",
-                                305419896
+                                "established",
+                                2271560481
                             ]
                         },
                         {
-                            "drop": null
+                            "accept": null
                         }
                     ],
                     [
                         {
                             "concat": [
-                                "established",
-                                2271560481
+                                "new",
+                                305419896
                             ]
                         },
                         {
-                            "accept": null
+                            "drop": null
                         }
                     ]
                 ]
tests/py/any/tcpopt.t.json.output +0 -77

80 lines not on this page · raw message

tests/shell/testcases/maps/dumps/named_ct_objects.json-nft +4 -4
index 34c8798dee8fb..21ab05653a6d3 100644
@@ -318,8 +318,8 @@
                     [
                       {
                         "concat": [
-                          "feed::17",
-                          512
+                          "dead::beef",
+                          123
                         ]
                       },
                       "exp2"
@@ -327,8 +327,8 @@
                     [
                       {
                         "concat": [
-                          "dead::beef",
-                          123
+                          "feed::17",
+                          512
                         ]
                       },
                       "exp2"
tests/shell/testcases/maps/dumps/named_ct_objects.nft +1 -1
index dab683bf5cdbd..18b52eb16a052 100644
@@ -58,7 +58,7 @@ table inet t {
 		ct expectation set ip saddr map @exp
 		ct expectation set ip6 saddr map { dead::beef : "exp2" }
 		ct expectation set ip6 daddr map { dead::beef : "exp2", feed::17 : "exp2" }
-		ct expectation set ip6 daddr . tcp dport map { feed::17 . 512 : "exp2", dead::beef . 123 : "exp2" }
+		ct expectation set ip6 daddr . tcp dport map { dead::beef . 123 : "exp2", feed::17 . 512 : "exp2" }
 		ct helper set ip6 saddr map { 1c3::c01d : "myftp", dead::beef : "myftp" }
 		ct helper set ip6 saddr map @helpobj
 		ct timeout set ip daddr map @timeoutmap
tests/shell/testcases/maps/dumps/typeof_integer_0.json-nft +6 -6
index 1df729b40a74f..65474c9e2a1b1 100644
@@ -117,23 +117,23 @@
           [
             {
               "concat": [
-                30,
-                30
+                20,
+                36
               ]
             },
             {
-              "drop": null
+              "accept": null
             }
           ],
           [
             {
               "concat": [
-                20,
-                36
+                30,
+                30
               ]
             },
             {
-              "accept": null
+              "drop": null
             }
           ]
         ]
tests/shell/testcases/maps/dumps/typeof_integer_0.nft +2 -2
index 19c24febffcc5..7bd7daaad7610 100644
@@ -8,8 +8,8 @@ table inet t {
 
 	map m2 {
 		typeof udp length . @ih,32,32 : verdict
-		elements = { 30 . 0x1e : drop,
-			     20 . 0x24 : accept }
+		elements = { 20 . 0x24 : accept,
+			     30 . 0x1e : drop }
 	}
 
 	chain c {
tests/shell/testcases/nft-f/dumps/0012different_defines_0.json-nft +4 -4
index 0e7ea228501b4..e266bf4c8a698 100644
@@ -361,14 +361,14 @@
                 "set": [
                   {
                     "concat": [
-                      "fe0::2",
-                      "tcp"
+                      "fe0::1",
+                      "udp"
                     ]
                   },
                   {
                     "concat": [
-                      "fe0::1",
-                      "udp"
+                      "fe0::2",
+                      "tcp"
                     ]
                   }
                 ]
tests/shell/testcases/nft-f/dumps/0012different_defines_0.nft +1 -1
index 4734b2fd8bd13..a6e16e7dd0336 100644
@@ -8,7 +8,7 @@ table inet t {
 		ip6 daddr fe0::1 ip6 saddr fe0::2
 		ip saddr vmap { 10.0.0.0 : drop, 10.0.0.2 : accept }
 		ip6 daddr vmap { fe0::1 : drop, fe0::2 : accept }
-		ip6 saddr . ip6 nexthdr { fe0::2 . tcp, fe0::1 . udp }
+		ip6 saddr . ip6 nexthdr { fe0::1 . udp, fe0::2 . tcp }
 		ip daddr . iif vmap { 10.0.0.0 . "lo" : accept }
 		tcp dport 100-222
 		udp dport vmap { 100-222 : accept }
tests/shell/testcases/optimizations/dumps/merge_nat_inet.json-nft +6 -6
index 99930f112ec69..7df802e6bd90b 100644
@@ -93,14 +93,14 @@
                         {
                           "concat": [
                             "enp2s0",
-                            "72.2.3.70",
-                            80
+                            "72.2.3.66",
+                            443
                           ]
                         },
                         {
                           "concat": [
                             "10.1.1.52",
-                            80
+                            443
                           ]
                         }
                       ],
@@ -123,14 +123,14 @@
                         {
                           "concat": [
                             "enp2s0",
-                            "72.2.3.66",
-                            443
+                            "72.2.3.70",
+                            80
                           ]
                         },
                         {
                           "concat": [
                             "10.1.1.52",
-                            443
+                            80
                           ]
                         }
                       ]
tests/shell/testcases/optimizations/dumps/merge_nat_inet.nft +1 -1
index a1a1135482b95..1e08d5a5a1229 100644
@@ -1,7 +1,7 @@
 table inet nat {
 	chain prerouting {
 		oif "lo" accept
-		dnat ip to iifname . ip daddr . tcp dport map { "enp2s0" . 72.2.3.70 . 80 : 10.1.1.52 . 80, "enp2s0" . 72.2.3.66 . 53122 : 10.1.1.10 . 22, "enp2s0" . 72.2.3.66 . 443 : 10.1.1.52 . 443 }
+		dnat ip to iifname . ip daddr . tcp dport map { "enp2s0" . 72.2.3.66 . 443 : 10.1.1.52 . 443, "enp2s0" . 72.2.3.66 . 53122 : 10.1.1.10 . 22, "enp2s0" . 72.2.3.70 . 80 : 10.1.1.52 . 80 }
 	}
 
 	chain postrouting {
tests/shell/testcases/optimizations/dumps/merge_reject.json-nft +8 -8
index 46ed0677d203e..8f468e019657c 100644
@@ -101,15 +101,15 @@
                   {
                     "concat": [
                       "tcp",
-                      "172.30.238.117",
-                      8080
+                      "172.30.33.71",
+                      3306
                     ]
                   },
                   {
                     "concat": [
                       "tcp",
-                      "172.30.33.71",
-                      3306
+                      "172.30.238.117",
+                      8080
                     ]
                   },
                   {
@@ -234,15 +234,15 @@
                   {
                     "concat": [
                       "tcp",
-                      "aaaa::3",
-                      8080
+                      "aaaa::2",
+                      3306
                     ]
                   },
                   {
                     "concat": [
                       "tcp",
-                      "aaaa::2",
-                      3306
+                      "aaaa::3",
+                      8080
                     ]
                   },
                   {
tests/shell/testcases/optimizations/dumps/merge_reject.nft +2 -2
index c29ad6d5648b6..1727d024866d7 100644
@@ -1,13 +1,13 @@
 table ip x {
 	chain y {
 		ip daddr 172.30.33.70 tcp dport 3306 counter packets 0 bytes 0 drop
-		meta l4proto . ip daddr . tcp dport { tcp . 172.30.238.117 . 8080, tcp . 172.30.33.71 . 3306, tcp . 172.30.254.251 . 3306 } counter packets 0 bytes 0 reject
+		meta l4proto . ip daddr . tcp dport { tcp . 172.30.33.71 . 3306, tcp . 172.30.238.117 . 8080, tcp . 172.30.254.251 . 3306 } counter packets 0 bytes 0 reject
 		ip daddr 172.30.254.252 tcp dport 3306 counter packets 0 bytes 0 reject with tcp reset
 	}
 }
 table ip6 x {
 	chain y {
-		meta l4proto . ip6 daddr . tcp dport { tcp . aaaa::3 . 8080, tcp . aaaa::2 . 3306, tcp . aaaa::4 . 3306 } counter packets 0 bytes 0 reject
+		meta l4proto . ip6 daddr . tcp dport { tcp . aaaa::2 . 3306, tcp . aaaa::3 . 8080, tcp . aaaa::4 . 3306 } counter packets 0 bytes 0 reject
 		ip6 daddr aaaa::5 tcp dport 3306 counter packets 0 bytes 0 reject with tcp reset
 	}
 }
tests/shell/testcases/optimizations/dumps/merge_stmts_concat.json-nft +21 -21

104 lines not on this page · raw message

tests/shell/testcases/optimizations/dumps/merge_stmts_concat.nft +4 -4
index d00ac417ca759..6150258512061 100644
@@ -2,18 +2,18 @@ table ip x {
 	chain y {
 		iifname . ip saddr . ip daddr { "eth1" . 1.1.1.1 . 2.2.2.3, "eth1" . 1.1.1.2 . 2.2.2.4, "eth1" . 1.1.1.2 . 2.2.3.0/24, "eth1" . 1.1.1.2 . 2.2.4.0-2.2.4.10, "eth2" . 1.1.1.3 . 2.2.2.5 } accept
 		ip protocol . th dport { tcp . 22, udp . 67 }
-		udp dport . ct state { 137 . new, 138 . new, 137 . untracked, 138 . untracked } accept
+		udp dport . ct state { 137 . new, 137 . untracked, 138 . new, 138 . untracked } accept
 	}
 
 	chain c1 {
-		udp dport . iifname { 51820 . "foo", 514 . "bar", 67 . "bar" } accept
+		udp dport . iifname { 67 . "bar", 514 . "bar", 51820 . "foo" } accept
 	}
 
 	chain c2 {
-		udp dport . iifname { 100 . "foo", 51820 . "foo", 514 . "bar", 67 . "bar" } accept
+		udp dport . iifname { 67 . "bar", 100 . "foo", 514 . "bar", 51820 . "foo" } accept
 	}
 
 	chain c3 {
-		udp dport . iifname { 100 . "foo", 51820 . "foo", 514 . "bar", 67 . "bar", 100 . "test", 51820 . "test" } accept
+		udp dport . iifname { 67 . "bar", 100 . "foo", 100 . "test", 514 . "bar", 51820 . "foo", 51820 . "test" } accept
 	}
 }
tests/shell/testcases/optimizations/dumps/merge_stmts_concat_vmap.json-nft +2 -2
index 5dfa40a821ebe..5259e5647cf08 100644
@@ -60,7 +60,7 @@
                     {
                       "concat": [
                         "broadcast",
-                        547
+                        67
                       ]
                     },
                     {
@@ -71,7 +71,7 @@
                     {
                       "concat": [
                         "broadcast",
-                        67
+                        547
                       ]
                     },
                     {
tests/shell/testcases/optimizations/dumps/merge_stmts_concat_vmap.nft +1 -1
index 780aa09adbe65..81abb99464e0a 100644
@@ -1,6 +1,6 @@
 table ip x {
 	chain x {
-		meta pkttype . udp dport vmap { broadcast . 547 : accept, broadcast . 67 : accept, multicast . 1900 : drop }
+		meta pkttype . udp dport vmap { broadcast . 67 : accept, broadcast . 547 : accept, multicast . 1900 : drop }
 	}
 
 	chain y {
tests/shell/testcases/sets/dumps/0029named_ifname_dtype_0.nft +2 -2
index 6f9832a96188f..e75d8a960e7d0 100644
@@ -12,8 +12,8 @@ table inet t {
 		type inet_service . ifname
 		elements = { 22 . "eth0",
 			     80 . "eth0",
-			     81 . "eth0",
-			     80 . "eth1" }
+			     80 . "eth1",
+			     81 . "eth0" }
 	}
 
 	set nv {
tests/shell/testcases/sets/dumps/0037_set_with_inet_service_0.json-nft +6 -6
index 1c3b559d48d43..cf1c1cc9d479e 100644
@@ -40,16 +40,16 @@
         "elem": [
           {
             "concat": [
-              "192.168.0.113",
+              "192.168.0.12",
               "tcp",
-              22
+              53
             ]
           },
           {
             "concat": [
               "192.168.0.12",
               "tcp",
-              53
+              80
             ]
           },
           {
@@ -61,16 +61,16 @@
           },
           {
             "concat": [
-              "192.168.0.12",
+              "192.168.0.13",
               "tcp",
               80
             ]
           },
           {
             "concat": [
-              "192.168.0.13",
+              "192.168.0.113",
               "tcp",
-              80
+              22
             ]
           }
         ]
tests/shell/testcases/sets/dumps/0037_set_with_inet_service_0.nft +4 -4
index 68b1f7bec4d84..0e85f7c20eba0 100644
@@ -1,11 +1,11 @@
 table inet filter {
 	set myset {
 		type ipv4_addr . inet_proto . inet_service
-		elements = { 192.168.0.113 . tcp . 22,
-			     192.168.0.12 . tcp . 53,
-			     192.168.0.12 . udp . 53,
+		elements = { 192.168.0.12 . tcp . 53,
 			     192.168.0.12 . tcp . 80,
-			     192.168.0.13 . tcp . 80 }
+			     192.168.0.12 . udp . 53,
+			     192.168.0.13 . tcp . 80,
+			     192.168.0.113 . tcp . 22 }
 	}
 
 	chain forward {
tests/shell/testcases/sets/dumps/typeof_sets_0.nft +2 -2
index 34aaab601cda3..1ceddfc4cded7 100644
@@ -67,8 +67,8 @@ table inet t {
 
 	set s14 {
 		typeof tcp option mptcp subtype . ip daddr
-		elements = { remove-addr . 10.1.1.1,
-			     mp-join . 10.1.1.2 }
+		elements = { mp-join . 10.1.1.2,
+			     remove-addr . 10.1.1.1 }
 	}
 
 	chain c1 {
tests/shell/testcases/sets/typeof_sets_0 +2 -2
index 28e39b4d2cb30..8850e9acea698 100755
@@ -223,8 +223,8 @@ $INPUT_VERSION_SET
 
 	set s14 {
 		typeof tcp option mptcp subtype . ip daddr
-		elements = { remove-addr . 10.1.1.1,
-			     mp-join . 10.1.1.2 }
+		elements = { mp-join . 10.1.1.2,
+			     remove-addr . 10.1.1.1 }
 	}
 $INPUT_OSF_CHAIN
 	chain c2 {
Signature · 1 line
2.51.0
author reviewer
#6 lore raw

PATCH v2 4/11 intervals: Convert byte order implicitly

In reply to Phil Sutter

When converting ranges to intervals, the latter's high and low values must be in network byte order. Instead of creating the low/high constant expressions with host byte order and converting the value, create them with Big Endian and keep the value as is. Upon export, Little Endian MPZ values will be byte-swapped by mpz_export_data() if BYTEORDER_BIG_ENDIAN is passed.

The benefit of this is that value's byteorder may be communicated to libnftnl later by looking at struct expr::byteorder field. By the time this information is required during netlink serialization, there is no other indicator for data byte order available.

---
 src/intervals.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
src/intervals.c +3 -7
index 40ab42832fd9e..29e8fab8172a1 100644
@@ -798,11 +798,8 @@ int setelem_to_interval(const struct set *set, struct expr *elem,
 	}
 
 	low = constant_expr_alloc(&key->location, set->key->dtype,
-				  set->key->byteorder, set->key->len, NULL);
-
+				  BYTEORDER_BIG_ENDIAN, set->key->len, NULL);
 	mpz_set(low->value, key->range.low);
-	if (set->key->byteorder == BYTEORDER_HOST_ENDIAN)
-		mpz_switch_byteorder(low->value, set->key->len / BITS_PER_BYTE);
 
 	low = set_elem_expr_alloc(&key->location, low);
 	set_elem_expr_copy(low, interval_expr_key(elem));
@@ -824,12 +821,11 @@ int setelem_to_interval(const struct set *set, struct expr *elem,
 	}
 
 	high = constant_expr_alloc(&key->location, set->key->dtype,
-				   set->key->byteorder, set->key->len,
+				   BYTEORDER_BIG_ENDIAN, set->key->len,
 				   NULL);
 	mpz_set(high->value, key->range.high);
 	mpz_add_ui(high->value, high->value, 1);
-	if (set->key->byteorder == BYTEORDER_HOST_ENDIAN)
-		mpz_switch_byteorder(high->value, set->key->len / BITS_PER_BYTE);
+	high->byteorder = BYTEORDER_BIG_ENDIAN;
 
 	high = set_elem_expr_alloc(&key->location, high);
 
Signature · 1 line
2.51.0
author reviewer
#7 lore raw

PATCH v2 5/11 expression: Set range expression 'len' field

In reply to Phil Sutter

The length value is needed for netlink debug output of concatenated ranges. Set it to one of the inner elements' lengths (which should be identical).

Since the inner element length may not be set initially, set it in eval phase again. This covers at least all cases in tests/py.

Without this, netlink_gen_concat_key() et al. would have to inspect element types and extract lengths accordingly, this is much easier.

---
 src/evaluate.c   | 1 +
 src/expression.c | 1 +
 2 files changed, 2 insertions(+)
src/evaluate.c +1 -0
index 5a5e6cb5b2885..62bf8e44b4ccc 100644
@@ -1347,6 +1347,7 @@ static int expr_evaluate_range(struct eval_ctx *ctx, struct expr **exprp)
 
 	datatype_set(range, left->dtype);
 	range->flags |= EXPR_F_CONSTANT;
+	range->len = left->len;
 	return 0;
 }
 
src/expression.c +1 -0
index 4d68967f112e4..e036c4bb69965 100644
@@ -1018,6 +1018,7 @@ struct expr *range_expr_alloc(const struct location *loc,
 			  BYTEORDER_INVALID, 0);
 	expr->left  = left;
 	expr->right = right;
+	expr->len = left->len;
 	return expr;
 }
 
Signature · 1 line
2.51.0
author reviewer
#8 lore raw

PATCH v2 6/11 netlink: Introduce struct nft_data_linearize::byteorder

In reply to Phil Sutter

Bits in this field indicate data is in host byte order and thus may need conversion when being printed "byte-by-byte" in libnftnl.

With regular immediate values, this field's value has boolean properties (if non-zero, data is in host byte order). Concatenations may contain components in different byte order, so with them each bit (at index N) indicates whether a component (at the same index) is in host byte order.

Communicate a possible byte order conversion in __netlink_gen_concat_key() back to caller since this has to be respected when setting 'byteorder' field in struct nft_data_linearize.

String-based values are special: While defined as being in host byte order in nftables, libnftnl shall print them without prior conversion like Big Endian values.

---
 include/netlink.h |  1 +
 src/netlink.c     | 60 +++++++++++++++++++++++++++++++++++++++--------
 2 files changed, 51 insertions(+), 10 deletions(-)
include/netlink.h +1 -0
index 2737d5708b295..a762cb485784f 100644
@@ -106,6 +106,7 @@ struct nft_data_linearize {
 	char		chain[NFT_CHAIN_MAXNAMELEN];
 	uint32_t	chain_id;
 	int		verdict;
+	uint32_t	byteorder;
 };
 
 struct nft_data_delinearize {
src/netlink.c +50 -10

154 lines not on this page · raw message

Signature · 1 line
2.51.0
author reviewer
#9 lore raw

PATCH v2 7/11 netlink: Introduce struct nft_data_linearize::sizes

In reply to Phil Sutter

This array holds each concat component's actual length in bytes. It is crucial because component data is padded to match register lengths and if libnftnl has to print data "in reverse" (to print Little Endian values byte-by-byte), it will print extra leading zeroes with odd data lengths and thus indicate number of printed bytes does no longer correctly reflect actual data length.

---
 include/netlink.h |  1 +
 src/netlink.c     | 14 ++++++++++----
 2 files changed, 11 insertions(+), 4 deletions(-)
include/netlink.h +1 -0
index a762cb485784f..aa25094dc7c1d 100644
@@ -107,6 +107,7 @@ struct nft_data_linearize {
 	uint32_t	chain_id;
 	int		verdict;
 	uint32_t	byteorder;
+	uint8_t		sizes[NFT_REG32_COUNT];
 };
 
 struct nft_data_delinearize {
src/netlink.c +10 -4
index 3a512753c7624..d81cfccb6c6aa 100644
@@ -382,7 +382,7 @@ static void netlink_gen_concat_key(const struct expr *expr,
 		if (byteorder == BYTEORDER_HOST_ENDIAN &&
 		    expr_basetype(i)->type != TYPE_STRING)
 			nld->byteorder |= 1 << n;
-		n++;
+		nld->sizes[n++] = div_round_up(i->len, BITS_PER_BYTE);
 	}
 
 	nft_data_memcpy(nld, data, len);
@@ -452,7 +452,7 @@ static void __netlink_gen_concat_expand(const struct expr *expr,
 		if (i->byteorder == BYTEORDER_HOST_ENDIAN &&
 		    expr_basetype(i)->type != TYPE_STRING)
 			nld->byteorder |= 1 << n;
-		n++;
+		nld->sizes[n++] = div_round_up(i->len, BITS_PER_BYTE);
 	}
 
 	list_for_each_entry(i, &expr_concat(expr)->expressions, list) {
@@ -460,7 +460,7 @@ static void __netlink_gen_concat_expand(const struct expr *expr,
 		if (i->byteorder == BYTEORDER_HOST_ENDIAN &&
 		    expr_basetype(i)->type != TYPE_STRING)
 			nld->byteorder |= 1 << n;
-		n++;
+		nld->sizes[n++] = div_round_up(i->len, BITS_PER_BYTE);
 	}
 
 	nft_data_memcpy(nld, data, len);
@@ -485,7 +485,7 @@ static void __netlink_gen_concat(const struct expr *expr,
 		if (i->byteorder == BYTEORDER_HOST_ENDIAN &&
 		    expr_basetype(i)->type != TYPE_STRING)
 			nld->byteorder |= 1 << n;
-		n++;
+		nld->sizes[n++] = div_round_up(i->len, BITS_PER_BYTE);
 	}
 
 	nft_data_memcpy(nld, data, len);
@@ -563,6 +563,8 @@ static void netlink_gen_range(const struct expr *expr,
 	offset = netlink_export_pad(data, expr->left->value, expr->left);
 	netlink_export_pad(data + offset, expr->right->value, expr->right);
 	nft_data_memcpy(nld, data, len);
+	nld->sizes[0] = div_round_up(expr->left->len, BITS_PER_BYTE);
+	nld->sizes[1] = div_round_up(expr->right->len, BITS_PER_BYTE);
 }
 
 static void netlink_gen_range_value(const struct expr *expr,
@@ -579,6 +581,8 @@ static void netlink_gen_range_value(const struct expr *expr,
 	offset = netlink_export_pad(data, expr->range.low, expr);
 	netlink_export_pad(data + offset, expr->range.high, expr);
 	nft_data_memcpy(nld, data, len);
+	nld->sizes[0] = div_round_up(expr->len, BITS_PER_BYTE);
+	nld->sizes[1] = nld->sizes[0];
 }
 
 static void netlink_gen_prefix(const struct expr *expr,
@@ -599,6 +603,8 @@ static void netlink_gen_prefix(const struct expr *expr,
 	mpz_clear(v);
 
 	nft_data_memcpy(nld, data, len);
+	nld->sizes[0] = div_round_up(expr->prefix->len, BITS_PER_BYTE);
+	nld->sizes[1] = nld->sizes[0];
 }
 
 static void netlink_gen_key(const struct expr *expr,
Signature · 1 line
2.51.0
author reviewer
#10 lore raw

PATCH v2 8/11 netlink: Make use of nftnl_{expr,set_elem}_set_imm()

In reply to Phil Sutter

Pass the previously collected byteorder (and sizes) to libnftnl for improved netlink debug output.

---
 src/netlink.c           | 18 ++++++++++++------
 src/netlink_linearize.c | 34 ++++++++++++++++++++++------------
 2 files changed, 34 insertions(+), 18 deletions(-)
src/netlink.c +12 -6
index d81cfccb6c6aa..ad19f8b7dc392 100644
@@ -139,17 +139,22 @@ struct nftnl_set_elem *alloc_nftnl_setelem(const struct expr *set,
 			netlink_gen_key(key, &nld);
 			key->flags &= ~EXPR_F_INTERVAL;
 
-			nftnl_set_elem_set(nlse, NFTNL_SET_ELEM_KEY, nld.value, nld.len);
+			nftnl_set_elem_set_imm(nlse, NFTNL_SET_ELEM_KEY,
+					       nld.value, nld.len,
+					       nld.byteorder, nld.sizes);
 
 			key->flags |= EXPR_F_INTERVAL_END;
 			netlink_gen_key(key, &nld);
 			key->flags &= ~EXPR_F_INTERVAL_END;
 
-			nftnl_set_elem_set(nlse, NFTNL_SET_ELEM_KEY_END,
-					   nld.value, nld.len);
+			nftnl_set_elem_set_imm(nlse, NFTNL_SET_ELEM_KEY_END,
+					       nld.value, nld.len,
+					       nld.byteorder, nld.sizes);
 		} else {
 			netlink_gen_key(key, &nld);
-			nftnl_set_elem_set(nlse, NFTNL_SET_ELEM_KEY, nld.value, nld.len);
+			nftnl_set_elem_set_imm(nlse, NFTNL_SET_ELEM_KEY,
+					       nld.value, nld.len,
+					       nld.byteorder, nld.sizes);
 		}
 		break;
 	}
@@ -217,8 +222,9 @@ struct nftnl_set_elem *alloc_nftnl_setelem(const struct expr *set,
 		case EXPR_RANGE:
 		case EXPR_RANGE_VALUE:
 		case EXPR_PREFIX:
-			nftnl_set_elem_set(nlse, NFTNL_SET_ELEM_DATA,
-					   nld.value, nld.len);
+			nftnl_set_elem_set_imm(nlse, NFTNL_SET_ELEM_DATA,
+					       nld.value, nld.len,
+					       nld.byteorder, nld.sizes);
 			break;
 		default:
 			BUG("unexpected set element expression");
src/netlink_linearize.c +22 -12
index 30bc0094cc7e6..ac0eaff9a23ca 100644
@@ -482,8 +482,10 @@ static struct expr *netlink_gen_prefix(struct netlink_linearize_ctx *ctx,
 	netlink_put_register(nle, NFTNL_EXPR_BITWISE_SREG, sreg);
 	netlink_put_register(nle, NFTNL_EXPR_BITWISE_DREG, sreg);
 	nftnl_expr_set_u32(nle, NFTNL_EXPR_BITWISE_LEN, nld.len);
-	nftnl_expr_set(nle, NFTNL_EXPR_BITWISE_MASK, nld.value, nld.len);
-	nftnl_expr_set(nle, NFTNL_EXPR_BITWISE_XOR, zero.value, zero.len);
+	nftnl_expr_set_imm(nle, NFTNL_EXPR_BITWISE_MASK,
+			   nld.value, nld.len, nld.byteorder);
+	nftnl_expr_set_imm(nle, NFTNL_EXPR_BITWISE_XOR,
+			   zero.value, zero.len, zero.byteorder);
 	nft_rule_add_expr(ctx, nle, &expr->location);
 
 	return expr->right->prefix;
@@ -551,15 +553,18 @@ static void netlink_gen_flagcmp(struct netlink_linearize_ctx *ctx,
 		nle = alloc_nft_expr("cmp");
 		netlink_put_register(nle, NFTNL_EXPR_CMP_SREG, sreg);
 		nftnl_expr_set_u32(nle, NFTNL_EXPR_CMP_OP, NFT_CMP_EQ);
-		nftnl_expr_set(nle, NFTNL_EXPR_CMP_DATA, nld2.value, nld2.len);
+		nftnl_expr_set_imm(nle, NFTNL_EXPR_CMP_DATA,
+				   nld2.value, nld2.len, nld2.byteorder);
 		nft_rule_add_expr(ctx, nle, &expr->location);
 	} else {
 		nle = alloc_nft_expr("bitwise");
 		netlink_put_register(nle, NFTNL_EXPR_BITWISE_SREG, sreg);
 		netlink_put_register(nle, NFTNL_EXPR_BITWISE_DREG, sreg);
 		nftnl_expr_set_u32(nle, NFTNL_EXPR_BITWISE_LEN, len);
-		nftnl_expr_set(nle, NFTNL_EXPR_BITWISE_MASK, nld2.value, nld2.len);
-		nftnl_expr_set(nle, NFTNL_EXPR_BITWISE_XOR, nld.value, nld.len);
+		nftnl_expr_set_imm(nle, NFTNL_EXPR_BITWISE_MASK,
+				   nld2.value, nld2.len, nld2.byteorder);
+		nftnl_expr_set_imm(nle, NFTNL_EXPR_BITWISE_XOR,
+				   nld.value, nld.len, nld.byteorder);
 		nft_rule_add_expr(ctx, nle, &expr->location);
 
 		nle = alloc_nft_expr("cmp");
@@ -569,7 +574,8 @@ static void netlink_gen_flagcmp(struct netlink_linearize_ctx *ctx,
 		else
 			nftnl_expr_set_u32(nle, NFTNL_EXPR_CMP_OP, NFT_CMP_NEQ);
 
-		nftnl_expr_set(nle, NFTNL_EXPR_CMP_DATA, nld.value, nld.len);
+		nftnl_expr_set_imm(nle, NFTNL_EXPR_CMP_DATA,
+				   nld.value, nld.len, nld.byteorder);
 		nft_rule_add_expr(ctx, nle, &expr->location);
 	}
 
@@ -645,7 +651,8 @@ static void netlink_gen_relational(struct netlink_linearize_ctx *ctx,
 	nftnl_expr_set_u32(nle, NFTNL_EXPR_CMP_OP,
 			   netlink_gen_cmp_op(expr->op));
 	netlink_gen_data(right, &nld);
-	nftnl_expr_set(nle, NFTNL_EXPR_CMP_DATA, nld.value, len);
+	nftnl_expr_set_imm(nle, NFTNL_EXPR_CMP_DATA,
+			   nld.value, len, nld.byteorder);
 	release_register(ctx, expr->left);
 
 	nft_rule_add_expr(ctx, nle, &expr->location);
@@ -681,8 +688,8 @@ static void netlink_gen_bitwise_shift(struct netlink_linearize_ctx *ctx,
 	netlink_gen_raw_data(expr->right->value, expr->right->byteorder,
 			     sizeof(uint32_t), &nld);
 
-	nftnl_expr_set(nle, NFTNL_EXPR_BITWISE_DATA, nld.value,
-		       nld.len);
+	nftnl_expr_set_imm(nle, NFTNL_EXPR_BITWISE_DATA,
+			   nld.value, nld.len, nld.byteorder);
 
 	nft_rule_add_expr(ctx, nle, &expr->location);
 }
@@ -747,9 +754,11 @@ static void netlink_gen_bitwise_mask_xor(struct netlink_linearize_ctx *ctx,
 	nftnl_expr_set_u32(nle, NFTNL_EXPR_BITWISE_LEN, len);
 
 	netlink_gen_raw_data(mask, expr->byteorder, len, &nld);
-	nftnl_expr_set(nle, NFTNL_EXPR_BITWISE_MASK, nld.value, nld.len);
+	nftnl_expr_set_imm(nle, NFTNL_EXPR_BITWISE_MASK,
+			   nld.value, nld.len, nld.byteorder);
 	netlink_gen_raw_data(xor, expr->byteorder, len, &nld);
-	nftnl_expr_set(nle, NFTNL_EXPR_BITWISE_XOR, nld.value, nld.len);
+	nftnl_expr_set_imm(nle, NFTNL_EXPR_BITWISE_XOR,
+			   nld.value, nld.len, nld.byteorder);
 
 	mpz_clear(tmp);
 	mpz_clear(val);
@@ -871,7 +880,8 @@ static void netlink_gen_immediate(struct netlink_linearize_ctx *ctx,
 	netlink_gen_data(expr, &nld);
 	switch (expr->etype) {
 	case EXPR_VALUE:
-		nftnl_expr_set(nle, NFTNL_EXPR_IMM_DATA, nld.value, nld.len);
+		nftnl_expr_set_imm(nle, NFTNL_EXPR_IMM_DATA,
+				   nld.value, nld.len, nld.byteorder);
 		break;
 	case EXPR_VERDICT:
 		if (expr->chain) {
Signature · 1 line
2.51.0
author reviewer
#11 lore raw

PATCH v2 9/11 tests: py: tools: Add regen_payloads.sh

In reply to Phil Sutter

Use this script to recreate all payload records.

---
 tests/py/tools/regen_payloads.sh | 74 ++++++++++++++++++++++++++++++++
 1 file changed, 74 insertions(+)
 create mode 100755 tests/py/tools/regen_payloads.sh
tests/py/tools/regen_payloads.sh new file +74 -0
new file mode 100755
index 0000000000000..9fcbc2c0912a5
@@ -0,0 +1,74 @@
+#!/bin/bash
+
+# update payload records in an automated fashion, trying to reduce diff sizes
+
+
+# scan payloadfile and print record for cmd (if found)
+find_payload() { # (payloadfile, cmd)
+	local found=false
+
+	readarray -t pl <"$1"
+	for l in "${pl[@]}"; do
+		if [[ "$l" == "# "* ]]; then
+			$found && return
+			[[ "$l" == "$2" ]] && found=true
+		fi
+		$found && echo "$l"
+	done
+	$found || echo "Warning: Command '$2' not found in '$1'" >&2
+}
+
+cd $(dirname $0)/../
+
+# make sure no stray output files get in the way
+rm -f */*.got */*.gotgot
+
+# store payload records for later
+# clear payload files to force regenerating (but leave them in place)
+for pl in */*.payload*; do
+	[[ $pl == *.bak ]] && continue # ignore leftover .bak files
+	cp "$pl" "${pl}.bak"
+	echo >"$pl"
+done
+
+# run the testsuite to create .got files
+# pass -f to keep going despite missing payloads
+./nft-test.py -f
+
+# restore old payload records
+for plbak in */*.bak; do
+	mv "$plbak" "${plbak%.bak}"
+done
+
+# sort created got files to match order in old payload records
+for g in ${@:-*/*.payload*.got}; do
+	pl=${g%.got}
+
+	[[ -f $g ]] || continue
+	[[ -f $pl ]] || continue
+
+	readarray -t ploads <"$g"
+	readarray -t cmds <<< $(grep '^# ' $pl)
+	for cmd in "${cmds[@]}"; do
+		found=false
+		for l in "${ploads[@]}"; do
+			if [[ "$l" == "# "* ]]; then
+				$found && break
+				[[ "$l" == "$cmd" ]] && found=true
+			fi
+			$found && [[ "$l" != "" ]] && echo "$l"
+		done
+		if ! $found; then
+			echo "Warning: Command '$cmd' not found in '$g'" >&2
+		else
+			echo ""
+		fi
+	done | head -n -1 >${g}got
+
+	mv "${g}got" "${g}"
+done
+
+# overwrite old payload records with new ones
+for got in */*.payload*.got; do
+	mv "${got}" "${got%.got}"
+done
Signature · 1 line
2.51.0
author reviewer
#12 lore raw

PATCH v2 10/11 tests: py: Update payload records

In reply to Phil Sutter

This is the bulk change of py test suite payload records with improved data reg printing in libnftnl using data (component) size and byteorder collected in nftables.

Aside from printing values in the right byte order and padded with zeroes to match their actual size, this patch also exposes the improved set element dump format:
* No '[end]' marker, 'element' clearly separates elements
* No semi-colon for non-map elements
* 'flags' value printed only if non-zero and prefixed by 'flags' to distinguish from element data

---
 tests/py/any/ct.t.payload               |  89 +++--
 tests/py/any/meta.t.payload             | 232 ++++++-------
 tests/py/any/meta.t.payload.bridge      |  10 +-
 tests/py/any/queue.t.payload            |   2 +-
 tests/py/any/rawpayload.t.payload       |  64 ++--
 tests/py/any/rt.t.payload               |   5 +-
 tests/py/any/tcpopt.t.payload           |  88 ++---
 tests/py/arp/arp.t.payload              |  99 +++---
 tests/py/arp/arp.t.payload.netdev       | 189 +++++-----
 tests/py/bridge/ether.t.payload         |  43 ++-
 tests/py/bridge/icmpX.t.payload         |  25 +-
 tests/py/bridge/meta.t.payload          |  20 +-
 tests/py/bridge/redirect.t.payload      |   2 +-
 tests/py/bridge/reject.t.payload        |  43 ++-
 tests/py/bridge/vlan.t.payload          | 262 +++++++-------
 tests/py/bridge/vlan.t.payload.netdev   | 316 ++++++++---------
 tests/py/inet/ah.t.payload              |  89 +++--
 tests/py/inet/comp.t.payload            |  53 ++-
 tests/py/inet/ct.t.payload              |  14 +-
 tests/py/inet/dccp.t.payload            |  53 ++-
 tests/py/inet/dnat.t.payload            |  47 ++-
 tests/py/inet/esp.t.payload             |  45 ++-
 tests/py/inet/ether-ip.t.payload        |  22 +-
 tests/py/inet/ether-ip.t.payload.netdev |  23 +-
 tests/py/inet/ether.t.payload           |  37 +-
 tests/py/inet/ether.t.payload.bridge    |  29 +-
 tests/py/inet/ether.t.payload.ip        |  37 +-
 tests/py/inet/fib.t.payload             |  12 +-
 tests/py/inet/geneve.t.payload          |  83 +++--
 tests/py/inet/gre.t.payload             |  53 ++-
 tests/py/inet/gretap.t.payload          |  59 ++--
 tests/py/inet/icmp.t.payload            |  37 +-
 tests/py/inet/icmpX.t.payload           |  32 +-
 tests/py/inet/ip.t.payload              |   4 +-
 tests/py/inet/ip.t.payload.bridge       |   4 +-
 tests/py/inet/ip.t.payload.inet         |   7 +-
 tests/py/inet/ip.t.payload.netdev       |   7 +-
 tests/py/inet/ip_tcp.t.payload          |  36 +-
 tests/py/inet/ip_tcp.t.payload.bridge   |  35 +-
 tests/py/inet/ip_tcp.t.payload.netdev   |  37 +-
 tests/py/inet/ipsec.t.payload           |  11 +-
 tests/py/inet/map.t.payload             |  11 +-
 tests/py/inet/map.t.payload.ip          |   7 +-
 tests/py/inet/map.t.payload.netdev      |  11 +-
 tests/py/inet/meta.t.payload            |  83 +++--
 tests/py/inet/osf.t.payload             |  16 +-
 tests/py/inet/payloadmerge.t.payload    |  43 ++-
 tests/py/inet/reject.t.payload.inet     |  43 ++-
 tests/py/inet/rt.t.payload              |   7 +-
 tests/py/inet/sctp.t.payload            | 159 +++++----
 tests/py/inet/sets.t.payload.bridge     |  15 +-
 tests/py/inet/sets.t.payload.inet       |  14 +-
 tests/py/inet/sets.t.payload.netdev     |  14 +-
 tests/py/inet/snat.t.payload            |  30 +-
 tests/py/inet/socket.t.payload          |   8 +-
 tests/py/inet/tcp.t.payload             | 360 +++++++++----------
 tests/py/inet/tproxy.t.payload          |  45 ++-
 tests/py/inet/udp.t.payload             | 112 +++---
 tests/py/inet/udplite.t.payload         |  81 +++--
 tests/py/inet/vmap.t.payload            |  13 +-
 tests/py/inet/vmap.t.payload.netdev     |  13 +-
 tests/py/inet/vxlan.t.payload           |  83 +++--
 tests/py/ip/ct.t.payload                |  46 +--
 tests/py/ip/dnat.t.payload.ip           | 117 ++++---
 tests/py/ip/dup.t.payload               |   7 +-
 tests/py/ip/ether.t.payload             |  37 +-
 tests/py/ip/hash.t.payload              |   2 +-
 tests/py/ip/icmp.t.payload.ip           | 312 ++++++++---------
 tests/py/ip/igmp.t.payload              |  61 ++--
 tests/py/ip/ip.t.payload                | 246 ++++++-------
 tests/py/ip/ip.t.payload.bridge         | 440 ++++++++++++------------
 tests/py/ip/ip.t.payload.inet           | 440 ++++++++++++------------
 tests/py/ip/ip.t.payload.netdev         | 434 +++++++++++------------
 tests/py/ip/ip_tcp.t.payload            |   9 +-
 tests/py/ip/masquerade.t.payload        |  71 ++--
 tests/py/ip/meta.t.payload              |  32 +-
 tests/py/ip/numgen.t.payload            |   4 +-
 tests/py/ip/objects.t.payload           |  26 +-
 tests/py/ip/redirect.t.payload          | 121 ++++---
 tests/py/ip/reject.t.payload            |   3 +-
 tests/py/ip/rt.t.payload                |   3 +-
 tests/py/ip/sets.t.payload.inet         |  38 +-
 tests/py/ip/sets.t.payload.ip           |  12 +-
 tests/py/ip/sets.t.payload.netdev       |  38 +-
 tests/py/ip/snat.t.payload              |  74 ++--
 tests/py/ip/tcp.t.payload               |  11 +-
 tests/py/ip/tproxy.t.payload            |  29 +-
 tests/py/ip6/ct.t.payload               |  12 +-
 tests/py/ip6/dnat.t.payload.ip6         |  38 +-
 tests/py/ip6/dst.t.payload.inet         |  60 ++--
 tests/py/ip6/dst.t.payload.ip6          |  30 +-
 tests/py/ip6/dup.t.payload              |   7 +-
 tests/py/ip6/ether.t.payload            |  36 +-
 tests/py/ip6/exthdr.t.payload.ip6       |  25 +-
 tests/py/ip6/frag.t.payload.inet        | 131 ++++---
 tests/py/ip6/frag.t.payload.ip6         |  75 ++--
 tests/py/ip6/frag.t.payload.netdev      | 131 ++++---
 tests/py/ip6/hbh.t.payload.inet         |  65 ++--
 tests/py/ip6/hbh.t.payload.ip6          |  33 +-
 tests/py/ip6/icmpv6.t.payload.ip6       | 322 ++++++++---------
 tests/py/ip6/ip6.t.payload.inet         | 359 ++++++++++---------
 tests/py/ip6/ip6.t.payload.ip6          | 191 +++++-----
 tests/py/ip6/map.t.payload              |   5 +-
 tests/py/ip6/masquerade.t.payload.ip6   |  71 ++--
 tests/py/ip6/meta.t.payload             |  36 +-
 tests/py/ip6/mh.t.payload.inet          | 132 +++----
 tests/py/ip6/mh.t.payload.ip6           |  66 ++--
 tests/py/ip6/redirect.t.payload.ip6     | 105 +++---
 tests/py/ip6/reject.t.payload.ip6       |   3 +-
 tests/py/ip6/rt.t.payload.inet          | 121 ++++---
 tests/py/ip6/rt.t.payload.ip6           |  61 ++--
 tests/py/ip6/rt0.t.payload              |   3 +-
 tests/py/ip6/sets.t.payload.inet        |  18 +-
 tests/py/ip6/sets.t.payload.ip6         |   4 +-
 tests/py/ip6/sets.t.payload.netdev      |  18 +-
 tests/py/ip6/snat.t.payload.ip6         |  23 +-
 tests/py/ip6/srh.t.payload              |  23 +-
 tests/py/ip6/tproxy.t.payload           |  29 +-
 tests/py/ip6/vmap.t.payload.inet        | 169 +++++----
 tests/py/ip6/vmap.t.payload.ip6         |  85 +++--
 tests/py/ip6/vmap.t.payload.netdev      | 169 +++++----
 tests/py/netdev/dup.t.payload           |   3 +-
 tests/py/netdev/fwd.t.payload           |   5 +-
 tests/py/netdev/reject.t.payload        |  41 ++-
 tests/py/netdev/tunnel.t.payload        |   5 +-
 125 files changed, 4385 insertions(+), 4461 deletions(-)
tests/py/any/ct.t.payload +44 -45
index 645041341ca86..ae4e0ec344876 100644
@@ -12,7 +12,7 @@ ip test-ip4 output
 # ct state {new,established, related, untracked}
 __set%d test-ip4 3
 __set%d test-ip4 0
-	element 00000008  : 0 [end]	element 00000002  : 0 [end]	element 00000004  : 0 [end]	element 00000040  : 0 [end]
+	element 00000008	element 00000002	element 00000004	element 00000040
 ip test-ip4 output
   [ ct load state => reg 1 ]
   [ lookup reg 1 set __set%d ]
@@ -20,7 +20,7 @@ ip test-ip4 output
 # ct state != {new,established, related, untracked}
 __set%d test-ip4 3
 __set%d test-ip4 0
-	element 00000008  : 0 [end]	element 00000002  : 0 [end]	element 00000004  : 0 [end]	element 00000040  : 0 [end]
+	element 00000008	element 00000002	element 00000004	element 00000040
 ip test-ip4 output
   [ ct load state => reg 1 ]
   [ lookup reg 1 set __set%d 0x1 ]
@@ -48,27 +48,27 @@ ip test-ip4 output
 # ct direction original
 ip test-ip4 output
   [ ct load direction => reg 1 ]
-  [ cmp eq reg 1 0x00000000 ]
+  [ cmp eq reg 1 0x00 ]
 
 # ct direction != original
 ip test-ip4 output
   [ ct load direction => reg 1 ]
-  [ cmp neq reg 1 0x00000000 ]
+  [ cmp neq reg 1 0x00 ]
 
 # ct direction reply
 ip test-ip4 output
   [ ct load direction => reg 1 ]
-  [ cmp eq reg 1 0x00000001 ]
+  [ cmp eq reg 1 0x01 ]
 
 # ct direction != reply
 ip test-ip4 output
   [ ct load direction => reg 1 ]
-  [ cmp neq reg 1 0x00000001 ]
+  [ cmp neq reg 1 0x01 ]
 
 # ct direction {reply, original}
 __set%d test-ip4 3
 __set%d test-ip4 0
-	element 00000001  : 0 [end]	element 00000000  : 0 [end]
+	element 01	element 00
 ip test-ip4 output
   [ ct load direction => reg 1 ]
   [ lookup reg 1 set __set%d ]
@@ -76,7 +76,7 @@ ip test-ip4 output
 # ct direction != {reply, original}
 __set%d test-ip4 3
 __set%d test-ip4 0
-	element 00000001  : 0 [end]	element 00000000  : 0 [end]
+	element 01	element 00
 ip test-ip4 output
   [ ct load direction => reg 1 ]
   [ lookup reg 1 set __set%d 0x1 ]
@@ -106,7 +106,7 @@ ip test-ip4 output
 # ct status {expected, seen-reply, assured, confirmed, dying}
 __set%d test-ip4 3
 __set%d test-ip4 0
-	element 00000001  : 0 [end]	element 00000002  : 0 [end]	element 00000004  : 0 [end]	element 00000008  : 0 [end]	element 00000200  : 0 [end]
+	element 00000001	element 00000002	element 00000004	element 00000008	element 00000200
 ip test-ip4 output
   [ ct load status => reg 1 ]
   [ lookup reg 1 set __set%d ]
@@ -114,7 +114,7 @@ ip test-ip4 output
 # ct status != {expected, seen-reply, assured, confirmed, dying}
 __set%d test-ip4 3
 __set%d test-ip4 0
-	element 00000001  : 0 [end]	element 00000002  : 0 [end]	element 00000004  : 0 [end]	element 00000008  : 0 [end]	element 00000200  : 0 [end]
+	element 00000001	element 00000002	element 00000004	element 00000008	element 00000200
 ip test-ip4 output
   [ ct load status => reg 1 ]
   [ lookup reg 1 set __set%d 0x1 ]
@@ -172,18 +172,18 @@ ip test-ip4 output
 ip test-ip4 output
   [ ct load mark => reg 1 ]
   [ byteorder reg 1 = hton(reg 1, 4, 4) ]
-  [ range eq reg 1 0x32000000 0x45000000 ]
+  [ range eq reg 1 0x00000032 0x00000045 ]
 
 # ct mark != 0x00000032-0x00000045
 ip test-ip4 output
   [ ct load mark => reg 1 ]
   [ byteorder reg 1 = hton(reg 1, 4, 4) ]
-  [ range neq reg 1 0x32000000 0x45000000 ]
+  [ range neq reg 1 0x00000032 0x00000045 ]
 
 # ct mark {0x32, 0x2222, 0x42de3}
 __set%d test-ip4 3
 __set%d test-ip4 0
-	element 00000032  : 0 [end]	element 00002222  : 0 [end]	element 00042de3  : 0 [end]
+	element 00000032	element 00002222	element 00042de3
 ip test-ip4 output
   [ ct load mark => reg 1 ]
   [ lookup reg 1 set __set%d ]
@@ -191,7 +191,7 @@ ip test-ip4 output
 # ct mark {0x32-0x2222, 0x4444-0x42de3}
 __set%d test-ip4 7
 __set%d test-ip4 0
-        element 00000000  : 1 [end]     element 32000000  : 0 [end]     element 23220000  : 1 [end]     element 44440000  : 0 [end]     element e42d0400  : 1 [end]
+	element 00000000 flags 1	element 00000032	element 00002223 flags 1	element 00004444	element 00042de4 flags 1
 ip test-ip4 output
   [ ct load mark => reg 1 ]
   [ byteorder reg 1 = hton(reg 1, 4, 4) ]
@@ -200,7 +200,7 @@ ip test-ip4 output
 # ct mark != {0x32, 0x2222, 0x42de3}
 __set%d test-ip4 3
 __set%d test-ip4 0
-	element 00000032  : 0 [end]	element 00002222  : 0 [end]	element 00042de3  : 0 [end]
+	element 00000032	element 00002222	element 00042de3
 ip test-ip4 output
   [ ct load mark => reg 1 ]
   [ lookup reg 1 set __set%d 0x1 ]
@@ -239,13 +239,13 @@ ip test-ip4 output
 ip test-ip4 output
   [ ct load expiration => reg 1 ]
   [ byteorder reg 1 = hton(reg 1, 4, 4) ]
-  [ range eq reg 1 0x60ea0000 0x80ee3600 ]
+  [ range eq reg 1 0x0000ea60 0x0036ee80 ]
 
 # ct expiration > 4d23h59m59s
 ip test-ip4 output
   [ ct load expiration => reg 1 ]
   [ byteorder reg 1 = hton(reg 1, 4, 4) ]
-  [ cmp gt reg 1 0x18c8bf19 ]
+  [ cmp gt reg 1 0x19bfc818 ]
 
 # ct expiration != 233
 ip test-ip4 output
@@ -256,18 +256,18 @@ ip test-ip4 output
 ip test-ip4 output
   [ ct load expiration => reg 1 ]
   [ byteorder reg 1 = hton(reg 1, 4, 4) ]
-  [ range eq reg 1 0xe8800000 0xc8af0000 ]
+  [ range eq reg 1 0x000080e8 0x0000afc8 ]
 
 # ct expiration != 33-45
 ip test-ip4 output
   [ ct load expiration => reg 1 ]
   [ byteorder reg 1 = hton(reg 1, 4, 4) ]
-  [ range neq reg 1 0xe8800000 0xc8af0000 ]
+  [ range neq reg 1 0x000080e8 0x0000afc8 ]
 
 # ct expiration {33, 55, 67, 88}
 __set%d test-ip4 3
 __set%d test-ip4 0
-	element 000080e8  : 0 [end]	element 0000d6d8  : 0 [end]	element 000105b8  : 0 [end]	element 000157c0  : 0 [end]
+	element 000080e8	element 0000d6d8	element 000105b8	element 000157c0
 ip test-ip4 output
   [ ct load expiration => reg 1 ]
   [ lookup reg 1 set __set%d ]
@@ -275,7 +275,7 @@ ip test-ip4 output
 # ct expiration != {33, 55, 67, 88}
 __set%d test-ip4 3
 __set%d test-ip4 0
-	element 000080e8  : 0 [end]	element 0000d6d8  : 0 [end]	element 000105b8  : 0 [end]	element 000157c0  : 0 [end]
+	element 000080e8	element 0000d6d8	element 000105b8	element 000157c0
 ip test-ip4 output
   [ ct load expiration => reg 1 ]
   [ lookup reg 1 set __set%d 0x1 ]
@@ -283,7 +283,7 @@ ip test-ip4 output
 # ct expiration {33-55, 66-88}
 __set%d test-ip4 7 size 5
 __set%d test-ip4 0
-	element 00000000  : 1 [end]	element e8800000  : 0 [end]	element d9d60000  : 1 [end]	element d0010100  : 0 [end]	element c1570100  : 1 [end]
+	element 00000000 flags 1	element 000080e8	element 0000d6d9 flags 1	element 000101d0	element 000157c1 flags 1
 ip test-ip4 output 
   [ ct load expiration => reg 1 ]
   [ byteorder reg 1 = hton(reg 1, 4, 4) ]
@@ -292,7 +292,7 @@ ip test-ip4 output
 # ct expiration != {33-55, 66-88}
 __set%d test-ip4 7 size 5
 __set%d test-ip4 0
-	element 00000000  : 1 [end]	element e8800000  : 0 [end]	element d9d60000  : 1 [end]	element d0010100  : 0 [end]	element c1570100  : 1 [end]
+	element 00000000 flags 1	element 000080e8	element 0000d6d9 flags 1	element 000101d0	element 000157c1 flags 1
 ip test-ip4 output 
   [ ct load expiration => reg 1 ]
   [ byteorder reg 1 = hton(reg 1, 4, 4) ]
@@ -301,12 +301,12 @@ ip test-ip4 output
 # ct helper "ftp"
 ip test-ip4 output
   [ ct load helper => reg 1 ]
-  [ cmp eq reg 1 0x00707466 0x00000000 0x00000000 0x00000000 ]
+  [ cmp eq reg 1 0x66747000 0x00000000 0x00000000 0x00000000 ]
 
 # ct state . ct mark { new . 0x12345678, new . 0x34127856, established . 0x12785634}
 __set%d test-ip4 3
 __set%d test-ip4 0
-	element 00000008 12345678  : 0 [end]	element 00000008 34127856  : 0 [end]	element 00000002 12785634  : 0 [end]
+	element 00000008 . 12345678	element 00000008 . 34127856	element 00000002 . 12785634
 ip test-ip4 output
   [ ct load state => reg 1 ]
   [ ct load mark => reg 9 ]
@@ -327,7 +327,7 @@ inet test-inet output
 # ct mark set mark map { 1 : 10, 2 : 20, 3 : 30 }
 __map%d test-ip4 b
 __map%d test-ip4 0
-        element 00000001  : 0000000a 0 [end]    element 00000002  : 00000014 0 [end]    element 00000003  : 0000001e 0 [end]
+	element 00000001 : 0000000a	element 00000002 : 00000014	element 00000003 : 0000001e
 ip test-ip4 output
   [ meta load mark => reg 1 ]
   [ lookup reg 1 set __map%d dreg 1 ]
@@ -346,31 +346,31 @@ ip
 ip test-ip4 output
   [ ct load bytes => reg 1 , dir original ]
   [ byteorder reg 1 = hton(reg 1, 8, 8) ]
-  [ cmp gt reg 1 0x00000000 0xa0860100 ]
+  [ cmp gt reg 1 0x00000000 0x000186a0 ]
 
 # ct reply packets < 100
 ip test-ip4 output
   [ ct load packets => reg 1 , dir reply ]
   [ byteorder reg 1 = hton(reg 1, 8, 8) ]
-  [ cmp lt reg 1 0x00000000 0x64000000 ]
+  [ cmp lt reg 1 0x00000000 0x00000064 ]
 
 # ct bytes > 100000
 ip test-ip4 output
   [ ct load bytes => reg 1 ]
   [ byteorder reg 1 = hton(reg 1, 8, 8) ]
-  [ cmp gt reg 1 0x00000000 0xa0860100 ]
+  [ cmp gt reg 1 0x00000000 0x000186a0 ]
 
 # ct avgpkt > 200
 ip test-ip4 output
   [ ct load avgpkt => reg 1 ]
   [ byteorder reg 1 = hton(reg 1, 8, 8) ]
-  [ cmp gt reg 1 0x00000000 0xc8000000 ]
+  [ cmp gt reg 1 0x00000000 0x000000c8 ]
 
 # ct original avgpkt < 500
 ip test-ip4 output
   [ ct load avgpkt => reg 1 , dir original ]
   [ byteorder reg 1 = hton(reg 1, 8, 8) ]
-  [ cmp lt reg 1 0x00000000 0xf4010000 ]
+  [ cmp lt reg 1 0x00000000 0x000001f4 ]
 
 # ct status expected,seen-reply,assured,confirmed,snat,dnat,dying
 ip test-ip4 output
@@ -423,53 +423,53 @@ ip test-ip4 output
 # ct label 127
 ip test-ip4 output
   [ ct load label => reg 1 ]
-  [ bitwise reg 1 = ( reg 1 & 0x00000000 0x00000000 0x00000000 0x80000000 ) ^ 0x00000000 0x00000000 0x00000000 0x00000000 ]
+  [ bitwise reg 1 = ( reg 1 & 0x80000000 0x00000000 0x00000000 0x00000000 ) ^ 0x00000000 0x00000000 0x00000000 0x00000000 ]
   [ cmp neq reg 1 0x00000000 0x00000000 0x00000000 0x00000000 ]
 
 # ct label set 127
 ip test-ip4 output
-  [ immediate reg 1 0x00000000 0x00000000 0x00000000 0x80000000 ]
+  [ immediate reg 1 0x80000000 0x00000000 0x00000000 0x00000000 ]
   [ ct set label with reg 1 ]
 
 # ct zone 0
 ip test-ip4 output
   [ ct load zone => reg 1 ]
-  [ cmp eq reg 1 0x00000000 ]
+  [ cmp eq reg 1 0x0000 ]
 
 # ct zone 23
 ip test-ip4 output
   [ ct load zone => reg 1 ]
-  [ cmp eq reg 1 0x00000017 ]
+  [ cmp eq reg 1 0x0017 ]
 
 # ct original zone 1
 ip test-ip4 output
   [ ct load zone => reg 1 , dir original ]
-  [ cmp eq reg 1 0x00000001 ]
+  [ cmp eq reg 1 0x0001 ]
 
 # ct reply zone 1
 ip test-ip4 output
   [ ct load zone => reg 1 , dir reply ]
-  [ cmp eq reg 1 0x00000001 ]
+  [ cmp eq reg 1 0x0001 ]
 
 # ct zone set 1
 ip test-ip4 output
-  [ immediate reg 1 0x00000001 ]
+  [ immediate reg 1 0x0001 ]
   [ ct set zone with reg 1 ]
 
 # ct original zone set 1
 ip test-ip4 output
-  [ immediate reg 1 0x00000001 ]
+  [ immediate reg 1 0x0001 ]
   [ ct set zone with reg 1 , dir original ]
 
 # ct reply zone set 1
 ip test-ip4 output
-  [ immediate reg 1 0x00000001 ]
+  [ immediate reg 1 0x0001 ]
   [ ct set zone with reg 1 , dir reply ]
 
 # ct zone set mark map { 1 : 1,  2 : 2 }
 __map%d test-ip4 b
 __map%d test-ip4 0
-        element 00000001  : 00000001 0 [end]    element 00000002  : 00000002 0 [end]
+	element 00000001 : 0001	element 00000002 : 0002
 ip test-ip4 output
   [ meta load mark => reg 1 ]
   [ lookup reg 1 set __map%d dreg 1 ]
@@ -482,7 +482,7 @@ ip test-ip4 output
 # ct direction . ct mark { original . 0x12345678, reply . 0x87654321}
 __set%d test-ip4 3 size 2
 __set%d test-ip4 0
-	element 00000000 12345678  : 0 [end]	element 00000001 87654321  : 0 [end]
+	element 00 . 12345678	element 01 . 87654321
 ip test-ip4 output 
   [ ct load direction => reg 1 ]
   [ ct load mark => reg 9 ]
@@ -491,7 +491,7 @@ ip test-ip4 output
 # ct state . ct mark vmap { new . 0x12345678 : drop, established . 0x87654321 : accept}
 __map%d test-ip4 b size 2
 __map%d test-ip4 0
-	element 00000008 12345678  : drop 0 [end]	element 00000002 87654321  : accept 0 [end]
+	element 00000008 . 12345678 : drop	element 00000002 . 87654321 : accept
 ip test-ip4 output 
   [ ct load state => reg 1 ]
   [ ct load mark => reg 9 ]
@@ -512,7 +512,7 @@ ip test-ip4 output
 # ct id 12345
 ip test-ip4 output
   [ ct load id => reg 1 ]
-  [ cmp eq reg 1 0x39300000 ]
+  [ cmp eq reg 1 0x00003039 ]
 
 # ct status ! dnat
 ip6
@@ -527,4 +527,3 @@ ip test-ip4 output
 # ct count over 3
 ip test-ip4 output
   [ connlimit count 3 flags 1 ]
-
tests/py/any/meta.t.payload +116 -116

831 lines not on this page · raw message

tests/py/any/meta.t.payload.bridge +5 -5
index 5997ccc7ba52b..b4e7ba374b4f0 100644
@@ -1,20 +1,20 @@
 # meta mark set vlan id map { 1 : 0x00000001, 4095 : 0x00004095 }
 __map%d test-bridge b size 2
 __map%d test-bridge 0
-	element 00000100  : 00000001 0 [end]	element 0000ff0f  : 00004095 0 [end]
+	element 0001 : 00000001	element 0fff : 00004095
 bridge test-bridge input
   [ payload load 2b @ link header + 12 => reg 1 ]
-  [ cmp eq reg 1 0x00000081 ]
+  [ cmp eq reg 1 0x8100 ]
   [ payload load 2b @ link header + 14 => reg 1 ]
-  [ bitwise reg 1 = ( reg 1 & 0x0000ff0f ) ^ 0x00000000 ]
+  [ bitwise reg 1 = ( reg 1 & 0x0fff ) ^ 0x0000 ]
   [ lookup reg 1 set __map%d dreg 1 ]
   [ meta set mark with reg 1 ]
 
 # meta mark set vlan id map @map1
 bridge test-bridge input
   [ payload load 2b @ link header + 12 => reg 1 ]
-  [ cmp eq reg 1 0x00000081 ]
+  [ cmp eq reg 1 0x8100 ]
   [ payload load 2b @ link header + 14 => reg 1 ]
-  [ bitwise reg 1 = ( reg 1 & 0x0000ff0f ) ^ 0x00000000 ]
+  [ bitwise reg 1 = ( reg 1 & 0x0fff ) ^ 0x0000 ]
   [ lookup reg 1 set map1 dreg 1 ]
   [ meta set mark with reg 1 ]
tests/py/any/queue.t.payload +1 -1
index 2f221930a1efc..b3b5dc051cdb2 100644
@@ -50,7 +50,7 @@ ip
 # queue flags bypass to oifname map { "eth0" : 0, "ppp0" : 2, "eth1" : 2 }
 __map%d test-ip4 b size 3
 __map%d test-ip4 0
-	element 30687465 00000000 00000000 00000000  : 00000000 0 [end]	element 30707070 00000000 00000000 00000000  : 00000002 0 [end]	element 31687465 00000000 00000000 00000000  : 00000002 0 [end]
+	element 65746830 00000000 00000000 00000000 : 0000	element 70707030 00000000 00000000 00000000 : 0002	element 65746831 00000000 00000000 00000000 : 0002
 ip
   [ meta load oifname => reg 1 ]
   [ lookup reg 1 set __map%d dreg 1 ]
tests/py/any/rawpayload.t.payload +32 -32

147 lines not on this page · raw message

tests/py/any/rt.t.payload +2 -3
index e1ecb2860ed08..a3d7a7ccec743 100644
@@ -6,10 +6,9 @@ ip test-ip4 input
 # rt ipsec exists
 ip test-ip4 input
   [ rt load ipsec => reg 1 ]
-  [ cmp eq reg 1 0x00000001 ]
+  [ cmp eq reg 1 0x01 ]
 
 # rt ipsec missing
 ip test-ip4 input
   [ rt load ipsec => reg 1 ]
-  [ cmp eq reg 1 0x00000000 ]
-
+  [ cmp eq reg 1 0x00 ]
tests/py/any/tcpopt.t.payload +44 -44

247 lines not on this page · raw message

tests/py/arp/arp.t.payload +49 -50

298 lines not on this page · raw message

tests/py/arp/arp.t.payload.netdev +94 -95

441 lines not on this page · raw message

tests/py/bridge/ether.t.payload +21 -22

81 lines not on this page · raw message

tests/py/bridge/icmpX.t.payload +12 -13
index f9ea7b60450af..d6634beadb26b 100644
@@ -1,36 +1,35 @@
 # ip protocol icmp icmp type echo-request
 bridge test-bridge input
   [ meta load protocol => reg 1 ]
-  [ cmp eq reg 1 0x00000008 ]
+  [ cmp eq reg 1 0x0800 ]
   [ payload load 1b @ network header + 9 => reg 1 ]
-  [ cmp eq reg 1 0x00000001 ]
+  [ cmp eq reg 1 0x01 ]
   [ payload load 1b @ transport header + 0 => reg 1 ]
-  [ cmp eq reg 1 0x00000008 ]
+  [ cmp eq reg 1 0x08 ]
 
 # icmp type echo-request
 bridge test-bridge input
   [ payload load 2b @ link header + 12 => reg 1 ]
-  [ cmp eq reg 1 0x00000008 ]
+  [ cmp eq reg 1 0x0800 ]
   [ meta load l4proto => reg 1 ]
-  [ cmp eq reg 1 0x00000001 ]
+  [ cmp eq reg 1 0x01 ]
   [ payload load 1b @ transport header + 0 => reg 1 ]
-  [ cmp eq reg 1 0x00000008 ]
+  [ cmp eq reg 1 0x08 ]
 
 # ip6 nexthdr icmpv6 icmpv6 type echo-request
 bridge test-bridge input
   [ meta load protocol => reg 1 ]
-  [ cmp eq reg 1 0x0000dd86 ]
+  [ cmp eq reg 1 0x86dd ]
   [ payload load 1b @ network header + 6 => reg 1 ]
-  [ cmp eq reg 1 0x0000003a ]
+  [ cmp eq reg 1 0x3a ]
   [ payload load 1b @ transport header + 0 => reg 1 ]
-  [ cmp eq reg 1 0x00000080 ]
+  [ cmp eq reg 1 0x80 ]
 
 # icmpv6 type echo-request
 bridge test-bridge input
   [ payload load 2b @ link header + 12 => reg 1 ]
-  [ cmp eq reg 1 0x0000dd86 ]
+  [ cmp eq reg 1 0x86dd ]
   [ meta load l4proto => reg 1 ]
-  [ cmp eq reg 1 0x0000003a ]
+  [ cmp eq reg 1 0x3a ]
   [ payload load 1b @ transport header + 0 => reg 1 ]
-  [ cmp eq reg 1 0x00000080 ]
-
+  [ cmp eq reg 1 0x80 ]
tests/py/bridge/meta.t.payload +10 -10
index 0a39842aedf3e..bbbf7968ed6ca 100644
@@ -1,37 +1,37 @@
 # meta obrname "br0"
 bridge test-bridge input
   [ meta load bri_oifname => reg 1 ]
-  [ cmp eq reg 1 0x00307262 0x00000000 0x00000000 0x00000000 ]
+  [ cmp eq reg 1 0x62723000 0x00000000 0x00000000 0x00000000 ]
 
 # meta ibrname "br0"
 bridge test-bridge input
   [ meta load bri_iifname => reg 1 ]
-  [ cmp eq reg 1 0x00307262 0x00000000 0x00000000 0x00000000 ]
+  [ cmp eq reg 1 0x62723000 0x00000000 0x00000000 0x00000000 ]
 
 # meta ibrvproto vlan
 bridge test-bridge input
   [ meta load bri_iifvproto => reg 1 ]
-  [ cmp eq reg 1 0x00000081 ]
+  [ cmp eq reg 1 0x8100 ]
 
 # meta ibrpvid 100
 bridge test-bridge input
   [ meta load bri_iifpvid => reg 1 ]
-  [ cmp eq reg 1 0x00000064 ]
+  [ cmp eq reg 1 0x0064 ]
 
 # meta protocol ip udp dport 67
 bridge test-bridge input
   [ meta load protocol => reg 1 ]
-  [ cmp eq reg 1 0x00000008 ]
+  [ cmp eq reg 1 0x0800 ]
   [ meta load l4proto => reg 1 ]
-  [ cmp eq reg 1 0x00000011 ]
+  [ cmp eq reg 1 0x11 ]
   [ payload load 2b @ transport header + 2 => reg 1 ]
-  [ cmp eq reg 1 0x00004300 ]
+  [ cmp eq reg 1 0x0043 ]
 
 # meta protocol ip6 udp dport 67
 bridge test-bridge input
   [ meta load protocol => reg 1 ]
-  [ cmp eq reg 1 0x0000dd86 ]
+  [ cmp eq reg 1 0x86dd ]
   [ meta load l4proto => reg 1 ]
-  [ cmp eq reg 1 0x00000011 ]
+  [ cmp eq reg 1 0x11 ]
   [ payload load 2b @ transport header + 2 => reg 1 ]
-  [ cmp eq reg 1 0x00004300 ]
+  [ cmp eq reg 1 0x0043 ]
tests/py/bridge/redirect.t.payload +1 -1
index 1fcfa5f1b04ff..a0afec94171fa 100644
@@ -1,4 +1,4 @@
 # meta broute set 1
 bridge test-bridge prerouting
-  [ immediate reg 1 0x00000001 ]
+  [ immediate reg 1 0x01 ]
   [ meta set broute with reg 1 ]
tests/py/bridge/reject.t.payload +21 -22

142 lines not on this page · raw message

tests/py/bridge/vlan.t.payload +131 -131

350 lines not on this page · raw message

tests/py/bridge/vlan.t.payload.netdev +158 -158

316 lines not on this page · raw message

tests/py/inet/ah.t.payload +44 -45

89 lines not on this page · raw message

tests/py/inet/comp.t.payload +26 -27

53 lines not on this page · raw message

tests/py/inet/ct.t.payload +7 -7
index 216dad2bb531c..4e9d5f04a6a2c 100644

Lines of this file are not shown. View the raw message.

tests/py/inet/dccp.t.payload +26 -27

53 lines not on this page · raw message

tests/py/inet/dnat.t.payload +23 -24

47 lines not on this page · raw message

tests/py/inet/esp.t.payload +22 -23

45 lines not on this page · raw message

tests/py/inet/ether-ip.t.payload +11 -11
index 62e37a597b967..912a19b857dfd 100644

Lines of this file are not shown. View the raw message.

tests/py/inet/ether-ip.t.payload.netdev +11 -12
index b0fa6d84b31b1..aca7a4b72ab7f 100644

Lines of this file are not shown. View the raw message.

tests/py/inet/ether.t.payload +18 -19
index 8b74a7815d8ec..e0a36d43745b6 100644

Lines of this file are not shown. View the raw message.

tests/py/inet/ether.t.payload.bridge +14 -15
index 0128d5f02b978..d5d4f5c0d49f7 100644

Lines of this file are not shown. View the raw message.

tests/py/inet/ether.t.payload.ip +18 -19
index 7c91f412c33ee..5a4fb00808b15 100644

Lines of this file are not shown. View the raw message.

tests/py/inet/fib.t.payload +6 -6
index 02d92b57a4776..612e5ba827a64 100644

Lines of this file are not shown. View the raw message.

tests/py/inet/geneve.t.payload +41 -42

83 lines not on this page · raw message

tests/py/inet/gre.t.payload +26 -27

53 lines not on this page · raw message

tests/py/inet/gretap.t.payload +29 -30

59 lines not on this page · raw message

tests/py/inet/icmp.t.payload +18 -19
index f98cfc39abed4..4db6b6fe2326e 100644

Lines of this file are not shown. View the raw message.

tests/py/inet/icmpX.t.payload +16 -16
index 9a761eef632ed..61b857b52737a 100644

Lines of this file are not shown. View the raw message.

tests/py/inet/ip.t.payload +2 -2
index 589a5cd35a806..6ed1967d29ae3 100644

Lines of this file are not shown. View the raw message.

tests/py/inet/ip.t.payload.bridge +2 -2
index 57dbc9eb42e77..3e7421c8152d3 100644

Lines of this file are not shown. View the raw message.

tests/py/inet/ip.t.payload.inet +3 -4
index 8df41defea0a1..f566c98814c5b 100644

Lines of this file are not shown. View the raw message.

tests/py/inet/ip.t.payload.netdev +3 -4
index 95be9194f2fed..e3799893f7428 100644

Lines of this file are not shown. View the raw message.

tests/py/inet/ip_tcp.t.payload +18 -18
index 1e16f8522849b..cf68b98a1468f 100644

Lines of this file are not shown. View the raw message.

tests/py/inet/ip_tcp.t.payload.bridge +17 -18
index 0344cd66668cc..121052d901137 100644

Lines of this file are not shown. View the raw message.

tests/py/inet/ip_tcp.t.payload.netdev +18 -19
index 915a78706d598..bef0d6f575a98 100644

Lines of this file are not shown. View the raw message.

tests/py/inet/ipsec.t.payload +5 -6
index f8ecd9d1cc1f3..2e012db1f6436 100644

Lines of this file are not shown. View the raw message.

tests/py/inet/map.t.payload +5 -6
index 50344ada9161a..f9ab4ef6d9125 100644

Lines of this file are not shown. View the raw message.

tests/py/inet/map.t.payload.ip +3 -4
index 3e45667573394..33c03e49d17f9 100644

Lines of this file are not shown. View the raw message.

tests/py/inet/map.t.payload.netdev +5 -6
index 2e60f09d752d6..af1cfeb72a630 100644

Lines of this file are not shown. View the raw message.

tests/py/inet/meta.t.payload +41 -42

83 lines not on this page · raw message

tests/py/inet/osf.t.payload +8 -8
index 6ddab9763b649..65d0a2e01a8d6 100644

Lines of this file are not shown. View the raw message.

tests/py/inet/payloadmerge.t.payload +21 -22

43 lines not on this page · raw message

tests/py/inet/reject.t.payload.inet +21 -22

43 lines not on this page · raw message

tests/py/inet/rt.t.payload +3 -4
index 84dea12caad5d..3d65fef625a45 100644

Lines of this file are not shown. View the raw message.

tests/py/inet/sctp.t.payload +79 -80

159 lines not on this page · raw message

tests/py/inet/sets.t.payload.bridge +7 -8
index 3dd9d57bc0ce8..c5be4cae0f730 100644

Lines of this file are not shown. View the raw message.

tests/py/inet/sets.t.payload.inet +7 -7
index 53c6b1821af7c..8c903b35aa49c 100644

Lines of this file are not shown. View the raw message.

tests/py/inet/sets.t.payload.netdev +7 -7
index e31aeb9274e66..376600152cc38 100644

Lines of this file are not shown. View the raw message.

tests/py/inet/snat.t.payload +15 -15
index 50519c6b6bb6f..3399d33ece150 100644

Lines of this file are not shown. View the raw message.

tests/py/inet/socket.t.payload +4 -4
index e66ccbf70aeaf..c3520db81833c 100644

Lines of this file are not shown. View the raw message.

tests/py/inet/tcp.t.payload +180 -180

360 lines not on this page · raw message

tests/py/inet/tproxy.t.payload +22 -23

45 lines not on this page · raw message

tests/py/inet/udp.t.payload +56 -56

112 lines not on this page · raw message

tests/py/inet/udplite.t.payload +40 -41

81 lines not on this page · raw message

tests/py/inet/vmap.t.payload +6 -7
index 29ec846deb2ee..c905f80eb2cf9 100644

Lines of this file are not shown. View the raw message.

tests/py/inet/vmap.t.payload.netdev +6 -7
index 3f51bb33054a2..881550df2883f 100644

Lines of this file are not shown. View the raw message.

tests/py/inet/vxlan.t.payload +41 -42

83 lines not on this page · raw message

tests/py/ip/ct.t.payload +23 -23

46 lines not on this page · raw message

tests/py/ip/dnat.t.payload.ip +58 -59

117 lines not on this page · raw message

tests/py/ip/dup.t.payload +3 -4
index 347dc07ad0be2..4e1c90702fa7e 100644

Lines of this file are not shown. View the raw message.

tests/py/ip/ether.t.payload +18 -19
index bd7c8f1506329..7d134894f1196 100644

Lines of this file are not shown. View the raw message.

tests/py/ip/hash.t.payload +1 -1
index fefe492d8cbef..f7241250628a3 100644

Lines of this file are not shown. View the raw message.

tests/py/ip/icmp.t.payload.ip +156 -156

312 lines not on this page · raw message

tests/py/ip/igmp.t.payload +30 -31

61 lines not on this page · raw message

tests/py/ip/ip.t.payload +123 -123

246 lines not on this page · raw message

tests/py/ip/ip.t.payload.bridge +220 -220

440 lines not on this page · raw message

tests/py/ip/ip.t.payload.inet +220 -220

440 lines not on this page · raw message

tests/py/ip/ip.t.payload.netdev +217 -217

434 lines not on this page · raw message

tests/py/ip/ip_tcp.t.payload +4 -5
index f6f640d43865b..cefbcafb392ce 100644

Lines of this file are not shown. View the raw message.

tests/py/ip/masquerade.t.payload +35 -36

71 lines not on this page · raw message

tests/py/ip/meta.t.payload +16 -16
index 880ac5d6c707a..bfdac5b3e4349 100644

Lines of this file are not shown. View the raw message.

tests/py/ip/numgen.t.payload +2 -2
index b4eadf857d13d..f405790e8f0de 100644

Lines of this file are not shown. View the raw message.

tests/py/ip/objects.t.payload +13 -13
index 3da4b28512b6f..b0b71818d5483 100644

Lines of this file are not shown. View the raw message.

tests/py/ip/redirect.t.payload +60 -61

121 lines not on this page · raw message

tests/py/ip/reject.t.payload +1 -2
index 5829065a154f6..c5419d096cf37 100644

Lines of this file are not shown. View the raw message.

tests/py/ip/rt.t.payload +1 -2
index 93eef4a77bb72..97c0ad30f2449 100644

Lines of this file are not shown. View the raw message.

tests/py/ip/sets.t.payload.inet +19 -19
index cc04b43d64bff..de8182e00c014 100644

Lines of this file are not shown. View the raw message.

tests/py/ip/sets.t.payload.ip +6 -6
index f9ee1f98203bf..957133707c62a 100644

Lines of this file are not shown. View the raw message.

tests/py/ip/sets.t.payload.netdev +19 -19
index 3d0dc79acfd91..66e20fa980221 100644

Lines of this file are not shown. View the raw message.

tests/py/ip/snat.t.payload +37 -37

74 lines not on this page · raw message

tests/py/ip/tcp.t.payload +5 -6
index 58956d984b1b7..cb464b17d0e8a 100644

Lines of this file are not shown. View the raw message.

tests/py/ip/tproxy.t.payload +14 -15
index dfe830ec37152..2f2ff0e2f5bec 100644

Lines of this file are not shown. View the raw message.

tests/py/ip6/ct.t.payload +6 -6
index a7a56d4be80bf..35f64e646f1cd 100644

Lines of this file are not shown. View the raw message.

tests/py/ip6/dnat.t.payload.ip6 +19 -19
index fe6e0422f074b..26f0f603b531c 100644

Lines of this file are not shown. View the raw message.

tests/py/ip6/dst.t.payload.inet +30 -30

60 lines not on this page · raw message

tests/py/ip6/dst.t.payload.ip6 +15 -15
index ac1fc8b39a2b7..f4fc9aed36671 100644

Lines of this file are not shown. View the raw message.

tests/py/ip6/dup.t.payload +3 -4
index c441d4be981bf..55bb3747d9608 100644

Lines of this file are not shown. View the raw message.

tests/py/ip6/ether.t.payload +18 -18
index 592b4ea0e0bcc..b26ad647a19c2 100644

Lines of this file are not shown. View the raw message.

tests/py/ip6/exthdr.t.payload.ip6 +12 -13
index be10d61ef6ccc..230a51375c797 100644

Lines of this file are not shown. View the raw message.

tests/py/ip6/frag.t.payload.inet +65 -66

131 lines not on this page · raw message

tests/py/ip6/frag.t.payload.ip6 +37 -38

75 lines not on this page · raw message

tests/py/ip6/frag.t.payload.netdev +65 -66

131 lines not on this page · raw message

tests/py/ip6/hbh.t.payload.inet +32 -33

65 lines not on this page · raw message

tests/py/ip6/hbh.t.payload.ip6 +16 -17
index a6bc7ae65475d..96c3ee2443f5e 100644

Lines of this file are not shown. View the raw message.

tests/py/ip6/icmpv6.t.payload.ip6 +161 -161

322 lines not on this page · raw message

tests/py/ip6/ip6.t.payload.inet +179 -180

359 lines not on this page · raw message

tests/py/ip6/ip6.t.payload.ip6 +95 -96

191 lines not on this page · raw message

tests/py/ip6/map.t.payload +2 -3
index 8e900c18c5e3d..ea39a81e83ff0 100644

Lines of this file are not shown. View the raw message.

tests/py/ip6/masquerade.t.payload.ip6 +35 -36

71 lines not on this page · raw message

tests/py/ip6/meta.t.payload +18 -18
index 6a37f1dee7edf..c36707421ba01 100644

Lines of this file are not shown. View the raw message.

tests/py/ip6/mh.t.payload.inet +66 -66

132 lines not on this page · raw message

tests/py/ip6/mh.t.payload.ip6 +33 -33

66 lines not on this page · raw message

tests/py/ip6/redirect.t.payload.ip6 +52 -53

105 lines not on this page · raw message

tests/py/ip6/reject.t.payload.ip6 +1 -2
index 3d4321b098c20..6b1282693a9a9 100644

Lines of this file are not shown. View the raw message.

tests/py/ip6/rt.t.payload.inet +60 -61

121 lines not on this page · raw message

tests/py/ip6/rt.t.payload.ip6 +30 -31

61 lines not on this page · raw message

tests/py/ip6/rt0.t.payload +1 -2
index 464b7f212fc5c..7b4d6d7b48e96 100644

Lines of this file are not shown. View the raw message.

tests/py/ip6/sets.t.payload.inet +9 -9
index 2dbb818a8aa1b..f694209f23b5b 100644

Lines of this file are not shown. View the raw message.

tests/py/ip6/sets.t.payload.ip6 +2 -2
index 7234b989a57db..8b7379a252fdc 100644

Lines of this file are not shown. View the raw message.

tests/py/ip6/sets.t.payload.netdev +9 -9
index 2ad0f434b3dc2..2441a44c8ca01 100644

Lines of this file are not shown. View the raw message.

tests/py/ip6/snat.t.payload.ip6 +11 -12
index 96a9ba0a3111d..01abb1ca3e677 100644

Lines of this file are not shown. View the raw message.

tests/py/ip6/srh.t.payload +11 -12
index 364940a95ee63..5c3031f3bdd23 100644

Lines of this file are not shown. View the raw message.

tests/py/ip6/tproxy.t.payload +14 -15
index 9f28e80b4142c..109b697ff9ff3 100644

Lines of this file are not shown. View the raw message.

tests/py/ip6/vmap.t.payload.inet +84 -85

169 lines not on this page · raw message

tests/py/ip6/vmap.t.payload.ip6 +42 -43

85 lines not on this page · raw message

tests/py/ip6/vmap.t.payload.netdev +84 -85

169 lines not on this page · raw message

tests/py/netdev/dup.t.payload +1 -2
index 51ff782c0525f..971dd1bbf5c5d 100644

Lines of this file are not shown. View the raw message.

tests/py/netdev/fwd.t.payload +2 -3
index f03077a60e2d1..3453c38f1a5f8 100644

Lines of this file are not shown. View the raw message.

tests/py/netdev/reject.t.payload +20 -21

41 lines not on this page · raw message

tests/py/netdev/tunnel.t.payload +2 -3
index 9148d0e5b6cb0..8692c92c5e5c0 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.51.0

Part of the diff is not shown here. View the raw message.

author reviewer
#13 lore raw

PATCH v2 11/11 utils: Introduce expr_print_debug()

In reply to Phil Sutter

A simple function to call in random places when debugging expression-related code.

---
 include/utils.h | 9 +++++++++
 1 file changed, 9 insertions(+)
include/utils.h +9 -0
index 6a0e494607c93..1c227f6849a22 100644
@@ -27,6 +27,15 @@
 #define pr_gmp_debug(fmt, arg...) ({ if (false) {}; 0; })
 #endif
 
+#define expr_print_debug(expr)					\
+{								\
+	struct output_ctx octx = { .output_fp = stdout };	\
+	printf("%s:%d: ", __FILE__, __LINE__);			\
+	printf("'" #expr "' type %s: ", expr_name(expr));	\
+	expr_print((expr), &octx);				\
+	printf("\n");						\
+}
+
 #define __fmtstring(x, y)	__attribute__((format(printf, x, y)))
 
 #define __must_check		__attribute__((warn_unused_result))
Signature · 1 line
2.51.0
author reviewer
#14 lore raw
In reply to Phil Sutter
Quoted 38 lines · Phil Sutter

Make use of recent changes to libnftnl to make test suites pass on both Little and Big Endian systems.

Changes since v1:
- First 12 patches accepted and pushed already, patches 27 and 28 as well
- Minimize changes to existing code: Drop patch 13 changing string-based expressions to be defined as Big Endian as well as related patches 14, 17 and 18
- Pull a fix for concatenated wildcard interface names upfront
- Follow with set element sorting changes, with improved patch descriptions and related test suite record changes folded into them for clarification of practical effect
- Review patch descriptions in general
- Add special casing to patch 5 to avoid string-based values being printed in reverse by libnftnl, also communicate any byteorder conversions from __netlink_gen_concat_key() back to caller for the same purpose

Patch 1 works around "funny" behaviour of GMP when partially exporting data and unwanted prefix-padding when exporting into an oversized buffer, all happening on Big Endian only.

Patches 2 and 3 deal with sorting of set elements. They are effective on Little Endian only, changing sort ordering to match that of Big Endian.

Patches 4 and 5 are preparation for the next two patches.

Patches 6 and 7 collect data for calls to newly introduced libnftnl API functions (in patch 8) to communicate byte order and component sizes in data regs to libnftnl.

Patch 10 contains the big payload records update, created with help from the script introduced in patch 9.

Patch 11 still contains the expr_print_debug() macro definition for use with printf-debugging.

Quoted 12 lines

Phil Sutter (11):
segtree: Fix range aggregation on Big Endian
mergesort: Fix sorting of string values
mergesort: Align concatenation sort order with Big Endian
intervals: Convert byte order implicitly
expression: Set range expression 'len' field
netlink: Introduce struct nft_data_linearize::byteorder
netlink: Introduce struct nft_data_linearize::sizes
netlink: Make use of nftnl_{expr,set_elem}_set_imm()
tests: py: tools: Add regen_payloads.sh
tests: py: Update payload records
utils: Introduce expr_print_debug()

Series applied.