* [PATCH v3] virtio-net: Add check for mac address while peer is vdpa
@ 2020-10-26 6:21 Cindy Lu
2020-10-30 8:53 ` Michael S. Tsirkin
2020-10-30 8:55 ` Michael S. Tsirkin
0 siblings, 2 replies; 4+ messages in thread
From: Cindy Lu @ 2020-10-26 6:21 UTC (permalink / raw)
To: lulu, mst, jasowang, qemu-devel; +Cc: qemu-stable
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..65a3a84573 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 {
+ info_report("Get an all zero mac address from hardware");
+ }
}
}
}
--
2.21.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v3] virtio-net: Add check for mac address while peer is vdpa
2020-10-26 6:21 [PATCH v3] virtio-net: Add check for mac address while peer is vdpa Cindy Lu
@ 2020-10-30 8:53 ` Michael S. Tsirkin
2020-10-30 8:55 ` Michael S. Tsirkin
1 sibling, 0 replies; 4+ messages in thread
From: Michael S. Tsirkin @ 2020-10-30 8:53 UTC (permalink / raw)
To: Cindy Lu; +Cc: jasowang, qemu-devel, qemu-stable
On Mon, Oct 26, 2020 at 02:21:26PM +0800, 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..65a3a84573 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 {
> + info_report("Get an all zero mac address from hardware");
s/Get/Got/
let's add more data here please "hardware" does not really
tell users what is going on. Let's mention at least the device
name and type, maybe peer name and type ...
> + }
> }
> }
> }
> --
> 2.21.3
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] virtio-net: Add check for mac address while peer is vdpa
2020-10-26 6:21 [PATCH v3] virtio-net: Add check for mac address while peer is vdpa Cindy Lu
2020-10-30 8:53 ` Michael S. Tsirkin
@ 2020-10-30 8:55 ` Michael S. Tsirkin
2020-10-30 9:08 ` Cindy Lu
1 sibling, 1 reply; 4+ messages in thread
From: Michael S. Tsirkin @ 2020-10-30 8:55 UTC (permalink / raw)
To: Cindy Lu; +Cc: jasowang, qemu-devel, qemu-stable
On Mon, Oct 26, 2020 at 02:21:26PM +0800, 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>
I wonder whether we can retrieve the mac earlier and fail init.
That would be better than second-guessing bad configs ...
> ---
> 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..65a3a84573 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 {
> + info_report("Get an all zero mac address from hardware");
> + }
> }
> }
> }
> --
> 2.21.3
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] virtio-net: Add check for mac address while peer is vdpa
2020-10-30 8:55 ` Michael S. Tsirkin
@ 2020-10-30 9:08 ` Cindy Lu
0 siblings, 0 replies; 4+ messages in thread
From: Cindy Lu @ 2020-10-30 9:08 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: Jason Wang, QEMU Developers, qemu-stable
On Fri, Oct 30, 2020 at 4:55 PM Michael S. Tsirkin <mst@redhat.com> wrote:
>
> On Mon, Oct 26, 2020 at 02:21:26PM +0800, 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>
>
> I wonder whether we can retrieve the mac earlier and fail init.
> That would be better than second-guessing bad configs ...
>
Sure, Thanks Michael and Jason, I will check this with NIC vendor
Thanks
Cindy
> > ---
> > 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..65a3a84573 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 {
> > + info_report("Get an all zero mac address from hardware");
> > + }
> > }
> > }
> > }
> > --
> > 2.21.3
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-10-30 9:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-26 6:21 [PATCH v3] virtio-net: Add check for mac address while peer is vdpa Cindy Lu
2020-10-30 8:53 ` Michael S. Tsirkin
2020-10-30 8:55 ` Michael S. Tsirkin
2020-10-30 9:08 ` Cindy Lu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.