Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp1054259rdb; Wed, 24 Jan 2024 03:36:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IHatQ/eKSYykyRRAI4LvU0Xvz2aaHZ951ehB0U6E9/cg/s/5Jghz2wv0hV9CiRPIirXetd1 X-Received: by 2002:a17:902:f7c7:b0:1d7:7790:1eec with SMTP id h7-20020a170902f7c700b001d777901eecmr425478plw.88.1706096216687; Wed, 24 Jan 2024 03:36:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706096216; cv=pass; d=google.com; s=arc-20160816; b=04WlsKe193fRa3/s8LRmGBsubO6EbzuuCuEkeMEtmhB9+BMeer2/A8gWrJOc/PD/KS yOEZJOjwNCvr+72MvEnqZA2B9PmD6DsRid/GWtxERy2acFohhy3f1YAfBoVIbNySeajO oIcgyHYJRPLJaIsMvCLR560jlxeIIBae49yt+Ca0hnhBR78pmv55tCLujFpVtlVwF5CP flfym3HI8NrajMfbVdOpK0HHYE4QKD4wy4uhqLggklqOpHe3uYopfhe8xED+dqqOfJ4C UNjxc6u3E6q+W1R2a/fMRMqN1VK01rSYM7iipXz37ftLZNtQqbIW/po+qEUE7o3I/HK0 76xg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:date:message-id; bh=4lR8dNoc1AeIunkolCglmPNf7iu6/JPffte0qbwomSI=; fh=nX8cF9YV83e4xjlpqqD4DcoNSQnMGTgpVQp60GZsejA=; b=tC+wHD7ZN1B2M3OkldaSqyHbIJS8P2RuyJErdwEG6Pee4UYC8pM4jBerxAN68tjDEm FJkWGCA/wUGVXKLi2U4R5ClooZTf4dh8qeQL1iGpZpmP1YLL2o8lcaHFH2a5UZ14aJgM rpQYf5qCSrsAK8Ir4tel86rATJQjGaCA4OjnZLHQu1mvYMOo7HQ0ranA30QzQ/hwbVkJ PPA8AjwY97xtbBff5j/yXiDq018sQ/t1Leyg7eAmhMAHAfAtQyZ9jqBYTazeh1KKbZjj n5X/NgXrXtS7QSHDQSGi2DlZT0f/q66tnCWETyv32Uf30VJqZnAGwie0I68/VKcRs0u3 +HXg== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-36829-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-36829-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id x2-20020a170902ec8200b001d743430a18si6276751plg.488.2024.01.24.03.36.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 03:36:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-36829-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-36829-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-36829-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 1FB0FB222D4 for ; Wed, 24 Jan 2024 11:04:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C774E1AAD2; Wed, 24 Jan 2024 11:04:15 +0000 (UTC) Received: from out30-100.freemail.mail.aliyun.com (out30-100.freemail.mail.aliyun.com [115.124.30.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B5CAA199B8 for ; Wed, 24 Jan 2024 11:04:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.100 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706094255; cv=none; b=nDM9k+xDUl+eAFUsJ6pYVSCS0cPvbVz9uIbVtQEzPFjzIUsDW5rk8LwaUQWcppAEmkvC+x6zBk6CXojSmsifiI7NazvmI5XrJrbXPYOZTK4cpAMrr38Qx0uQ8vWVjTIKEZ92SbQKSUxmz8LpWVq1ehmfA7Vkwn00LGGoR5c6FdQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706094255; c=relaxed/simple; bh=RQj3sUXdtYHYvevvKwr5sdDtzYfqublH8XzC8qK0vO4=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=PG+ga/a3UINHjnz0lPER7NoitKR936+EQozFiJR8H6Qj+3XxqUA0pOWpHbbF7LOSaMJTxcT0mvsSCcTmMWYhIjTXWMTxyiB4k7hrFIQ57cmoNYX1xsSkzF9+vkjcgEoVaPnc7zqCbvOK3zYSIV+GlyvMvCq0d2aUbII3ZSdLxjQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; arc=none smtp.client-ip=115.124.30.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R121e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046050;MF=hengqi@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0W.GRcE5_1706094243; Received: from 30.221.149.132(mailfrom:hengqi@linux.alibaba.com fp:SMTPD_---0W.GRcE5_1706094243) by smtp.aliyun-inc.com; Wed, 24 Jan 2024 19:04:03 +0800 Message-ID: <896749de-39b6-4081-91f3-1e316706a0e9@linux.alibaba.com> Date: Wed, 24 Jan 2024 19:04:02 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 2/3] virtio_net: Add missing virtio header in skb for XDP_PASS To: Liang Chen Cc: virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo References: <20240124085721.54442-1-liangchen.linux@gmail.com> <20240124085721.54442-3-liangchen.linux@gmail.com> From: Heng Qi In-Reply-To: <20240124085721.54442-3-liangchen.linux@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 在 2024/1/24 下午4:57, Liang Chen 写道: > For the XDP_PASS scenario of the XDP path, the skb constructed with > xdp_buff does not include the virtio header. Adding the virtio header > information back when creating the skb. > > Signed-off-by: Liang Chen > --- > drivers/net/virtio_net.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > index b56828804e5f..2de46eb4c661 100644 > --- a/drivers/net/virtio_net.c > +++ b/drivers/net/virtio_net.c > @@ -1270,6 +1270,9 @@ static struct sk_buff *receive_small_xdp(struct net_device *dev, > if (unlikely(!skb)) > goto err; > > + /* Store the original virtio header for subsequent use by the driver. */ > + memcpy(skb_vnet_common_hdr(skb), &virtnet_xdp.hdr, vi->hdr_len); If xdp push or xdp pull modifies xdp_buff, will the original header still apply to the modified data? Thanks, Heng > + > if (metasize) > skb_metadata_set(skb, metasize); > > @@ -1635,6 +1638,9 @@ static struct sk_buff *receive_mergeable_xdp(struct net_device *dev, > head_skb = build_skb_from_xdp_buff(dev, vi, xdp, xdp_frags_truesz); > if (unlikely(!head_skb)) > break; > + /* Store the original virtio header for subsequent use by the driver. */ > + memcpy(skb_vnet_common_hdr(head_skb), &virtnet_xdp.hdr, vi->hdr_len); > + > return head_skb; > > case XDP_TX: