Netdev List
 help / color / mirror / Atom feed
* [PATCH iproute2-next] Fix netdevsim switch_id display truncation
@ 2026-07-12  3:45 Gris Ge
  0 siblings, 0 replies; only message in thread
From: Gris Ge @ 2026-07-12  3:45 UTC (permalink / raw)
  To: netdev, David Ahern; +Cc: Gris Ge

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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-07-12  3:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-12  3:45 [PATCH iproute2-next] Fix netdevsim switch_id display truncation Gris Ge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox