From: "Benoît Monin" <benoit.monin@gmx.fr>
To: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
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>,
Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next] net: skip offload for NETIF_F_IPV6_CSUM if ipv6 header contains extension
Date: Mon, 07 Oct 2024 16:54:12 +0200 [thread overview]
Message-ID: <7056440.9J7NaK4W3v@benoit.monin> (raw)
In-Reply-To: <670326ed8220a_135479294d1@willemb.c.googlers.com.notmuch>
07/10/2024 Willem de Bruijn wrote :
> Benoît Monin wrote:
> > Devices with NETIF_F_IP_CSUM capability can checksum TCP and UDP over
> > IPv4 with an IP header that may contains options; whereas devices with
> > NETIF_F_IPV6_CSUM capability can only checksum TCP and UDP over IPv6 if
> > the IP header does not contains extension.
>
> Are both these statements universally true across devices?
>
> I can believe for NETIF_F_IP_CSUM that this is the definition, and
> that devices that cannot handle options must fix it up indivually in
> ndo_features_check.
>
> And same for NETIF_F_IPV6_CSUM with extension headers.
>
> But it would be good to see where this is asserted in the code, or
> examples of drivers that have to perform such actions.
>
I was referring to the documentation in skbuff.h that describes
NETIF_F_IP_CSUM and NETIF_F_IPV6_CSUM.
For NETIF_F_IPV6_CSUM, at least fsl_dpa and r8169 expect
ipv6_hdr(skb)->nexthdr to be IPPROTO_{TCP,UDP} to compute the correct
checksum for IPv6.
I posted more details about the problem I am trying to fix with this
patch in the following thread:
https://lore.kernel.org/netdev/26548921.1r3eYUQgxm@benoit.monin/T/#u
> > Enforce that in skb_csum_hwoffload_help by checking the network header
> > length in the case where the IP header version is 6. We cannot simply
> > rely on the network header length since the IPv4 header can from 20 to
> > 60 bytes whereas the IPv6 header must be 40 bytes. So we check the
> > version field which is common to IPv4 and IPv6 headers.
> >
> > This fixes checksumming errors seen with ip6_tunnel and fou6
> > encapsulation, for example with GRE-in-UDP over IPv6:
> > * fou6 adds a UDP header with a partial checksum if the inner packet
> > does not contains a valid checksum.
>
> Where in the code is this conditional on the inner packet csum?
>
This is done by udp6_set_csum, which called by fou6_build_udp.
> > * ip6_tunnel adds an IPv6 header with a destination option extension
> > header if encap_limit is non-zero (the default value is 4).
>
>
> If this is a fix, we'll need to target net and best effort find a
> suitable fixes tag.
>
I guess the particular problem I have found is present since the merge
of fou6 in 4.7, but it might not be the only code path to create an
IPv6 packet with an extension header and a partial checksum.
> > Signed-off-by: Benoît Monin <benoit.monin@gmx.fr>
> > ---
> > net/core/dev.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> > diff --git a/net/core/dev.c b/net/core/dev.c
> > index ea5fbcd133ae..199831d86ec1 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 (ip_hdr(skb)->version == 6 &&
> > + 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);
>
--
Benoît
next prev parent reply other threads:[~2024-10-07 14:54 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-04 15:45 [PATCH net-next] net: skip offload for NETIF_F_IPV6_CSUM if ipv6 header contains extension Benoît Monin
2024-10-07 0:10 ` Willem de Bruijn
2024-10-07 14:54 ` Benoît Monin [this message]
2024-10-07 20:44 ` Willem de Bruijn
2024-10-10 16:02 ` Benoît Monin
2024-10-21 15:25 ` Benoît Monin
2024-10-21 22:04 ` Willem de Bruijn
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=7056440.9J7NaK4W3v@benoit.monin \
--to=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 \
--cc=willemdebruijn.kernel@gmail.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;
as well as URLs for NNTP newsgroup(s).