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 754A0A04F1; Mon, 9 Dec 2019 02:53:22 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AAC703576; Mon, 9 Dec 2019 02:53:21 +0100 (CET) Received: from m12-12.163.com (m12-12.163.com [220.181.12.12]) by dpdk.org (Postfix) with ESMTP id 023812C17 for ; Mon, 9 Dec 2019 02:53:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=3xVXbEl/RZu0jCpsyP konnYRUmV7c2YtayVAuQXLTjc=; b=nLUS81HAekgm1YxUlIZh2CO+vzhOdj7XjQ uBfv/w4b8OjaIKYPnPvCnmpzw/E7crTLYqt5RYdEuxm6nhHw++lanC/2oJbGqrSh +/siI7e6SK7PZrC6N2yl20fRZX8vy+q9rwSsz+ZLzLcMSxqtDyCJqjiRiFu6md77 0OGj7W3cY= Received: from localhost.localdomain.localdomain (unknown [106.38.115.14]) by smtp8 (Coremail) with SMTP id DMCowAC3muEIqe1d7e4OXA--.23690S2; Mon, 09 Dec 2019 09:53:16 +0800 (CST) From: Zhike Wang To: dev@dpdk.org Cc: wangzhike@jd.com, ferruh.yigit@intel.com, cian.ferriter@intel.com, Zhike Wang Date: Mon, 9 Dec 2019 09:53:09 +0800 Message-Id: <1575856389-37732-1-git-send-email-wangzk320@163.com> X-Mailer: git-send-email 1.8.3.1 X-CM-TRANSID: DMCowAC3muEIqe1d7e4OXA--.23690S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7tr1fJw1fGr4fXr4UuFy5XFb_yoW8Aw17pF sxWryIyw4xJF4xG3WkAF4UArn8G397Ga4jgrZ2gw1Yka4q9r17Wry0kFySvFy8K3s5Grs8 ZrWDXFnxC3Z0kr7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UxfH8UUUUU= X-Originating-IP: [106.38.115.14] X-CM-SenderInfo: pzdqw6bntsiqqrwthudrp/1tbipQiGulUMWBHJUQABsY Subject: [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" From: Zhike Wang Previously large packet would be dropped, instead now it is better to keep it via truncating it. Signed-off-by: Zhike Wang --- drivers/net/pcap/rte_eth_pcap.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) 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; pp = rte_eth_devices[dumper_q->port_id].process_private; dumper = pp->tx_dumper[dumper_q->queue_id]; @@ -325,28 +325,24 @@ struct pmd_devargs_all { * dumper */ for (i = 0; i < nb_pkts; i++) { mbuf = bufs[i]; - len = rte_pktmbuf_pkt_len(mbuf); + len = caplen = 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 = sizeof(temp_data); } calculate_timestamp(&header.ts); header.len = len; - header.caplen = header.len; + header.caplen = 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)); num_tx++; - tx_bytes += len; + tx_bytes += caplen; rte_pktmbuf_free(mbuf); } -- 1.8.3.1