summaryrefslogtreecommitdiff
path: root/lib/librte_ip_frag
diff options
context:
space:
mode:
authorAnatoly Burakov <anatoly.burakov@intel.com>2014-06-18 15:50:34 +0100
committerThomas Monjalon <thomas.monjalon@6wind.com>2014-06-26 22:51:07 +0200
commit2505824261f3e64ae357655c3545c46628f377fd (patch)
tree1386c8337b588ff41a150d9f5530ed9e546e6c6e /lib/librte_ip_frag
parent148585ec293f51ec150baa85a1a7e6bd347dcf44 (diff)
downloaddpdk-2505824261f3e64ae357655c3545c46628f377fd.zip
dpdk-2505824261f3e64ae357655c3545c46628f377fd.tar.gz
dpdk-2505824261f3e64ae357655c3545c46628f377fd.tar.xz
ip_frag: fix order of key compare arguments
When using key compare function, it uses key length of the first argument to determine how long should be the keys that are compared. However, currently we are passing a key from the fragmentation table as first argument. the problem with this is that this key is potentially uninitialized (i.e. contains all zeroes, including key length). this leads to a nasty bug of comparing only the key id's and not keys themselves. Of course, a safer way would be to do RTE_MAX between key lengths, but since this compare is done per-packet, every cycle counts, so we just use the key whose length is guaranteed to be correct because it comes from an actual packet. Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com> Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Diffstat (limited to 'lib/librte_ip_frag')
-rw-r--r--lib/librte_ip_frag/ip_frag_internal.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/librte_ip_frag/ip_frag_internal.c b/lib/librte_ip_frag/ip_frag_internal.c
index 6203740..a2c645b 100644
--- a/lib/librte_ip_frag/ip_frag_internal.c
+++ b/lib/librte_ip_frag/ip_frag_internal.c
@@ -346,7 +346,7 @@ ip_frag_lookup(struct rte_ip_frag_tbl *tbl,
max_cycles = tbl->max_cycles;
assoc = tbl->bucket_entries;
- if (tbl->last != NULL && ip_frag_key_cmp(&tbl->last->key, key) == 0)
+ if (tbl->last != NULL && ip_frag_key_cmp(key, &tbl->last->key) == 0)
return (tbl->last);
/* different hashing methods for IPv4 and IPv6 */
@@ -378,7 +378,7 @@ ip_frag_lookup(struct rte_ip_frag_tbl *tbl,
p1, i, assoc,
IPv6_KEY_BYTES(p1[i].key.src_dst), p1[i].key.id, p1[i].start);
- if (ip_frag_key_cmp(&p1[i].key, key) == 0)
+ if (ip_frag_key_cmp(key, &p1[i].key) == 0)
return (p1 + i);
else if (ip_frag_key_is_empty(&p1[i].key))
empty = (empty == NULL) ? (p1 + i) : empty;
@@ -404,7 +404,7 @@ ip_frag_lookup(struct rte_ip_frag_tbl *tbl,
p2, i, assoc,
IPv6_KEY_BYTES(p2[i].key.src_dst), p2[i].key.id, p2[i].start);
- if (ip_frag_key_cmp(&p2[i].key, key) == 0)
+ if (ip_frag_key_cmp(key, &p2[i].key) == 0)
return (p2 + i);
else if (ip_frag_key_is_empty(&p2[i].key))
empty = (empty == NULL) ?( p2 + i) : empty;