virtio-net: Add check for mac address while peer is vdpa
PATCH v3 1/1 virtio-net: Add check for mac address while peer is vdpa
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(-)
hw/net/virtio-net.c +6 -1
@@ -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" ); + } } } }
Signature · 1 line
2.21.3
Quoted 22 lines · 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 insteadSigned-off-by Cindy Lu <[email protected]>--- hw/net/virtio-net.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)hw/net/virtio-net.c +1
-0@@ -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 ));
hw/net/virtio-net.c static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config) · line 158
Quoted 8 lines
hw/net/virtio-net.c +4
-1@@ -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 ...
Quoted 6 lines
hw/net/virtio-net.c +1
-0+ } } } }Signature · 1 line
2.21.3
Quoted 5 lines · 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 insteadSigned-off-by Cindy Lu <[email protected]>
I wonder whether we can retrieve the mac earlier and fail init. That would be better than second-guessing bad configs ...
Quoted 31 lines
--- hw/net/virtio-net.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)hw/net/virtio-net.c +6
-1@@ -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" ); + } } } }Signature · 1 line
2.21.3
Quoted 11 lines · Michael S. Tsirkin
Quoted 5 lines · 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 insteadSigned-off-by Cindy Lu <[email protected]>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
Quoted 32 lines
Quoted 31 lines
--- hw/net/virtio-net.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)hw/net/virtio-net.c +6
-2@@ -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