[libvirt] [PATCH] qemu: handle multicast overflow on macvtap for NIC_RX_FILTER_CHANGED

Jason Baron posted 1 patch 5 years, 5 months ago
Test syntax-check passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/1542812696-27642-1-git-send-email-jbaron@akamai.com
src/qemu/qemu_driver.c | 26 +++++++++++++++++++-------
1 file changed, 19 insertions(+), 7 deletions(-)
[libvirt] [PATCH] qemu: handle multicast overflow on macvtap for NIC_RX_FILTER_CHANGED
Posted by Jason Baron 5 years, 5 months ago
Guest network devices can set 'overflow' when there are a number of multicast
ips configured. For virtio_net, the limit is only 64. In this case, the list
of mac addresses is empty and the 'overflow' condition is set. Thus, the guest
will currently receive no multicast traffic in this state.

When 'overflow' is set in the guest, let's turn this into ALLMULTI on the host.

Signed-off-by: Jason Baron <jbaron@akamai.com>
---
 src/qemu/qemu_driver.c | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 7fb9102..ea36db8 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4443,11 +4443,11 @@ static void
 syncNicRxFilterMultiMode(char *ifname, virNetDevRxFilterPtr guestFilter,
                          virNetDevRxFilterPtr hostFilter)
 {
-    if (hostFilter->multicast.mode != guestFilter->multicast.mode) {
+    if (hostFilter->multicast.mode != guestFilter->multicast.mode ||
+        guestFilter->multicast.overflow) {
         switch (guestFilter->multicast.mode) {
             case VIR_NETDEV_RX_FILTER_MODE_ALL:
                 if (virNetDevSetRcvAllMulti(ifname, true)) {
-
                     VIR_WARN("Couldn't set allmulticast flag to 'on' for "
                              "device %s while responding to "
                              "NIC_RX_FILTER_CHANGED", ifname);
@@ -4455,17 +4455,29 @@ syncNicRxFilterMultiMode(char *ifname, virNetDevRxFilterPtr guestFilter,
                 break;
 
             case VIR_NETDEV_RX_FILTER_MODE_NORMAL:
-                if (virNetDevSetRcvMulti(ifname, true)) {
+                if (guestFilter->multicast.overflow &&
+                    (hostFilter->multicast.mode == VIR_NETDEV_RX_FILTER_MODE_ALL)) {
+                    break;
+                }
 
+                if (virNetDevSetRcvMulti(ifname, true)) {
                     VIR_WARN("Couldn't set multicast flag to 'on' for "
                              "device %s while responding to "
                              "NIC_RX_FILTER_CHANGED", ifname);
                 }
 
-                if (virNetDevSetRcvAllMulti(ifname, false)) {
-                    VIR_WARN("Couldn't set allmulticast flag to 'off' for "
-                             "device %s while responding to "
-                             "NIC_RX_FILTER_CHANGED", ifname);
+                if (guestFilter->multicast.overflow == true) {
+                    if (virNetDevSetRcvAllMulti(ifname, true)) {
+                        VIR_WARN("Couldn't set allmulticast flag to 'on' for "
+                                 "device %s while responding to "
+                                 "NIC_RX_FILTER_CHANGED", ifname);
+                    }
+                } else {
+                    if (virNetDevSetRcvAllMulti(ifname, false)) {
+                         VIR_WARN("Couldn't set allmulticast flag to 'off' for "
+                                  "device %s while responding to "
+                                  "NIC_RX_FILTER_CHANGED", ifname);
+                    }
                 }
                 break;
 
-- 
2.7.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: handle multicast overflow on macvtap for NIC_RX_FILTER_CHANGED
Posted by Michael S. Tsirkin 5 years, 5 months ago
On Wed, Nov 21, 2018 at 10:04:56AM -0500, Jason Baron wrote:
> Guest network devices can set 'overflow' when there are a number of multicast
> ips configured. For virtio_net, the limit is only 64. In this case, the list
> of mac addresses is empty and the 'overflow' condition is set. Thus, the guest
> will currently receive no multicast traffic in this state.
> 
> When 'overflow' is set in the guest, let's turn this into ALLMULTI on the host.
> 
> Signed-off-by: Jason Baron <jbaron@akamai.com>

Good catch, thanks!

Acked-by: Michael S. Tsirkin <mst@redhat.com>


> ---
>  src/qemu/qemu_driver.c | 26 +++++++++++++++++++-------
>  1 file changed, 19 insertions(+), 7 deletions(-)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 7fb9102..ea36db8 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -4443,11 +4443,11 @@ static void
>  syncNicRxFilterMultiMode(char *ifname, virNetDevRxFilterPtr guestFilter,
>                           virNetDevRxFilterPtr hostFilter)
>  {
> -    if (hostFilter->multicast.mode != guestFilter->multicast.mode) {
> +    if (hostFilter->multicast.mode != guestFilter->multicast.mode ||
> +        guestFilter->multicast.overflow) {
>          switch (guestFilter->multicast.mode) {
>              case VIR_NETDEV_RX_FILTER_MODE_ALL:
>                  if (virNetDevSetRcvAllMulti(ifname, true)) {
> -
>                      VIR_WARN("Couldn't set allmulticast flag to 'on' for "
>                               "device %s while responding to "
>                               "NIC_RX_FILTER_CHANGED", ifname);
> @@ -4455,17 +4455,29 @@ syncNicRxFilterMultiMode(char *ifname, virNetDevRxFilterPtr guestFilter,
>                  break;
>  
>              case VIR_NETDEV_RX_FILTER_MODE_NORMAL:
> -                if (virNetDevSetRcvMulti(ifname, true)) {
> +                if (guestFilter->multicast.overflow &&
> +                    (hostFilter->multicast.mode == VIR_NETDEV_RX_FILTER_MODE_ALL)) {
> +                    break;
> +                }
>  
> +                if (virNetDevSetRcvMulti(ifname, true)) {
>                      VIR_WARN("Couldn't set multicast flag to 'on' for "
>                               "device %s while responding to "
>                               "NIC_RX_FILTER_CHANGED", ifname);
>                  }
>  
> -                if (virNetDevSetRcvAllMulti(ifname, false)) {
> -                    VIR_WARN("Couldn't set allmulticast flag to 'off' for "
> -                             "device %s while responding to "
> -                             "NIC_RX_FILTER_CHANGED", ifname);
> +                if (guestFilter->multicast.overflow == true) {
> +                    if (virNetDevSetRcvAllMulti(ifname, true)) {
> +                        VIR_WARN("Couldn't set allmulticast flag to 'on' for "
> +                                 "device %s while responding to "
> +                                 "NIC_RX_FILTER_CHANGED", ifname);
> +                    }
> +                } else {
> +                    if (virNetDevSetRcvAllMulti(ifname, false)) {
> +                         VIR_WARN("Couldn't set allmulticast flag to 'off' for "
> +                                  "device %s while responding to "
> +                                  "NIC_RX_FILTER_CHANGED", ifname);
> +                    }
>                  }
>                  break;
>  
> -- 
> 2.7.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list