numam-dpdk/lib/librte_lpm
Christian Ehrhardt 7cc3f2c2a4 lpm: fix freeing in compatibility mode
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: d4c18f0a1d ("lpm: fix missing free")

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
2016-05-02 12:37:48 +02:00
..
Makefile lpm/arm: support NEON 2016-03-11 15:56:07 +01:00
rte_lpm6.c lpm: fix allocation of an existing object 2016-04-06 17:30:06 +02:00
rte_lpm6.h tailq: move to dynamic tailq 2015-03-10 12:06:08 +01:00
rte_lpm_neon.h lpm/arm: support NEON 2016-03-11 15:56:07 +01:00
rte_lpm_sse.h lpm/x86: move SSE implementation to be architecture agnostic 2016-03-11 15:50:11 +01:00
rte_lpm_version.map lpm: extend IPv4 next hop field 2016-03-09 22:57:43 +01:00
rte_lpm.c lpm: fix freeing in compatibility mode 2016-05-02 12:37:48 +02:00
rte_lpm.h lpm/arm: support NEON 2016-03-11 15:56:07 +01:00