ip_frag: fix overflow in key comparison

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@zte.com.cn>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
This commit is contained in:
Li Han 2018-08-01 22:01:03 -04:00 committed by Thomas Monjalon
parent d02a2dab2d
commit 8721e07478

View File

@ -75,10 +75,11 @@ ip_frag_key_invalidate(struct ip_frag_key * key)
}
/* 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;
uint32_t i;
uint64_t val;
val = k1->id ^ k2->id;
for (i = 0; i < k1->key_len; i++)
val |= k1->src_dst[i] ^ k2->src_dst[i];