Commit 2575b654 authored by David S. Miller's avatar David S. Miller

[XFRM]: Simplify xfrm_spi_hash

It can use __xfrm{4,6}_addr_hash().
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a624c108
...@@ -107,35 +107,20 @@ static inline unsigned xfrm_src_hash(xfrm_address_t *addr, unsigned short family ...@@ -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); return __xfrm_src_hash(addr, family, xfrm_state_hmask);
} }
static inline unsigned int __xfrm4_spi_hash(xfrm_address_t *addr, u32 spi, u8 proto, static inline unsigned int
unsigned int hmask) __xfrm_spi_hash(xfrm_address_t *addr, u32 spi, u8 proto, unsigned short family,
{ 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)
{ {
unsigned int h = spi ^ proto;
switch (family) { switch (family) {
case AF_INET: case AF_INET:
return __xfrm4_spi_hash(addr, spi, proto, hmask); h ^= __xfrm4_addr_hash(addr);
break;
case AF_INET6: 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 static inline unsigned int
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment