aboutsummaryrefslogtreecommitdiffstats
path: root/src/vlib
AgeCommit message (Collapse)AuthorFilesLines
2022-08-29vlib: use error description when dropping packetsArthur de Kerhor1-1/+1
Using the error name makes it less explicit in the packet trace than the error description when a packet is dropped. Example of the trace when the TTL is <=1: 01:03:17:015278: drop ip4-input: time_expired We should have "ip4 ttl <= 1" instead of "time_expired" Type: fix Change-Id: Ic9decf10d609cc938e39d0f449359e41c406267e Signed-off-by: Arthur de Kerhor <arthurdekerhor@gmail.com>
2022-08-25vlib: introduce DMA infrastructureMarvin Liu5-0/+445
This patch introduces DMA infrastructure into vlib. This is well known that large amount of memory movements will drain core resource. Nowadays more and more hardware accelerators were designed out for freeing core from this burden. Meanwhile some restrictions still remained when utilizing hardware accelerators, e.g. cross numa throughput will have a significant drop compared to same node. Normally the number of hardware accelerator instances will less than cores number, not to mention that applications number will even beyond the number of cores. Some hardware may support share virtual address with cores, while others are not. Here we introduce new DMA infrastructure which can fulfill the requirements of vpp applications like session and memif and in the meantime dealing with hardware limitations. Here is some design backgrounds: Backend is the abstract of resource which allocated from DMA device and can do some basic operations like configuration, DMA copy and result query. Config is the abstract of application DMA requirement. Application need to request an unique config index from DMA infrastructure. This unique config index is associated with backend resource. Two options cpu fallback and barrier before last can be specified in config. DMA transfer will be performed by CPU when backend is busy if cpu fallback option is enabled. DMA transfer callback will be in order if barrier before last option is enabled. We constructs all the stuffs that DMA transfer request needed into DMA batch. It contains the pattern of DMA descriptors and function pointers for submission and callback. One DMA transfer request need multiple times batch update and one time batch submission. DMA backends will assigned to config's workers threads equally. Lock will be used for thread-safety if same backends assigned to multiple threads. Backend node will check all the pending requests in worker thread and do callback with the pointer of DMA batch if transfer completed. Application can utilize cookie in DMA batch for selves usage. DMA architecture: +----------+ +----------+ +----------+ +----------+ | Config1 | | Config2 | | Config1 | | Config2 | +----------+ +----------+ +----------+ +----------+ || || || || +-------------------------+ +-------------------------+ | DMA polling thread A | | DMA polling thread B | +-------------------------+ +-------------------------+ || || +----------+ +----------+ | Backend1 | | Backend2 | +----------+ +----------+ Type: feature Signed-off-by: Marvin Liu <yong.liu@intel.com> Change-Id: I1725e0c26687985aac29618c9abe4f5e0de08ebf
2022-08-24vlib: allow longer version stringMatthew Smith1-2/+2
Type: improvement When trying to use a version string in a downstream build that appends a timestamp to the standard version string, compiling fails because the version string is too long for the version and version_required fields in vlib_plugin_registration_t. Increase the size of those arrays from 32 to 64 chars. Signed-off-by: Matthew Smith <mgsmith@netgate.com> Change-Id: I3632139e5ae7110aa4769359f380ad29522ad4ed
2022-08-19vlib: memory leak in vlib_register_errors on create and delete interfaceSteven Luong1-0/+1
format returns a vector which must be free or memory is leaked. From show memory 3716528 66716 0x7fffbfeb0db0 _vec_resize_internal + 0xe6 _vec_add + 0x164 do_percent + 0xb82 va_format + 0xb9 format + 0x156 vlib_register_errors + 0x76c setup_tx_node + 0x5c vnet_register_interface + 0xca6 vnet_eth_register_interface + 0xdd memif_create_if + 0x975 memif_create_command_fn + 0x461 vlib_cli_dispatch_sub_commands + 0xec8 (gdb) list *(vlib_register_errors + 0x76c) 0x7ffff6e8280c is in vlib_register_errors (/home/sluong/vpp/vpp/src/vlib/error.c:224). 219 220 vec_validate (nm->node_by_error, n->error_heap_index + n_errors - 1); 221 222 for (u32 i = 0; i < n_errors; i++) 223 { 224 t.format = (char *) format (0, "%v %s: %%d", n->name, cd[i].name); 225 vm->error_elog_event_types[n->error_heap_index + i] = t; 226 nm->node_by_error[n->error_heap_index + i] = n->index; 227 } Type: fix Signed-off-by: Steven Luong <sluong@cisco.com> Change-Id: I2983f081b7e2c1b2d18d66afe45282933efbe127
2022-08-09vlib: vlib_validate_buffer_enqueue_with_aux_x1Mohammed Hawari2-0/+71
This change implement a flavour of vlib_validate_buffer_enqueue_x1 with aux data support Change-Id: I2ecf7af49cf15ecd23b12d8acd57fe90546c1af7 Type: improvement Signed-off-by: Mohammed Hawari <mohammed@hawari.fr>
2022-07-19stats: add loops per second counter in the stats segment.Radha krishna Saragadam1-3/+15
This change adds loops per second in the stats segment. Applications using the stats segment to monitor VPP can use this for better monitoring Type: fix Signed-off-by: Radha krishna Saragadam <krishna_srk2003@yahoo.com> Change-Id: I53081f40ee918eec9763513a639b9d8a02488b20
2022-07-06misc: pass NULL instead of 0 for pointer in variadic functionsAndreas Schultz3-16/+12
0 is not NULL (at least not in all cases), passing 0 into a variadic function in a place where the consumer reads it as pointer might leave parts of the pointer uninitilized and hence filled with random data. It seems that this used to work with gcc, but clang seems to treat the 0 in those places as a 32bit integer. Type: fix Signed-off-by: Ivan Shvedunov <ivan4th@gmail.com> Signed-off-by: Andreas Schultz <andreas.schultz@travelping.com> Change-Id: I37d975eef5a1ad98fbfb65ebe47d73458aafea00
2022-07-01buffers: protect against bad thread indicesJon Loeliger1-0/+3
There is a very rare bug in NAT processing that yeilds a thread index of ~0. When this happens, vlib_get_frame_queue_elt() suffers a segfault and VPP quits. Prevent an outright fault by dropping the packet instead. Type: fix Signed-off-by: Jon Loeliger <jdl@netgate.com> Change-Id: I48c7a268925bb821ea15e58db5d4bfb211c40c09
2022-06-29vlib: enqueue_to_next_with_aux implementationMohammed Hawari4-37/+233
Change-Id: I0e1bb39d765ec3efa7b28ca02fb7beeb23607e51 Type: improvement Signed-off-by: Mohammed Hawari <mohammed@hawari.fr>
2022-06-07vlib: fix crash on packet on deleted interfacePim van Pelt1-3/+6
If ip4_neighbor_probe (or any other) is sending packet to a deleted interface, ASSERT trips and dataplane crashes. Example: create loopback interface instance 0 set interface ip address loop0 10.0.0.1/32 set interface state GigabitEthernet3/0/1 up set interface state loop0 up set interface state loop0 down set interface ip address del loop0 10.0.0.1/32 delete loopback interface intfc loop0 set interface state GigabitEthernet3/0/1 down set interface state GigabitEthernet3/0/1 up comment { the following crashes VPP } set interface state GigabitEthernet3/0/1 down This sequence reliably crashes VPP: (gdb)p n->name $4 = (u8 *) 0x7fff82b47578 "interface-3-output-deleted” If the interface doesn't exist, return ~0 and be tolerant of this in the two call sites of counter_index() Type: fix Signed-off-by: Pim van Pelt <pim@ipng.nl> Change-Id: I90ec58fc0d14b20c9822703fe914f2ce89acb18d
2022-06-01stats: swap used and total statsLeland Krych1-2/+2
Type: fix reported stats seem to have mixed up used and total counters Signed-off-by: Leland Krych <leland.krych@gmail.com> Change-Id: I221c7b114c0da2ed53171d7f047a4bda07ee6cb2
2022-06-01vlib: add VLIB_NUM_WORKERS_CHANGE_FN() handlerDamjan Marion4-10/+15
Allows features to update their data structures after change in number of worker threads. Type: improvement Change-Id: Icd4d197e28608f5bbb1edd13eb624cd98e33cafe Signed-off-by: Damjan Marion <damarion@cisco.com>
2022-05-24vlib: implement aux data handoffMohammed Hawari6-19/+125
Type: improvement Change-Id: I20b41537a249a55f01004e45392b34adaa8fd792 Signed-off-by: Mohammed Hawari <mohammed@hawari.fr>
2022-05-19stats: fix collector updates of symlinksArthur de Kerhor1-3/+9
A node name is not bound to a node index. For example, if an interface is deleted and re-added, the indexes of its nodes "<itfc_name>-tx" and "<itfc_name>-output" may change. Thus, when the collector updates the nodes stats, it should first delete all the symlinks for nodes that have changed their names before adding new symlinks. Otherwise, it could attempt to add already existing symlinks or delete valid ones. Example of a series of command that triggers a crash in the assert `ASSERT (node_data[i].symlinks[j] != CLIB_U32_MAX);`: ``` create loopback interface create loopback interface ``` Wait for the nodes stats to update, then: ``` delete loopback interface intfc loop0 delete loopback interface intfc loop1 create loopback interface create loopback interface ``` Type: fix Change-Id: Ief8e7135e5c02dc6bc64dc94b76cff21ea9ab3a9 Signed-off-by: Arthur de Kerhor <arthurdekerhor@gmail.com>
2022-05-16vlib: exec cli line-by-line processing and script updatesDamjan Marion1-31/+39
Type: improvement Change-Id: I82e7c0acc547794bcc7c42f4b8881a8251bf7a9b Signed-off-by: Damjan Marion <damarion@cisco.com>
2022-05-14session: revert "fix session cli maybe parse wrong args if executed in files"Damjan Marion2-41/+0
Fixed at infra level. Type: improvement Change-Id: I43cf16870c1d2e12189073f7786d62375c46e2c2 Signed-off-by: Damjan Marion <damarion@cisco.com>
2022-05-13vlib: process startup config exec scripts line by lineDamjan Marion3-1/+72
This fixes long standing annoyance that CLIs with optional args cannot be executed from file, as they cannot distinguish between valid optional args and next line in the file. Multiline statements can be provided simply by using backslash before \n. Also comments are supported - everything after # is ignored up to the end of the line. Example: # multiline cli using backslash show version \ verbose # end of line comment packet-generator new { \ name x \ limit 5 \ # comment inside cmultiline cli \ size 128-128 \ interface local0 \ node null-node \ data { \ incrementing 30 \ } \ } Type: fix Change-Id: Ia6d588169bae14e6e3f18effe94820d05ace1dbf Signed-off-by: Damjan Marion <damarion@cisco.com>
2022-05-06session: fix session cli maybe parse wrong args if executed in filesXiaoming Jiang2-0/+41
Type: fix Signed-off-by: Xiaoming Jiang <jiangxiaoming@outlook.com> Change-Id: Id19a52df4f237cf5d85d305fdc279ab7df2d6f4b
2022-05-06stats: add vlib_stats_free_string_vectorDamjan Marion2-0/+8
Type: improvement Change-Id: Ifa9f908b24b5fe867826601d32eeb4f0d639fbeb Signed-off-by: Damjan Marion <damarion@cisco.com>
2022-05-06stats: strings in string vector are c stringsDamjan Marion1-0/+1
Type: fix Change-Id: I9cf9376f2813f7bceecc6a9d714dcb98df77615d Signed-off-by: Damjan Marion <damarion@cisco.com>
2022-04-26stats: string vector and node collector improvementsDamjan Marion4-109/+149
Type: improvement Change-Id: Ibdadeb4e685f45a93f45504a84709391489abb6a Signed-off-by: Damjan Marion <damarion@cisco.com>
2022-04-15stats: store heap in the directory_entry vectorDamjan Marion2-15/+2
Type: improvement Change-Id: I878803d14d1070ef5a00ed9d3f72022906d55191 Signed-off-by: Damjan Marion <damarion@cisco.com>
2022-04-14vlib: disable cpu pinning if not configuredBenoît Ganne2-19/+17
In some environment like when running a lot of functional tests, it can be useful to run more VPP instances than CPU and let the Linux scheduler decide what to do. This change disable cpu pinning altogether in the single-threaded case, provided that no main-core is explicitely specified in the config Type: improvement Change-Id: I8c2f36fdd49c00f9adaaeb4c81aefb27c3420a9b Signed-off-by: Benoît Ganne <bganne@cisco.com> Signed-off-by: Mohammed Hawari <mohammed@hawari.fr>
2022-04-12vppinfra: vector perf improvementsDamjan Marion1-3/+2
Type: improvement Change-Id: I37c187af80c21b8fb1ab15af112527a837e0df9e Signed-off-by: Damjan Marion <damarion@cisco.com>
2022-04-08stats: fix vector overrun in expend checkDmitry Valter1-2/+2
Do not access allocated elements beyond the end of the vector. They are allocated, but not yet valid both logically (they are at best NULLs) and according to ASAN. Type: fix Change-Id: Iaf43767d6d3bd4c24c7c5a0ba9b3410bbeeb0556 Signed-off-by: Dmitry Valter <d-valter@yandex-team.ru>
2022-04-06stats: avoid linear search for empty entryDamjan Marion3-10/+16
Type: improvement Change-Id: Ie4cdc6d8906da3d1cd18a8f1d7076283546d3003 Signed-off-by: Damjan Marion <damarion@cisco.com>
2022-04-06interface: unregister node counters on interface deleteDamjan Marion2-7/+19
Type: fix Change-Id: I2562ae5833b542c29bcd5025a9a6756e5de95a42 Signed-off-by: Damjan Marion <damarion@cisco.com>
2022-04-06vlib: clear frame flags on freeStanislav Zaikin1-0/+2
Type: fix Change-Id: If4a7ac244832ef72d82c71b0277bc110b9500537 Signed-off-by: Stanislav Zaikin <zstaseg@gmail.com>
2022-04-05vppinfra: refactor address sanitizerDamjan Marion1-2/+2
Type: refactor Change-Id: I5ca142ec1557d5b5c3806b43553ad9d3b5ea1112 Signed-off-by: Damjan Marion <damarion@cisco.com>
2022-04-04vppinfra: make _vec_len() read-onlyDamjan Marion11-49/+49
Use of _vec_len() to set vector length breaks address sanitizer. Users should use vec_set_len(), vec_inc_len(), vec_dec_len () instead. Type: improvement Change-Id: I441ae948771eb21c23a61f3ff9163bdad74a2cb8 Signed-off-by: Damjan Marion <damarion@cisco.com>
2022-04-04vlib: remove unused fieldsDamjan Marion3-17/+0
Type: refactor Change-Id: I449fcea92a1c96dd7dd0bcad893060ad1c614351 Signed-off-by: Damjan Marion <damarion@cisco.com>
2022-04-04vlib: improve exec path searchDamjan Marion3-8/+33
Fixes VPP invocation with relative path, i.e.: $ bin/vpp unix interactive Type: improvement Change-Id: I0278710bb472b92e31389b2d28955c3d33550230 Signed-off-by: Damjan Marion <damarion@cisco.com>
2022-04-04vlib: fix memory leak in load_one_pluginDamjan Marion1-0/+2
Type: fix Fixes: 500ba9f Change-Id: I32872a084276d9b38ff07cdccccb746c0212777f Signed-off-by: Damjan Marion <damarion@cisco.com>
2022-03-31vlib: add support for workers syncFlorin Coras2-0/+64
Adds api that allows workers to synchronize through main thread. Type: improvement Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: I1e75e2fb5144d397d19b13c4dfc7e937f11c044c
2022-03-31stats: use vlib_stats_validate in collectorDamjan Marion1-28/+5
Type: refactor Change-Id: Ib2bf9f11209eb310b289b3202b2beeccc3637df0 Signed-off-by: Damjan Marion <damarion@cisco.com>
2022-03-31stats: convert error counters to normal countersDamjan Marion7-143/+85
Change-Id: I9794da718805b40cc922e4f3cf316255398029a9 Type: improvement Signed-off-by: Damjan Marion <damarion@cisco.com> Signed-off-by: Ole Troan <ot@cisco.com>
2022-03-30vppinfra: vector allocator reworkDamjan Marion2-6/+4
- support of in-place growth of vectors (if there is available space next to existing alloc) - drops the need for alloc_aligned_at_offset from memory allocator, which allows easier swap to different memory allocator and reduces malloc overhead - rework of pool and vec macros to inline functions to improve debuggability - fix alignment - in many cases macros were not using native alignment of the particular datatype. Explicitly setting alignment with XXX_aligned() versions of the macro is not needed anymore in > 99% of cases - fix ASAN usage - avoid use of vector of voids, this was root cause of several bugs found in vec_* and pool_* function where sizeof() was used on voids instead of real vector data type - introduce minimal alignment which is currently 8 bytes, vectors will be always aligned at least to that value (underlay allocator actually always provide 16-byte aligned allocs) Type: improvement Change-Id: I20f4b081bb13bbf7bc0ace85cc4e301787f12fdf Signed-off-by: Damjan Marion <damarion@cisco.com>
2022-03-29vlib: fix unaligned runtime_dataDmitry Valter1-0/+2
Align runtime_data to 8 bytes to avoid alignment issues with any pointers in runtime_data located structures. Type: fix Signed-off-by: Dmitry Valter <d-valter@yandex-team.ru> Change-Id: I9cb1b73595e654a4b15c45f87b43fa6cfbcb6e51
2022-03-28vlib: use pthread_attr_setstack() to set thread stackDamjan Marion1-12/+26
Type: improvement Change-Id: I4c7f2f63651df4362ce1e0e36d885fedf55595c6 Signed-off-by: Damjan Marion <damarion@cisco.com>
2022-03-23vlib: send full error message to syslogJing Peng1-22/+6
Currently the last character of the error message string is temporarily changed to a null byte '\0' before the string is sent to syslog(3), resulting in confusingly incomplete log entries. This patch changes the syslog format to "%.*s" so that the maximum number of characters to be printed could be controlled. Type: improvement Signed-off-by: Jing Peng <pj.hades@gmail.com> Change-Id: I1bd6295c19b51b962a3d8ee3016cd91ffb2a4eaf
2022-03-23vppinfra: change vlib_register_node so it takes format string for node nameDamjan Marion3-23/+13
This allows specifying both c string and vector for node name and removes need for crafting temporary string. Type: improvement Change-Id: I0b016cd70aeda0f68eb6f9171c5152f303be7369 Signed-off-by: Damjan Marion <damarion@cisco.com>
2022-03-23vlib: avoid use of vector of voidsDamjan Marion2-3/+3
Type: fix Change-Id: I76e28854db8a1e9134c816c0c5d81b031dc4e27d Signed-off-by: Damjan Marion <damarion@cisco.com>
2022-03-23vlib: mitigate outdated new cli session eventsVladislav Grishenko1-1/+5
Possible races while concurrent additon to the new sessions vector in a one process and remove from it in an another need to be avoided. Let the vector be changed in the new session process function only. Also cli_file_pool element may be freed already at the new session event arrive timepoint, still causing unexpected cli banner for noninteracive cli sessions. Type: fix Fixes: 17a67218587d40541ff522c6a86f354720481fbb Signed-off-by: Vladislav Grishenko <themiron@yandex-team.ru> Change-Id: I022d16dd3aad9c9330834d35c58938f04b015b08
2022-03-23vlib: fix memory leak on process nodes reforkingVladislav Grishenko1-0/+1
The processes vector leaked on reforking and needs to be freed before recloning from main node processes. Type: fix Signed-off-by: Vladislav Grishenko <themiron@yandex-team.ru> Change-Id: Id69bc3fd42e2efacfcd521f98e6e51a9c712fef5
2022-03-23vlib: leave SIGCONT signal with its default handlerVladislav Grishenko1-0/+1
Systemd always sends SIGCONT after KillSignal, to ensure that even suspended tasks can be terminated cleanly. However, the default action of SIGCONT handler in VPP such as unix_signal_handler() is process termination with coredump, what is not really desired. So, leave it alike SIGSTOP with its default handler. Type: feature Signed-off-by: Vladislav Grishenko <themiron@yandex-team.ru> Change-Id: I54c06d21669ec3c709322d746db9e28448c31bb8
2022-03-23stats: fix crash due to pointer taken before validateDamjan Marion1-2/+4
Type: fix Change-Id: Iee9eab18da142bfe0645761deea13b0fe911a43b Signed-off-by: Damjan Marion <damarion@cisco.com>
2022-03-21stats: fix vlib_stats_validate_will_expand_internalDamjan Marion1-2/+2
Type: fix Change-Id: If4c0b23aaa4fc57c0783efcbe349aba5e5885b30 Signed-off-by: Damjan Marion <damarion@cisco.com>
2022-03-18vppinfra: use stored vec header size to find headerDamjan Marion1-1/+1
Type: refactor Change-Id: Iaa1e43c87c5725ab33ea8489bff2a7bda18b9c79 Signed-off-by: Damjan Marion <damarion@cisco.com>
2022-03-17vlib: fix vlib_mains vector alignmentFlorin Coras1-1/+1
Type: fix Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: Ib3d1ac6c82bc0c00e445b15d4102e4fd755f8e2d
2022-03-15vlib: add vlib_frame_bitmap_andDamjan Marion1-0/+8
Type: improvement Change-Id: I531115f32c484e4c4794173d24e15f3b5b8f547b Signed-off-by: Damjan Marion <damarion@cisco.com>