xfrm: xfrm_state_mtu should return at least 1280 for ipv6
Jianwen reported that IPv6 Interoperability tests are failing in an
IPsec case where one of the links between the IPsec peers has an MTU
of 1280. The peer generates a packet larger than this MTU, the router
replies with a "Packet too big" message indicating an MTU of 1280.
When the peer tries to send another large packet, xfrm_state_mtu
returns 1280 - ipsec_overhead, which causes ip6_setup_cork to fail
with EINVAL.
We can fix this by forcing xfrm_state_mtu to return IPV6_MIN_MTU when
IPv6 is used. After going through IPsec, the packet will then be
fragmented to obey the actual network's PMTU, just before leaving the
host.
Currently, TFC padding is capped to PMTU - overhead to avoid
fragementation: after padding and encapsulation, we still fit within
the PMTU. That behavior is preserved in this patch.
Fixes: 91657eafb6
("xfrm: take net hdr len into account for esp payload size calculation")
Reported-by: Jianwen Ji <jiji@redhat.com>
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
This commit is contained in:
parent
88a5af9439
commit
b515d26372
|
@ -1546,6 +1546,7 @@ void xfrm_sad_getinfo(struct net *net, struct xfrmk_sadinfo *si);
|
||||||
void xfrm_spd_getinfo(struct net *net, struct xfrmk_spdinfo *si);
|
void xfrm_spd_getinfo(struct net *net, struct xfrmk_spdinfo *si);
|
||||||
u32 xfrm_replay_seqhi(struct xfrm_state *x, __be32 net_seq);
|
u32 xfrm_replay_seqhi(struct xfrm_state *x, __be32 net_seq);
|
||||||
int xfrm_init_replay(struct xfrm_state *x);
|
int xfrm_init_replay(struct xfrm_state *x);
|
||||||
|
u32 __xfrm_state_mtu(struct xfrm_state *x, int mtu);
|
||||||
u32 xfrm_state_mtu(struct xfrm_state *x, int mtu);
|
u32 xfrm_state_mtu(struct xfrm_state *x, int mtu);
|
||||||
int __xfrm_init_state(struct xfrm_state *x, bool init_replay, bool offload);
|
int __xfrm_init_state(struct xfrm_state *x, bool init_replay, bool offload);
|
||||||
int xfrm_init_state(struct xfrm_state *x);
|
int xfrm_init_state(struct xfrm_state *x);
|
||||||
|
|
|
@ -673,7 +673,7 @@ static int esp_output(struct xfrm_state *x, struct sk_buff *skb)
|
||||||
struct xfrm_dst *dst = (struct xfrm_dst *)skb_dst(skb);
|
struct xfrm_dst *dst = (struct xfrm_dst *)skb_dst(skb);
|
||||||
u32 padto;
|
u32 padto;
|
||||||
|
|
||||||
padto = min(x->tfcpad, xfrm_state_mtu(x, dst->child_mtu_cached));
|
padto = min(x->tfcpad, __xfrm_state_mtu(x, dst->child_mtu_cached));
|
||||||
if (skb->len < padto)
|
if (skb->len < padto)
|
||||||
esp.tfclen = padto - skb->len;
|
esp.tfclen = padto - skb->len;
|
||||||
}
|
}
|
||||||
|
|
|
@ -708,7 +708,7 @@ static int esp6_output(struct xfrm_state *x, struct sk_buff *skb)
|
||||||
struct xfrm_dst *dst = (struct xfrm_dst *)skb_dst(skb);
|
struct xfrm_dst *dst = (struct xfrm_dst *)skb_dst(skb);
|
||||||
u32 padto;
|
u32 padto;
|
||||||
|
|
||||||
padto = min(x->tfcpad, xfrm_state_mtu(x, dst->child_mtu_cached));
|
padto = min(x->tfcpad, __xfrm_state_mtu(x, dst->child_mtu_cached));
|
||||||
if (skb->len < padto)
|
if (skb->len < padto)
|
||||||
esp.tfclen = padto - skb->len;
|
esp.tfclen = padto - skb->len;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2518,7 +2518,7 @@ void xfrm_state_delete_tunnel(struct xfrm_state *x)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(xfrm_state_delete_tunnel);
|
EXPORT_SYMBOL(xfrm_state_delete_tunnel);
|
||||||
|
|
||||||
u32 xfrm_state_mtu(struct xfrm_state *x, int mtu)
|
u32 __xfrm_state_mtu(struct xfrm_state *x, int mtu)
|
||||||
{
|
{
|
||||||
const struct xfrm_type *type = READ_ONCE(x->type);
|
const struct xfrm_type *type = READ_ONCE(x->type);
|
||||||
struct crypto_aead *aead;
|
struct crypto_aead *aead;
|
||||||
|
@ -2549,7 +2549,17 @@ u32 xfrm_state_mtu(struct xfrm_state *x, int mtu)
|
||||||
return ((mtu - x->props.header_len - crypto_aead_authsize(aead) -
|
return ((mtu - x->props.header_len - crypto_aead_authsize(aead) -
|
||||||
net_adj) & ~(blksize - 1)) + net_adj - 2;
|
net_adj) & ~(blksize - 1)) + net_adj - 2;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(xfrm_state_mtu);
|
EXPORT_SYMBOL_GPL(__xfrm_state_mtu);
|
||||||
|
|
||||||
|
u32 xfrm_state_mtu(struct xfrm_state *x, int mtu)
|
||||||
|
{
|
||||||
|
mtu = __xfrm_state_mtu(x, mtu);
|
||||||
|
|
||||||
|
if (x->props.family == AF_INET6 && mtu < IPV6_MIN_MTU)
|
||||||
|
return IPV6_MIN_MTU;
|
||||||
|
|
||||||
|
return mtu;
|
||||||
|
}
|
||||||
|
|
||||||
int __xfrm_init_state(struct xfrm_state *x, bool init_replay, bool offload)
|
int __xfrm_init_state(struct xfrm_state *x, bool init_replay, bool offload)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue