From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id E08BEA04F1; Mon, 9 Dec 2019 12:26:15 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 23F982C12; Mon, 9 Dec 2019 12:26:15 +0100 (CET) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 889BE1F5 for ; Mon, 9 Dec 2019 12:26:13 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Dec 2019 03:26:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,294,1571727600"; d="scan'208";a="210083818" Received: from irsmsx105.ger.corp.intel.com ([163.33.3.28]) by fmsmga008.fm.intel.com with ESMTP; 09 Dec 2019 03:26:11 -0800 Received: from irsmsx102.ger.corp.intel.com ([169.254.2.130]) by irsmsx105.ger.corp.intel.com ([169.254.7.165]) with mapi id 14.03.0439.000; Mon, 9 Dec 2019 11:26:10 +0000 From: "Ferriter, Cian" To: Zhike Wang , "dev@dpdk.org" CC: "wangzhike@jd.com" , "Yigit, Ferruh" Thread-Topic: [PATCH v2] net/pcap: truncate packet if it is too large Thread-Index: AQHVrjNzPfGjWior+E2E/AbG3knlkaexqJeQ Date: Mon, 9 Dec 2019 11:26:09 +0000 Message-ID: <579B86492DFB364BBA627A48FB30C90E75E2AB1D@IRSMSX102.ger.corp.intel.com> References: <1575856389-37732-1-git-send-email-wangzk320@163.com> In-Reply-To: <1575856389-37732-1-git-send-email-wangzk320@163.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiODAzMmZhNTMtMmIxZC00MmE3LThjY2QtNzQyMGFjMGYzZDE1IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoieWsxRjBOU1BwTjh3aVwvY3ZYQkJ5RkpnM2VvUmVncXpWaEMwa2loS1FmaXBEdFFqYnQ3M3hDQ0pEXC96N1lKa2NYIn0= dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v2] net/pcap: truncate packet if it is too large X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi Zhike, I've tested the behavior before and after this patch and can verify that th= e packets are being correctly truncated. Code looks good to me too. Reviewed-by: Cian Ferriter Thanks, Cian > -----Original Message----- > From: Zhike Wang > Sent: Monday 9 December 2019 01:53 > To: dev@dpdk.org > Cc: wangzhike@jd.com; Yigit, Ferruh ; Ferriter, C= ian > ; Zhike Wang > Subject: [PATCH v2] net/pcap: truncate packet if it is too large >=20 > From: Zhike Wang >=20 > Previously large packet would be dropped, instead now it is better to kee= p it > via truncating it. >=20 > Signed-off-by: Zhike Wang > --- > drivers/net/pcap/rte_eth_pcap.c | 16 ++++++---------- > 1 file changed, 6 insertions(+), 10 deletions(-) >=20 > diff --git a/drivers/net/pcap/rte_eth_pcap.c > b/drivers/net/pcap/rte_eth_pcap.c index aa7ef6f..b4c79d1 100644 > --- a/drivers/net/pcap/rte_eth_pcap.c > +++ b/drivers/net/pcap/rte_eth_pcap.c > @@ -313,7 +313,7 @@ struct pmd_devargs_all { > struct pcap_pkthdr header; > pcap_dumper_t *dumper; > unsigned char temp_data[RTE_ETH_PCAP_SNAPLEN]; > - size_t len; > + size_t len, caplen; >=20 > pp =3D rte_eth_devices[dumper_q->port_id].process_private; > dumper =3D pp->tx_dumper[dumper_q->queue_id]; > @@ -325,28 +325,24 @@ struct pmd_devargs_all { > * dumper */ > for (i =3D 0; i < nb_pkts; i++) { > mbuf =3D bufs[i]; > - len =3D rte_pktmbuf_pkt_len(mbuf); > + len =3D caplen =3D rte_pktmbuf_pkt_len(mbuf); > if (unlikely(!rte_pktmbuf_is_contiguous(mbuf) && > len > sizeof(temp_data))) { > - PMD_LOG(ERR, > - "Dropping multi segment PCAP packet. Size > (%zd) > max size (%zd).", > - len, sizeof(temp_data)); > - rte_pktmbuf_free(mbuf); > - continue; > + caplen =3D sizeof(temp_data); > } >=20 > calculate_timestamp(&header.ts); > header.len =3D len; > - header.caplen =3D header.len; > + header.caplen =3D caplen; > /* rte_pktmbuf_read() returns a pointer to the data directly > * in the mbuf (when the mbuf is contiguous) or, otherwise, > * a pointer to temp_data after copying into it. > */ > pcap_dump((u_char *)dumper, &header, > - rte_pktmbuf_read(mbuf, 0, len, temp_data)); > + rte_pktmbuf_read(mbuf, 0, caplen, temp_data)); >=20 > num_tx++; > - tx_bytes +=3D len; > + tx_bytes +=3D caplen; > rte_pktmbuf_free(mbuf); > } >=20 > -- > 1.8.3.1 >=20