af_packet: vec functions should not be used on pool 43/543/1
authorDamjan Marion <damarion@cisco.com>
Wed, 16 Mar 2016 21:59:21 +0000 (22:59 +0100)
committerDamjan Marion <damarion@cisco.com>
Wed, 16 Mar 2016 21:59:21 +0000 (22:59 +0100)
Change-Id: Ifc67db0575a7517ac24519894996906ea44ead67
Signed-off-by: Damjan Marion <damarion@cisco.com>
vnet/vnet/devices/af_packet/af_packet.c
vnet/vnet/devices/af_packet/device.c
vnet/vnet/devices/af_packet/node.c

index 93c8e0c..bbaabad 100644 (file)
@@ -200,7 +200,7 @@ af_packet_create_if(vlib_main_t * vm, u8 * host_if_name, u8 * hw_addr_set)
     goto error;
 
   /* So far everything looks good, let's create interface */
-  vec_add2 (apm->interfaces, apif, 1);
+  pool_get (apm->interfaces, apif);
   if_index = apif - apm->interfaces;
 
   apif->fd = fd;
@@ -241,7 +241,7 @@ af_packet_create_if(vlib_main_t * vm, u8 * host_if_name, u8 * hw_addr_set)
   if (error)
     {
       memset(apif, 0, sizeof(*apif));
-      _vec_len(apm->interfaces) -= 1;
+      pool_put(apm->interfaces, apif);
       clib_error_report (error);
       ret = VNET_API_ERROR_SYSCALL_ERROR_1;
       goto error;
index c00c689..1e05104 100644 (file)
@@ -47,7 +47,7 @@ static u8 * format_af_packet_device_name (u8 * s, va_list * args)
 {
   u32 i = va_arg (*args, u32);
   af_packet_main_t * apm = &af_packet_main;
-  af_packet_if_t * apif = vec_elt_at_index (apm->interfaces, i);
+  af_packet_if_t * apif = pool_elt_at_index (apm->interfaces, i);
 
   s = format (s, "host-%s", apif->host_if_name);
   return s;
@@ -75,7 +75,7 @@ af_packet_interface_tx (vlib_main_t * vm,
   u32 n_left = frame->n_vectors;
   u32 n_sent = 0;
   vnet_interface_output_runtime_t * rd = (void *) node->runtime_data;
-  af_packet_if_t * apif = vec_elt_at_index (apm->interfaces, rd->dev_instance);
+  af_packet_if_t * apif = pool_elt_at_index (apm->interfaces, rd->dev_instance);
   int block = 0;
   u32 block_size = apif->tx_req->tp_block_size;
   u32 frame_size = apif->tx_req->tp_frame_size;
index eadb592..19c0188 100644 (file)
@@ -124,7 +124,7 @@ af_packet_device_input_fn  (vlib_main_t * vm, vlib_node_runtime_t * node,
                            vlib_frame_t * frame, u32 device_idx)
 {
   af_packet_main_t * apm = &af_packet_main;
-  af_packet_if_t * apif = vec_elt_at_index(apm->interfaces, device_idx);
+  af_packet_if_t * apif = pool_elt_at_index(apm->interfaces, device_idx);
   struct tpacket2_hdr *tph;
   u32 next_index = AF_PACKET_INPUT_NEXT_ETHERNET_INPUT;
   u32 block = 0;