From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f196.google.com ([209.85.192.196]:40715 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752590AbeBTQ5U (ORCPT ); Tue, 20 Feb 2018 11:57:20 -0500 Received: by mail-pf0-f196.google.com with SMTP id m5so2042958pff.7 for ; Tue, 20 Feb 2018 08:57:20 -0800 (PST) Subject: Re: [net PATCH 2/4] virtio_net: fix XDP code path in receive_small() To: Jesper Dangaard Brouer , Jason Wang Cc: "Michael S. Tsirkin" , netdev@vger.kernel.org, Alexei Starovoitov , Saeed Mahameed , Daniel Borkmann , "David S. Miller" , Tariq Toukan References: <151913348634.28247.17519468037896960567.stgit@firesoul> <151913352995.28247.4449049695120368682.stgit@firesoul> From: John Fastabend Message-ID: <8532eda0-94fa-44e2-d73e-b7b14a13b9ab@gmail.com> Date: Tue, 20 Feb 2018 08:57:18 -0800 MIME-Version: 1.0 In-Reply-To: <151913352995.28247.4449049695120368682.stgit@firesoul> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: netdev-owner@vger.kernel.org List-ID: On 02/20/2018 05:32 AM, Jesper Dangaard Brouer wrote: > When configuring virtio_net to use the code path 'receive_small()', > in-order to get correct XDP_REDIRECT support, I discovered TCP packets > would get silently dropped when loading an XDP program action XDP_PASS. > > The bug seems to be that receive_small() when XDP is loaded check that > hdr->hdr.flags is zero, which seems wrong as hdr.flags contains the > flags VIRTIO_NET_HDR_F_* : > #define VIRTIO_NET_HDR_F_NEEDS_CSUM 1 /* Use csum_start, csum_offset */ > #define VIRTIO_NET_HDR_F_DATA_VALID 2 /* Csum is valid */ > > TCP got dropped as it had the VIRTIO_NET_HDR_F_DATA_VALID flag set. > > The flags that are relevant here are the VIRTIO_NET_HDR_GSO_* flags > stored in hdr->hdr.gso_type. Thus, the fix is just check that none of > the gso_type flags have been set. > > Fixes: bb91accf2733 ("virtio-net: XDP support for small buffers") > Signed-off-by: Jesper Dangaard Brouer > --- Acked-by: John Fastabend Thanks! > drivers/net/virtio_net.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > index 0ca91942a884..10c8fc46b588 100644 > --- a/drivers/net/virtio_net.c > +++ b/drivers/net/virtio_net.c > @@ -558,7 +558,7 @@ static struct sk_buff *receive_small(struct net_device *dev, > void *orig_data; > u32 act; > > - if (unlikely(hdr->hdr.gso_type || hdr->hdr.flags)) > + if (unlikely(hdr->hdr.gso_type)) > goto err_xdp; > > if (unlikely(xdp_headroom < virtnet_get_headroom(vi))) { >