summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFahad Naeem <fahadnaeemkhan@gmail.com>2022-04-04 10:31:04 -0400
committerDamjan Marion <dmarion@me.com>2022-05-04 15:18:18 +0000
commit08183d790401a978b1af61f9b072d5a0526fde73 (patch)
treec70e95dfa668b1d67b4723c33a46b833411fcf43
parent98ca76ab87c63a43b9bba6366ee5ca405709b6bc (diff)
vhost: use_custom_mac set in create_vhost_user_if_v2
Type: fix set use_custom_mac for args in create_vhost_user_if_v2 API Add testcase for custom mac-address Signed-off-by: Fahad Naeem <fahadnaeemkhan@gmail.com> Change-Id: Iac64d818e0f1e6d36187fe769ee33d202aaafd05 Signed-off-by: Fahad Naeem <fahadnaeemkhan@gmail.com>
-rw-r--r--src/vnet/devices/virtio/vhost_user_api.c1
-rw-r--r--test/test_vhost.py28
2 files changed, 29 insertions, 0 deletions
diff --git a/src/vnet/devices/virtio/vhost_user_api.c b/src/vnet/devices/virtio/vhost_user_api.c
index df6768d4cde..6dd9da08a23 100644
--- a/src/vnet/devices/virtio/vhost_user_api.c
+++ b/src/vnet/devices/virtio/vhost_user_api.c
@@ -168,6 +168,7 @@ vl_api_create_vhost_user_if_v2_t_handler (vl_api_create_vhost_user_if_v2_t *
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;
diff --git a/test/test_vhost.py b/test/test_vhost.py
index e8cb27d6ed4..aefae90f2f6 100644
--- a/test/test_vhost.py
+++ b/test/test_vhost.py
@@ -119,5 +119,33 @@ class TesVhostInterface(VppTestCase):
events = self.vapi.collect_events()
self.assert_equal(len(events), 0, "number of events")
+ def test_vhost_interface_custom_mac_addr(self):
+ """ Vhost User interface custom mac address test """
+
+ mac_addr = "aa:bb:cc:dd:ee:ff"
+ vhost_if = VppVhostInterface(self,
+ sock_filename='/tmp/sock1',
+ use_custom_mac=1,
+ mac_address=mac_addr)
+
+ # create vhost interface
+ vhost_if.add_vpp_config()
+ self.sleep(0.1)
+
+ # verify mac in the dump
+ if_dump_list = self.vapi.sw_interface_dump(
+ sw_if_index=vhost_if.sw_if_index
+ )
+ self.assert_equal(len(if_dump_list), 1, "if dump length")
+
+ [if_dump] = if_dump_list
+ self.assert_equal(
+ if_dump.l2_address.mac_string, mac_addr, "MAC Address"
+ )
+
+ # delete VirtualEthernet
+ self.logger.info("Deleting VirtualEthernet")
+ vhost_if.remove_vpp_config()
+
if __name__ == '__main__':
unittest.main(testRunner=VppTestRunner)