Commit bbe2f399b222f1f2fcf5cd2ea78e4f5c9a66c64e
Committed by
Mark McLoughlin
1 parent
f10c592e
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>
Showing
1 changed file
with
11 additions
and
8 deletions
hw/virtio-net.c
... | ... | @@ -347,14 +347,17 @@ static int receive_filter(VirtIONet *n, const uint8_t *buf, int size) |
347 | 347 | return 0; |
348 | 348 | } |
349 | 349 | |
350 | - if ((ptr[0] & 1) && n->allmulti) | |
351 | - return 1; | |
352 | - | |
353 | - if (!memcmp(ptr, bcast, sizeof(bcast))) | |
354 | - return 1; | |
355 | - | |
356 | - if (!memcmp(ptr, n->mac, ETH_ALEN)) | |
357 | - return 1; | |
350 | + if (ptr[0] & 1) { // multicast | |
351 | + if (!memcmp(ptr, bcast, sizeof(bcast))) { | |
352 | + return 1; | |
353 | + } else if (n->allmulti) { | |
354 | + return 1; | |
355 | + } | |
356 | + } else { // unicast | |
357 | + if (!memcmp(ptr, n->mac, ETH_ALEN)) { | |
358 | + return 1; | |
359 | + } | |
360 | + } | |
358 | 361 | |
359 | 362 | for (i = 0; i < n->mac_table.in_use; i++) { |
360 | 363 | if (!memcmp(ptr, &n->mac_table.macs[i * ETH_ALEN], ETH_ALEN)) | ... | ... |