qemu-stable
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2] virtio-net: Add check for mac address while peer is vdpa


From: Jason Wang
Subject: Re: [PATCH v2] virtio-net: Add check for mac address while peer is vdpa
Date: Mon, 26 Oct 2020 10:43:45 +0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0


On 2020/10/23 下午5:15, Cindy Lu wrote:
Sometime vdpa get an all 0 mac address from the hardware, this will cause the 
traffic down
So we add the check for this part.
if we get an 0 mac address we will use the default mac address instead

Signed-off-by: Cindy Lu <lulu@redhat.com>
---
  hw/net/virtio-net.c | 7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 9179013ac4..f1648fc47d 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -126,6 +126,7 @@ 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));
@@ -151,7 +152,11 @@ static void virtio_net_get_config(VirtIODevice *vdev, 
uint8_t *config)
          ret = vhost_net_get_config(get_vhost_net(nc->peer), (uint8_t 
*)&netcfg,
                                     n->config_size);
          if (ret != -1) {
-            memcpy(config, &netcfg, n->config_size);
+            if (memcmp(&netcfg.mac, &zero, sizeof(zero)) != 0) {
+                memcpy(config, &netcfg, n->config_size);
+        } else {
+                error_report("Get an all zero mac address from hardware");
+            }
          }
      }
  }


Applied.

Thanks




reply via email to

[Prev in Thread] Current Thread [Next in Thread]