IPv6 xfrm GSO fragmentation bug
Subsystems (3)
Herbert Xu
maintainerHi Steffen:
I received a bug report regarding poor IPComp performance over IPv6:
https://bugzilla.redhat.com/show_bug.cgi?id=1257952
It appears to have been caused by
commit dd767856a36e00b631d65ebc4bb81b19915532d6
Author: Steffen Klassert <[email protected]> Date: Tue Oct 11 01:44:30 2011 +0000
xfrm6: Don't call icmpv6_send on local error
which addded an MTU check without a GSO override.
Fixing it obviously isn't difficult, but I am wondering why I can't find a corresponding patch for IPv4. Do we need that check to be present in xfrm6_output at all? If we do why isn't it needed for IPv4 as well?
Thanks,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Steffen Klassert
maintainerQuoted 13 lines · Herbert Xu
Hi Steffen:
I received a bug report regarding poor IPComp performance over IPv6:
https://bugzilla.redhat.com/show_bug.cgi?id=1257952It appears to have been caused by
commit
dd767856a36e00b631d65ebc4bb81b19915532d6Author: Steffen Klassert <[email protected]> Date: Tue Oct 11 01:44:30 2011 +0000
Quoted 8 lines
xfrm6: Don't call
icmpv6_sendon local errorwhich addded an MTU check without a GSO override.
Fixing it obviously isn't difficult, but I am wondering why I can't find a corresponding patch for IPv4. Do we need that check to be present in
xfrm6_outputat all? If we do why isn't it needed for IPv4 as well?
As far as I remember, this was to catch local message size errors before __xfrm6_output calls ip6_fragment which would use icmpv6_send for the error notification. IPv4 does not do fragmentation in the xfrm4_output functions, so this mtu check was not needed there.
I think just adding the gso checks should be fine.
Herbert Xu
maintainerQuoted 8 lines · Steffen Klassert
As far as I remember, this was to catch local message size errors before
__xfrm6_outputcallsip6_fragmentwhich would useicmpv6_sendfor the error notification. IPv4 does not do fragmentation in thexfrm4_outputfunctions, so this mtu check was not needed there.I think just adding the gso checks should be fine.
I see where the bug came from. Indeed IPv6 does do fragmentation but only for tunnel mode. While your patch added a check that also affected transport mode. So in addition to the GSO fix we should also make the MTU check conditional to tunnel mode.
Cheers,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Herbert Xu
maintainerQuoted 5 lines · Herbert Xu
I see where the bug came from. Indeed IPv6 does do fragmentation but only for tunnel mode. While your patch added a check that also affected transport mode. So in addition to the GSO fix we should also make the MTU check conditional to tunnel mode.
Here is the patch:
---8<---
ipv6: Fix IPsec pre-encap fragmentation check
The IPv6 IPsec pre-encap path performs fragmentation for tunnel-mode packets. That is, we perform fragmentation pre-encap rather than post-encap.
A check was added later to ensure that proper MTU information is passed back for locally generated traffic. Unfortunately this check was performed on all IPsec packets, including transport-mode packets.
What's more, the check failed to take GSO into account.
The end result is that transport-mode GSO packets get dropped at the check.
This patch fixes it by moving the tunnel mode check forward as well as adding the GSO check.
net/ipv6/xfrm6_output.c +11 -6
@@ -136,6 +136,7 @@ static int __xfrm6_output(struct sock *sk, struct sk_buff *skb)struct dst_entry *dst =skb_dst (skb);struct xfrm_state *x = dst->xfrm;int mtu; +bool toobig;#ifdef CONFIG_NETFILTER if (!x) {
@@ -144,25 +145,29 @@ static int __xfrm6_output(struct sock *sk, struct sk_buff *skb) }#endif +if (x->props.mode !=XFRM_MODE_TUNNEL ) + goto skip_frag; +if (skb->protocol ==htons (ETH_P_IPV6 )) mtu =ip6_skb_dst_mtu (skb);else mtu =dst_mtu (skb_dst (skb)); -if (skb->len > mtu &&xfrm6_local_dontfrag (skb)) { + toobig = skb->len > mtu && !skb_is_gso (skb); + +if (toobig &&xfrm6_local_dontfrag (skb)) {xfrm6_local_rxpmtu (skb, mtu);return -EMSGSIZE ; - }else if (!skb->ignore_df && skb->len > mtu && skb->sk) { + }else if (!skb->ignore_df && toobig && skb->sk) {xfrm_local_error (skb, mtu);return -EMSGSIZE ; } -if (x->props.mode ==XFRM_MODE_TUNNEL && - ((skb->len > mtu && !skb_is_gso (skb)) || -dst_allfrag (skb_dst (skb)))) { +if (toobig ||dst_allfrag (skb_dst (skb)))return ip6_fragment (sk, skb, x->outer_mode->afinfo->output_finish); - } + +skip_frag:return x->outer_mode->afinfo->output_finish (sk, skb); }
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Quoted 23 lines · Herbert Xu
Quoted 5 lines · Herbert Xu
I see where the bug came from. Indeed IPv6 does do fragmentation but only for tunnel mode. While your patch added a check that also affected transport mode. So in addition to the GSO fix we should also make the MTU check conditional to tunnel mode.
Here is the patch:
---8<---
ipv6: Fix IPsec pre-encap fragmentation checkThe IPv6 IPsec pre-encap path performs fragmentation for tunnel-mode packets. That is, we perform fragmentation pre-encap rather than post-encap.
A check was added later to ensure that proper MTU information is passed back for locally generated traffic. Unfortunately this check was performed on all IPsec packets, including transport-mode packets.
What's more, the check failed to take GSO into account.
Quoted 8 lines
The end result is that transport-mode GSO packets get dropped at the check.
This patch fixes it by moving the tunnel mode check forward as well as adding the GSO check.
Fixes dd767856a36e ("xfrm6: Don't call icmpv6_send on local error")Signed-off-by Herbert Xu <[email protected]>
Applied to the ipsec tree, thanks Herbert!