Commit b08e2fc8 authored by Herbert Xu's avatar Herbert Xu Committed by David S. Miller

[IPSEC]: Add xfrm_state_mtu()

This patch introduces the function xfrm_state_mtu which calculates
the MTU under a specific SA.  This function can be simplified once
we get rid all other uses of get_max_size as we can move the calculation
into the invidual SA type.
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7a352fda
......@@ -807,6 +807,7 @@ extern void xfrm_state_flush(u8 proto);
extern int xfrm_replay_check(struct xfrm_state *x, u32 seq);
extern void xfrm_replay_advance(struct xfrm_state *x, u32 seq);
extern int xfrm_state_check(struct xfrm_state *x, struct sk_buff *skb);
extern int xfrm_state_mtu(struct xfrm_state *x, int mtu);
extern int xfrm4_rcv(struct sk_buff *skb);
extern int xfrm4_output(struct sk_buff *skb);
extern int xfrm4_tunnel_register(struct xfrm_tunnel *handler);
......
......@@ -966,6 +966,36 @@ void xfrm_state_delete_tunnel(struct xfrm_state *x)
}
EXPORT_SYMBOL(xfrm_state_delete_tunnel);
int xfrm_state_mtu(struct xfrm_state *x, int mtu)
{
int res = mtu;
res -= x->props.header_len;
for (;;) {
int m = res;
if (m < 68)
return 68;
spin_lock_bh(&x->lock);
if (x->km.state == XFRM_STATE_VALID &&
x->type && x->type->get_max_size)
m = x->type->get_max_size(x, m);
else
m += x->props.header_len;
spin_unlock_bh(&x->lock);
if (m <= mtu)
break;
res -= (m - mtu);
}
return res;
}
EXPORT_SYMBOL(xfrm_state_mtu);
void __init xfrm_state_init(void)
{
int i;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment