Set hardware iface state for loopback interfaces 17/517/2
authorPierre Pfister <ppfister@cisco.com>
Wed, 9 Mar 2016 18:22:32 +0000 (18:22 +0000)
committerGerrit Code Review <gerrit@fd.io>
Fri, 11 Mar 2016 15:20:48 +0000 (15:20 +0000)
So unless I have missed something, loopback interfaces
are spawned hardware-down and never set up. This patch
uses the same process as tapcli interfaces by
mirroring sw state to hw state.

Change-Id: I94198c1c880de773daccbb63ca8d32c4c7e26a74
Signed-off-by: Pierre Pfister <ppfister@cisco.com>
vnet/vnet/ethernet/interface.c

index 1f7276e..429530e 100644 (file)
@@ -301,10 +301,20 @@ static u8 * format_simulated_ethernet_name (u8 * s, va_list * args)
   return format (s, "loop%d", dev_instance);
 }
 
+static clib_error_t *
+simulated_ethernet_admin_up_down (vnet_main_t * vnm, u32 hw_if_index, u32 flags)
+{
+  u32 hw_flags = (flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) ?
+      VNET_HW_INTERFACE_FLAG_LINK_UP : 0;
+  vnet_hw_interface_set_flags (vnm, hw_if_index, hw_flags);
+  return 0;
+}
+
 VNET_DEVICE_CLASS (ethernet_simulated_device_class) = {
   .name = "Loopback",
   .format_device_name = format_simulated_ethernet_name,
   .tx_function = simulated_ethernet_interface_tx,
+  .admin_up_down_function = simulated_ethernet_admin_up_down,
 };
 
 int vnet_create_loopback_interface (u32 * sw_if_indexp, u8 *mac_address)