Skip to contentSkip to conversation

Fix netdevsim switch_id display truncation

PATCH New Gris Ge 1 participant 1 message Jul 12

Subsystems (2)
lore
Share & tools
lore

Gris Ge

author
#0 lore raw

PATCH 1/1 Fix netdevsim switch_id display truncation

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.

---
 include/utils.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/utils.h +1 -1
index f0d45bad..c451baa9 100644
@@ -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));
Signature · 1 line
2.55.0