path: root/lib/librte_ip_frag
AgeCommit message (Collapse)Author
2018-11-06ip_frag: use key length for key comparisonKonstantin Ananyev
Right now reassembly code relies on src_dst[] being all zeroes to determine is it free/occupied entry in the fragments table. This is suboptimal and error prone - user can crash DPDK ip_reassembly app by something like the following scapy script: x=Ether(src=...,dst=...)/IP(dst='',src='',id=0)/('X'*1000) frags=fragment(x, fragsize=500) sendp(frags, iface=...) To overcome that issue and reduce overhead of 'key invalidate' and 'key is empty' operations - add key_len into keys comparision procedure. Fixes: 4f1a8f633862 ("ip_frag: add IPv6 reassembly") Cc: Reported-by: Ryan E Hall <> Reported-by: Alexander V Gutkin <> Signed-off-by: Konstantin Ananyev <>
2018-11-06ip_frag: check fragment length of incoming packetKonstantin Ananyev
Under some conditions ill-formed fragments might cause reassembly code to corrupt mbufs and/or crash. Let say the following fragments sequence: <ofs=0,len=100, flags=MF> <ofs=96,len=100, flags=MF> <ofs=200,len=0,flags=MF> <ofs=200,len=100,flags=0> can trigger the problem. To overcome such situation, added check that fragment length of incoming value is greater than zero. Fixes: 601e279df074 ("ip_frag: move fragmentation/reassembly headers into a library") Fixes: 4f1a8f633862 ("ip_frag: add IPv6 reassembly") Cc: Reported-by: Ryan E Hall <> Reported-by: Alexander V Gutkin <> Signed-off-by: Konstantin Ananyev <>
2018-10-28ip_frag: fix overflow in key comparisonLi Han
in struct ip_frag_key,src_dst[] type is uint64_t. but "val" which to store the calc restult ,type is uint32_t. we may lost high 32 bit key. and function return value is int, but it won't return < 0. Signed-off-by: Li Han <> Acked-by: Konstantin Ananyev <>
2018-09-19ip_frag: add function to delete expired entriesAlex Kiselev
A fragmented packets is supposed to live no longer than max_cycles, but the lib deletes an expired packet only occasionally when it scans a bucket to find an empty slot while adding a new packet. Therefore a fragment might sit in the table forever. Signed-off-by: Alex Kiselev <> Acked-by: Konstantin Ananyev <>
2018-05-14ip_frag: fix some debug logsLi Han
In ip_frag_process, some IP_FRAG_LOG content is wrong. Fixes: 4f1a8f633862 ("ip_frag: add IPv6 reassembly") Cc: Signed-off-by: Li Han <> Acked-by: Konstantin Ananyev <>
2018-04-15ip_frag: fix double free of chained mbufsAllain Legacy
The first mbuf and the last mbuf to be visited in the preceding loop are not set to NULL in the fragmentation table. This creates the possibility of a double free when the fragmentation table is later freed with rte_ip_frag_table_destroy(). Fixes: 95908f52393d ("ip_frag: free mbufs on reassembly table destroy") Cc: Signed-off-by: Allain Legacy <> Acked-by: Konstantin Ananyev <>
2018-01-30build: replace license text with SPDX tagBruce Richardson
Signed-off-by: Bruce Richardson <> Reviewed-by: Luca Boccassi <>
2018-01-30lib: build with mesonBruce Richardson
Add non-EAL libraries to DPDK build. The compat lib is a special case, along with the previously-added EAL, but all other libs can be build using the same set of commands, where the individual files only need to specify their dependencies, source files, header files and ABI versions. Signed-off-by: Bruce Richardson <> Reviewed-by: Harry van Haaren <> Acked-by: Keith Wiles <> Acked-by: Luca Boccassi <>
2018-01-17lib: fix missing includes in exported headersAdrien Mazarguil
Many exported headers rely on definitions found in rte_config.h without including it, as shown by the following command: grep -L '^#include <rte_config.h>' -- \ $(grep -Rl \ $(sed -n '/^#define \([^ ]\+\).*$/{s//\1/;H;};${x;s/\n//;s/\n/\\|/g;p;}' \ build/include/rte_config.h) \ -- build/include/) We cannot assume external applications will include rte_config.h on their own, neither directly nor through a -include parameter like DPDK does internally. This not only causes obvious compilation failures that can be reproduced with such as: [...]/rte_memory.h:88:43: error: ‘RTE_CACHE_LINE_SIZE’ was not declared in this scope #define __rte_cache_aligned __rte_aligned(RTE_CACHE_LINE_SIZE) ^ It also results in less visible issues, for instance rte_hash_crc.h relying on RTE_ARCH_X86_64's presence to provide dedicated inline functions. This patch partially reverts the commit below and adds missing include lines to the remaining files. Fixes: f1a7a5c5f404 ("remove include of generated config header") Cc: Signed-off-by: Adrien Mazarguil <> Acked-by: Thomas Monjalon <>
2018-01-04lib: use SPDX tag for Intel copyright filesBruce Richardson
Replace the BSD license header with the SPDX tag for files with only an Intel copyright on them. Signed-off-by: Bruce Richardson <>
2017-11-13lib: fix typosPavel Shirshov
Signed-off-by: Pavel Shirshov <>
2017-10-24mk: do not generate LDLIBS from directory dependenciesOlivier Matz
The list of libraries in LDLIBS was generated from the DEPDIRS-xyz variable. This is valid when the subdirectory name match the library name, but it's not always the case, especially for PMDs. The patches removes this feature and explicitly adds the proper libraries in LDLIBS. Some DEPDIRS-xyz variables become useless, remove them. Reported-by: Gage Eads <> Signed-off-by: Olivier Matz <> Reviewed-by: Gage Eads <>
2017-08-31ip_frag: rename map file to standardized nameBruce Richardson
The filenames of the linker map files for DPDK libraries, all follow a standard format: rte_<libname> The ip_frag version, however, was missing an underscore in the name, so was non-standard. By changing this, we no longer need the build system to explicitly be given the name of the mapfile, as it can determine it from the directory/library name. Signed-off-by: Bruce Richardson <> Reviewed-by: Ferruh Yigit <>
2017-07-04ip_frag: check for x86 rather than SSE4Bruce Richardson
Since SSE4 is now part of the minimum requirements for DPDK, we don't need to check for its presence any more. Signed-off-by: Bruce Richardson <> Acked-by: Konstantin Ananyev <>
2017-06-22ip_frag: handle MTU sizes not aligned to 8 bytesAllain Legacy
The rte_ipv4_fragment_packet API expects that the link/interface MTU value passed in be divisible by 8 bytes. Given the name of the parameter is "mtu" rather than "frag_size" it is not necessarily the case that it will be divisible by 8. An MTU of 1500 happens to produce a max fragment size of 1480 (1500 - sizeof(ipv4_hdr)) which is divisible by 8 but other MTU values such as 1600 or 9000 do not produce values that are divisible by 8. Unfortunately, the API checks that the frag_size value produced is divisible by 8 with a call to RTE_ASSERT which is only enabled when the RTE_LOG_LEVEL >= RTE_LOG_DEBUG. In cases where the log level is set normally the code silently continues and produces IP fragments that have invalid fragment offset values. An application may not have control over what MTU a user selects and rather than have each application adjust the MTU to pass a suitable value to the fragmentation API this change modifies the fragmentation API to handle cases where the "mtu" argument is not divisible by 8 and automatically adjust the internal "frag_size". Signed-off-by: Allain Legacy <> Acked-by: Konstantin Ananyev <>
2017-06-22ip_frag: free mbufs on reassembly table destroyDahir Osman
The rte_ip_frag_table_destroy procedure simply releases the memory for the table without freeing the packet buffers that may be referenced in the hash table for in-flight or incomplete packet reassembly operations. To prevent leaked mbufs go through the list of fragments and free each one individually. Fixes: 416707812c03 ("ip_frag: refactor reassembly code into a proper library") Cc: Reported-by: Matt Peters <> Signed-off-by: Allain Legacy <> Acked-by: Konstantin Ananyev <>
2017-06-14fix typos using codespell utilityJerin Jacob
Fixing typos across dpdk source code using codespell utility. Skipped the ethdev driver's base code fixes to keep the base code intact. Signed-off-by: Jerin Jacob <> Acked-by: John McNamara <>
2017-03-27mk: optimize directory dependenciesOlivier Matz
Before this patch, the management of dependencies between directories had several issues: - the generation of .depdirs, done at configuration is slow: it can take more than one minute on some slow targets (usually ~10s on a standard PC without -j). - for instance, it is possible to express a dependency like: - app/foo depends on lib/librte_foo - and lib/librte_foo depends on app/bar But this won't work because the directories are traversed with a depth-first algorithm, so we have to choose between doing 'app' before or after 'lib'. - the script is too complex. - we cannot use "make -d" for debug, because the output of make is used for the generation of .depdirs. This patch moves the DEPDIRS-* variables in the upper Makefile, making the dependencies much easier to calculate. A DEPDIRS variable is still used to process library dependencies in LDLIBS. After this commit, "make config" is almost immediate. Signed-off-by: Olivier Matz <> Tested-by: Robin Jarry <> Tested-by: Jerin Jacob <>
2016-11-07ip_frag: fix IP reassembly regressionWenzhuo Lu
After changing pkt[0] to pkt[], the example IP reassembly is not working. It's weird because this change is fine. There should be no difference between them. As a workaround, revert this change. Fixes: 347a1e037fd3 ("lib: use C99 syntax for zero-size arrays") Reported-by: Huilong Xu <> Signed-off-by: Wenzhuo Lu <>
2016-10-05ip_frag: fix missing dependency on hash libraryPanu Matilainen
Not sure what exactly changed and where, but I've started getting build failures on Fedora rawhide i386: lib/librte_ip_frag/ip_frag_internal.c:36:23: fatal error: rte_jhash.h: No such file or directory #include <rte_jhash.h> ^ Looking at librte_ip_frag, it clearly depends on librte_hash so its probably more a question of something commonly masking the issue. Signed-off-by: Panu Matilainen <>
2016-09-13lib: use C99 syntax for zero-size arraysAdrien Mazarguil
Exported header files used by applications should allow the strictest compiler flags. Language extensions used in many places must be explicitly marked or removed to avoid warnings and compilation failures. The extension keyword is used whenever the C99 syntax cannot do it. This commit prevents the following errors: error: ISO C forbids zero-size array `[...]' Signed-off-by: Adrien Mazarguil <>
2016-07-16ip_frag: fix doxygen formattingHiroyuki Mikita
This commit fixes some functions missing in API documentation. Signed-off-by: Hiroyuki Mikita <>
2016-06-29mk: fix internal dependenciesThomas Monjalon
Some libraries were missing their dependency on eal, mbuf, mempool, ring and kvargs. It is revealed by the linker option "-z defs". Signed-off-by: Thomas Monjalon <>
2016-06-13mk: fix missing internal dependenciesChristian Ehrhardt
This patch adds missing DEPDIRS to avoid any library referring to symbols they are not linked against. Signed-off-by: Christian Ehrhardt <>
2016-05-02eal: add assert macro for debugThomas Monjalon
The macro RTE_VERIFY always checks a condition. It is optimized with "unlikely" hint. While this macro is well suited for test applications, it is preferred in libraries and examples to enable such check in debug mode. That's why the macro RTE_ASSERT is introduced to call RTE_VERIFY only if built with debug logs enabled. A lot of assert macros were duplicated and enabled with a specific flag. Removing these #ifdef allows to test these code branches more easily and avoid dead code pitfalls. The ENA_ASSERT is kept (in debug mode only) because it has more parameters to log. Signed-off-by: Thomas Monjalon <>
2016-05-02ip_frag: fix double free of chained mbufsChaeyong Chong
If any fragment hole is found in ipv4_frag_reassemble() and ipv6_frag_reassemble(), whole ip_frag_pkt mbufs are moved to death-row. Any mbufs already chained to another mbuf are freed multiple times as there are still in ip_frag_pkt array. Signed-off-by: Chaeyong Chong <> Acked-by: Konstantin Ananyev <>
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 <>
2015-10-25mbuf: move chaining from ip_frag librarySimon Kagstrom
Chaining/segmenting mbufs can be useful in many places, so make it global. Signed-off-by: Simon Kagstrom <> Signed-off-by: Johan Faltstrom <> Acked-by: Olivier Matz <>
2015-10-08ip_frag: fix bit-fields in ipv6 fragment extensionPiotr Azarewicz
Previous implementation won't work on every environment. The order of allocation of bit-fields within a unit (high-order to low-order or low-order to high-order) is implementation-defined. Solution: used bytes instead of bit fields. Signed-off-by: Piotr Azarewicz <> Acked-by: Konstantin Ananyev <> Acked-by: Cristian Dumitrescu <>
2015-06-24mbuf: use offset macroCyril Chemparathy
This patch simply applies the transform previously committed in scripts/cocci/mtod-offset.cocci. No other modifications have been made here. Signed-off-by: Cyril Chemparathy <> Acked-by: Olivier Matz <>
2015-06-24eal: add and use unaligned integer typesCyril Chemparathy
On machines that are strict on pointer alignment, current code breaks on GCC's -Wcast-align checks on casts from narrower to wider types. This patch introduces new unaligned_uint(16|32|64)_t types, which correctly retain alignment in such cases. Strict alignment architectures will need to define CONFIG_RTE_ARCH_STRICT_ALIGN in order to effect these new types. Signed-off-by: Cyril Chemparathy <> Acked-by: Olivier Matz <>
2015-06-23lib: remove extra parenthesis after returnFerruh Yigit
Remove extra parenthesis from return statements. Signed-off-by: Ferruh Yigit <>
2015-06-02ip_frag: fix build with gcc 5.1Bruce Richardson
On Fedora 22, with GCC 5.1, errors are reported due to array accesses being potentially out of bounds. This commit fixes this by adding in an extra bounds check to the loop counter. Signed-off-by: Bruce Richardson <> Acked-by: Neil Horman <>
2015-05-11ip_frag: remove inclusion of mbuf headerBruce Richardson
The ip_frag header file includes the mbuf header file, but it does not need to do so as it only uses pointers to the struct rte_mbuf type, and does not use any of the mbuf internals, nor any of the mbuf functions or macros. Therefore the inclusion is unnecessary, and can be replaced by a forward declaration of the mbuf type. Signed-off-by: Bruce Richardson <> Acked-by: Olivier Matz <>
2015-03-10tailq: remove unneeded inclusionsDavid Marchand
Only keep inclusion where really needed. Signed-off-by: David Marchand <> Acked-by: Neil Horman <>
2015-02-23mbuf: remove build option to disable refcntSergio Gonzalez Monroy
This patch removes all references to RTE_MBUF_REFCNT, setting the refcnt field in the mbuf struct permanently. Signed-off-by: Sergio Gonzalez Monroy <> Acked-by: Olivier Matz <> Acked-by: Konstantin Ananyev <>
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 <> Acked-by: Sergio Gonzalez Monroy <>
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 <> Acked-by: Sergio Gonzalez Monroy <>
2015-01-27ip_frag: fix header for C++Marc Sune
Add missing extern 'C' decls in rte_ip_frag.h. Fixes: 601e279df074 ("move fragmentation/reassembly headers into a library") Signed-off-by: Marc Sune <> Acked-by: Thomas Monjalon <>
2014-12-11lib: fix cache alignment of structuresJia Yu
Include rte_memory.h for lib files that use __rte_cache_aligned attribute. Consider the following code: struct per_core_foo { ... } __rte_cache_aligned; struct global_foo { struct per_core_foo foo[RTE_MAX_CORE]; }; If __rte_cache_aligned is not defined (rte_memory.h is not included), the code compiles but the structure is not aligned... it defines the structure and creates a global variable called __rte_cache_aligned. And this can lead to really bad things if this code is in a .h that is included by files that may or may not include rte_memory.h Signed-off-by: Jia Yu <> Acked-by: Thomas Monjalon <>
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 <> [Thomas: updated on HEAD, including PPC]
2014-10-30ip_frag: disable ip fragmentation if mbuf refcnt is disabledPablo de Lara
rte_ipv4_fragment_packet() and rte_ipv6_fragment packet() call rte_pktmbuf_attach() to attach the segment of the original packet to the segment of the new fragmented one. Such function is not declared if RTE_MBUF_REFCNT is disabled, as it needs to call rte_mbuf_refcnt_update, not declared either. Therefore, the ipv4/v6 fragmentation libraries are disabled in that situation. Signed-off-by: Pablo de Lara <> Acked-by: Sergio Gonzalez Monroy <>
2014-09-17mbuf: replace data pointer by an offsetOlivier Matz
The mbuf structure already contains a pointer to the beginning of the buffer (m->buf_addr). It is not needed to use 8 bytes again to store another pointer to the beginning of the data. Using a 16 bits unsigned integer is enough as we know that a mbuf is never longer than 64KB. We gain 6 bytes in the structure thanks to this modification. Signed-off-by: Olivier Matz <> * Updated to apply to latest on mainline. * Disabled vector PMD in config as it relies heavily on the mbuf layout This will be re-enabled in a subsequent commit once vPMD has been reworked to take account of mbuf changes. Signed-off-by: Bruce Richardson <> Acked-by: Olivier Matz <>
2014-09-17mbuf: flatten struct vlan_macipBruce Richardson
The vlan_macip structure combined a vlan tag id with l2 and l3 headers lengths for tracking offloads. However, this structure was only used as a unit by the e1000 and ixgbe drivers, not generally. This patch removes the structure from the mbuf header and places the fields into the mbuf structure directly at the required point, without any net effect on the structure layout. This allows us to treat the vlan tags and header length fields as separate for future mbuf changes. The drivers which were written to use the combined structure still do so, using a driver-local definition of it. Reduce perf regression caused by splitting vlan_macip field. This is done by providing a single uint16_t value to allow writing/clearing the l2 and l3 lengths together. There is still a small perf hit to the slow path TX due to the reads from vlan_tci and l2/l3 lengths being separated. (<5% in my tests with testpmd with no extra params). Unfortunately, this cannot be eliminated, without restoring the vlan tags and l2/l3 lengths as a combined 32-bit field. This would prevent us from ever looking to move those fields about and is an artificial tie that applies only for performance in igb and ixgbe drivers. Therefore, this patch keeps the vlan_tci field separate from the lengths as the best solution going forward. Signed-off-by: Bruce Richardson <> Acked-by: Olivier Matz <> Acked-by: Pablo de Lara <>
2014-09-17mbuf: remove the rte_pktmbuf structureOlivier Matz
The rte_pktmbuf structure was initially included in the rte_mbuf structure. This was needed when there was 2 types of mbuf (ctrl and packet). As the control mbuf has been removed, we can merge the rte_pktmbuf into the rte_mbuf structure. Advantages of doing this: - the access to mbuf fields is easier (ex: m->data instead of m-> - make the structure more consistent: for instance, there was no reason to have the ol_flags field in rte_mbuf - it will allow a deeper reorganization of the rte_mbuf structure in the next commits, allowing to gain several bytes in it Signed-off-by: Olivier Matz <> [Bruce: updated for latest code and new example apps] Signed-off-by: Bruce Richardson <> Acked-by: Pablo de Lara <>
2014-06-26ip_frag: custom memmoveAnatoly Burakov
Some implementations of memmove may make a copy of src before writing to dst. We avoid that by explicitly writing from src to dst backwards. Signed-off-by: Anatoly Burakov <> Acked-by: Thomas Monjalon <>
2014-06-26ip_frag: fix order of key compare argumentsAnatoly Burakov
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 whose length is guaranteed to be correct because it comes from an actual packet. Signed-off-by: Anatoly Burakov <> Acked-by: Thomas Monjalon <>
2014-06-26ip_frag: fix debug macrosAnatoly Burakov
Signed-off-by: Anatoly Burakov <> Acked-by: Thomas Monjalon <>
2014-06-26ip_frag: fix commentAnatoly Burakov
Signed-off-by: Anatoly Burakov <> Acked-by: Thomas Monjalon <>
2014-06-26ip_frag: replace hardcoded value with a macroAnatoly Burakov
Signed-off-by: Anatoly Burakov <> Acked-by: Thomas Monjalon <>