Skip to content

Commit

Permalink
mac-learning: Speed up mac_table_hash().
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
blp committed Apr 19, 2012
1 parent 7376da6 commit 18e8912
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/mac-learning.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 *
Expand Down

0 comments on commit 18e8912

Please sign in to comment.