hs-test: fix LDPreloadIperfVppTest
[vpp.git] / src / vnet / ethernet / p2p_ethernet.c
index e3f667b..0ece84f 100644 (file)
@@ -96,6 +96,31 @@ p2p_ethernet_add_del (vlib_main_t * vm, u32 parent_if_index,
          if (vnet_create_sw_interface (vnm, &template, &p2pe_sw_if_index))
            return VNET_API_ERROR_SUBIF_CREATE_FAILED;
 
+         /* Allocate counters for this interface. */
+         {
+           u32 i;
+
+           vnet_interface_counter_lock (im);
+
+           for (i = 0; i < vec_len (im->sw_if_counters); i++)
+             {
+               vlib_validate_simple_counter (&im->sw_if_counters[i],
+                                             p2pe_sw_if_index);
+               vlib_zero_simple_counter (&im->sw_if_counters[i],
+                                         p2pe_sw_if_index);
+             }
+
+           for (i = 0; i < vec_len (im->combined_sw_if_counters); i++)
+             {
+               vlib_validate_combined_counter (&im->combined_sw_if_counters
+                                               [i], p2pe_sw_if_index);
+               vlib_zero_combined_counter (&im->combined_sw_if_counters[i],
+                                           p2pe_sw_if_index);
+             }
+
+           vnet_interface_counter_unlock (im);
+         }
+
          vnet_interface_main_t *im = &vnm->interface_main;
          sup_and_sub_key =
            ((u64) (hi->sw_if_index) << 32) | (u64) p2pe_subif_id;
@@ -121,6 +146,8 @@ p2p_ethernet_add_del (vlib_main_t * vm, u32 parent_if_index,
              vnet_feature_enable_disable ("device-input",
                                           "p2p-ethernet-input",
                                           parent_if_index, 1, 0, 0);
+             vnet_feature_enable_disable ("port-rx-eth", "p2p-ethernet-input",
+                                          parent_if_index, 1, 0, 0);
              /* Set promiscuous mode on the l2 interface */
              ethernet_set_flags (vnm, parent_if_index,
                                  ETHERNET_INTERFACE_FLAG_ACCEPT_ALL);
@@ -128,7 +155,8 @@ p2p_ethernet_add_del (vlib_main_t * vm, u32 parent_if_index,
            }
          p2pm->p2p_ethernet_by_sw_if_index[parent_if_index]++;
          /* set the interface mode */
-         set_int_l2_mode (vm, vnm, MODE_L3, p2pe_subif_id, 0, 0, 0, 0);
+         set_int_l2_mode (vm, vnm, MODE_L3, p2pe_sw_if_index, 0,
+                          L2_BD_PORT_TYPE_NORMAL, 0, 0);
          return 0;
        }
       return VNET_API_ERROR_SUBIF_ALREADY_EXISTS;
@@ -150,6 +178,9 @@ p2p_ethernet_add_del (vlib_main_t * vm, u32 parent_if_index,
                  vnet_feature_enable_disable ("device-input",
                                               "p2p-ethernet-input",
                                               parent_if_index, 0, 0, 0);
+                 vnet_feature_enable_disable ("port-rx-eth",
+                                              "p2p-ethernet-input",
+                                              parent_if_index, 0, 0, 0);
                  /* Disable promiscuous mode on the l2 interface */
                  ethernet_set_flags (vnm, parent_if_index, 0);
                }
@@ -222,10 +253,11 @@ vnet_p2p_ethernet_add_del (vlib_main_t * vm, unformat_input_t * input,
   return 0;
 }
 
-VLIB_CLI_COMMAND (p2p_ethernet_add_del_command, static) =
-{
-.path = "p2p_ethernet ",.function = vnet_p2p_ethernet_add_del,.short_help =
-    "p2p_ethernet <intfc> <mac-address> [sub-id <id> | del]",};
+VLIB_CLI_COMMAND (p2p_ethernet_add_del_command, static) = {
+  .path = "p2p_ethernet",
+  .function = vnet_p2p_ethernet_add_del,
+  .short_help = "p2p_ethernet <intfc> <mac-address> [sub-id <id>|del]",
+};
 
 static clib_error_t *
 p2p_ethernet_init (vlib_main_t * vm)