From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id F1259B108 for ; Wed, 18 Jun 2014 16:50:30 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 18 Jun 2014 07:45:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,501,1400050800"; d="scan'208";a="559596183" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga002.jf.intel.com with ESMTP; 18 Jun 2014 07:50:40 -0700 Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com [10.237.217.45]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id s5IEocQN009274 for ; Wed, 18 Jun 2014 15:50:38 +0100 Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id s5IEocmK025979 for ; Wed, 18 Jun 2014 15:50:38 +0100 Received: (from aburakov@localhost) by sivswdev01.ir.intel.com with id s5IEocss025975 for dev@dpdk.org; Wed, 18 Jun 2014 15:50:38 +0100 From: Anatoly Burakov To: dev@dpdk.org Date: Wed, 18 Jun 2014 15:50:34 +0100 Message-Id: <08e117af2c6b8a537ce1c0ad3bfd605df8fa4b4c.1403102825.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH 07/10] ip_frag: fix order of arguments to key compare function X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Jun 2014 14:50:31 -0000 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 --- 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