Revert "L2-input: use vlib_buffer_enqueue_to_next"
[vpp.git] / src / vnet / l2 / l2_input.c
index c2df5ac..7e41c88 100644 (file)
@@ -176,7 +176,8 @@ classify_and_dispatch (l2input_main_t * msm, vlib_buffer_t * b0, u32 * next0)
       u8 protocol = ((ip6_header_t *) l3h0)->protocol;
 
       /* Disable bridge forwarding (flooding will execute instead if not xconnect) */
-      feat_mask &= ~(L2INPUT_FEAT_FWD | L2INPUT_FEAT_UU_FLOOD);
+      feat_mask &= ~(L2INPUT_FEAT_FWD |
+                    L2INPUT_FEAT_UU_FLOOD | L2INPUT_FEAT_GBP_FWD);
 
       /* Disable ARP-term for non-ARP and non-ICMP6 packet */
       if (ethertype != ETHERNET_TYPE_ARP &&
@@ -538,6 +539,27 @@ l2input_set_bridge_features (u32 bd_index, u32 feat_mask, u32 feat_value)
   return bd_config->feature_bitmap;
 }
 
+void
+l2input_interface_mac_change (u32 sw_if_index,
+                             const u8 * old_address, const u8 * new_address)
+{
+  /* check if the sw_if_index passed is a BVI in a BD */
+  l2_input_config_t *intf_config;
+
+  intf_config = l2input_intf_config (sw_if_index);
+
+  if (intf_config->bridge && intf_config->bvi)
+    {
+      /* delete and re-add l2fib entry for the bvi interface */
+      l2fib_del_entry (old_address, intf_config->bd_index, sw_if_index);
+      l2fib_add_entry (new_address,
+                      intf_config->bd_index,
+                      sw_if_index,
+                      L2FIB_ENTRY_RESULT_FLAG_BVI |
+                      L2FIB_ENTRY_RESULT_FLAG_STATIC);
+    }
+}
+
 /**
  * Set the subinterface to run in l2 or l3 mode.
  * For L3 mode, just the sw_if_index is specified.
@@ -563,7 +585,7 @@ set_int_l2_mode (vlib_main_t * vm, vnet_main_t * vnet_main, /*           */
   l2_input_config_t *config;
   l2_bridge_domain_t *bd_config;
   i32 l2_if_adjust = 0;
-  u32 slot;
+  vnet_device_class_t *dev_class;
 
   hi = vnet_get_sup_hw_interface (vnet_main, sw_if_index);
   config = l2input_intf_config (sw_if_index);
@@ -585,14 +607,7 @@ set_int_l2_mode (vlib_main_t * vm, vnet_main_t * vnet_main,        /*           */
          config->bvi = 0;
 
          /* delete the l2fib entry for the bvi interface */
-         l2fib_del_entry (hi->hw_address, config->bd_index);
-
-         /* Make loop output node send packet back to ethernet-input node */
-         slot =
-           vlib_node_add_named_next_with_slot (vm, hi->tx_node_index,
-                                               "ethernet-input",
-                                               VNET_SIMULATED_ETHERNET_TX_NEXT_ETHERNET_INPUT);
-         ASSERT (slot == VNET_SIMULATED_ETHERNET_TX_NEXT_ETHERNET_INPUT);
+         l2fib_del_entry (hi->hw_address, config->bd_index, sw_if_index);
 
          /* since this is a no longer BVI interface do not to flood to it */
          si = vnet_get_sw_interface (vnm, sw_if_index);
@@ -690,18 +705,13 @@ set_int_l2_mode (vlib_main_t * vm, vnet_main_t * vnet_main,       /*           */
              config->bvi = 1;
 
              /* create the l2fib entry for the bvi interface */
-             l2fib_add_fwd_entry (hi->hw_address, bd_index, sw_if_index, 1, 1);        /* static + bvi */
+             l2fib_add_entry (hi->hw_address, bd_index, sw_if_index,
+                              L2FIB_ENTRY_RESULT_FLAG_BVI |
+                              L2FIB_ENTRY_RESULT_FLAG_STATIC);
 
              /* Disable learning by default. no use since l2fib entry is static. */
              config->feature_bitmap &= ~L2INPUT_FEAT_LEARN;
 
-             /* Make loop output node send packet to l2-input node */
-             slot =
-               vlib_node_add_named_next_with_slot (vm, hi->tx_node_index,
-                                                   "l2-input",
-                                                   VNET_SIMULATED_ETHERNET_TX_NEXT_ETHERNET_INPUT);
-             ASSERT (slot == VNET_SIMULATED_ETHERNET_TX_NEXT_ETHERNET_INPUT);
-
              /* since this is a BVI interface we want to flood to it */
              si = vnet_get_sw_interface (vnm, sw_if_index);
              si->flood_class = VNET_FLOOD_CLASS_BVI;
@@ -798,6 +808,12 @@ set_int_l2_mode (vlib_main_t * vm, vnet_main_t * vnet_main,        /*           */
   /* Set up the L2/L3 flag in the interface parsing tables */
   ethernet_sw_interface_set_l2_mode (vnm, sw_if_index, (mode != MODE_L3));
 
+  dev_class = vnet_get_device_class (vnet_main, hi->dev_class_index);
+  if (dev_class->set_l2_mode_function)
+    {
+      dev_class->set_l2_mode_function (vnet_main, hi, l2_if_adjust);
+    }
+
   return 0;
 }