From mboxrd@z Thu Jan 1 00:00:00 1970 From: Willem de Bruijn Subject: Re: [RFC PATCH v2 06/10] udp: cope with UDP GRO packet misdirection Date: Sun, 21 Oct 2018 16:08:17 -0400 Message-ID: References: <63e4ceb238db122d3d831f0809285243701b2284.1539957909.git.pabeni@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Cc: Network Development , Willem de Bruijn , steffen.klassert@secunet.com To: Paolo Abeni Return-path: Received: from mail-ed1-f66.google.com ([209.85.208.66]:42248 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725723AbeJVEYY (ORCPT ); Mon, 22 Oct 2018 00:24:24 -0400 Received: by mail-ed1-f66.google.com with SMTP id b7-v6so35945470edd.9 for ; Sun, 21 Oct 2018 13:08:54 -0700 (PDT) In-Reply-To: <63e4ceb238db122d3d831f0809285243701b2284.1539957909.git.pabeni@redhat.com> Sender: netdev-owner@vger.kernel.org List-ID: On Fri, Oct 19, 2018 at 10:31 AM Paolo Abeni wrote: > > In some scenarios, the GRO engine can assemble an UDP GRO packet > that ultimately lands on a non GRO-enabled socket. > This patch tries to address the issue explicitly checking for the UDP > socket features before enqueuing the packet, and eventually segmenting > the unexpected GRO packet, as needed. > > We must also cope with re-insertion requests: after segmentation the > UDP code calls the helper introduced by the previous patches, as needed. > > Signed-off-by: Paolo Abeni > --- > +static inline struct sk_buff *udp_rcv_segment(struct sock *sk, > + struct sk_buff *skb) > +{ > + struct sk_buff *segs; > + > + /* the GSO CB lays after the UDP one, no need to save and restore any > + * CB fragment, just initialize it > + */ > + segs = __skb_gso_segment(skb, NETIF_F_SG, false); > + if (unlikely(IS_ERR(segs))) > + kfree_skb(skb); > + else if (segs) > + consume_skb(skb); > + return segs; > +} > + > + > +void ip_protocol_deliver_rcu(struct net *net, struct sk_buff *skb, int proto); > + > +static int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) > +{ > + struct sk_buff *next, *segs; > + int ret; > + > + if (likely(!udp_unexpected_gso(sk, skb))) > + return udp_queue_rcv_one_skb(sk, skb); > + > + BUILD_BUG_ON(sizeof(struct udp_skb_cb) > SKB_SGO_CB_OFFSET); > + __skb_push(skb, -skb_mac_offset(skb)); > + segs = udp_rcv_segment(sk, skb); > + for (skb = segs; skb; skb = next) { need to check IS_ERR(segs) again?