af_packet: include if name in fanout id 51/43151/2
authorFlorin Coras <[email protected]>
Thu, 12 Jun 2025 07:51:46 +0000 (03:51 -0400)
committerFlorin Coras <[email protected]>
Thu, 12 Jun 2025 07:55:23 +0000 (07:55 +0000)
Useful when running multiple vpps with veth interfaces with same device
ids and multiple rx/tx queues configured

Type: improvement

Change-Id: I9fd23ad941883850f694c973db8cb8345dd901c2
Signed-off-by: Florin Coras <[email protected]>
src/plugins/af_packet/af_packet.c

index 56d90c0..86c2685 100644 (file)
@@ -434,6 +434,14 @@ error:
   return ret;
 }
 
+static u32
+af_packet_make_fanout_id (af_packet_if_t *apif)
+{
+  u16 if_hash =
+    hash_memory (apif->host_if_name, strlen ((char *) apif->host_if_name), 0);
+  return (apif->dev_instance & 0xffff) ^ (if_hash & 0xff00);
+}
+
 int
 af_packet_queue_init (vlib_main_t *vm, af_packet_if_t *apif,
                      af_packet_create_if_arg_t *arg,
@@ -506,9 +514,9 @@ af_packet_queue_init (vlib_main_t *vm, af_packet_if_t *apif,
 
   if (rx_queue || tx_queue)
     {
-      ret =
-       create_packet_sock (apif->host_if_index, rx_req, tx_req, &fd, &ring,
-                           apif->dev_instance, &arg->flags, apif->version);
+      ret = create_packet_sock (apif->host_if_index, rx_req, tx_req, &fd,
+                               &ring, af_packet_make_fanout_id (apif),
+                               &arg->flags, apif->version);
 
       if (ret != 0)
        goto error;