aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDavid S. Miller <davem@sunset.davemloft.net>2006-08-24 03:42:45 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2006-09-22 18:08:39 -0400
commitedcd582152090bfb0ccb4ad444c151798a73eda8 (patch)
tree9d6051e71c5c22c50315d6b2c740170002469288 /include
parent2770834c9f44afd1bfa13914c7285470775af657 (diff)
[XFRM]: Pull xfrm_state_by{spi,src} hash table knowledge out of afinfo.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r--include/net/xfrm.h78
1 files changed, 0 insertions, 78 deletions
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index cc83443f301e..dd3b84b9c04e 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -243,14 +243,10 @@ extern int __xfrm_state_delete(struct xfrm_state *x);
243 243
244struct xfrm_state_afinfo { 244struct xfrm_state_afinfo {
245 unsigned short family; 245 unsigned short family;
246 struct list_head *state_bysrc;
247 struct list_head *state_byspi;
248 int (*init_flags)(struct xfrm_state *x); 246 int (*init_flags)(struct xfrm_state *x);
249 void (*init_tempsel)(struct xfrm_state *x, struct flowi *fl, 247 void (*init_tempsel)(struct xfrm_state *x, struct flowi *fl,
250 struct xfrm_tmpl *tmpl, 248 struct xfrm_tmpl *tmpl,
251 xfrm_address_t *daddr, xfrm_address_t *saddr); 249 xfrm_address_t *daddr, xfrm_address_t *saddr);
252 struct xfrm_state *(*state_lookup)(xfrm_address_t *daddr, u32 spi, u8 proto);
253 struct xfrm_state *(*state_lookup_byaddr)(xfrm_address_t *daddr, xfrm_address_t *saddr, u8 proto);
254 int (*tmpl_sort)(struct xfrm_tmpl **dst, struct xfrm_tmpl **src, int n); 250 int (*tmpl_sort)(struct xfrm_tmpl **dst, struct xfrm_tmpl **src, int n);
255 int (*state_sort)(struct xfrm_state **dst, struct xfrm_state **src, int n); 251 int (*state_sort)(struct xfrm_state **dst, struct xfrm_state **src, int n);
256}; 252};
@@ -431,80 +427,6 @@ static inline void xfrm_pols_put(struct xfrm_policy **pols, int npols)
431} 427}
432#endif 428#endif
433 429
434#define XFRM_DST_HSIZE 1024
435
436static __inline__
437unsigned __xfrm4_dst_hash(xfrm_address_t *addr)
438{
439 unsigned h;
440 h = ntohl(addr->a4);
441 h = (h ^ (h>>16)) % XFRM_DST_HSIZE;
442 return h;
443}
444
445static __inline__
446unsigned __xfrm6_dst_hash(xfrm_address_t *addr)
447{
448 unsigned h;
449 h = ntohl(addr->a6[2]^addr->a6[3]);
450 h = (h ^ (h>>16)) % XFRM_DST_HSIZE;
451 return h;
452}
453
454static __inline__
455unsigned __xfrm4_src_hash(xfrm_address_t *addr)
456{
457 return __xfrm4_dst_hash(addr);
458}
459
460static __inline__
461unsigned __xfrm6_src_hash(xfrm_address_t *addr)
462{
463 return __xfrm6_dst_hash(addr);
464}
465
466static __inline__
467unsigned xfrm_src_hash(xfrm_address_t *addr, unsigned short family)
468{
469 switch (family) {
470 case AF_INET:
471 return __xfrm4_src_hash(addr);
472 case AF_INET6:
473 return __xfrm6_src_hash(addr);
474 }
475 return 0;
476}
477
478static __inline__
479unsigned __xfrm4_spi_hash(xfrm_address_t *addr, u32 spi, u8 proto)
480{
481 unsigned h;
482 h = ntohl(addr->a4^spi^proto);
483 h = (h ^ (h>>10) ^ (h>>20)) % XFRM_DST_HSIZE;
484 return h;
485}
486
487static __inline__
488unsigned __xfrm6_spi_hash(xfrm_address_t *addr, u32 spi, u8 proto)
489{
490 unsigned h;
491 h = ntohl(addr->a6[2]^addr->a6[3]^spi^proto);
492 h = (h ^ (h>>10) ^ (h>>20)) % XFRM_DST_HSIZE;
493 return h;
494}
495
496static __inline__
497unsigned xfrm_spi_hash(xfrm_address_t *addr, u32 spi, u8 proto, unsigned short family)
498{
499 switch (family) {
500 case AF_INET:
501 return __xfrm4_spi_hash(addr, spi, proto);
502 case AF_INET6:
503 return __xfrm6_spi_hash(addr, spi, proto);
504 }
505 return 0; /*XXX*/
506}
507
508extern void __xfrm_state_destroy(struct xfrm_state *); 430extern void __xfrm_state_destroy(struct xfrm_state *);
509 431
510static inline void __xfrm_state_put(struct xfrm_state *x) 432static inline void __xfrm_state_put(struct xfrm_state *x)