From: Paolo Abeni <pabeni@redhat.com>
To: Eric Dumazet <edumazet@google.com>,
Richard Gobert <richardbgobert@gmail.com>
Cc: davem@davemloft.net, kuba@kernel.org, dsahern@kernel.org,
willemdebruijn.kernel@gmail.com, alobakin@pm.me,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net v4 1/2] net: gro: fix udp bad offset in socket lookup by adding {inner_}network_offset to napi_gro_cb
Date: Thu, 02 May 2024 11:18:52 +0200 [thread overview]
Message-ID: <ada57e67645c7ebbbebe0c5d6e603113fc1be2e6.camel@redhat.com> (raw)
In-Reply-To: <CANn89i+rCK4jmjRUXywpeQeE1PPjNF=kf1_kEOB+UTYzi3MkYw@mail.gmail.com>
On Tue, 2024-04-30 at 18:17 +0200, Eric Dumazet wrote:
> On Tue, Apr 30, 2024 at 4:40 PM Richard Gobert <richardbgobert@gmail.com> wrote:
> >
> > Commits a602456 ("udp: Add GRO functions to UDP socket") and 57c67ff ("udp:
> > additional GRO support") introduce incorrect usage of {ip,ipv6}_hdr in the
> > complete phase of gro. The functions always return skb->network_header,
> > which in the case of encapsulated packets at the gro complete phase, is
> > always set to the innermost L3 of the packet. That means that calling
> > {ip,ipv6}_hdr for skbs which completed the GRO receive phase (both in
> > gro_list and *_gro_complete) when parsing an encapsulated packet's _outer_
> > L3/L4 may return an unexpected value.
> >
> > This incorrect usage leads to a bug in GRO's UDP socket lookup.
> > udp{4,6}_lib_lookup_skb functions use ip_hdr/ipv6_hdr respectively. These
> > *_hdr functions return network_header which will point to the innermost L3,
> > resulting in the wrong offset being used in __udp{4,6}_lib_lookup with
> > encapsulated packets.
> >
> > This patch adds network_offset and inner_network_offset to napi_gro_cb, and
> > makes sure both are set correctly.
> >
> > To fix the issue, network_offsets union is used inside napi_gro_cb, in
> > which both the outer and the inner network offsets are saved.
> >
> > Reproduction example:
> >
> > Endpoint configuration example (fou + local address bind)
> >
> > # ip fou add port 6666 ipproto 4
> > # ip link add name tun1 type ipip remote 2.2.2.1 local 2.2.2.2 encap fou encap-dport 5555 encap-sport 6666 mode ipip
> > # ip link set tun1 up
> > # ip a add 1.1.1.2/24 dev tun1
> >
> > Netperf TCP_STREAM result on net-next before patch is applied:
> >
> > net-next main, GRO enabled:
> > $ netperf -H 1.1.1.2 -t TCP_STREAM -l 5
> > Recv Send Send
> > Socket Socket Message Elapsed
> > Size Size Size Time Throughput
> > bytes bytes bytes secs. 10^6bits/sec
> >
> > 131072 16384 16384 5.28 2.37
> >
> > net-next main, GRO disabled:
> > $ netperf -H 1.1.1.2 -t TCP_STREAM -l 5
> > Recv Send Send
> > Socket Socket Message Elapsed
> > Size Size Size Time Throughput
> > bytes bytes bytes secs. 10^6bits/sec
> >
> > 131072 16384 16384 5.01 2745.06
> >
> > patch applied, GRO enabled:
> > $ netperf -H 1.1.1.2 -t TCP_STREAM -l 5
> > Recv Send Send
> > Socket Socket Message Elapsed
> > Size Size Size Time Throughput
> > bytes bytes bytes secs. 10^6bits/sec
> >
> > 131072 16384 16384 5.01 2877.38
> >
> > Fixes: 57c67ff4bd92 ("udp: additional GRO support")
>
> Nit: I would think the bug was added later in
> a6024562ffd7 ("udp: Add GRO functions to UDP socket")
No need to repost: I'm updating that in PW.
Cheers,
Paolo
next prev parent reply other threads:[~2024-05-02 9:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-30 14:35 [PATCH net v4 0/2] net: gro: add flush/flush_id checks and fix wrong offset in udp Richard Gobert
2024-04-30 14:35 ` [PATCH net v4 1/2] net: gro: fix udp bad offset in socket lookup by adding {inner_}network_offset to napi_gro_cb Richard Gobert
2024-04-30 16:17 ` Eric Dumazet
2024-05-02 9:18 ` Paolo Abeni [this message]
2024-04-30 18:28 ` Willem de Bruijn
2024-04-30 14:35 ` [PATCH net v4 2/2] net: gro: add flush check in udp_gro_receive_segment Richard Gobert
2024-04-30 18:32 ` Willem de Bruijn
2024-05-02 9:20 ` [PATCH net v4 0/2] net: gro: add flush/flush_id checks and fix wrong offset in udp patchwork-bot+netdevbpf
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=ada57e67645c7ebbbebe0c5d6e603113fc1be2e6.camel@redhat.com \
--to=pabeni@redhat.com \
--cc=alobakin@pm.me \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=richardbgobert@gmail.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
all inboxes | Powered by JetHome®