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 D0901A04AB; Fri, 8 Nov 2019 03:33:47 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1622F1BF16; Fri, 8 Nov 2019 03:33:47 +0100 (CET) Received: from m12-13.163.com (m12-13.163.com [220.181.12.13]) by dpdk.org (Postfix) with ESMTP id 600721BF0A for ; Fri, 8 Nov 2019 03:33:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=WYou1TbCp9xHEOJ5St Jvv1YQLAmpnfz0s5GdP5MDQSU=; b=IqcA7ntQaLS+93ZJgx+nfK4hj2AO9x3b9F 3wjm0/S+AD4kv/qx19RQfyyVQA/uwXlGfJyeEZdhJts5kg/HnMZ8+fDQkk/2nLgt NfjUwtNtBBMzr6v50TMMi1x6rTlCnBxs+mCyXoe4Qpm8eYUOVmXKInxFcr08uKam qALQGgYwY= Received: from localhost.localdomain (unknown [106.38.115.21]) by smtp9 (Coremail) with SMTP id DcCowAAnpPQD1MRdMFJPIA--.50620S2; Fri, 08 Nov 2019 10:33:43 +0800 (CST) From: Zhike Wang To: dev@dpdk.org Cc: wangzhike@jd.com Date: Fri, 8 Nov 2019 10:33:37 +0800 Message-Id: <1573180417-5528-1-git-send-email-wangzk320@163.com> X-Mailer: git-send-email 1.8.3.1 X-CM-TRANSID: DcCowAAnpPQD1MRdMFJPIA--.50620S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7tr1fJw1fGr18GryxJr1fWFg_yoW8Ar4fpF sxWryIyw4xJF4xG3WkAF4UArn8W3yxGa4qgrWxK34Yka4v9r1xWry0kFySvry8K3s5Jr43 ZrWDJFnxC3Z0kr7anT9S1TB71UUUUjUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jIUDJUUUUU= X-Originating-IP: [106.38.115.21] X-CM-SenderInfo: pzdqw6bntsiqqrwthudrp/1tbiGAdnulv2Y8lI1QAAsY Subject: [dpdk-dev] [PATCH] 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, 7 insertions(+), 9 deletions(-) diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c index 5186d8f..4614239 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]; @@ -328,25 +328,23 @@ struct pmd_devargs_all { len = 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); + } else { + caplen = len; } 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