diff options
author | Alexey Dobriyan <adobriyan@gmail.com> | 2011-11-22 01:46:02 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-11-22 15:27:18 -0500 |
commit | 26bff940dd975499c6c47438d4395d7d215911e8 (patch) | |
tree | 7b6774138e3033d7ab6df080419740083caee2ae /include | |
parent | 3ee32fee65ef6a4a8a4188e913be7dd90ba9e058 (diff) |
xfrm: optimize ipv4 selector matching
Current addr_match() is errh, under-optimized.
Compiler doesn't know that memcmp() branch doesn't trigger for IPv4.
Also, pass addresses by value -- they fit into register.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r-- | include/net/xfrm.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/include/net/xfrm.h b/include/net/xfrm.h index b203e14d26b7..4de7ed9016d9 100644 --- a/include/net/xfrm.h +++ b/include/net/xfrm.h | |||
@@ -827,6 +827,14 @@ static inline bool addr_match(const void *token1, const void *token2, | |||
827 | return true; | 827 | return true; |
828 | } | 828 | } |
829 | 829 | ||
830 | static inline bool addr4_match(__be32 a1, __be32 a2, u8 prefixlen) | ||
831 | { | ||
832 | /* C99 6.5.7 (3): u32 << 32 is undefined behaviour */ | ||
833 | if (prefixlen == 0) | ||
834 | return true; | ||
835 | return !((a1 ^ a2) & htonl(0xFFFFFFFFu << (32 - prefixlen))); | ||
836 | } | ||
837 | |||
830 | static __inline__ | 838 | static __inline__ |
831 | __be16 xfrm_flowi_sport(const struct flowi *fl, const union flowi_uli *uli) | 839 | __be16 xfrm_flowi_sport(const struct flowi *fl, const union flowi_uli *uli) |
832 | { | 840 | { |