diff options
author | Ben Pfaff <blp@nicira.com> | 2012-04-09 14:33:56 -0700 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2012-04-18 20:37:43 -0700 |
commit | 18e89129873f9dbdcdaa3cee909c1690da008e8d (patch) | |
tree | 04acc7d550228e286a60dd248d70cfdcafaf487e /lib/mac-learning.c | |
parent | 7376da647fb2d327f8765381b27b4db8d81a104f (diff) |
mac-learning: Speed up mac_table_hash().
Signed-off-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'lib/mac-learning.c')
-rw-r--r-- | lib/mac-learning.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/mac-learning.c b/lib/mac-learning.c index e0618c2e..68fc6214 100644 --- a/lib/mac-learning.c +++ b/lib/mac-learning.c @@ -28,6 +28,7 @@ #include "poll-loop.h" #include "tag.h" #include "timeval.h" +#include "unaligned.h" #include "util.h" #include "vlan-bitmap.h" #include "vlog.h" @@ -49,7 +50,9 @@ static uint32_t mac_table_hash(const struct mac_learning *ml, const uint8_t mac[ETH_ADDR_LEN], uint16_t vlan) { - return hash_bytes(mac, ETH_ADDR_LEN, vlan ^ ml->secret); + unsigned int mac1 = get_unaligned_u32((uint32_t *) mac); + unsigned int mac2 = get_unaligned_u16((uint16_t *) (mac + 4)); + return hash_3words(mac1, mac2 | (vlan << 16), ml->secret); } static struct mac_entry * |