aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@linux-foundation.org>2007-03-12 19:25:32 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-04-26 01:25:11 -0400
commitfd74e6ccd522e2f26163eb5ac1abebcab2bd017c (patch)
tree12908a8736012d0c7203724c90139615dc221143 /net
parenteddc9ec53be2ecdbf4efe0efd4a83052594f0ac0 (diff)
[BRIDGE]: faster compare for link local addresses
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>
Diffstat (limited to 'net')
-rw-r--r--net/bridge/br_input.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c
index 35b94f9a1ac5..a260679afad8 100644
--- a/net/bridge/br_input.c
+++ b/net/bridge/br_input.c
@@ -112,7 +112,11 @@ static int br_handle_local_finish(struct sk_buff *skb)
112 */ 112 */
113static inline int is_link_local(const unsigned char *dest) 113static inline int is_link_local(const unsigned char *dest)
114{ 114{
115 return memcmp(dest, br_group_address, 5) == 0 && (dest[5] & 0xf0) == 0; 115 const u16 *a = (const u16 *) dest;
116 static const u16 *const b = (const u16 *const ) br_group_address;
117 static const u16 m = __constant_cpu_to_be16(0xfff0);
118
119 return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | ((a[2] ^ b[2]) & m)) == 0;
116} 120}
117 121
118/* 122/*