summaryrefslogtreecommitdiffstats
path: root/src/vnet/devices
diff options
context:
space:
mode:
authorSteven Luong <sluong@cisco.com>2021-01-26 23:44:19 -0800
committerBeno�t Ganne <bganne@cisco.com>2021-01-27 16:47:03 +0000
commitd6361c7b899aa8ca8643c0d0c93fce25f3e78be2 (patch)
tree719514d15690338dcc0ace92178c31bba548cf66 /src/vnet/devices
parent68d2753569592e424e7584e2f921f68d1b3d2088 (diff)
vhost: vhost interface hardware address not set
The check args->hwaddr is always true and it always copies the mac address from args->hwaddr even though none was set. Check args->use_custom_mac instead. Type: fix Fixes: gerrit 29970 Signed-off-by: Steven Luong <sluong@cisco.com> Change-Id: I0c51bf1ea79b02c4fbdc3c52e694f186bdd96600
Diffstat (limited to 'src/vnet/devices')
-rw-r--r--src/vnet/devices/virtio/vhost_user.c13
-rw-r--r--src/vnet/devices/virtio/vhost_user.h1
-rw-r--r--src/vnet/devices/virtio/vhost_user_api.c1
3 files changed, 9 insertions, 6 deletions
diff --git a/src/vnet/devices/virtio/vhost_user.c b/src/vnet/devices/virtio/vhost_user.c
index b45b18b8433..426f03c6ab1 100644
--- a/src/vnet/devices/virtio/vhost_user.c
+++ b/src/vnet/devices/virtio/vhost_user.c
@@ -1521,17 +1521,18 @@ error:
* Create ethernet interface for vhost user interface.
*/
static void
-vhost_user_create_ethernet (vnet_main_t * vnm, vlib_main_t * vm,
- vhost_user_intf_t * vui, u8 * hwaddress)
+vhost_user_create_ethernet (vnet_main_t *vnm, vlib_main_t *vm,
+ vhost_user_intf_t *vui,
+ vhost_user_create_if_args_t *args)
{
vhost_user_main_t *vum = &vhost_user_main;
u8 hwaddr[6];
clib_error_t *error;
/* create hw and sw interface */
- if (hwaddress)
+ if (args->use_custom_mac)
{
- clib_memcpy (hwaddr, hwaddress, 6);
+ clib_memcpy (hwaddr, args->hwaddr, 6);
}
else
{
@@ -1667,7 +1668,7 @@ vhost_user_create_if (vnet_main_t * vnm, vlib_main_t * vm,
/* Protect the uninitialized vui from being dispatched by rx/tx */
vlib_worker_thread_barrier_sync (vm);
pool_get (vhost_user_main.vhost_user_interfaces, vui);
- vhost_user_create_ethernet (vnm, vm, vui, args->hwaddr);
+ vhost_user_create_ethernet (vnm, vm, vui, args);
vlib_worker_thread_barrier_release (vm);
vhost_user_vui_init (vnm, vui, server_sock_fd, args, &sw_if_idx);
@@ -1775,7 +1776,7 @@ vhost_user_connect_command_fn (vlib_main_t * vm,
;
else if (unformat (line_input, "hwaddr %U", unformat_ethernet_address,
args.hwaddr))
- ;
+ args.use_custom_mac = 1;
else if (unformat (line_input, "renumber %d",
&args.custom_dev_instance))
args.renumber = 1;
diff --git a/src/vnet/devices/virtio/vhost_user.h b/src/vnet/devices/virtio/vhost_user.h
index 06c78bce857..63a0bc0da48 100644
--- a/src/vnet/devices/virtio/vhost_user.h
+++ b/src/vnet/devices/virtio/vhost_user.h
@@ -109,6 +109,7 @@ typedef struct
u8 enable_gso;
u8 enable_packed;
u8 enable_event_idx;
+ u8 use_custom_mac;
/* return */
u32 sw_if_index;
diff --git a/src/vnet/devices/virtio/vhost_user_api.c b/src/vnet/devices/virtio/vhost_user_api.c
index a4e027f214e..86656883bd8 100644
--- a/src/vnet/devices/virtio/vhost_user_api.c
+++ b/src/vnet/devices/virtio/vhost_user_api.c
@@ -86,6 +86,7 @@ vl_api_create_vhost_user_if_t_handler (vl_api_create_vhost_user_if_t * mp)
if (mp->use_custom_mac)
mac_address_decode (mp->mac_address, (mac_address_t *) args.hwaddr);
+ args.use_custom_mac = mp->use_custom_mac;
args.is_server = mp->is_server;
args.sock_filename = (char *) mp->sock_filename;
args.renumber = mp->renumber;