Skip to content

Commit

Permalink
[BRIDGE]: faster compare for link local addresses
Browse files Browse the repository at this point in the history
Use logic operations rather than memcmp() to compare destination
address with link local multicast addresses.

Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Stephen Hemminger authored and David S. Miller committed Apr 26, 2007
1 parent eddc9ec commit fd74e6c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion net/bridge/br_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ static int br_handle_local_finish(struct sk_buff *skb)
*/
static inline int is_link_local(const unsigned char *dest)
{
return memcmp(dest, br_group_address, 5) == 0 && (dest[5] & 0xf0) == 0;
const u16 *a = (const u16 *) dest;
static const u16 *const b = (const u16 *const ) br_group_address;
static const u16 m = __constant_cpu_to_be16(0xfff0);

return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | ((a[2] ^ b[2]) & m)) == 0;
}

/*
Expand Down

0 comments on commit fd74e6c

Please sign in to comment.