diff mbox series

[3/3] virtio_net: remove the unnecessary check in get_config

Message ID 20240806005814.51651-3-lulu@redhat.com
State New
Headers show
Series [1/3] virtio_net: Add the check for vdpa's mac address | expand

Commit Message

Cindy Lu Aug. 6, 2024, 12:58 a.m. UTC
The vdpa device with MAC address 0 should not boot.
So remove the check here

Signed-off-by: Cindy Lu <lulu@redhat.com>
---
 hw/net/virtio-net.c | 13 -------------
 1 file changed, 13 deletions(-)

Comments

Jason Wang Aug. 6, 2024, 3:09 a.m. UTC | #1
On Tue, Aug 6, 2024 at 8:58 AM Cindy Lu <lulu@redhat.com> wrote:
>
> The vdpa device with MAC address 0 should not boot.
> So remove the check here
>
> Signed-off-by: Cindy Lu <lulu@redhat.com>

Please describe what issues you've seen, and how it is fixed by this commit.

Thanks

> ---
>  hw/net/virtio-net.c | 13 -------------
>  1 file changed, 13 deletions(-)
>
> diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> index c144ae2e78..8a7c743ad3 100644
> --- a/hw/net/virtio-net.c
> +++ b/hw/net/virtio-net.c
> @@ -142,7 +142,6 @@ static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config)
>      VirtIONet *n = VIRTIO_NET(vdev);
>      struct virtio_net_config netcfg;
>      NetClientState *nc = qemu_get_queue(n->nic);
> -    static const MACAddr zero = { .a = { 0, 0, 0, 0, 0, 0 } };
>
>      int ret = 0;
>      memset(&netcfg, 0 , sizeof(struct virtio_net_config));
> @@ -170,18 +169,6 @@ static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config)
>          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);
> -        }
> -
>          netcfg.status |= virtio_tswap16(vdev,
>                                          n->status & VIRTIO_NET_S_ANNOUNCE);
>          memcpy(config, &netcfg, n->config_size);
> --
> 2.45.0
>
Cindy Lu Aug. 6, 2024, 9:47 a.m. UTC | #2
On Tue, 6 Aug 2024 at 11:09, Jason Wang <jasowang@redhat.com> wrote:
>
> On Tue, Aug 6, 2024 at 8:58 AM Cindy Lu <lulu@redhat.com> wrote:
> >
> > The vdpa device with MAC address 0 should not boot.
> > So remove the check here
> >
> > Signed-off-by: Cindy Lu <lulu@redhat.com>
>
> Please describe what issues you've seen, and how it is fixed by this commit.
>
> Thanks
>
this is a fix after the previous one. In the previous fix, the device
with MAC address 0 would not allow booting, so there is no need to
check if the MAC address is 0 here.
I will re-organize  the whole patch and make it more clear
Thanks
Cindy
> > ---
> >  hw/net/virtio-net.c | 13 -------------
> >  1 file changed, 13 deletions(-)
> >
> > diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> > index c144ae2e78..8a7c743ad3 100644
> > --- a/hw/net/virtio-net.c
> > +++ b/hw/net/virtio-net.c
> > @@ -142,7 +142,6 @@ static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config)
> >      VirtIONet *n = VIRTIO_NET(vdev);
> >      struct virtio_net_config netcfg;
> >      NetClientState *nc = qemu_get_queue(n->nic);
> > -    static const MACAddr zero = { .a = { 0, 0, 0, 0, 0, 0 } };
> >
> >      int ret = 0;
> >      memset(&netcfg, 0 , sizeof(struct virtio_net_config));
> > @@ -170,18 +169,6 @@ static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config)
> >          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);
> > -        }
> > -
> >          netcfg.status |= virtio_tswap16(vdev,
> >                                          n->status & VIRTIO_NET_S_ANNOUNCE);
> >          memcpy(config, &netcfg, n->config_size);
> > --
> > 2.45.0
> >
>
diff mbox series

Patch

diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index c144ae2e78..8a7c743ad3 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -142,7 +142,6 @@  static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config)
     VirtIONet *n = VIRTIO_NET(vdev);
     struct virtio_net_config netcfg;
     NetClientState *nc = qemu_get_queue(n->nic);
-    static const MACAddr zero = { .a = { 0, 0, 0, 0, 0, 0 } };
 
     int ret = 0;
     memset(&netcfg, 0 , sizeof(struct virtio_net_config));
@@ -170,18 +169,6 @@  static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config)
         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);
-        }
-
         netcfg.status |= virtio_tswap16(vdev,
                                         n->status & VIRTIO_NET_S_ANNOUNCE);
         memcpy(config, &netcfg, n->config_size);