From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f51.google.com (mail-wm0-f51.google.com [74.125.82.51]) by dpdk.org (Postfix) with ESMTP id 9C372C424 for ; Thu, 28 Jan 2016 12:09:55 +0100 (CET) Received: by mail-wm0-f51.google.com with SMTP id p63so19376093wmp.1 for ; Thu, 28 Jan 2016 03:09:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lightcyber-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=QefB1DGFldCl3QdXhNhXgjbQ9h/I1k4PAid8LThQ0XI=; b=rUwOyjQfr4PSqjYfQWAEg/fSHaoNcQzb2LMXY2KDzB3xtNhIdMncDjkNfRH9vqE6gw gB6unF/VMxW3uqBD+famVDW7a3ljeWW/ubHu5sEU+Ve9NBUGPZjyVDSLdJB7ejVPwZ+o zmA5N0H//eSPM5IhSX4pdMRcV4oUhojvxe93Mi+Bic/OY6zlGF3kZawPMLv1yRB/JgoL bQ65gynDJR9ped860FbryR7J/n9d4SW16pMsykmpRl9ioDyrG4YErltObj89rJUEWqFk X7QrPSWx4Qc8T7z405T3AIiJF1CNeHs7pej2CUBURm4f+1d/GbaNI4n07IKD3Csn6FJO gH5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=QefB1DGFldCl3QdXhNhXgjbQ9h/I1k4PAid8LThQ0XI=; b=TpyaSBjAxUc0tFRI+3ctaLAWGlYkGX1hrnNIicnRA8LLqFEqXX8e7fRdwdsd6JLdjQ ZmyzyOozKvuYh0vcwM4Bouig2pl8xwSxqfZe9XGPw3STVbWAsy7FNvpspresV0MJ7Z4R 9yUzHKw6Vrh6JG/Xy2CN0Vyo5N1fRc552ZAjkhB2T7sJQMSplmKCAyzpLF1DUWzCqBht Xmddf/2XsMWcJPPuLB0kRg3xGpi09c14MrRQqFeVNzyU3gmi+ePsdnHYS+5z4BWm+C/E Yfl6yvyD8Z9OGtEMDaU1/bd6F+GHlLaYX1CFEv1kiXxeDzdMtP+MUjs4huv5eQlL5N9i eZ1w== X-Gm-Message-State: AG10YORT77+BNyaJioT8qhvT6PI6Br+/r8UOwe1Z/nh6fPe+wqxyHUui3hRwtqSucWYu2A== X-Received: by 10.28.98.198 with SMTP id w189mr2334270wmb.39.1453979395467; Thu, 28 Jan 2016 03:09:55 -0800 (PST) Received: from localhost.localdomain (bzq-156-168-31-238.red.bezeqint.net. [31.168.156.238]) by smtp.gmail.com with ESMTPSA id y188sm2359439wmy.11.2016.01.28.03.09.54 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 28 Jan 2016 03:09:54 -0800 (PST) From: Dror Birkman To: nicolas.pernas.maradei@emutex.com, john.mcnamara@intel.com Date: Thu, 28 Jan 2016 13:09:50 +0200 Message-Id: <1453979390-36685-1-git-send-email-dror.birkman@lightcyber.com> X-Mailer: git-send-email 2.6.3 Cc: dev@dpdk.org, Dror Birkman Subject: [dpdk-dev] [PATCH] pcap: fix captured frame length X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Jan 2016 11:09:55 -0000 The actual captured length is header.caplen, whereas header.len is the original length on the wire. Signed-off-by: Dror Birkman --- Without this fix, if the captured length is smaller than the original length on the wire, mbuf will contain incorrect data. drivers/net/pcap/rte_eth_pcap.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c index f9230eb..1d121f8 100644 --- a/drivers/net/pcap/rte_eth_pcap.c +++ b/drivers/net/pcap/rte_eth_pcap.c @@ -220,25 +220,25 @@ eth_pcap_rx(void *queue, buf_size = (uint16_t)(rte_pktmbuf_data_room_size(pcap_q->mb_pool) - RTE_PKTMBUF_HEADROOM); - if (header.len <= buf_size) { + if (header.caplen <= buf_size) { /* pcap packet will fit in the mbuf, go ahead and copy */ rte_memcpy(rte_pktmbuf_mtod(mbuf, void *), packet, - header.len); - mbuf->data_len = (uint16_t)header.len; + header.caplen); + mbuf->data_len = (uint16_t)header.caplen; } else { /* Try read jumbo frame into multi mbufs. */ if (unlikely(eth_pcap_rx_jumbo(pcap_q->mb_pool, mbuf, packet, - header.len) == -1)) + header.caplen) == -1)) break; } - mbuf->pkt_len = (uint16_t)header.len; + mbuf->pkt_len = (uint16_t)header.caplen; mbuf->port = pcap_q->in_port; bufs[num_rx] = mbuf; num_rx++; - rx_bytes += header.len; + rx_bytes += header.caplen; } pcap_q->rx_pkts += num_rx; pcap_q->rx_bytes += rx_bytes; -- 2.6.3