From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: "Eric Dumazet" <edumazet@google.com>,
"Benoît Monin" <benoit.monin@gmx.fr>
Cc: "David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>, Jiri Pirko <jiri@resnulli.us>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Lorenzo Bianconi <lorenzo@kernel.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 net] net: skip offload for NETIF_F_IPV6_CSUM if ipv6 header contains extension
Date: Tue, 31 Dec 2024 05:56:50 -0500 [thread overview]
Message-ID: <6773cdf25a15a_534e22946f@willemb.c.googlers.com.notmuch> (raw)
In-Reply-To: <CANn89iK1hdC3Nt8KPhOtTF8vCPc1AHDCtse_BTNki1pWxAByTQ@mail.gmail.com>
Eric Dumazet wrote:
> On Thu, Oct 24, 2024 at 4:01 PM Benoît Monin <benoit.monin@gmx.fr> wrote:
> >
> > As documented in skbuff.h, devices with NETIF_F_IPV6_CSUM capability
> > can only checksum TCP and UDP over IPv6 if the IP header does not
> > contains extension.
> >
> > This is enforced for UDP packets emitted from user-space to an IPv6
> > address as they go through ip6_make_skb(), which calls
> > __ip6_append_data() where a check is done on the header size before
> > setting CHECKSUM_PARTIAL.
> >
> > But the introduction of UDP encapsulation with fou6 added a code-path
> > where it is possible to get an skb with a partial UDP checksum and an
> > IPv6 header with extension:
> > * fou6 adds a UDP header with a partial checksum if the inner packet
> > does not contains a valid checksum.
> > * ip6_tunnel adds an IPv6 header with a destination option extension
> > header if encap_limit is non-zero (the default value is 4).
> >
> > The thread linked below describes in more details how to reproduce the
> > problem with GRE-in-UDP tunnel.
> >
> > Add a check on the network header size in skb_csum_hwoffload_help() to
> > make sure no IPv6 packet with extension header is handed to a network
> > device with NETIF_F_IPV6_CSUM capability.
> >
> > Link: https://lore.kernel.org/netdev/26548921.1r3eYUQgxm@benoit.monin/T/#u
> > Fixes: aa3463d65e7b ("fou: Add encap ops for IPv6 tunnels")
> > Signed-off-by: Benoît Monin <benoit.monin@gmx.fr>
> > ---
> > changelog
> > * v2:
> > - patch against net instead of net-next
> > - clarify documentation of NETIF_F_IPV6_CSUM
> > - add link to thread describing the problem
> > - add fixes tag
> > - use vlan_get_protocol to check for IPv6
> > * v1:
> > - https://lore.kernel.org/netdev/0dc0c2af98e96b1df20bd36aeaed4eb4e27d507e.1728056028.git.benoit.monin@gmx.fr/T/#u
> > ---
> > net/core/dev.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> > diff --git a/net/core/dev.c b/net/core/dev.c
> > index ea5fbcd133ae..8453e14d301b 100644
> > --- a/net/core/dev.c
> > +++ b/net/core/dev.c
> > @@ -3639,6 +3639,9 @@ int skb_csum_hwoffload_help(struct sk_buff *skb,
> > return 0;
> >
> > if (features & (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM)) {
> > + if (vlan_get_protocol(skb) == htons(ETH_P_IPV6) &&
> > + skb_network_header_len(skb) != sizeof(struct ipv6hdr))
> > + goto sw_checksum;
> > switch (skb->csum_offset) {
> > case offsetof(struct tcphdr, check):
> > case offsetof(struct udphdr, check):
> > @@ -3646,6 +3649,7 @@ int skb_csum_hwoffload_help(struct sk_buff *skb,
> > }
> > }
> >
> > +sw_checksum:
> > return skb_checksum_help(skb);
> > }
> > EXPORT_SYMBOL(skb_csum_hwoffload_help);
>
>
> FYI, this patch broke BIG TCP over IPv6.
>
> [ 239.698598] Oops skb_network_header_len()=48 skb->len=67210
> [ 239.704122] skb len=67210 headroom=162 headlen=94 tailroom=0
> mac=(162,14) mac_len=0 net=(176,48) trans=224
> shinfo(txflags=0 nr_frags=3 gso(size=1428 type=16 segs=47))
> csum(0x1000e0 start=224 offset=16 ip_summed=3
> complete_sw=0 valid=0 level=0)
> hash(0xadf29e31 sw=0 l4=1) proto=0x86dd pkttype=0 iif=0
> priority=0x18020 mark=0x0 alloc_cpu=46 vlan_all=0x0
> encapsulation=0 inner(proto=0x0000, mac=0, net=0,
I'm looking into the following fix
+++ b/net/core/dev.c
@@ -3642,7 +3642,8 @@ int skb_csum_hwoffload_help(struct sk_buff *skb,
if (features & (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM)) {
if (vlan_get_protocol(skb) == htons(ETH_P_IPV6) &&
- skb_network_header_len(skb) != sizeof(struct ipv6hdr))
+ skb_network_header_len(skb) != sizeof(struct ipv6hdr) &&
+ !ipv6_has_hopopt_jumbo(skb))
goto sw_checksum;
next prev parent reply other threads:[~2024-12-31 10:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-24 14:01 [PATCH v2 net] net: skip offload for NETIF_F_IPV6_CSUM if ipv6 header contains extension Benoît Monin
2024-10-25 14:55 ` Willem de Bruijn
2024-12-23 10:40 ` Eric Dumazet
2024-12-31 10:56 ` Willem de Bruijn [this message]
2024-12-31 15:24 ` Benoît Monin
2024-12-31 16:00 ` Eric Dumazet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6773cdf25a15a_534e22946f@willemb.c.googlers.com.notmuch \
--to=willemdebruijn.kernel@gmail.com \
--cc=benoit.monin@gmx.fr \
--cc=bigeasy@linutronix.de \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lorenzo@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox