qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] virtio-net: Add check for mac address while peer is vdpa
@ 2020-10-23  9:07 Cindy Lu
  2020-10-23  9:12 ` no-reply
  0 siblings, 1 reply; 5+ messages in thread
From: Cindy Lu @ 2020-10-23  9:07 UTC (permalink / raw)
  To: mst, jasowang, qemu-devel; +Cc: qemu-stable, Cindy Lu

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



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] virtio-net: Add check for mac address while peer is vdpa
  2020-10-23  9:07 [PATCH] virtio-net: Add check for mac address while peer is vdpa Cindy Lu
@ 2020-10-23  9:12 ` no-reply
  0 siblings, 0 replies; 5+ messages in thread
From: no-reply @ 2020-10-23  9:12 UTC (permalink / raw)
  To: lulu; +Cc: jasowang, qemu-stable, qemu-devel, lulu, mst

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] virtio-net: Add check for mac address while peer is vdpa
  2021-02-24  7:59 ` Michael S. Tsirkin
@ 2021-02-25 16:43   ` Cindy Lu
  0 siblings, 0 replies; 5+ messages in thread
From: Cindy Lu @ 2021-02-25 16:43 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Eugenio Perez Martin, Jason Wang, Adrian Moreno Zapata, QEMU Developers

sure, Thanks michael, I will address, these comment and send a new version

On Wed, Feb 24, 2021 at 3:59 PM Michael S. Tsirkin <mst@redhat.com> wrote:
>
> > [PATCH] virtio-net: Add check for mac address while peer is vdpa
> please do keep numbering patch versions.
>
>
> On Wed, Feb 24, 2021 at 03:33:33PM +0800, Cindy Lu wrote:
> > Sometime vdpa get an all zero mac address from the hardware, this will cause the
> > traffic down, So we add the check for in part.if we get an zero mac address we will
> > use the default/cmdline mac address instead
>
> How does this differ from v4 of same patch?
>
> Lots of typos above. I guess I can just rewrite the whole log ...
>
> >
> > 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);
>
> Below needs a huge code comment explaining what is going on.
>
> E.g.  if we get a valid mac from peer, use it.
>
> If we get 0 instead
> then we don't know the peer mac but since the
> mac is 0 and that is not a legal value,
> try to proceed assume something else (management, hardware) sets up the mac
> correctly and consistently with the qemu configuration.
>
>
> > +            if (memcmp(&netcfg.mac, &zero, sizeof(zero)) != 0) {
>
> != 0 is not necessary
>
> > +                memcpy(config, &netcfg, n->config_size);
>
> > +        } else {
> > +                error_report("Get an all zero mac address from hardware");
>
> So why are you skipping the copying of the whole config space? Why not
> just skip the mac? Seems quite risky e.g. looks like it will break
> things like reporting the link status, right?
>
> > +            }
> >          }
> >      }
> >  }
> > --
> > 2.21.3
>



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] virtio-net: Add check for mac address while peer is vdpa
  2021-02-24  7:33 Cindy Lu
@ 2021-02-24  7:59 ` Michael S. Tsirkin
  2021-02-25 16:43   ` Cindy Lu
  0 siblings, 1 reply; 5+ messages in thread
From: Michael S. Tsirkin @ 2021-02-24  7:59 UTC (permalink / raw)
  To: Cindy Lu; +Cc: eperezma, jasowang, amorenoz, qemu-devel

> [PATCH] virtio-net: Add check for mac address while peer is vdpa
please do keep numbering patch versions.


On Wed, Feb 24, 2021 at 03:33:33PM +0800, Cindy Lu wrote:
> Sometime vdpa get an all zero mac address from the hardware, this will cause the
> traffic down, So we add the check for in part.if we get an zero mac address we will
> use the default/cmdline mac address instead

How does this differ from v4 of same patch?

Lots of typos above. I guess I can just rewrite the whole log ...

> 
> 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);

Below needs a huge code comment explaining what is going on.

E.g.  if we get a valid mac from peer, use it.

If we get 0 instead
then we don't know the peer mac but since the
mac is 0 and that is not a legal value,
try to proceed assume something else (management, hardware) sets up the mac
correctly and consistently with the qemu configuration.


> +            if (memcmp(&netcfg.mac, &zero, sizeof(zero)) != 0) {

!= 0 is not necessary

> +                memcpy(config, &netcfg, n->config_size);

> +        } else {
> +                error_report("Get an all zero mac address from hardware");

So why are you skipping the copying of the whole config space? Why not
just skip the mac? Seems quite risky e.g. looks like it will break
things like reporting the link status, right?

> +            }
>          }
>      }
>  }
> -- 
> 2.21.3



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] virtio-net: Add check for mac address while peer is vdpa
@ 2021-02-24  7:33 Cindy Lu
  2021-02-24  7:59 ` Michael S. Tsirkin
  0 siblings, 1 reply; 5+ messages in thread
From: Cindy Lu @ 2021-02-24  7:33 UTC (permalink / raw)
  To: mst, jasowang, qemu-devel; +Cc: eperezma, amorenoz, lulu

Sometime vdpa get an all zero mac address from the hardware, this will cause the
traffic down, So we add the check for in part.if we get an zero mac address we will
use the default/cmdline 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");
+            }
         }
     }
 }
-- 
2.21.3



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-02-25 16:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-23  9:07 [PATCH] virtio-net: Add check for mac address while peer is vdpa Cindy Lu
2020-10-23  9:12 ` no-reply
2021-02-24  7:33 Cindy Lu
2021-02-24  7:59 ` Michael S. Tsirkin
2021-02-25 16:43   ` Cindy Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).