qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: qemu-devel@nongnu.org, anthony@codemonkey.ws, mst@redhat.com
Cc: kvm@vger.kernel.org
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	[thread overview]
Message-ID: <20100927125109.12060.19145.stgit@dhcp-91-7.nay.redhat.com.englab.nay.redhat.com> (raw)
In-Reply-To: <20100927124606.12060.66912.stgit@dhcp-91-7.nay.redhat.com.englab.nay.redhat.com>

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 <jasowang@redhat.com>
---
 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) {

  parent reply	other threads:[~2010-09-27 12:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-27 12:50 [Qemu-devel] [RFC PATCH 0/4] Model specific function for nic announcement Jason Wang
2010-09-27 12:50 ` [Qemu-devel] [RFC PATCH 1/4] net: move announce_self_create to net.c Jason Wang
2010-09-27 12:51 ` [Qemu-devel] [RFC PATCH 2/4] net: Introduce model specific nic announce function Jason Wang
2010-09-27 12:51 ` Jason Wang [this message]
2010-09-27 12:51 ` [Qemu-devel] [RFC PATCH 4/4] virtio-net: implement virtio-net specific " Jason Wang
2010-09-27 14:25 ` [Qemu-devel] Re: [RFC PATCH 0/4] Model specific function for nic announcement Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100927125109.12060.19145.stgit@dhcp-91-7.nay.redhat.com.englab.nay.redhat.com \
    --to=jasowang@redhat.com \
    --cc=anthony@codemonkey.ws \
    --cc=kvm@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).