Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754537AbcLZCes (ORCPT ); Sun, 25 Dec 2016 21:34:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42714 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751968AbcLZCeq (ORCPT ); Sun, 25 Dec 2016 21:34:46 -0500 Subject: Re: [PATCH net 4/9] virtio-net: correctly handle XDP_PASS for linearized packets To: John Fastabend , mst@redhat.com, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <1482503852-12438-1-git-send-email-jasowang@redhat.com> <1482503852-12438-5-git-send-email-jasowang@redhat.com> <585D4966.9060605@gmail.com> Cc: john.r.fastabend@intel.com From: Jason Wang Message-ID: <372cf0e9-a1ab-a45c-82dc-5f45af6bc7dc@redhat.com> Date: Mon, 26 Dec 2016 10:34:39 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <585D4966.9060605@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 26 Dec 2016 02:34:46 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1709 Lines: 49 On 2016年12月23日 23:57, John Fastabend wrote: > On 16-12-23 06:37 AM, Jason Wang wrote: >> When XDP_PASS were determined for linearized packets, we try to get >> new buffers in the virtqueue and build skbs from them. This is wrong, >> we should create skbs based on existed buffers instead. Fixing them by >> creating skb based on xdp_page. >> >> With this patch "ping 192.168.100.4 -s 3900 -M do" works for XDP_PASS. >> >> Cc: John Fastabend >> Signed-off-by: Jason Wang >> --- >> drivers/net/virtio_net.c | 10 ++++++++-- >> 1 file changed, 8 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c >> index 58ad40e..470293e 100644 >> --- a/drivers/net/virtio_net.c >> +++ b/drivers/net/virtio_net.c >> @@ -578,8 +578,14 @@ static struct sk_buff *receive_mergeable(struct net_device *dev, >> act = do_xdp_prog(vi, rq, xdp_prog, xdp_page, offset, len); >> switch (act) { >> case XDP_PASS: >> - if (unlikely(xdp_page != page)) >> - __free_pages(xdp_page, 0); >> + /* We can only create skb based on xdp_page. */ >> + if (unlikely(xdp_page != page)) { >> + rcu_read_unlock(); >> + put_page(page); >> + head_skb = page_to_skb(vi, rq, xdp_page, >> + 0, len, PAGE_SIZE); >> + return head_skb; >> + } >> break; >> case XDP_TX: >> if (unlikely(xdp_page != page)) >> > Great thanks. This was likely working before because of the memory > leak fixed in 3/9. Looks not, without this and 3/9 the code will try to get buffers and build skb for a new packet instead of existed buffers. Thanks > > Acked-by: John Fastabend