aboutsummaryrefslogtreecommitdiffstats
path: root/net/xfrm
diff options
context:
space:
mode:
authorDavid S. Miller <davem@sunset.davemloft.net>2006-08-24 06:26:44 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2006-09-22 18:08:44 -0400
commit2575b65434d56559bd03854450b9b6aaf19b9c90 (patch)
tree6e7ae9460a5a61b97f3964b2cb97ff5524e2557b /net/xfrm
parenta624c108e5595b5827796c253481436929cd5344 (diff)
[XFRM]: Simplify xfrm_spi_hash
It can use __xfrm{4,6}_addr_hash(). Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/xfrm')
-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