diff options
-rw-r--r-- | vnet/vnet/ethernet/ethernet.h | 1 | ||||
-rw-r--r-- | vnet/vnet/ethernet/node.c | 35 |
2 files changed, 36 insertions, 0 deletions
diff --git a/vnet/vnet/ethernet/ethernet.h b/vnet/vnet/ethernet/ethernet.h index 6f16527c0e3..f519f4f3190 100644 --- a/vnet/vnet/ethernet/ethernet.h +++ b/vnet/vnet/ethernet/ethernet.h @@ -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 diff --git a/vnet/vnet/ethernet/node.c b/vnet/vnet/ethernet/node.c index 7b9924f5cde..e8902fd7410 100644 --- a/vnet/vnet/ethernet/node.c +++ b/vnet/vnet/ethernet/node.c @@ -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, |