From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <stable-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 31F07A2EFC
	for <public@inbox.dpdk.org>; Tue, 15 Oct 2019 10:14:32 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 018D91D453;
	Tue, 15 Oct 2019 10:14:32 +0200 (CEST)
Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com
 [148.163.129.52]) by dpdk.org (Postfix) with ESMTP id 910031D44B;
 Tue, 15 Oct 2019 10:14:28 +0200 (CEST)
X-Virus-Scanned: Proofpoint Essentials engine
Received: from webmail.solarflare.com (uk.solarflare.com [193.34.186.16])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits))
 (No client certificate requested)
 by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id C1DF4940064;
 Tue, 15 Oct 2019 08:14:26 +0000 (UTC)
Received: from [192.168.38.17] (91.220.146.112) by ukex01.SolarFlarecom.com
 (10.17.10.4) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 15 Oct
 2019 09:14:19 +0100
To: Tiwei Bie <tiwei.bie@intel.com>
CC: Marvin Liu <yong.liu@intel.com>, <maxime.coquelin@redhat.com>,
 <zhihong.wang@intel.com>, <stephen@networkplumber.org>, <dev@dpdk.org>,
 <stable@dpdk.org>, Kevin Traynor <ktraynor@redhat.com>, Luca Boccassi
 <bluca@debian.org>
References: <20190923140511.107939-1-yong.liu@intel.com>
 <ea94171a-ef64-6909-a976-388b8fadc7e2@solarflare.com>
 <20191015053309.GA18809@___>
From: Andrew Rybchenko <arybchenko@solarflare.com>
Message-ID: <62ccfe11-9302-2b2f-13c3-87cc37b172fb@solarflare.com>
Date: Tue, 15 Oct 2019 11:14:15 +0300
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101
 Thunderbird/60.9.0
MIME-Version: 1.0
In-Reply-To: <20191015053309.GA18809@___>
Content-Type: text/plain; charset="utf-8"; format=flowed
Content-Transfer-Encoding: 7bit
Content-Language: en-GB
X-Originating-IP: [91.220.146.112]
X-ClientProxiedBy: ocex03.SolarFlarecom.com (10.20.40.36) To
 ukex01.SolarFlarecom.com (10.17.10.4)
X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.5.1010-24978.003
X-TM-AS-Result: No-11.146100-8.000000-10
X-TMASE-MatchedRID: byfwvk+IcRnmLzc6AOD8DfHkpkyUphL9SeIjeghh/zMdQW9W2F3v/ciT
 Wug2C4DNBTL3N8yyT9ePQi9XuOWoOGzj1zlNQsvv4jRkIImnX0NfAXPuWnqbj7t0cvfchz7yRzs
 TPtipeqrodd+2IFCZpqJZALSXBkSFpUxzcSQ8HaTwqDryy7bDITB4tWHctlhIw62uSG5kL1aj1Z
 rjLTOfz2j8uEoo2xGh/Eml6Vez+EoNKzHdZvkNCRIRh9wkXSlFu8ZgmQ167rWsBbMjHUED8Ozn6
 eE2grwnDV46xym6Sorq2PGDWaqIuyzB69I7dfoFzfqlpbtmcWhRvgR0hkbG4PyQXCBzKijhUKnZ
 C4CXj7eKK7oqyLhtj15vbElLXtAv7/9r2G5AnUSeAiCmPx4NwLTrdaH1ZWqCZYJ9vPJ1vSDiaBc
 E8wFw3o2j49Ftap9EOwBXM346/+zUhDM9xFHZ3QXnRKjI6XUoYqzWZX6DQqpqolFKk2ksSdELrs
 isNJZW
X-TM-AS-User-Approved-Sender: Yes
X-TM-AS-User-Blocked-Sender: No
X-TMASE-Result: 10--11.146100-8.000000
X-TMASE-Version: SMEX-12.5.0.1300-8.5.1010-24978.003
X-MDID: 1571127267-c0PFkGaEKt9Y
Subject: Re: [dpdk-stable] [dpdk-dev] [PATCH] net/virtio: fix mbuf data and
 pkt length mismatch
X-BeenThere: stable@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches for DPDK stable branches <stable.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/stable>,
 <mailto:stable-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/stable/>
List-Post: <mailto:stable@dpdk.org>
List-Help: <mailto:stable-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/stable>,
 <mailto:stable-request@dpdk.org?subject=subscribe>
Errors-To: stable-bounces@dpdk.org
Sender: "stable" <stable-bounces@dpdk.org>

Hi Tiwei,

On 10/15/19 8:33 AM, Tiwei Bie wrote:
> On Mon, Oct 14, 2019 at 06:15:42PM +0300, Andrew Rybchenko wrote:
>>> diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c
>>> index 27ead19fb..822cce06d 100644
>>> --- a/drivers/net/virtio/virtio_rxtx.c
>>> +++ b/drivers/net/virtio/virtio_rxtx.c
>>> @@ -597,9 +597,8 @@ virtqueue_enqueue_xmit_inorder(struct virtnet_tx *txvq,
>>>    		dxp->cookie = (void *)cookies[i];
>>>    		dxp->ndescs = 1;
>>> -		hdr = (struct virtio_net_hdr *)
>>> -			rte_pktmbuf_prepend(cookies[i], head_size);
>>> -		cookies[i]->pkt_len -= head_size;
>>> +		hdr = (struct virtio_net_hdr *)(char *)cookies[i]->buf_addr +
>>> +			cookies[i]->data_off - head_size;
>>>    		/* if offload disabled, hdr is not zeroed yet, do it now */
>>>    		if (!vq->hw->has_tx_offload)
>>> @@ -608,9 +607,10 @@ virtqueue_enqueue_xmit_inorder(struct virtnet_tx *txvq,
>>>    			virtqueue_xmit_offload(hdr, cookies[i], true);
>>>    		start_dp[idx].addr  = VIRTIO_MBUF_DATA_DMA_ADDR(cookies[i], vq);
>> As I understand the problem is here. It points to start of the packet
>> (Ethernet header) since data_off is not changed above now, but
>> should point to virtio_net_hdr before the packet.
>>
>> I think the patch fixes the bug in a wrong direction. It looks better
>> to simply remove
>>
>>      cookies[i]->pkt_len -= head_size;
>>
>> above and care about real packet length difference in
>> virtio_update_packet_stats() or when it is called from Tx path.
>>
>> If it is OK for maintainers I'm ready to send patches to rollback back
>> this one and fix it as described above.
> Hi Andrew,
>
> Thanks for looking into this! Feel free to send your fix.
> PS. Another thing also needs to be noticed is that, after
> prepending the net hdr with rte_pktmbuf_prepend(), below
> code in virtio_update_packet_stats() won't be able to
> access the ether header as expected:
>
> https://github.com/DPDK/dpdk/blob/31b798a6f08e9b333b94b8bb26910209aa810b73/drivers/net/virtio/virtio_rxtx.c#L134-L140

Thanks for the information. Looking closer I've changed my mind.
Will send patch shortly.

Andrew.