From: Rick Jones <rick.jones2@hp.com>
To: Stephen Hemminger <shemminger@linux-foundation.org>
Cc: David Miller <davem@davemloft.net>, netdev@vger.kernel.org
Subject: Re: bridge: faster compare for link local addresses
Date: Mon, 12 Mar 2007 17:05:39 -0700 [thread overview]
Message-ID: <45F5EAD3.8050501@hp.com> (raw)
In-Reply-To: <20070312162015.5d22cd68@dxpl.pdx.osdl.net>
Stephen Hemminger wrote:
> Use logic operations rather than memcmp() to compare destination
> address with link local multicast addresses.
>
> Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
>
> ---
> net/bridge/br_input.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> --- netem-dev.orig/net/bridge/br_input.c
> +++ netem-dev/net/bridge/br_input.c
> @@ -112,7 +112,11 @@ static int br_handle_local_finish(struct
> */
> 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;
> }
Being paranoid - are there no worries about the alignment of dest?
rick jones
next prev parent reply other threads:[~2007-03-13 0:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-12 23:20 bridge: faster compare for link local addresses Stephen Hemminger
2007-03-12 23:26 ` David Miller
2007-03-13 0:05 ` Rick Jones [this message]
2007-03-13 0:10 ` David Miller
2007-03-13 14:01 ` Andi Kleen
2007-03-13 13:38 ` Eric Dumazet
2007-03-13 19:39 ` David Miller
2007-03-13 20:06 ` Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=45F5EAD3.8050501@hp.com \
--to=rick.jones2@hp.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=shemminger@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).