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

Cindy Lu posted 1 patch 3 years, 6 months ago
Test checkpatch failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20201023090743.3023-1-lulu@redhat.com
Maintainers: Jason Wang <jasowang@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>
There is a newer version of this series
hw/net/virtio-net.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
[PATCH] virtio-net: Add check for mac address while peer is vdpa
Posted by Cindy Lu 3 years, 6 months ago
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
---
 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");
+            }
         }
     }
 }
-- 
2.21.3


Re: [PATCH] virtio-net: Add check for mac address while peer is vdpa
Posted by no-reply@patchew.org 3 years, 6 months ago
Patchew URL: https://patchew.org/QEMU/20201023090743.3023-1-lulu@redhat.com/



Hi,

This series seems to have some coding style problems. See output below for
more information:

Type: series
Message-id: 20201023090743.3023-1-lulu@redhat.com
Subject: [PATCH] virtio-net: Add check for mac address while peer is vdpa

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 - [tag update]      patchew/160343854912.8460.17915238517799132371.stgit@pasha-ThinkPad-X280 -> patchew/160343854912.8460.17915238517799132371.stgit@pasha-ThinkPad-X280
 - [tag update]      patchew/20201023064618.21409-1-kraxel@redhat.com -> patchew/20201023064618.21409-1-kraxel@redhat.com
 - [tag update]      patchew/20201023073351.251332-1-thuth@redhat.com -> patchew/20201023073351.251332-1-thuth@redhat.com
 * [new tag]         patchew/20201023090743.3023-1-lulu@redhat.com -> patchew/20201023090743.3023-1-lulu@redhat.com
Switched to a new branch 'test'
e1cc13b virtio-net: Add check for mac address while peer is vdpa

=== OUTPUT BEGIN ===
ERROR: Missing Signed-off-by: line(s)

total: 1 errors, 0 warnings, 19 lines checked

Commit e1cc13b8bc77 (virtio-net: Add check for mac address while peer is vdpa) has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===

Test command exited with code: 1


The full log is available at
http://patchew.org/logs/20201023090743.3023-1-lulu@redhat.com/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com