summaryrefslogtreecommitdiffstats
path: root/tests/lib (follow)
Commit message (Collapse)AuthorAgeFilesLines
* lib: add flag to have libyang load internal ietf-yang-library moduleChristian Hopps2024-10-074-5/+4
| | | | | | | | | | | | | | | | | | | | Mgmtd makes use of libyang's internal ietf-yang-library module to add support for said module to FRR management. Previously, mgmtd was loading this module explicitly; however, that required that libyang's `ietf-yang-library.yang` module definition file be co-located with FRR's yang files so that it (and ietf-datastore.yang) would be found when searched for by libyang using FRRs search path. This isn't always the case depending on how the user compiles and installs libyang so mgmtd was failing to run in some cases. Instead of doing it the above way we simply tell libyang to load it's internal version of ietf-yang-library when we initialize the libyang context. This required adding a boolean to a couple of the init functions which is why so many files are touched (although all the changes are minimal). Signed-off-by: Christian Hopps <chopps@labn.net>
* tests: Check if built-in Lua functions are workingDonatas Abraitis2024-09-241-0/+16
| | | | Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
* *: Create termtable specific temp memoryDonald Sharp2024-09-011-18/+18
| | | | | | | | | | When trying to track down a MTYPE_TMP memory leak it's harder to search for it when you happen to have some usage of ttable_dump. Let's just give it it's own memory type so that we can avoid confusion in the future. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* lib: common debug config outputIgor Ryzhov2024-08-271-2/+0
| | | | | | | Implement common code for debug config output and remove daemon-specific code that is duplicated everywhere. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* lib: rework debug initIgor Ryzhov2024-08-274-0/+8
| | | | | | | | | | The debug library allows to register a `debug_set_all` callback which should enable all debugs in a daemon. This callback is implemented exactly the same in each daemon. Instead of duplicating the code, rework the lib to allow registration of each debug type, and implement the common code only once in the lib. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* vtysh, lib: preprocess CLI graphsDavid Lamparter2024-07-311-1/+1
| | | | | | | | | | | | | | | | | Store a parsed and built graph of the CLI nodes in vtysh, rather than parsing and building that graph every time vtysh starts up. This provides a 3x to 5x reduction in vtysh startup overhead: `vtysh -c 'configure' -c 'interface lo' -c 'do show version'` - before: 92.9M cycles, 1114 samples - after: 16.5M cycles, 330 samples This improvement is particularly visible for users scripting `vtysh -c` calls, which notably includes topotests. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* tests: fix TSAN warnings in atomlist testDavid Lamparter2024-06-201-9/+9
| | | | | | | | | | | | The atomlist test consists of a sequence of (MT) sub-tests, from which counters are collected and verified. TSAN doesn't know that these counters are synchronized by way of the sub-test starting and finishing, so it complains. Just use atomics to get rid of the warning. (This is solely an issue with the test, not the atomlist code. There are no warnings from that.) Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* tests: silence TSAN warning on test_seqlock exitDavid Lamparter2024-06-201-0/+1
| | | | | | | TSAN warns about leaving the second thread dangling. Doesn't really matter, but just add a pthread_join to get rid of the warning. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* tests/lib: fix seqlock testDavid Lamparter2024-06-201-2/+2
| | | | | | | | | | | | | | | | | | | | seqlock_bump() used to return the value before bumping, but that's unhelpful if you were to actually need it. I had changed it to return the value after, but the update to the test got lost at some point. The return value is not in fact used anywhere in FRR, so while it is a bug, it has zero impact. NB: yes, test_seqlock is not run, which sounds wrong. The problem here is that (a) the test itself uses sleeps and is timing sensitive, which would raise false positives. And (b), the test is meaningless if executed once. It needs to be run millions of times under various conditions (e.g. load) to catch rare races, and it needs to be run on machines with "odd" memory models (in this case I used BE ppc32 and ppc64 systems as test platforms.) Fixes: 6046b690b53 ("lib/seqlock: avoid syscalls in no-waiter cases") Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* Merge pull request #16184 from LabNConsulting/chopps/fe-notify-selectJafar Al-Gharaibeh2024-06-131-0/+27
|\ | | | | mgmtd: add notification selection to front-end API
| * lib: darr: add free with element cleanup functionsChristian Hopps2024-06-071-0/+27
| | | | | | | | | | | | | | | | | | - `darr_free_free` to `darr_free` each element prior to `darr_free` the array. - `darr_free_func` to call `func` on each element prior to `darr_free` the array. Signed-off-by: Christian Hopps <chopps@labn.net>
* | tests: Extend prefix_sg print UT for IPv6Mike RE Mallin2024-05-311-3/+9
|/ | | | Signed-off-by: Mike RE Mallin <mremallin@gmail.com>
* tests: embed YANG in mgmtd unit-test binChristian Hopps2024-05-171-0/+4
| | | | | | | `make check` should run w/o installing FRR first. Thus we need to embed the yang modules otherwise mgmtd unit-test fails. Signed-off-by: Christian Hopps <chopps@labn.net>
* tests: add test for NB RPC callbackIgor Ryzhov2024-04-223-0/+50
| | | | Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* grpc: fix grpc for various failuresChristian Hopps2024-03-211-1/+1
| | | | | | | | | | lib: don't define a `fallthrough` in c++ to avoid conflict with protobuf c++ check: add link libs required by some versions of grpc++ or it's dependent linked libs tests: don't fail the test due to known at exit memleaks Signed-off-by: Christian Hopps <chopps@labn.net>
* tests: exercise `%w`/`%wf` printfrr modifiersDavid Lamparter2024-03-101-0/+12
| | | | | | Added by ISO C23 / N2680, implementation imported from FreeBSD. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* tests: fix grpc testChristian Hopps2024-02-121-1/+1
| | | | Signed-off-by: Christian Hopps <chopps@labn.net>
* staticd: fix NB dependency hackIgor Ryzhov2024-02-011-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | Currently, staticd configuration is tightly coupled with VRF existence. Because of that, it has to use a hack in NB infrastructure to create a VRF configuration when at least one static route is configured for this VRF. This hack is incompatible with mgmtd, because mgmtd doesn't execute configuration callbacks. Because of that, the configuration may become out of sync between mgmtd and staticd. There are two main cases: 1. Create static route in a VRF. The VRF data node will be created automatically in staticd by the NB hack, but not in mgmtd. 2. Delete VRF which has some static routes configured. The static route configuration will be deleted from staticd by the NB hack, but not from mgmtd. To fix the problem, decouple configuration of static routes from VRF configuration. Now it is possible to configure static routes even if the VRF doesn't exist yet. Once the VRF is created, staticd applies all the preconfigured routes. This change also fixes the problem with static routes being preserved in the system when staticd "control-plane-protocol" container is deleted but the VRF is still configured. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* lib: implement missing YANG choice/case statements.Christian Hopps2024-01-112-0/+31
| | | | Signed-off-by: Christian Hopps <chopps@labn.net>
* *: remove sys/stat.h from zebra.hDonald Sharp2024-01-093-0/+3
| | | | Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* lib: fixes required after rebasingChristian Hopps2023-12-281-5/+2
| | | | | | | | lib: fix checkpatch warnings lib: darr: disable check mgmtd: fix initialization Signed-off-by: Christian Hopps <chopps@labn.net>
* lib: darr: add new access and str functionsChristian Hopps2023-12-283-1/+156
| | | | | | | - darr_last(), and darr_strdup_cap(). - strcat, strdup, strlen, strnul equivs. Signed-off-by: Christian Hopps <chopps@labn.net>
* lib: Update int and ll decoders with new MTYPEDonald Lee2023-11-211-2/+2
| | | | | | | In the master branch a new MTYPE_SCRIPT_RES was created for frrscript_get_results, lua_to decoders should use that Signed-off-by: Donald Lee <dlqs@gmx.com>
* lib: Create encoders for int and rename stuffDonald Lee2023-11-211-2/+10
| | | | | | | Create encoders/decoders for int and rename current int encoders /decoders to long long. Signed-off-by: Donald Lee <dlqs@gmx.com>
* lib: Remove unused WQ_RETRY_XXX enumsDonald Sharp2023-11-031-6/+0
| | | | | | | | | These enum's have been around since 2005 and FRR still does not have any users of these particular values. After almost 20 years, let's simplify the code slightly and remove them. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* tests: have unit-test check more paths for the grpc.so moduleChristian Hopps2023-10-271-0/+11
| | | | Signed-off-by: Christian Hopps <chopps@labn.net>
* tests: exercise `%b` printfrr format specifierDavid Lamparter2023-09-031-0/+3
| | | | | | Added by ISO C23 / N2630, implementation imported from FreeBSD. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* Merge pull request #14016 from mjstapp/event_exec_ptrDonald Sharp2023-08-151-1/+1
|\ | | | | * : include event ptr in event_execute api
| * * : include event ptr in event_execute apiMark Stapp2023-07-251-1/+1
| | | | | | | | | | | | | | | | | | Include an event ptr-to-ptr in the event_execute() api call, like the various schedule api calls. This allows the execute() api to cancel an existing scheduled task if that task is being executed inline. Signed-off-by: Mark Stapp <mjs@labn.net>
* | lib: Do not use time_t as a special Lua encoder/decoderDonatas Abraitis2023-08-011-3/+4
| | | | | | | | | | | | This is purely an integer (long long/long), and causes issues for 32-bit systems. Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
* | tests: fix strncpy warningQuentin Young2023-07-251-2/+3
|/ | | | | | | | | GCC/clang warns about using strncpy in such a way that it does not copy the null byte of a string; as implemented it was fine, but to fix the warning, just use strlcat which was purpose made for the task being accomplished here. Signed-off-by: Quentin Young <qlyoung@qlyoung.net>
* tests: Fix Compilation Error and RuntimePath changes for test_grpcRajesh Gangam2023-07-141-5/+5
| | | | | | | | The runtime path for grpc.so has been changed for test_grpc.cpp and also there were couple of definitions which are duplicate, hence renamed them. Signed-off-by: Rajesh Gangam <rajeshgangam@gmail.com>
* lib: add dynamic array typeChristian Hopps2023-06-282-0/+286
| | | | Signed-off-by: Christian Hopps <chopps@labn.net>
* mgmtd: KISS the locking codeChristian Hopps2023-06-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Move away from things like "lock if not locked" type code, require the user has locked prior to geting to that point. For now we warn if we are taking a lock we already had; however, this should really be a failure point. New requirements: SETCFG - not implicit commit - requires user has locked candidate DS and they must unlock after implicit commit - requires user has locked candidate and running DS both locks will be unlocked on reply to the SETCFG COMMITCFG - requires user has locked candidate and running DS and they must unlock after rollback - this code now get both locks and then does an unlock and early return thing on the adapter side. It needs to be un-special cased in follow up work that would also include tests for this functionality. Signed-off-by: Christian Hopps <chopps@labn.net>
* tests: Fix out of tree build for lua scriptingEugene Crosser2023-05-091-0/+6
| | | | | | | | | | | | | | | | | | | test_frrscript is run from the `tests` directory and expects the sample lua script `script1.lua` to be present in the `lib` directory. When the package is built out of tree (which always happens when a debian package is built), and scripting is enabled, test fails because the lua file is not present in the `tests/lib/` subdir of the _build_ directory. Fix this by adding `script1.lua` as an extra dependency for `test_frrscript`, and a recipe that copies the file from the source tree to the build tree (note: it needs to be marked ".PHONY" because otherwise `make` thinks that it already exists, in the source tree). After this commit, the following command starts to work: dpkg-buildpackage --build-profiles=pkg.frr.lua -b -uc Signed-off-by: Eugene Crosser <crosser@average.org>
* lib: fix _hash_member() crash w/ empty hashDavid Lamparter2023-04-211-0/+5
| | | | | | | | | | | | | The typesafe hash _member() didn't check tabshift/count before proceeding to look at the hash table, leading it to dereference a NULL pointer when the hash table is in fact empty. Test case added to tests/lib/test_typelist. Note this function is not currently used anywhere. Only lib/cspf.c uses _member(), but it does so on a RB-tree rather than a hash. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* tests: Copy script1.lua for make distDonatas Abraitis2023-04-081-1/+1
| | | | | | This is needed for `make dist` when building Docker images with Lua support. Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
* lib: Remove getopt.c and getopt1.cDonald Sharp2023-03-281-1/+0
| | | | | | | Why do we need getopt code that is standard in everything that we compile against? Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* *: Convert event.h to frrevent.hDonald Sharp2023-03-2411-11/+11
| | | | | | | We should probably prevent any type of namespace collision with something else. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* *: Convert `struct event_master` to `struct event_loop`Donald Sharp2023-03-2422-23/+23
| | | | | | Let's find a better name for it. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* *: Convert thread_master_XXX functions to event_master_XXXDonald Sharp2023-03-2410-16/+16
| | | | Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* *: Convert THREAD_XXX macros to EVENT_XXX macrosDonald Sharp2023-03-241-1/+1
| | | | Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* *: Convert struct thread_master to struct event_master and it's ilkDonald Sharp2023-03-2422-23/+23
| | | | | | | Convert the `struct thread_master` to `struct event_master` across the code base. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* *: Convert thread_should_yield and thread_set_yield_timeDonald Sharp2023-03-241-1/+1
| | | | | | | Convert thread_should_yield and thread_set_yield_time to event_should_yield and event_set_yield_time Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* *: Convert thread_execute to event_executeDonald Sharp2023-03-241-1/+1
| | | | Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* *: Convert thread_fetch and thread_call to event_fetch and event_callDonald Sharp2023-03-246-12/+12
| | | | Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* *: Convert thread_cancelXXX to event_cancelXXXDonald Sharp2023-03-242-3/+3
| | | | | | Modify the code base so that thread_cancel becomes event_cancel Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* *: Convert thread_add_XXX functions to event_add_XXXDonald Sharp2023-03-245-15/+15
| | | | Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* *: Rename `struct thread` to `struct event`Donald Sharp2023-03-249-15/+15
| | | | | | | | | Effectively a massive search and replace of `struct thread` to `struct event`. Using the term `thread` gives people the thought that this event system is a pthread when it is not Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* *: Rename thread.[ch] to event.[ch]Donald Sharp2023-03-2411-11/+11
| | | | | | | | | | | This is a first in a series of commits, whose goal is to rename the thread system in FRR to an event system. There is a continual problem where people are confusing `struct thread` with a true pthread. In reality, our entire thread.c is an event system. In this commit rename the thread.[ch] files to event.[ch]. Signed-off-by: Donald Sharp <sharpd@nvidia.com>