[dpdk-dev] [PATCH] lib/librte_ip_frag:fix ip_frag_key_cmp bug

Ananyev, Konstantin konstantin.ananyev at intel.com
Fri Aug 24 13:04:13 CEST 2018



> -----Original Message-----
> From: Li Han [mailto:han.li1 at zte.com.cn]
> Sent: Thursday, August 2, 2018 3:01 AM
> To: Ananyev, Konstantin <konstantin.ananyev at intel.com>
> Cc: dev at dpdk.org; Li Han <han.li1 at zte.com.cn>
> Subject: [PATCH] [dpdk-dev] lib/librte_ip_frag:fix ip_frag_key_cmp bug
> 
> in struct ip_frag_key,src_dst[] type is uint64_t.
> but "val" which to store the calc restult ,type is uint32_t.
> we may lost high 32 bit key. and function return value is int,
> but it won't return < 0.
> 
> Signed-off-by: Li Han <han.li1 at zte.com.cn>
> ---
>  lib/librte_ip_frag/ip_frag_common.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/librte_ip_frag/ip_frag_common.h b/lib/librte_ip_frag/ip_frag_common.h
> index 197acf8..ca69680 100644
> --- a/lib/librte_ip_frag/ip_frag_common.h
> +++ b/lib/librte_ip_frag/ip_frag_common.h
> @@ -69,10 +69,10 @@ struct ip_frag_pkt * ip_frag_lookup(struct rte_ip_frag_tbl *tbl,
>  }
> 
>  /* compare two keys */
> -static inline int
> +static inline uint64_t
>  ip_frag_key_cmp(const struct ip_frag_key * k1, const struct ip_frag_key * k2)
>  {
> -	uint32_t i, val;
> +	uint64_t i, val;
>  	val = k1->id ^ k2->id;
>  	for (i = 0; i < k1->key_len; i++)
>  		val |= k1->src_dst[i] ^ k2->src_dst[i];
> --

As a nit - no point to make *i* 64-bit.
Apart from that:
Acked-by: Konstantin Ananyev <konstantin.ananyev at intel.com>

> 1.8.3.1



More information about the dev mailing list