2023-01-22 10:20:13

by Laurent Vivier

[permalink] [raw]
Subject: [PATCH 3/4] vdpa_sim_net: don't always set VIRTIO_NET_F_MAC

if vdpa dev command doesn't set a MAC address, don't report
VIRTIO_NET_F_MAC.

As vdpa_sim_net sets VIRTIO_NET_F_MAC without setting the MAC address,
virtio-net doesn't set a random one and the address appears to be the
zero MAC address.

Signed-off-by: Laurent Vivier <[email protected]>
---
drivers/vdpa/vdpa_sim/vdpa_sim_net.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim_net.c b/drivers/vdpa/vdpa_sim/vdpa_sim_net.c
index 584b975a98a7..28e858659b85 100644
--- a/drivers/vdpa/vdpa_sim/vdpa_sim_net.c
+++ b/drivers/vdpa/vdpa_sim/vdpa_sim_net.c
@@ -257,6 +257,12 @@ static int vdpasim_net_dev_add(struct vdpa_mgmt_dev *mdev, const char *name,
dev_attr.work_fn = vdpasim_net_work;
dev_attr.buffer_size = PAGE_SIZE;

+ /* if vdpa dev doesn't provide a MAC address,
+ * don't report we have one
+ */
+ if (!(config->mask & (1 << VDPA_ATTR_DEV_NET_CFG_MACADDR)))
+ dev_attr.supported_features &= ~(1ULL << VIRTIO_NET_F_MAC);
+
simdev = vdpasim_create(&dev_attr, config);
if (IS_ERR(simdev))
return PTR_ERR(simdev);
--
2.39.0