Imported Upstream version 16.07-rc1
[deb_dpdk.git] / debian / patches / ubuntu-backport-39-lpm-fix-freeing-in-compatibility-mode.patch
1 Description: backport of dpdk 16.07 fix 7cc3f2c2
2
3 Author: Christian Ehrhardt <christian.ehrhardt@canonical.com>
4 Date:   Tue Apr 12 15:49:27 2016 +0200
5
6     lpm: fix freeing in compatibility mode
7
8     Back then when we fixed the missing free lpm I was to quickly to say yes
9     if it applies not only to the lpm6 but also to all of the lpm code.
10
11     It turned out to not apply to all of them. In rte_lpm_create_v20 there
12     is an unexpected fused allocation:
13     mem_size = sizeof(*lpm) + (sizeof(lpm->rules_tbl[0]) * max_rules);
14     [...]
15     lpm = (struct rte_lpm_v20 *)rte_zmalloc_socket(mem_name,mem_size,
16                    RTE_CACHE_LINE_SIZE, socket_id);
17
18     That causes lpm->rules_tbl not to have an own struct malloc_elem that
19     can be derived via RTE_PTR_SUB(data, MALLOC_ELEM_HEADER_LEN) in
20     malloc_elem_from_data.
21     Due to that the rte_lpm_free_v20 accidentially misderives the elem and
22     assumes it is ELEM_FREE triggering in malloc_elem_free
23     if (!malloc_elem_cookies_ok(elem) || elem->state !=
24             return -1;
25
26     While it seems counter-intuitive the way to properly remove rules_tbl in
27     the old fused allocation style of rte_lpm_free_v20 is to not remove it.
28
29     The newer rte_lpm_free_v1604 is safe because in rte_lpm_create_v1604
30     rules_tbl is a separate allocation.
31
32     Fixes: d4c18f0a1d5d ("lpm: fix missing free")
33
34     Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
35     Acked-by: Olivier Matz <olivier.matz@6wind.com>
36
37 Forwarded: yes (in DPDK 16.07)
38 Author: Christian Ehrhardt <christian.ehrhardt@canonical.com>
39 Last-Update: 2016-05-17
40
41 Index: dpdk/lib/librte_lpm/rte_lpm.c
42 ===================================================================
43 --- dpdk.orig/lib/librte_lpm/rte_lpm.c
44 +++ dpdk/lib/librte_lpm/rte_lpm.c
45 @@ -373,7 +373,6 @@ rte_lpm_free_v20(struct rte_lpm_v20 *lpm
46  
47         rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
48  
49 -       rte_free(lpm->rules_tbl);
50         rte_free(lpm);
51         rte_free(te);
52  }