aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorAlex Williamson <alex.williamson@hp.com>2009-06-05 14:47:02 -0600
committerMark McLoughlin <markmc@redhat.com>2009-06-09 11:38:50 +0100
commitbbe2f399b222f1f2fcf5cd2ea78e4f5c9a66c64e (patch)
tree990edb89cb7d8f94089cf1e13aa369c76c9050f5 /hw
parentf10c592e8d35e59a11cf7af1484ab1051acc3ef6 (diff)
virtio-net: reorganize receive_filter()
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 <alex.williamson@hp.com> Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/virtio-net.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index 13eb0d1f09..445976a41a 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -347,14 +347,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))