summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@sunset.davemloft.net>2006-08-24 03:26:44 -0700
committerDavid S. Miller <davem@sunset.davemloft.net>2006-09-22 15:08:44 -0700
commit2575b65434d56559bd03854450b9b6aaf19b9c90 (patch)
tree6e7ae9460a5a61b97f3964b2cb97ff5524e2557b
parenta624c108e5595b5827796c253481436929cd5344 (diff)
downloadkernel-crypto-2575b65434d56559bd03854450b9b6aaf19b9c90.tar.gz
kernel-crypto-2575b65434d56559bd03854450b9b6aaf19b9c90.tar.xz
kernel-crypto-2575b65434d56559bd03854450b9b6aaf19b9c90.zip
[XFRM]: Simplify xfrm_spi_hash
It can use __xfrm{4,6}_addr_hash(). Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/xfrm/xfrm_state.c33
1 files changed, 9 insertions, 24 deletions
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 7e5daafc186..98200397e09 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -107,35 +107,20 @@ static inline unsigned xfrm_src_hash(xfrm_address_t *addr, unsigned short family
return __xfrm_src_hash(addr, family, xfrm_state_hmask);
}
-static inline unsigned int __xfrm4_spi_hash(xfrm_address_t *addr, u32 spi, u8 proto,
- unsigned int hmask)
-{
- unsigned int h;
- h = ntohl(addr->a4^spi^proto);
- h = (h ^ (h>>10) ^ (h>>20)) & hmask;
- return h;
-}
-
-static inline unsigned int __xfrm6_spi_hash(xfrm_address_t *addr, u32 spi, u8 proto,
- unsigned int hmask)
-{
- unsigned int h;
- h = ntohl(addr->a6[2]^addr->a6[3]^spi^proto);
- h = (h ^ (h>>10) ^ (h>>20)) & hmask;
- return h;
-}
-
-static inline
-unsigned __xfrm_spi_hash(xfrm_address_t *addr, u32 spi, u8 proto, unsigned short family,
- unsigned int hmask)
+static inline unsigned int
+__xfrm_spi_hash(xfrm_address_t *addr, u32 spi, u8 proto, unsigned short family,
+ unsigned int hmask)
{
+ unsigned int h = spi ^ proto;
switch (family) {
case AF_INET:
- return __xfrm4_spi_hash(addr, spi, proto, hmask);
+ h ^= __xfrm4_addr_hash(addr);
+ break;
case AF_INET6:
- return __xfrm6_spi_hash(addr, spi, proto, hmask);
+ h ^= __xfrm6_addr_hash(addr);
+ break;
}
- return 0; /*XXX*/
+ return (h ^ (h >> 10) ^ (h >> 20)) & hmask;
}
static inline unsigned int