[PATCH iproute2] u32: fix IPv6 port match pretty printing
From: Prabhakar Pujeri <hidden>
Date: 2026-08-31 10:41:04
Subsystem:
the rest · Maintainer:
Linus Torvalds
parse_ip6() stores source and destination ports in the 32-bit key at
offset 40. print_ipv6() checks offset 20 instead, so it does not print
the decoded port fields. The source and destination labels in that case
are also reversed relative to the layout produced by pack_key16().
Handle offset 40 and use the source label for the high half and the
destination label for the low half. This matches the parser and the
equivalent IPv4 printer in both text and JSON output.
Fixes: d13cee6d598d ("Add IPV6 match pretty print")
Signed-off-by: Prabhakar Pujeri <redacted>
---
tc/f_u32.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/tc/f_u32.c b/tc/f_u32.c
index ae285146..304fbfa8 100644
--- a/tc/f_u32.c
+++ b/tc/f_u32.c@@ -948,22 +948,22 @@ static void print_ipv6(const struct tc_u32_key *key) } break; - case 20: + case 40: switch (ntohl(key->mask)) { case 0x0000ffff: print_nl(); - print_uint(PRINT_ANY, "sport", " match sport %u", + print_uint(PRINT_ANY, "dport", " match dport %u", ntohl(key->val) & 0xffff); break; case 0xffff0000: - print_uint(PRINT_ANY, "dport", "match dport %u", + print_uint(PRINT_ANY, "sport", "match sport %u", ntohl(key->val) >> 16); break; case 0xffffffff: print_nl(); - print_uint(PRINT_ANY, "sport", " match sport %u, ", + print_uint(PRINT_ANY, "dport", " match dport %u, ", ntohl(key->val) & 0xffff); - print_uint(PRINT_ANY, "dport", "match dport %u", + print_uint(PRINT_ANY, "sport", "match sport %u", ntohl(key->val) >> 16); break;
--
2.55.0