[dpdk-dev] [PATCH] pcap: Fixed bug in eth_pcap_rx function

Jiajia, SunX sunx.jiajia at intel.com
Tue Aug 12 04:29:48 CEST 2014


Tested-by: Jiajia SunX   <sunx.jiajia at intel.com>

This patch fixed a bug by changing eth_pcap_rx function, and is ready to integrate into DPDK.org.

> -----Original Message-----
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Pablo de Lara
> Sent: Tuesday, August 05, 2014 6:18 PM
> To: dev at dpdk.org
> Subject: [dpdk-dev] [PATCH] pcap: Fixed bug in eth_pcap_rx function
> 
> Normally, bufs[i] stores the mbuf pointer, the index of buf[i]
> is the loop count i, but if header.len > buf_size, DPDK will
> free the mbuf, but the loop count i still increases, so some
> of the items in bufs[] might be NULL ponter, causing a potential
> DPDK core. Using num_rx as the index for bufs[] solves the problem.
> 
> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch at intel.com>
> ---
>  lib/librte_pmd_pcap/rte_eth_pcap.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/lib/librte_pmd_pcap/rte_eth_pcap.c
> b/lib/librte_pmd_pcap/rte_eth_pcap.c
> index c77ee25..eebe768 100644
> --- a/lib/librte_pmd_pcap/rte_eth_pcap.c
> +++ b/lib/librte_pmd_pcap/rte_eth_pcap.c
> @@ -154,7 +154,7 @@ eth_pcap_rx(void *queue,
>  			rte_memcpy(mbuf->pkt.data, packet, header.len);
>  			mbuf->pkt.data_len = (uint16_t)header.len;
>  			mbuf->pkt.pkt_len = mbuf->pkt.data_len;
> -			bufs[i] = mbuf;
> +			bufs[num_rx] = mbuf;
>  			num_rx++;
>  		} else {
>  			/* pcap packet will not fit in the mbuf, so drop
> packet */
> --
> 1.7.0.7



More information about the dev mailing list