aboutsummaryrefslogtreecommitdiffstats
path: root/net/xfrm/xfrm_state.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-04-27 12:26:46 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-04-27 12:26:46 -0400
commit15c54033964a943de7b0763efd3bd0ede7326395 (patch)
tree840b292612d1b5396d5bab5bde537a9013db3ceb /net/xfrm/xfrm_state.c
parentad5da3cf39a5b11a198929be1f2644e17ecd767e (diff)
parent912a41a4ab935ce8c4308428ec13fc7f8b1f18f4 (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6: (448 commits) [IPV4] nl_fib_lookup: Initialise res.r before fib_res_put(&res) [IPV6]: Fix thinko in ipv6_rthdr_rcv() changes. [IPV4]: Add multipath cached to feature-removal-schedule.txt [WIRELESS] cfg80211: Clarify locking comment. [WIRELESS] cfg80211: Fix locking in wiphy_new. [WEXT] net_device: Don't include wext bits if not required. [WEXT]: Misc code cleanups. [WEXT]: Reduce inline abuse. [WEXT]: Move EXPORT_SYMBOL statements where they belong. [WEXT]: Cleanup early ioctl call path. [WEXT]: Remove options. [WEXT]: Remove dead debug code. [WEXT]: Clean up how wext is called. [WEXT]: Move to net/wireless [AFS]: Eliminate cmpxchg() usage in vlocation code. [RXRPC]: Fix pointers passed to bitops. [RXRPC]: Remove bogus atomic_* overrides. [AFS]: Fix u64 printing in debug logging. [AFS]: Add "directory write" support. [AFS]: Implement the CB.InitCallBackState3 operation. ...
Diffstat (limited to 'net/xfrm/xfrm_state.c')
-rw-r--r--net/xfrm/xfrm_state.c60
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)
233static void xfrm_timer_handler(unsigned long data) 233static 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}
422EXPORT_SYMBOL(xfrm_state_flush); 422EXPORT_SYMBOL(xfrm_state_flush);
423 423
424void 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}
432EXPORT_SYMBOL(xfrm_sad_getinfo);
433
424static int 434static int
425xfrm_init_tempsel(struct xfrm_state *x, struct flowi *fl, 435xfrm_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);
1051int xfrm_state_check_expire(struct xfrm_state *x) 1061int 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}
1668EXPORT_SYMBOL(xfrm_state_delete_tunnel); 1678EXPORT_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 */
1676int xfrm_state_mtu(struct xfrm_state *x, int mtu) 1680int 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