qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC PATCH 3/4] virtio-net: Limit the num of uni/multicast


From: Jason Wang
Subject: [Qemu-devel] [RFC PATCH 3/4] virtio-net: Limit the num of uni/multicast mac addresses
Date: Mon, 27 Sep 2010 20:51:09 +0800
User-agent: StGit/0.15

In order to send gratuitous packet for each mac address, we need to keep
track every macaddress after migration which is obviously conflicted with the
overload policy currently used in qemu which just forward all packets to guest
when it can't record all the macaddress. So we need to limit the num of
uni/multicast mac addresses in qemu.

Signed-off-by: Jason Wang <address@hidden>
---
 hw/virtio-net.c |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index 0a9cae2..79afb65 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -291,7 +291,9 @@ static int virtio_net_handle_mac(VirtIONet *n, uint8_t cmd,
                mac_data.entries * ETH_ALEN);
         n->mac_table.in_use += mac_data.entries;
     } else {
-        n->mac_table.uni_overflow = 1;
+        /* Gratuitous packet could not be built properly in overflow mode, so 
we
+         * never allow uni_overflow here. */
+        return VIRTIO_NET_ERR;
     }
 
     n->mac_table.first_multi = n->mac_table.in_use;
@@ -309,7 +311,9 @@ static int virtio_net_handle_mac(VirtIONet *n, uint8_t cmd,
                    mac_data.entries * ETH_ALEN);
             n->mac_table.in_use += mac_data.entries;
         } else {
-            n->mac_table.multi_overflow = 1;
+            /* Gratuitous packet could not be built properly in overflow mode,
+             * so we never allow multi_overflow here. */
+            return VIRTIO_NET_ERR;
         }
     }
 
@@ -844,9 +848,8 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int 
version_id)
             qemu_get_buffer(f, n->mac_table.macs,
                             n->mac_table.in_use * ETH_ALEN);
         } else if (n->mac_table.in_use) {
-            qemu_fseek(f, n->mac_table.in_use * ETH_ALEN, SEEK_CUR);
-            n->mac_table.multi_overflow = n->mac_table.uni_overflow = 1;
-            n->mac_table.in_use = 0;
+            error_report("virtio-net: Overflow was not permitted.");
+            return -EINVAL;
         }
     }
  
@@ -873,6 +876,10 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int 
version_id)
     if (version_id >= 9) {
         n->mac_table.multi_overflow = qemu_get_byte(f);
         n->mac_table.uni_overflow = qemu_get_byte(f);
+        if (n->mac_table.multi_overflow || n->mac_table.uni_overflow) {
+            error_report("virtio-net: Overflow was not permitted");
+            return -EINVAL;
+        }
     }
 
     if (version_id >= 10) {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]