lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 12 Mar 2007 17:05:39 -0700
From:	Rick Jones <rick.jones2@...com>
To:	Stephen Hemminger <shemminger@...ux-foundation.org>
Cc:	David Miller <davem@...emloft.net>, netdev@...r.kernel.org
Subject: Re: bridge: faster compare for link local addresses

Stephen Hemminger wrote:
> Use logic operations rather than memcmp() to compare destination
> address with link local multicast addresses.
> 
> Signed-off-by: Stephen Hemminger <shemminger@...ux-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
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists