diff options
Diffstat (limited to 'net/xfrm/xfrm_state.c')
-rw-r--r-- | net/xfrm/xfrm_state.c | 60 |
1 files changed, 25 insertions, 35 deletions
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c index e3a0bcfa5df1..f3a61ebd8d65 100644 --- a/net/xfrm/xfrm_state.c +++ b/net/xfrm/xfrm_state.c | |||
@@ -233,7 +233,7 @@ static inline unsigned long make_jiffies(long secs) | |||
233 | static void xfrm_timer_handler(unsigned long data) | 233 | static void xfrm_timer_handler(unsigned long data) |
234 | { | 234 | { |
235 | struct xfrm_state *x = (struct xfrm_state*)data; | 235 | struct xfrm_state *x = (struct xfrm_state*)data; |
236 | unsigned long now = (unsigned long)xtime.tv_sec; | 236 | unsigned long now = get_seconds(); |
237 | long next = LONG_MAX; | 237 | long next = LONG_MAX; |
238 | int warn = 0; | 238 | int warn = 0; |
239 | int err = 0; | 239 | int err = 0; |
@@ -326,7 +326,7 @@ struct xfrm_state *xfrm_state_alloc(void) | |||
326 | init_timer(&x->rtimer); | 326 | init_timer(&x->rtimer); |
327 | x->rtimer.function = xfrm_replay_timer_handler; | 327 | x->rtimer.function = xfrm_replay_timer_handler; |
328 | x->rtimer.data = (unsigned long)x; | 328 | x->rtimer.data = (unsigned long)x; |
329 | x->curlft.add_time = (unsigned long)xtime.tv_sec; | 329 | x->curlft.add_time = get_seconds(); |
330 | x->lft.soft_byte_limit = XFRM_INF; | 330 | x->lft.soft_byte_limit = XFRM_INF; |
331 | x->lft.soft_packet_limit = XFRM_INF; | 331 | x->lft.soft_packet_limit = XFRM_INF; |
332 | x->lft.hard_byte_limit = XFRM_INF; | 332 | x->lft.hard_byte_limit = XFRM_INF; |
@@ -421,6 +421,16 @@ restart: | |||
421 | } | 421 | } |
422 | EXPORT_SYMBOL(xfrm_state_flush); | 422 | EXPORT_SYMBOL(xfrm_state_flush); |
423 | 423 | ||
424 | void xfrm_sad_getinfo(struct xfrm_sadinfo *si) | ||
425 | { | ||
426 | spin_lock_bh(&xfrm_state_lock); | ||
427 | si->sadcnt = xfrm_state_num; | ||
428 | si->sadhcnt = xfrm_state_hmask; | ||
429 | si->sadhmcnt = xfrm_state_hashmax; | ||
430 | spin_unlock_bh(&xfrm_state_lock); | ||
431 | } | ||
432 | EXPORT_SYMBOL(xfrm_sad_getinfo); | ||
433 | |||
424 | static int | 434 | static int |
425 | xfrm_init_tempsel(struct xfrm_state *x, struct flowi *fl, | 435 | xfrm_init_tempsel(struct xfrm_state *x, struct flowi *fl, |
426 | struct xfrm_tmpl *tmpl, | 436 | struct xfrm_tmpl *tmpl, |
@@ -458,7 +468,7 @@ static struct xfrm_state *__xfrm_state_lookup(xfrm_address_t *daddr, __be32 spi, | |||
458 | x->id.daddr.a6)) | 468 | x->id.daddr.a6)) |
459 | continue; | 469 | continue; |
460 | break; | 470 | break; |
461 | }; | 471 | } |
462 | 472 | ||
463 | xfrm_state_hold(x); | 473 | xfrm_state_hold(x); |
464 | return x; | 474 | return x; |
@@ -493,7 +503,7 @@ static struct xfrm_state *__xfrm_state_lookup_byaddr(xfrm_address_t *daddr, xfrm | |||
493 | x->props.saddr.a6)) | 503 | x->props.saddr.a6)) |
494 | continue; | 504 | continue; |
495 | break; | 505 | break; |
496 | }; | 506 | } |
497 | 507 | ||
498 | xfrm_state_hold(x); | 508 | xfrm_state_hold(x); |
499 | return x; | 509 | return x; |
@@ -722,7 +732,7 @@ static struct xfrm_state *__find_acq_core(unsigned short family, u8 mode, u32 re | |||
722 | (struct in6_addr *)saddr)) | 732 | (struct in6_addr *)saddr)) |
723 | continue; | 733 | continue; |
724 | break; | 734 | break; |
725 | }; | 735 | } |
726 | 736 | ||
727 | xfrm_state_hold(x); | 737 | xfrm_state_hold(x); |
728 | return x; | 738 | return x; |
@@ -755,7 +765,7 @@ static struct xfrm_state *__find_acq_core(unsigned short family, u8 mode, u32 re | |||
755 | ipv6_addr_copy((struct in6_addr *)x->id.daddr.a6, | 765 | ipv6_addr_copy((struct in6_addr *)x->id.daddr.a6, |
756 | (struct in6_addr *)daddr); | 766 | (struct in6_addr *)daddr); |
757 | break; | 767 | break; |
758 | }; | 768 | } |
759 | 769 | ||
760 | x->km.state = XFRM_STATE_ACQ; | 770 | x->km.state = XFRM_STATE_ACQ; |
761 | x->id.proto = proto; | 771 | x->id.proto = proto; |
@@ -1051,7 +1061,7 @@ EXPORT_SYMBOL(xfrm_state_update); | |||
1051 | int xfrm_state_check_expire(struct xfrm_state *x) | 1061 | int xfrm_state_check_expire(struct xfrm_state *x) |
1052 | { | 1062 | { |
1053 | if (!x->curlft.use_time) | 1063 | if (!x->curlft.use_time) |
1054 | x->curlft.use_time = (unsigned long)xtime.tv_sec; | 1064 | x->curlft.use_time = get_seconds(); |
1055 | 1065 | ||
1056 | if (x->km.state != XFRM_STATE_VALID) | 1066 | if (x->km.state != XFRM_STATE_VALID) |
1057 | return -EINVAL; | 1067 | return -EINVAL; |
@@ -1667,37 +1677,17 @@ void xfrm_state_delete_tunnel(struct xfrm_state *x) | |||
1667 | } | 1677 | } |
1668 | EXPORT_SYMBOL(xfrm_state_delete_tunnel); | 1678 | EXPORT_SYMBOL(xfrm_state_delete_tunnel); |
1669 | 1679 | ||
1670 | /* | ||
1671 | * This function is NOT optimal. For example, with ESP it will give an | ||
1672 | * MTU that's usually two bytes short of being optimal. However, it will | ||
1673 | * usually give an answer that's a multiple of 4 provided the input is | ||
1674 | * also a multiple of 4. | ||
1675 | */ | ||
1676 | int xfrm_state_mtu(struct xfrm_state *x, int mtu) | 1680 | int xfrm_state_mtu(struct xfrm_state *x, int mtu) |
1677 | { | 1681 | { |
1678 | int res = mtu; | 1682 | int res; |
1679 | |||
1680 | res -= x->props.header_len; | ||
1681 | |||
1682 | for (;;) { | ||
1683 | int m = res; | ||
1684 | |||
1685 | if (m < 68) | ||
1686 | return 68; | ||
1687 | |||
1688 | spin_lock_bh(&x->lock); | ||
1689 | if (x->km.state == XFRM_STATE_VALID && | ||
1690 | x->type && x->type->get_max_size) | ||
1691 | m = x->type->get_max_size(x, m); | ||
1692 | else | ||
1693 | m += x->props.header_len; | ||
1694 | spin_unlock_bh(&x->lock); | ||
1695 | |||
1696 | if (m <= mtu) | ||
1697 | break; | ||
1698 | res -= (m - mtu); | ||
1699 | } | ||
1700 | 1683 | ||
1684 | spin_lock_bh(&x->lock); | ||
1685 | if (x->km.state == XFRM_STATE_VALID && | ||
1686 | x->type && x->type->get_mtu) | ||
1687 | res = x->type->get_mtu(x, mtu); | ||
1688 | else | ||
1689 | res = mtu; | ||
1690 | spin_unlock_bh(&x->lock); | ||
1701 | return res; | 1691 | return res; |
1702 | } | 1692 | } |
1703 | 1693 | ||