diff options
author | Eugenio Pérez <eperezma@redhat.com> | 2022-12-21 12:50:12 +0100 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2023-01-08 01:54:21 -0500 |
commit | ebc141a62508dc91901373c1a19fe7e2cf560dfb (patch) | |
tree | d9700221126be4eb4eaa6496d62b9a86ec992213 | |
parent | 0ab12aa32462817f0a53fa6f6ce4baf664ef1713 (diff) | |
download | qemu-ebc141a62508dc91901373c1a19fe7e2cf560dfb.zip qemu-ebc141a62508dc91901373c1a19fe7e2cf560dfb.tar.gz qemu-ebc141a62508dc91901373c1a19fe7e2cf560dfb.tar.bz2 |
virtio_net: Modify virtio_net_get_config to early return
Next patches introduce more code on vhost-vdpa branch, with already have
too much indentation.
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Message-Id: <20221221115015.1400889-2-eperezma@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-rw-r--r-- | hw/net/virtio-net.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 9cbdfa5..b30038d 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -168,20 +168,22 @@ static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config) if (nc->peer && nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_VDPA) { ret = vhost_net_get_config(get_vhost_net(nc->peer), (uint8_t *)&netcfg, n->config_size); - if (ret != -1) { - /* - * Some NIC/kernel combinations present 0 as the mac address. As - * that is not a legal address, try to proceed with the - * address from the QEMU command line in the hope that the - * address has been configured correctly elsewhere - just not - * reported by the device. - */ - if (memcmp(&netcfg.mac, &zero, sizeof(zero)) == 0) { - info_report("Zero hardware mac address detected. Ignoring."); - memcpy(netcfg.mac, n->mac, ETH_ALEN); - } - memcpy(config, &netcfg, n->config_size); + if (ret == -1) { + return; } + + /* + * Some NIC/kernel combinations present 0 as the mac address. As that + * is not a legal address, try to proceed with the address from the + * QEMU command line in the hope that the address has been configured + * correctly elsewhere - just not reported by the device. + */ + if (memcmp(&netcfg.mac, &zero, sizeof(zero)) == 0) { + info_report("Zero hardware mac address detected. Ignoring."); + memcpy(netcfg.mac, n->mac, ETH_ALEN); + } + + memcpy(config, &netcfg, n->config_size); } } |