Message ID | 20230122100526.2302556-4-lvivier@redhat.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | virtio_net: vdpa: update MAC address when it is generated by virtio-net | expand |
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);
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 <lvivier@redhat.com> --- drivers/vdpa/vdpa_sim/vdpa_sim_net.c | 6 ++++++ 1 file changed, 6 insertions(+)