[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <AE90C24D6B3A694183C094C60CF0A2F6D8AED7@saturn3.aculab.com>
Date: Tue, 22 Nov 2011 14:50:59 -0000
From: "David Laight" <David.Laight@...LAB.COM>
To: "Alexey Dobriyan" <adobriyan@...il.com>, <davem@...emloft.net>
Cc: <netdev@...r.kernel.org>
Subject: RE: [PATCH] xfrm: optimize ipv4 selector matching
> +static inline int addr4_match(const __be32 a1, const __be32
> a2, const u8 prefixlen)
> +{
> + /* C99 6.5.7 (3): u32 << 32 is undefined behaviour */
> + if (prefixlen == 0) {
> + /* Matching constants result in smaller assembly. */
> + return 0xFFFFFFFFu;
> + }
> + return !((a1 ^ a2) & htonl(0xFFFFFFFFu << (32 - prefixlen)));
> +}
> +
It would probably be clearer to 'return 1' when prefixlen is zero.
If this is a common path, might be worth caching
htonl(0xFFFFFFFFu << (32 - prefixlen))
in the enclosing structure.
David
--
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