summaryrefslogtreecommitdiff
path: root/lib/librte_lpm
AgeCommit message (Collapse)Author
2016-05-02lpm6: fix possible garbage in lookupDaniel Mrzyglod
Fix issue reported by clang scan-build Value of pointer tbl_next was uninitialized. When function lookup_step() take else branch it may provide garbage into tbl = tbl_next; Fixes: 5c510e13a9cb ("lpm: add IPv6 support") Signed-off-by: Daniel Mrzyglod <danielx.t.mrzyglod@intel.com>
2016-05-02lpm6: fix missing header dependencyIgor Ryzhov
Include stdint.h for the definition of uint*_t types. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2016-05-02lpm: fix freeing in compatibility modeChristian Ehrhardt
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 <christian.ehrhardt@canonical.com> Acked-by: Olivier Matz <olivier.matz@6wind.com>
2016-04-06lpm: fix allocation of an existing objectOlivier Matz
Change rte_lpm*_create() functions to return NULL and set rte_errno to EEXIST when the object name already exists. This is the behavior described in the API documentation in the header file. These functions were returning a pointer to the existing object in that case, but it is a problem as the caller did not know if the object had to be freed or not. Doing this change also makes the lpm API more consistent with the other APIs (mempool, rings, ...). Fixes: 916e4f4f4e ("memory: fix for multi process support") Signed-off-by: Olivier Matz <olivier.matz@6wind.com> Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
2016-03-31lpm: fix build of anonymous union initializationMichael Qiu
In SUSE11-SP3 i686 platform, with gcc 4.5.1, there is a compile issue: rte_lpm.c: In function ‘add_depth_small_v20’: rte_lpm.c:778:7: error: unknown field ‘next_hop’ specified in initializer The root cause is gcc only allow anonymous union initialized according to the field it is defined. But next_hop is defined in different field when in different platform(Endian). One solution is add if define in the code to avoid this issue, but there is a simple way, initialize it separately later. Fixes: afc5c914a083 ("lpm: fix big endian support") Signed-off-by: Michael Qiu <michael.qiu@intel.com>
2016-03-22lpm6: fix use after freeChristian Ehrhardt
In certain autotests lpm->max_rules turned out to be non initialized. That was caused by a failing allocation for lpm->rules_tbl in rte_lpm6_create. It then left the function via goto exit with lpm freed, but still a pointer value being set. In case of an allocation failure it resets lpm to NULL now, to avoid the upper layers operate on that already freed memory. Along that is also makes the RTE_LOG message of the failed allocation unique. Fixes: 5c510e13a9cb ("lpm: add IPv6 support") Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com> Acked-by: Stephen Hemminger <stephen@networkplumber.org> Acked-by: Olivier Matz <olivier.matz@6wind.com>
2016-03-22lpm6: fix missing freeChristian Ehrhardt
lpm6 autotests failed with the default alloc of 512M Memory. While >=2500M was a workaround it became clear while debugging that it had a leak. One could see a lot of output like: LPM Test tests6[i]: FAIL LPM: LPM memory allocation failed It turned out that in rte_lpm6_free - lpm might not be freed if it didn't find a te (early return) - lpm->rules_tbl was not freed ever Fixes: 899d8bc9b3b5 ("lpm: make tailq fully local") Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com> Acked-by: Bruce Richardson <bruce.richardson@intel.com> Acked-by: Olivier Matz <olivier.matz@6wind.com>
2016-03-22lpm: fix use after freeChristian Ehrhardt
There were further chances for a use after free by returning an already freed pointer in rte_lpm_create for v20 and v1604. Along that is also makes the RTE_LOG messages of the failed allocations unique. Fixes: f1f7261838b3 ("lpm: add a new config structure for IPv4") Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com> Acked-by: Olivier Matz <olivier.matz@6wind.com>
2016-03-22lpm: fix missing freeChristian Ehrhardt
In rte_lpm_free lpm might not be freed if it didn't find a te (early return) The two lpm interfaces rte_lpm_free_v20 and rte_lpm_free_v1604 had a leak. rte_lpm_free_v20 might have missed to free rules_tbl rte_lpm_free_v1604 due to an early exit might have missed to free rules_tbl and lpm itself. Fixes: 899d8bc9b3b5 ("lpm: make tailq fully local") Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com> Acked-by: Bruce Richardson <bruce.richardson@intel.com> Acked-by: Olivier Matz <olivier.matz@6wind.com>
2016-03-11lpm/arm: support NEONJerin Jacob
Enabled CONFIG_RTE_LIBRTE_LPM, CONFIG_RTE_LIBRTE_TABLE, CONFIG_RTE_LIBRTE_PIPELINE libraries for arm and arm64 TABLE, PIPELINE libraries were disabled due to LPM library dependency. Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com> Signed-off-by: Jianbo Liu <jianbo.liu@linaro.org>
2016-03-11lpm/x86: move SSE implementation to be architecture agnosticJerin Jacob
-Used architecture agnostic xmm_t to represent 128 bit SIMD variable -Introduced vect_* API abstraction in app/test to test rte_lpm_lookupx4 API in architecture agnostic way -Moved rte_lpm_lookupx4 SSE implementation to architecture specific rte_lpm_sse.h file to accommodate new rte_lpm_lookupx4 implementation for a different architecture. Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com> Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
2016-03-09lpm: add a new config structure for IPv4Michal Kobylinski
A new rte_lpm_config structure is used so LPM library will allocate exactly the amount of memory which is necessary to hold application’s rules. Signed-off-by: Michal Kobylinski <michalx.kobylinski@intel.com> Acked-by: David Hunt <david.hunt@intel.com>
2016-03-09lpm: extend IPv4 next hop fieldMichal Kobylinski
This patch extend next_hop field from 8-bits to 24-bits in LPM library for IPv4. Added versioning symbols to functions and updated library and applications that have a dependency on LPM library. Signed-off-by: Michal Kobylinski <michalx.kobylinski@intel.com> Acked-by: David Hunt <david.hunt@intel.com>
2016-03-04lpm: merge tbl24 and tbl8 structuresBruce Richardson
The tbl8 and tbl24 structures were essentially identical except for slightly different names for one or two fields. Merge these two structures into a single structure definition. Two fields have been renamed as part of this change: the "ext_entry" field in the tbl24 has been renamed to "valid_group" to match the tbl8 value to make the merge easier, and the "tbl8_gindex" field has been renamed to "group_idx". The "valid_group" field now serves two purposes: in a tbl8 it indicates if the group, i.e. the tbl8, is valid, and in a tbl24, it indicates if the "group_idx" is valid, i.e. whether the value is a next_hop or a tbl8 index. [The name "group_idx" was used to make this latter link between the fields clearer] Suggested-by: Vladimir Medvedkin <medvedkinv@gmail.com> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2016-02-10remove extra parentheses in return statementHuawei Xie
fix the error reported by checkpatch: "ERROR: return is not a function, parentheses are not required" remove parentheses in return like: "return (logical expressions)" remove parentheses in return a function like: "return (rte_mempool_lookup(...))" Fixes: 6307b909b8e0 ("lib: remove extra parenthesis after return") Signed-off-by: Huawei Xie <huawei.xie@intel.com>
2015-11-04lpm: fix incorrect reuse of already allocated tbl8Na Na
Fixes an initialization issue of 'valid_group' in the delete_depth_small(). When adding an entry to a tbl8, the .valid_group field should always be set, so that future adds do not accidently find and use this table, thinking it is currently invalid, i.e. unused, and thereby overwrite existing entries. Signed-off-by: Na Na <nana.nn@alibaba-inc.com> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
2015-11-04lpm: fix condition check in deleteNa Na
Fixes an issue of check logic in delete_depth_small function. For a tbl24 entry, the 'ext_entry' field indicates whether we need to use tbl8_gindex to read the next_hop from a tbl8 entry, or whether it can be read directly from this entry. If a route is deleted, the prefix of previous route is used to override the deleted route. When checking the depth of the previous route the conditional checks both the ext_entry and the depth, but the "else" leg fails to take account that the condition could fail for one of two possible reasons, leading to an incorrect flow when 'ext_entry == 0' is true, but 'lpm->tbl24[i].depth > depth' is false. The fix here is to add a condition check to the else leg so that it only executes when ext_entry is set. Signed-off-by: Na Na <nana.nn@alibaba-inc.com> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
2015-09-03lpm: remove deprecated fieldThomas Monjalon
The library version is incremented. Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com> Acked-by: Stephen Hemminger <stephen@networkplumber.org> Acked-by: Neil Horman <nhorman@tuxdriver.com>
2015-08-03lpm: fix depth small entry addZhe Tao
When adding a "depth small" entry, if its extended flag is not set and its depth is smaller than the one in the tbl24, nothing should be done otherwise will operate on the wrong memory area. Signed-off-by: Zhe Tao <zhe.tao@intel.com> Acked-by: Cunming Liang <cunming.liang@intel.com>
2015-07-16mem: move librte_malloc to eal/commonSergio Gonzalez Monroy
Move malloc inside eal and create a new section in MAINTAINERS file for Memory Allocation in EAL. Create a dummy malloc library to avoid breaking applications that have librte_malloc in their DT_NEEDED entries. This is the first step towards using malloc to allocate memory directly from memsegs. Thus, memzones would allocate memory through malloc, allowing to free memzones. Signed-off-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
2015-07-10lpm: fix big endian supportXuelin Shi
This module uses type conversion between struct and int. Also truncation and comparison is used with this int. It is not safe for different endian arch. Add ifdef for big endian struct to fix this issue. Signed-off-by: Xuelin Shi <xuelin.shi@freescale.com> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
2015-06-23lib: remove extra parenthesis after returnFerruh Yigit
Remove extra parenthesis from return statements. Signed-off-by: Ferruh Yigit <ferruhy@gmail.com>
2015-06-12lib: fix whitespaceStephen Hemminger
More places with trailing whitespace, and empty blank lines Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2015-03-20eal/x86: move header file for vector instructionsKonstantin Ananyev
lib/librte_eal/common/include/rte_common_vect.h -> lib/librte_eal/common/include/arch/x86/rte_vect.h Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com> Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
2015-03-10tailq: move to dynamic tailqDavid Marchand
Use dynamic tailq rather than static entries. Signed-off-by: David Marchand <david.marchand@6wind.com> Acked-by: Neil Horman <nhorman@tuxdriver.com>
2015-03-10tailq: remove unneeded inclusionsDavid Marchand
Only keep inclusion where really needed. Signed-off-by: David Marchand <david.marchand@6wind.com> Acked-by: Neil Horman <nhorman@tuxdriver.com>
2015-02-24lpm: fix overflow issueIgor Ryzhov
LPM table overflow may occur if table is full and added rule has the biggest depth that already have some rules. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
2015-02-03mk: add library version extensionNeil Horman
To differentiate libraries that break ABI, we add a library version number suffix to the library, which must be incremented when a given libraries ABI is broken. This patch enforces that addition, sets the initial abi soname extension to 1 for each library and creates a symlink to the base SONAME so that the test applications will link properly. Signed-off-by: Neil Horman <nhorman@tuxdriver.com> Acked-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
2015-02-03lib: provide initial versioningNeil Horman
Add linker version script files to each DPDK library to put a stake in the ground from which we can start cleaning up API's Signed-off-by: Neil Horman <nhorman@tuxdriver.com> Acked-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
2015-01-28eal: introduce ymm type for AVX 256-bitKonstantin Ananyev
New data type to manipulate 256 bit AVX values. Rename field in the rte_xmm to keep common naming across SSE/AVX fields. Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com> Acked-by: Neil Horman <nhorman@tuxdriver.com>
2014-11-27add prefix to cache line macrosSergio Gonzalez Monroy
CACHE_LINE_SIZE is a macro defined in machine/param.h in FreeBSD and conflicts with DPDK macro version. Adding RTE_ prefix to avoid conflicts. CACHE_LINE_MASK and CACHE_LINE_ROUNDUP are also prefixed. Signed-off-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com> [Thomas: updated on HEAD, including PPC]
2014-07-22lpm: make tailq fully localAnatoly Burakov
Since the data structures such as rings are shared in their entirety, those TAILQ pointers are shared as well. Meaning that, after a successful rte_ring creation, the tailq_next pointer of the last ring in the TAILQ will be updated with a pointer to a ring which may not be present in the address space of another process (i.e. a ring that may be host-local or guest-local, and not shared over IVSHMEM). Any successive ring create/lookup on the other side of IVSHMEM will result in trying to dereference an invalid pointer. This patchset fixes this problem by creating a default tailq entry that may be used by any data structure that chooses to use TAILQs. This default TAILQ entry will consist of a tailq_next/tailq_prev pointers, and an opaque pointer to arbitrary data. All TAILQ pointers from data structures themselves will be removed and replaced by those generic TAILQ entries, thus fixing the problem of potentially exposing local address space to shared structures. Technically, only rte_ring structure require modification, because IVSHMEM is only using memzones (which aren't in TAILQs) and rings, but for consistency's sake other TAILQ-based data structures were adapted as well. Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com> Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
2014-06-27eal: deprecate rte_snprintfStephen Hemminger
The function rte_snprintf serves no useful purpose. It is the same as snprintf() for all valid inputs. Deprecate it and replace all uses in current code. Leave the tests for the deprecated function in place. Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>
2014-06-17lpm: check rule existenceCristian Dumitrescu
Added API function for LPM IPv4 and IPv6 to query for the existence of a rule/route and return the next hop ID associated with the route if route is present. This is used by the Packet Framework LPM table for implementing a routing table. Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com> Acked-by: Pablo de Lara Guarch <pablo.de.lara.guarch@intel.com> Acked by: Ivan Boule <ivan.boule@6wind.com>
2014-06-12lpm: introduce rte_lpm_lookupx4Konstantin Ananyev
Allows to lookup four IP addresses in an LPM table. Uses SSE instrincts. Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com> Tested-by: Waterman Cao <waterman.cao@intel.com> Acked-by: Pablo de Lara Guarch <pablo.de.lara.guarch@intel.com>
2014-06-11remove trailing whitespacesBruce Richardson
This commit removes trailing whitespace from lines in files. Almost all files are affected, as the BSD license copyright header had trailing whitespace on 4 lines in it [hence the number of files reporting 8 lines changed in the diffstat]. Signed-off-by: Bruce Richardson <bruce.richardson@intel.com> Acked-by: Neil Horman <nhorman@tuxdriver.com> [Thomas: remove spaces before tabs in libs] [Thomas: remove more trailing spaces in non-C files] Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
2014-02-25update Intel copyright years to 2014Bruce Richardson
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2014-01-15lpm: fix sub-rule deletionIntel
Restore group validation flag of the tbl8 entry if sub-rule is replaced by an encompassing rule. Signed-off-by: Intel
2013-11-21lpm: fix route addingIntel
Signed-off-by: Intel
2013-10-09lpm: rework rules storageIntel
Signed-off-by: Intel
2013-10-09doc: whitespace changes in licensesIntel
Signed-off-by: Intel
2013-09-17lpm: add IPv6 supportIntel
Signed-off-by: Intel
2013-07-25update copyright date to 2013Intel
Signed-off-by: Intel
2013-07-25lib: fix unused valuesZijie Pan
Fix warnings of type "Value stored to 'xxx' is never read". Signed-off-by: Zijie Pan <zijie.pan@6wind.com> Acked-by: Ivan Boule <ivan.boule@6wind.com> Acked-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
2013-07-25memory: fix for multi process supportIntel
Signed-off-by: Intel
2013-07-25lpm: rework lpm lookup + add bulk functionIntel
Signed-off-by: Intel
2013-07-25lpm: allocate memory on right numa socketIntel
Signed-off-by: Intel
2013-07-25lpm: don't use memzone for allocationsIntel
Signed-off-by: Intel
2013-07-25lpm: minor changesIntel
Signed-off-by: Intel
2013-07-25lib: update tailq apiIntel
Signed-off-by: Intel