From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from proxy.6wind.com (host.76.145.23.62.rev.coltfrance.com [62.23.145.76]) by dpdk.org (Postfix) with ESMTP id E10DC2935 for ; Tue, 12 Apr 2016 17:06:46 +0200 (CEST) Received: from [10.16.0.195] (unknown [10.16.0.195]) by proxy.6wind.com (Postfix) with ESMTP id 4228024C73; Tue, 12 Apr 2016 17:06:04 +0200 (CEST) Message-ID: <570D0EFC.2060107@6wind.com> Date: Tue, 12 Apr 2016 17:06:36 +0200 From: Olivier MATZ User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.7.0 MIME-Version: 1.0 To: Christian Ehrhardt , bruce.richardson@intel.com, dev@dpdk.org References: <1460468967-9206-1-git-send-email-christian.ehrhardt@canonical.com> In-Reply-To: <1460468967-9206-1-git-send-email-christian.ehrhardt@canonical.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] lpm: fix freeing of rules_tbl in rte_lpm_free_v20 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: Tue, 12 Apr 2016 15:06:47 -0000 Hi, On 04/12/2016 03:49 PM, Christian Ehrhardt wrote: > Back then when we fixed the missing free lpm I was to quickly to say yes > if it applies not only to the lpm6 but also to all of the lpm code. > > It turned out to not apply to all of them. In rte_lpm_create_v20 there > is an unexpected fused allocation: > mem_size = sizeof(*lpm) + (sizeof(lpm->rules_tbl[0]) * max_rules); > [...] > lpm = (struct rte_lpm_v20 *)rte_zmalloc_socket(mem_name,mem_size, > RTE_CACHE_LINE_SIZE, socket_id); > > That causes lpm->rules_tbl not to have an own struct malloc_elem that > can be derived via RTE_PTR_SUB(data, MALLOC_ELEM_HEADER_LEN) in > malloc_elem_from_data. > Due to that the rte_lpm_free_v20 accidentially misderives the elem and > assumes it is ELEM_FREE triggering in malloc_elem_free > if (!malloc_elem_cookies_ok(elem) || elem->state != > return -1; > > While it seems counter-intuitive the way to properly remove rules_tbl in > the old fused allocation style of rte_lpm_free_v20 is to not remove it. > > The newer rte_lpm_free_v1604 is safe because in rte_lpm_create_v1604 > rules_tbl is a separate allocation. > > Fixes: d4c18f0a1d5d ("lpm: fix missing free") > > Signed-off-by: Christian Ehrhardt Acked-by: Olivier Matz Thanks, I missed it too during the review.