aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 7e5daafc1863..98200397e098 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
107 return __xfrm_src_hash(addr, family, xfrm_state_hmask); 107 return __xfrm_src_hash(addr, family, xfrm_state_hmask);
108} 108}
109 109
110static inline unsigned int __xfrm4_spi_hash(xfrm_address_t *addr, u32 spi, u8 proto, 110static inline unsigned int
111 unsigned int hmask) 111__xfrm_spi_hash(xfrm_address_t *addr, u32 spi, u8 proto, unsigned short family,
112{ 112 unsigned int hmask)
113 unsigned int h;
114 h = ntohl(addr->a4^spi^proto);
115 h = (h ^ (h>>10) ^ (h>>20)) & hmask;
116 return h;
117}
118
119static inline unsigned int __xfrm6_spi_hash(xfrm_address_t *addr, u32 spi, u8 proto,
120 unsigned int hmask)
121{
122 unsigned int h;
123 h = ntohl(addr->a6[2]^addr->a6[3]^spi^proto);
124 h = (h ^ (h>>10) ^ (h>>20)) & hmask;
125 return h;
126}
127
128static inline
129unsigned __xfrm_spi_hash(xfrm_address_t *addr, u32 spi, u8 proto, unsigned short family,
130 unsigned int hmask)
131{ 113{
114 unsigned int h = spi ^ proto;
132 switch (family) { 115 switch (family) {
133 case AF_INET: 116 case AF_INET:
134 return __xfrm4_spi_hash(addr, spi, proto, hmask); 117 h ^= __xfrm4_addr_hash(addr);
118 break;
135 case AF_INET6: 119 case AF_INET6:
136 return __xfrm6_spi_hash(addr, spi, proto, hmask); 120 h ^= __xfrm6_addr_hash(addr);
121 break;
137 } 122 }
138 return 0; /*XXX*/ 123 return (h ^ (h >> 10) ^ (h >> 20)) & hmask;
139} 124}
140 125
141static inline unsigned int 126static inline unsigned int