Netdev List
 help / color / mirror / Atom feed
From: Prabhakar Pujeri <prabhakar.pujeri@dell.com>
To: prabhakar.pujeri@dell.com, netdev@vger.kernel.org
Subject: [PATCH iproute2] u32: fix IPv6 port match pretty printing
Date: Mon, 31 Aug 2026 10:40:57 +0000	[thread overview]
Message-ID: <20260831104057.2176-1-prabhakar.pujeri@dell.com> (raw)

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 <prabhakar.pujeri@dell.com>
---
 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


             reply	other threads:[~2026-08-31 10:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-31 10:40 Prabhakar Pujeri [this message]
2026-09-01 15:58 ` [PATCH iproute2] u32: fix IPv6 port match pretty printing Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260831104057.2176-1-prabhakar.pujeri@dell.com \
    --to=prabhakar.pujeri@dell.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox