From: Paolo Abeni <pabeni@redhat.com>
To: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Cc: Network Development <netdev@vger.kernel.org>,
Willem de Bruijn <willemb@google.com>,
steffen.klassert@secunet.com
Subject: Re: [RFC PATCH v2 02/10] udp: implement GRO for plain UDP sockets.
Date: Mon, 22 Oct 2018 12:13:45 +0200 [thread overview]
Message-ID: <c046191abff49ddaef72b870182d4e922b8d80a2.camel@redhat.com> (raw)
In-Reply-To: <CAF=yD-Jr4_x6KrNQugEtOuVfA5c_jtvJEhCizmyAJM0OLR-g_g@mail.gmail.com>
On Sun, 2018-10-21 at 16:06 -0400, Willem de Bruijn wrote:
> On Fri, Oct 19, 2018 at 10:30 AM Paolo Abeni <pabeni@redhat.com> wrote:
> >
> > This is the RX counterpart of commit bec1f6f69736 ("udp: generate gso
> > with UDP_SEGMENT"). When UDP_GRO is enabled, such socket is also
> > eligible for GRO in the rx path: UDP segments directed to such socket
> > are assembled into a larger GSO_UDP_L4 packet.
> >
> > The core UDP GRO support is enabled with setsockopt(UDP_GRO).
> >
> > Initial benchmark numbers:
> >
> > Before:
> > udp rx: 1079 MB/s 769065 calls/s
> >
> > After:
> > udp rx: 1466 MB/s 24877 calls/s
> >
> >
> > This change introduces a side effect in respect to UDP tunnels:
> > after a UDP tunnel creation, now the kernel performs a lookup per ingress
> > UDP packet, while before such lookup happened only if the ingress packet
> > carried a valid internal header csum.
> >
> > v1 -> v2:
> > - use a new option to enable UDP GRO
> > - use static keys to protect the UDP GRO socket lookup
> >
> > Signed-off-by: Paolo Abeni <pabeni@redhat.com>
> > ---
> > include/linux/udp.h | 3 +-
> > include/uapi/linux/udp.h | 1 +
> > net/ipv4/udp.c | 7 +++
> > net/ipv4/udp_offload.c | 109 +++++++++++++++++++++++++++++++--------
> > net/ipv6/udp_offload.c | 6 +--
> > 5 files changed, 98 insertions(+), 28 deletions(-)
> >
> > diff --git a/include/linux/udp.h b/include/linux/udp.h
> > index a4dafff407fb..f613b329852e 100644
> > --- a/include/linux/udp.h
> > +++ b/include/linux/udp.h
> > @@ -50,11 +50,12 @@ struct udp_sock {
> > __u8 encap_type; /* Is this an Encapsulation socket? */
> > unsigned char no_check6_tx:1,/* Send zero UDP6 checksums on TX? */
> > no_check6_rx:1,/* Allow zero UDP6 checksums on RX? */
> > - encap_enabled:1; /* This socket enabled encap
> > + encap_enabled:1, /* This socket enabled encap
> > * processing; UDP tunnels and
> > * different encapsulation layer set
> > * this
> > */
> > + gro_enabled:1; /* Can accept GRO packets */
> >
> > /*
> > * Following member retains the information to create a UDP header
> > * when the socket is uncorked.
> > diff --git a/include/uapi/linux/udp.h b/include/uapi/linux/udp.h
> > index 09502de447f5..30baccb6c9c4 100644
> > --- a/include/uapi/linux/udp.h
> > +++ b/include/uapi/linux/udp.h
> > @@ -33,6 +33,7 @@ struct udphdr {
> > #define UDP_NO_CHECK6_TX 101 /* Disable sending checksum for UDP6X */
> > #define UDP_NO_CHECK6_RX 102 /* Disable accpeting checksum for UDP6 */
> > #define UDP_SEGMENT 103 /* Set GSO segmentation size */
> > +#define UDP_GRO 104 /* This socket can receive UDP GRO packets */
> >
> > /* UDP encapsulation types */
> > #define UDP_ENCAP_ESPINUDP_NON_IKE 1 /* draft-ietf-ipsec-nat-t-ike-00/01 */
> > diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
> > index 9fcb5374e166..3c277378814f 100644
> > --- a/net/ipv4/udp.c
> > +++ b/net/ipv4/udp.c
> > @@ -115,6 +115,7 @@
> > #include "udp_impl.h"
> > #include <net/sock_reuseport.h>
> > #include <net/addrconf.h>
> > +#include <net/udp_tunnel.h>
> >
> > struct udp_table udp_table __read_mostly;
> > EXPORT_SYMBOL(udp_table);
> > @@ -2459,6 +2460,12 @@ int udp_lib_setsockopt(struct sock *sk, int level, int optname,
> > up->gso_size = val;
> > break;
> >
> > + case UDP_GRO:
> > + if (valbool)
> > + udp_tunnel_encap_enable(sk->sk_socket);
> > + up->gro_enabled = valbool;
>
> The socket lock is not held here, so multiple updates to
> up->gro_enabled and the up->encap_enabled and the static branch can
> race. Syzkaller is adept at generating those.
Good catch. I was fooled by the current existing code. I think there
are potentially similar issues for UDP_ENCAP, UDPLITE_SEND_CSCOV, ...
Since the rx path don't take it anymore and we don't risk starving, I
think we should could/always acquire the socket lock on setsockopt,
wdyt?
> > +#define UDO_GRO_CNT_MAX 64
> > +static struct sk_buff *udp_gro_receive_segment(struct list_head *head,
> > + struct sk_buff *skb)
> > +{
> > + struct udphdr *uh = udp_hdr(skb);
> > + struct sk_buff *pp = NULL;
> > + struct udphdr *uh2;
> > + struct sk_buff *p;
> > +
> > + /* requires non zero csum, for simmetry with GSO */
>
> symmetry
Thanks ;)
Paolo
next prev parent reply other threads:[~2018-10-22 18:31 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-19 14:25 [RFC PATCH v2 00/10] udp: implement GRO support Paolo Abeni
2018-10-19 14:25 ` [RFC PATCH v2 01/10] udp: implement complete book-keeping for encap_needed Paolo Abeni
2018-10-22 16:06 ` Willem de Bruijn
2018-10-25 13:00 ` Paolo Abeni
2018-10-19 14:25 ` [RFC PATCH v2 02/10] udp: implement GRO for plain UDP sockets Paolo Abeni
2018-10-21 20:06 ` Willem de Bruijn
2018-10-22 10:13 ` Paolo Abeni [this message]
2018-10-22 15:15 ` Willem de Bruijn
2018-10-22 11:24 ` Steffen Klassert
2018-10-22 13:41 ` Paolo Abeni
2018-10-22 15:51 ` Willem de Bruijn
2018-10-19 14:25 ` [RFC PATCH v2 03/10] udp: add support for UDP_GRO cmsg Paolo Abeni
2018-10-21 20:07 ` Willem de Bruijn
2018-10-22 15:44 ` Paolo Abeni
2018-10-19 14:25 ` [RFC PATCH v2 04/10] ip: factor out protocol delivery helper Paolo Abeni
2018-10-19 14:25 ` [RFC PATCH v2 05/10] ipv6: " Paolo Abeni
2018-10-19 14:25 ` [RFC PATCH v2 06/10] udp: cope with UDP GRO packet misdirection Paolo Abeni
2018-10-21 20:08 ` Willem de Bruijn
2018-10-22 10:29 ` Paolo Abeni
2018-10-22 16:00 ` Willem de Bruijn
2018-10-22 11:43 ` Steffen Klassert
2018-10-22 12:51 ` Paolo Abeni
2018-10-23 10:29 ` Steffen Klassert
2018-10-22 19:04 ` Subash Abhinov Kasiviswanathan
2018-10-23 7:59 ` Paolo Abeni
2018-10-24 0:55 ` Subash Abhinov Kasiviswanathan
2018-10-19 14:25 ` [RFC PATCH v2 07/10] selftests: add GRO support to udp bench rx program Paolo Abeni
2018-10-21 20:08 ` Willem de Bruijn
2018-10-22 10:31 ` Paolo Abeni
2018-10-19 14:25 ` [RFC PATCH v2 08/10] selftests: conditionally enable XDP support in udpgso_bench_rx Paolo Abeni
2018-10-21 20:09 ` Willem de Bruijn
2018-10-22 10:37 ` Paolo Abeni
2018-10-19 14:25 ` [RFC PATCH v2 09/10] selftests: add some benchmark for UDP GRO Paolo Abeni
2018-10-19 14:25 ` [RFC PATCH v2 10/10] selftests: add functionals test " Paolo Abeni
2018-10-21 20:09 ` Willem de Bruijn
2018-10-22 10:46 ` Paolo Abeni
2018-10-21 20:05 ` [RFC PATCH v2 00/10] udp: implement GRO support Willem de Bruijn
2018-10-22 9:41 ` Paolo Abeni
2018-10-23 12:10 ` Steffen Klassert
2018-10-23 12:22 ` Paolo Abeni
2018-10-24 10:55 ` Steffen Klassert
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=c046191abff49ddaef72b870182d4e922b8d80a2.camel@redhat.com \
--to=pabeni@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=steffen.klassert@secunet.com \
--cc=willemb@google.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).