vnet: fix set interfaces rx-placement cli 91/43591/2
authorBenoît Ganne <[email protected]>
Wed, 20 Aug 2025 08:13:52 +0000 (10:13 +0200)
committerDamjan Marion <[email protected]>
Thu, 28 Aug 2025 20:19:49 +0000 (20:19 +0000)
 - unformat() parses 32-bit integers whereas clib_thread_t is a 16-bit
   integers, yielding stack overflow
 - no need to pass thread_index when parsing main
 - validate thread_index otherwise ~0 + 1 arithmetic done in
   set_hw_interface_rx_placement() selects main thread by default

Type: fix
Fixes: fc7b794758fbdd9bcae337e90255c1fc1e548808

Change-Id: I36dcba977573a32f6f91e6c5470966f35cce30ed
Signed-off-by: Benoît Ganne <[email protected]>
src/vnet/interface_cli.c

index b49ad24..a92718b 100644 (file)
@@ -1732,7 +1732,7 @@ set_interface_rx_placement (vlib_main_t *vm, unformat_input_t *input,
   vnet_main_t *vnm = vnet_get_main ();
   u32 hw_if_index = (u32) ~ 0;
   u32 queue_id = (u32) 0;
-  clib_thread_index_t thread_index = CLIB_INVALID_THREAD_INDEX;
+  u32 thread_index = (u32) ~0;
   u8 is_main = 0;
 
   if (!unformat_user (input, unformat_line_input, line_input))
@@ -1745,7 +1745,7 @@ set_interface_rx_placement (vlib_main_t *vm, unformat_input_t *input,
        ;
       else if (unformat (line_input, "queue %d", &queue_id))
        ;
-      else if (unformat (line_input, "main", &thread_index))
+      else if (unformat (line_input, "main"))
        is_main = 1;
       else if (unformat (line_input, "worker %d", &thread_index))
        ;
@@ -1763,6 +1763,9 @@ set_interface_rx_placement (vlib_main_t *vm, unformat_input_t *input,
   if (hw_if_index == (u32) ~ 0)
     return clib_error_return (0, "please specify valid interface name");
 
+  if (thread_index == (u32) ~0 && !is_main)
+    return clib_error_return (0, "please specify valid worker thread or main");
+
   error = set_hw_interface_rx_placement (hw_if_index, queue_id, thread_index,
                                         is_main);