Add ability to set l2_mode_noprot 14/914/4
authorChristian Dechamplain (cdechamp) <cdechamp@cisco.com>
Tue, 5 Apr 2016 14:40:38 +0000 (10:40 -0400)
committerDave Barach <openvpp@barachs.net>
Thu, 28 Apr 2016 16:34:32 +0000 (16:34 +0000)
Change-Id: I3767a1bbe55452600863e145cbc12b114d6d1024
Signed-off-by: Todd Foggoa (tfoggoa) <tfoggoa@cisco.com>
vnet/vnet/ethernet/ethernet.h
vnet/vnet/ethernet/node.c

index 6f16527..f519f4f 100644 (file)
@@ -355,6 +355,7 @@ ethernet_buffer_get_header (vlib_buffer_t * b)
 ethernet_main_t * ethernet_get_main (vlib_main_t * vm);
 u32 ethernet_set_flags (vnet_main_t * vnm, u32 hw_if_index, u32 flags);
 void ethernet_sw_interface_set_l2_mode (vnet_main_t * vnm, u32 sw_if_index, u32 l2);
+void ethernet_sw_interface_set_l2_mode_noport (vnet_main_t * vnm, u32 sw_if_index, u32 l2);
 void ethernet_set_rx_redirect (vnet_main_t * vnm, vnet_hw_interface_t * hi, u32 enable);
 
 int
index 7b9924f..e8902fd 100644 (file)
@@ -839,6 +839,41 @@ ethernet_sw_interface_set_l2_mode (vnet_main_t * vnm,
   return;
 }
 
+/*
+ * Set the L2/L3 mode for the subinterface regardless of port
+ */
+void
+ethernet_sw_interface_set_l2_mode_noport (vnet_main_t * vnm,
+                                          u32 sw_if_index,
+                                          u32 l2)
+{
+  subint_config_t *subint;
+  u32 dummy_flags;
+  u32 dummy_unsup;
+
+  /* Find the config for this subinterface */
+  subint = ethernet_sw_interface_get_config (vnm, sw_if_index, &dummy_flags, &dummy_unsup);
+
+  if (subint == 0) {
+    /* unimplemented or not ethernet */
+    goto done;
+  }
+
+  /*
+   * Double check that the config we found is for our interface (or the
+   * interface is down)
+   */
+  ASSERT ((subint->sw_if_index == sw_if_index) | (subint->sw_if_index == ~0));
+
+  if (l2) {
+    subint->flags |= SUBINT_CONFIG_L2;
+  } else {
+    subint->flags &= ~SUBINT_CONFIG_L2;
+  }
+
+ done:
+  return;
+}
 
 static clib_error_t *
 ethernet_sw_interface_add_del (vnet_main_t * vnm,