summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLi Han <han.li1@zte.com.cn>2018-08-01 22:01:03 -0400
committerThomas Monjalon <thomas@monjalon.net>2018-10-28 11:16:49 +0100
commit8721e07478c6edc9565645047742f79c654cfd1b (patch)
tree28cc087e62a04da8a63a8baeac11562e358dc665 /lib
parentd02a2dab2dfb33969c74412e99720a9eaf1e703a (diff)
downloaddpdk-8721e07478c6edc9565645047742f79c654cfd1b.zip
dpdk-8721e07478c6edc9565645047742f79c654cfd1b.tar.gz
dpdk-8721e07478c6edc9565645047742f79c654cfd1b.tar.xz
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>
Diffstat (limited to 'lib')
-rw-r--r--lib/librte_ip_frag/ip_frag_common.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/librte_ip_frag/ip_frag_common.h b/lib/librte_ip_frag/ip_frag_common.h
index 0fdcc7d..0f62e2e 100644
--- a/lib/librte_ip_frag/ip_frag_common.h
+++ b/lib/librte_ip_frag/ip_frag_common.h
@@ -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];