aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/devices/tap/tap.c39
-rw-r--r--src/vnet/devices/virtio/virtio.c2
2 files changed, 21 insertions, 20 deletions
diff --git a/src/vnet/devices/tap/tap.c b/src/vnet/devices/tap/tap.c
index f2903a95adc..7f0a0e9943d 100644
--- a/src/vnet/devices/tap/tap.c
+++ b/src/vnet/devices/tap/tap.c
@@ -246,15 +246,14 @@ tap_create_if (vlib_main_t * vm, tap_create_if_args_t * args)
}
}
- if (!ethernet_mac_address_is_zero (args->host_mac_addr))
+ if (ethernet_mac_address_is_zero (args->host_mac_addr))
+ ethernet_mac_address_generate (args->host_mac_addr);
+ args->error = vnet_netlink_set_link_addr (vif->ifindex,
+ args->host_mac_addr);
+ if (args->error)
{
- args->error = vnet_netlink_set_link_addr (vif->ifindex,
- args->host_mac_addr);
- if (args->error)
- {
- args->rv = VNET_API_ERROR_NETLINK_ERROR;
- goto error;
- }
+ args->rv = VNET_API_ERROR_NETLINK_ERROR;
+ goto error;
}
if (args->host_bridge)
@@ -320,18 +319,6 @@ tap_create_if (vlib_main_t * vm, tap_create_if_args_t * args)
}
}
- /* switch back to old net namespace */
- if (args->host_namespace)
- {
- if (setns (old_netns_fd, CLONE_NEWNET) == -1)
- {
- args->rv = VNET_API_ERROR_SYSCALL_ERROR_2;
- args->error = clib_error_return_unix (0, "setns '%s'",
- args->host_namespace);
- goto error;
- }
- }
-
if (args->host_mtu_set)
{
args->error =
@@ -355,6 +342,18 @@ tap_create_if (vlib_main_t * vm, tap_create_if_args_t * args)
args->host_mtu_size = tm->host_mtu_size;
}
+ /* switch back to old net namespace */
+ if (args->host_namespace)
+ {
+ if (setns (old_netns_fd, CLONE_NEWNET) == -1)
+ {
+ args->rv = VNET_API_ERROR_SYSCALL_ERROR_2;
+ args->error = clib_error_return_unix (0, "setns '%s'",
+ args->host_namespace);
+ goto error;
+ }
+ }
+
/* Set vhost memory table */
i = sizeof (struct vhost_memory) + sizeof (struct vhost_memory_region);
vhost_mem = clib_mem_alloc (i);
diff --git a/src/vnet/devices/virtio/virtio.c b/src/vnet/devices/virtio/virtio.c
index 90adf97dc3c..88511d74411 100644
--- a/src/vnet/devices/virtio/virtio.c
+++ b/src/vnet/devices/virtio/virtio.c
@@ -317,6 +317,8 @@ virtio_show (vlib_main_t * vm, u32 * hw_if_indices, u8 show_descr, u32 type)
vlib_cli_output (vm, " name \"%s\"", vif->host_if_name);
if (vif->net_ns)
vlib_cli_output (vm, " host-ns \"%s\"", vif->net_ns);
+ vlib_cli_output (vm, " host-mac-addr %U", format_ethernet_address,
+ vif->host_mac_addr);
if (vif->host_mtu_size)
vlib_cli_output (vm, " host-mtu-size \"%d\"",
vif->host_mtu_size);