Netdev List
 help / color / mirror / Atom feed
From: Gris Ge <cnfourt@gmail.com>
To: netdev@vger.kernel.org, David Ahern <dsahern@kernel.org>
Cc: Gris Ge <cnfourt@gmail.com>
Subject: [PATCH iproute2-next] Fix netdevsim switch_id display truncation
Date: Sun, 12 Jul 2026 11:45:17 +0800	[thread overview]
Message-ID: <20260712034528.937880-2-cnfourt@gmail.com> (raw)

Problem:

The `ip -d link show sim0` against of netdevsim interface, the
`switchid` only has 62 chars. The kernel `struct netdev_phys_item_id`
confirmed the switch id is 32 bytes which should produces 64 hex chars.

Root cause:

When `print_linkinfo()` showing `switchid`, it invokes `hexstring_n2a()`
which output hex string to `SPRINT_BUF(b1)` including trailing NULL.
The 32 bytes binary need 65 chars including trailing NULL while
`SPRINT_BUF` is 64 chars.

Fix:

Bump `SPRINT_BSIZE` from 64 to 128.

Signed-off-by: Gris Ge <cnfourt@gmail.com>
---
 include/utils.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/utils.h b/include/utils.h
index f0d45bad..c451baa9 100644
--- a/include/utils.h
+++ b/include/utils.h
@@ -39,7 +39,7 @@ extern bool do_all;
 extern int echo_request;
 extern int use_iec;
 
-#define SPRINT_BSIZE 64
+#define SPRINT_BSIZE 128
 #define SPRINT_BUF(x)	char x[SPRINT_BSIZE]
 
 void incomplete_command(void) __attribute__((noreturn));
-- 
2.55.0


                 reply	other threads:[~2026-07-12  3:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260712034528.937880-2-cnfourt@gmail.com \
    --to=cnfourt@gmail.com \
    --cc=dsahern@kernel.org \
    --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