qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 3/7] virtio-net: reorganize receive_filter()


From: Alex Williamson
Subject: [Qemu-devel] [PATCH 3/7] virtio-net: reorganize receive_filter()
Date: Fri, 05 Jun 2009 14:47:02 -0600
User-agent: StGIT/0.14.2

Reorganize receive_filter to better handle the split between
unicast and multicast filtering.  This allows us to skip the
broadcast check on unicast packets and leads to more opportunities
for optimization.

Signed-off-by: Alex Williamson <address@hidden>
---

 hw/virtio-net.c |   19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index de5a59f..395b735 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -344,14 +344,17 @@ static int receive_filter(VirtIONet *n, const uint8_t 
*buf, int size)
             return 0;
     }
 
-    if ((ptr[0] & 1) && n->allmulti)
-        return 1;
-
-    if (!memcmp(ptr, bcast, sizeof(bcast)))
-        return 1;
-
-    if (!memcmp(ptr, n->mac, ETH_ALEN))
-        return 1;
+    if (ptr[0] & 1) { // multicast
+        if (!memcmp(ptr, bcast, sizeof(bcast))) {
+            return 1;
+        } else if (n->allmulti) {
+            return 1;
+        }
+    } else { // unicast
+        if (!memcmp(ptr, n->mac, ETH_ALEN)) {
+            return 1;
+        }
+    }
 
     for (i = 0; i < n->mac_table.in_use; i++) {
         if (!memcmp(ptr, &n->mac_table.macs[i * ETH_ALEN], ETH_ALEN))





reply via email to

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