diff options
author | David S. Miller <davem@sunset.davemloft.net> | 2006-08-24 03:42:45 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-09-22 18:08:39 -0400 |
commit | edcd582152090bfb0ccb4ad444c151798a73eda8 (patch) | |
tree | 9d6051e71c5c22c50315d6b2c740170002469288 /include/net | |
parent | 2770834c9f44afd1bfa13914c7285470775af657 (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/net')
-rw-r--r-- | include/net/xfrm.h | 78 |
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 | ||
244 | struct xfrm_state_afinfo { | 244 | struct 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 | |||
436 | static __inline__ | ||
437 | unsigned __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 | |||
445 | static __inline__ | ||
446 | unsigned __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 | |||
454 | static __inline__ | ||
455 | unsigned __xfrm4_src_hash(xfrm_address_t *addr) | ||
456 | { | ||
457 | return __xfrm4_dst_hash(addr); | ||
458 | } | ||
459 | |||
460 | static __inline__ | ||
461 | unsigned __xfrm6_src_hash(xfrm_address_t *addr) | ||
462 | { | ||
463 | return __xfrm6_dst_hash(addr); | ||
464 | } | ||
465 | |||
466 | static __inline__ | ||
467 | unsigned 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 | |||
478 | static __inline__ | ||
479 | unsigned __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 | |||
487 | static __inline__ | ||
488 | unsigned __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 | |||
496 | static __inline__ | ||
497 | unsigned 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 | |||
508 | extern void __xfrm_state_destroy(struct xfrm_state *); | 430 | extern void __xfrm_state_destroy(struct xfrm_state *); |
509 | 431 | ||
510 | static inline void __xfrm_state_put(struct xfrm_state *x) | 432 | static inline void __xfrm_state_put(struct xfrm_state *x) |