DPDK patches and discussions
 help / color / mirror / Atom feed
From: Anatoly Burakov <anatoly.burakov@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 07/10] ip_frag: fix order of arguments to key compare function
Date: Wed, 18 Jun 2014 15:50:34 +0100	[thread overview]
Message-ID: <08e117af2c6b8a537ce1c0ad3bfd605df8fa4b4c.1403102825.git.anatoly.burakov@intel.com> (raw)
In-Reply-To: <cover.1403102825.git.anatoly.burakov@intel.com>
In-Reply-To: <cover.1403102825.git.anatoly.burakov@intel.com>

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 whos length is guaranteed to be correct because it comes
from an actual packet.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_ip_frag/ip_frag_internal.c | 6 +++---
 1 file 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;
-- 
1.8.1.4

  parent reply	other threads:[~2014-06-18 14:50 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-18 14:50 [dpdk-dev] [PATCH 00/10] rte_ip_frag: various fixes for lib and examples Anatoly Burakov
2014-06-18 14:50 ` [dpdk-dev] [PATCH 01/10] ip_frag: rename RTE_IP_FRAG_ASSERT to IP_FRAG_ASSERT Anatoly Burakov
2014-06-18 14:50 ` [dpdk-dev] [PATCH 02/10] ip_frag: fix debug macros Anatoly Burakov
2014-06-18 14:50 ` [dpdk-dev] [PATCH 03/10] ip_frag: renaming rte_ip_frag_pkt to ip_frag_pkt Anatoly Burakov
2014-06-18 14:50 ` [dpdk-dev] [PATCH 04/10] ip_frag: fix stats macro, rename rte_ip_frag_tbl_stat structure Anatoly Burakov
2014-06-18 14:50 ` [dpdk-dev] [PATCH 05/10] ip_frag: small fix, replace hardcode with a macro Anatoly Burakov
2014-06-18 14:50 ` [dpdk-dev] [PATCH 06/10] ip_frag: replace memmove with custom copying Anatoly Burakov
2014-06-18 14:50 ` Anatoly Burakov [this message]
2014-06-18 14:50 ` [dpdk-dev] [PATCH 08/10] ip_fragmentation: small fixes Anatoly Burakov
2014-06-18 14:50 ` [dpdk-dev] [PATCH 09/10] ip_reassembly: " Anatoly Burakov
2014-06-18 14:50 ` [dpdk-dev] [PATCH 10/10] rte_ip_frag: API header file fix Anatoly Burakov
2014-06-26 21:10 ` [dpdk-dev] [PATCH 00/10] rte_ip_frag: various fixes for lib and examples Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=08e117af2c6b8a537ce1c0ad3bfd605df8fa4b4c.1403102825.git.anatoly.burakov@intel.com \
    --to=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).