aboutsummaryrefslogtreecommitdiffstats
path: root/net/xfrm/xfrm_state.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/xfrm/xfrm_state.c')
-rw-r--r--net/xfrm/xfrm_state.c36
1 files changed, 8 insertions, 28 deletions
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 63a20e818164..69a3600afd9d 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -1667,37 +1667,17 @@ void xfrm_state_delete_tunnel(struct xfrm_state *x)
1667} 1667}
1668EXPORT_SYMBOL(xfrm_state_delete_tunnel); 1668EXPORT_SYMBOL(xfrm_state_delete_tunnel);
1669 1669
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) 1670int xfrm_state_mtu(struct xfrm_state *x, int mtu)
1677{ 1671{
1678 int res = mtu; 1672 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 1673
1674 spin_lock_bh(&x->lock);
1675 if (x->km.state == XFRM_STATE_VALID &&
1676 x->type && x->type->get_mtu)
1677 res = x->type->get_mtu(x, mtu);
1678 else
1679 res = mtu;
1680 spin_unlock_bh(&x->lock);
1701 return res; 1681 return res;
1702} 1682}
1703 1683