linux-cp: auto select tap id when creating lcp pair 56/38456/5
authorStanislav Zaikin <[email protected]>
Thu, 9 Mar 2023 18:35:11 +0000 (19:35 +0100)
committerMatthew Smith <[email protected]>
Fri, 6 Sep 2024 14:09:48 +0000 (14:09 +0000)
Now when lcp pair is created, tap instance is based on hw_id. But tap
interface with such instance can already exist. Introduce an offset and
auto-selection based on it.

Type: fix

Signed-off-by: Stanislav Zaikin <[email protected]>
Change-Id: I9db39106b0b0d5bf95c445b03e5b7ff52f946dd2

src/plugins/linux-cp/lcp_interface.c
src/vnet/devices/tap/tap.c
src/vnet/devices/tap/tap.h

index b1c0ad5..61665ad 100644 (file)
@@ -1001,7 +1001,8 @@ lcp_itf_pair_create (u32 phy_sw_if_index, u8 *host_if_name,
          clib_max (1, lcp_get_default_num_queues (0 /* is_tx */)),
        .num_tx_queues =
          clib_max (1, lcp_get_default_num_queues (1 /* is_tx */)),
-       .id = hw->hw_if_index,
+       .id = ~0,
+       .auto_id_offset = 4096,
        .sw_if_index = ~0,
        .rx_ring_sz = 256,
        .tx_ring_sz = 256,
index 1e2ee87..b0b0a3a 100644 (file)
@@ -85,7 +85,7 @@ virtio_eth_set_max_frame_size (vnet_main_t *vnm, vnet_hw_interface_t *hi,
   return 0;
 }
 
-#define TAP_MAX_INSTANCE 1024
+#define TAP_MAX_INSTANCE 8192
 
 static void
 tap_free (vlib_main_t * vm, virtio_if_t * vif)
@@ -162,7 +162,8 @@ tap_create_if (vlib_main_t * vm, tap_create_if_args_t * args)
     }
   else
     {
-      args->id = clib_bitmap_first_clear (tm->tap_ids);
+      args->id = clib_bitmap_next_clear (tm->tap_ids, args->auto_id_offset %
+                                                       TAP_MAX_INSTANCE);
     }
 
   if (args->id > TAP_MAX_INSTANCE)
index 6b88c34..1df2fb7 100644 (file)
@@ -42,6 +42,7 @@ typedef enum
 typedef struct
 {
   u32 id;
+  u32 auto_id_offset;
   u8 mac_addr_set;
   mac_address_t mac_addr;
   u16 num_rx_queues;