Commit graph

305 commits

Author SHA1 Message Date
Mark Stapp da8fce3830 tests: use little-endian order for libyang api
Use the expected - little-endian - byte-order for a param
to one of the libyang apis; tests fail on LE architectures
otherwise.

Signed-off-by: Mark Stapp <mjs@cisco.com>
2025-04-15 13:15:09 -04:00
Mark Stapp e2515f7a4f tests: clean up variable-shadow warnings
Clean up -Wshadow warnings in unit-tests

Signed-off-by: Mark Stapp <mjs@cisco.com>
2025-04-08 14:41:27 -04:00
Christian Hopps bc3f7d9c07 tests: fix wrong callback function parameters in unit-test
Signed-off-by: Christian Hopps <chopps@labn.net>
2025-03-15 04:12:31 +00:00
Christian Hopps 986501029e tests: deal with configure overridden timestamp prec in unit test
Previously if you configured a different timestamp precision then
`make check` would fail as the non-default config is generated and
fails test_cli config file comparison.

Signed-off-by: Christian Hopps <chopps@labn.net>
2025-03-15 04:11:48 +00:00
Christian Hopps d58a8f473b lib: add darr_strlen_fixup() to update len based on NUL term
Signed-off-by: Christian Hopps <chopps@labn.net>
2025-03-14 08:37:46 +00:00
Christian Hopps bce25cf43b tests: add oper test using existing libyang state tree
Signed-off-by: Christian Hopps <chopps@labn.net>
2025-02-26 13:38:42 +00:00
Christian Hopps 73df7da40a tests: add unit-test for choice/case node queries
Signed-off-by: Christian Hopps <chopps@labn.net>
2025-02-22 16:25:31 +00:00
Donald Sharp 9219fa39f2
Merge pull request #17649 from ariel-anieli/calloc-warns
tests: clear `-Wcalloc-transposed-args` warnings
2025-02-12 13:00:36 -05:00
Donald Sharp 96ab6ae32b
Merge pull request #17781 from LabNConsulting/chopps/fix-keyless-list-query
fix xpath query on keyless list with positional predicate
2025-01-07 13:17:37 -05:00
Christian Hopps e729676cfe tests: add test for new northbound get function
Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-07 07:01:46 -05:00
Christian Hopps 0ce15fb0f7 tests: add unit test case for keyless list xpath queries
Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-07 01:24:38 -05:00
Ariel Otilibili 84d0ab9896 tests: clear -Wcalloc-transposed-args warnings
* order of arguments was swapped; not consistent with calloc signature
* therefore producing -Wcalloc-transposed-args during compilation.

Link: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
Link: https://man7.org/linux/man-pages/man3/calloc.3p.html
Signed-off-by: Ariel Otilibili <ariel.otilibili@6wind.com>
2025-01-06 15:47:55 +01:00
Donatas Abraitis 77df36c3b9 lib: Fix Lua script unit test
When building for big-endian architectures, this is failing because of
long long / int casting issues, let's use a separate integer to get the
results.

This is especially important when building the Docker images for multiple arches.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-11-18 17:25:08 +02:00
Donald Sharp 1cb6b71b40 lib, tests: Remove in6addr_cmp function from the system
This function should just be memcmp.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-31 10:04:19 -04:00
David Lamparter b3e4007197 lib: refactor memstats logging, fix ACTIVEATEXIT
Move the various destinations handling into lib/memory.c, include
"normal" logging as target, and make `ACTIVEATEXIT` properly non-error
as it was intended to be.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-10-17 13:58:57 +02:00
Christian Hopps e8648a0c72 lib: add flag to have libyang load internal ietf-yang-library module
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>
2024-10-07 03:32:44 +00:00
Donatas Abraitis 623fb6d996 tests: Check if built-in Lua functions are working
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-09-24 13:40:37 +03:00
Donald Sharp d97c535c1e *: Create termtable specific temp memory
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>
2024-09-01 13:07:46 -04:00
Igor Ryzhov 82e52e0f21 lib: common debug config output
Implement common code for debug config output and remove daemon-specific
code that is duplicated everywhere.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-08-27 09:53:02 -04:00
Igor Ryzhov 5dac696154 lib: rework debug init
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>
2024-08-27 09:53:02 -04:00
David Lamparter 4bc41193e8 vtysh, lib: preprocess CLI graphs
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>
2024-07-31 08:08:53 -04:00
David Lamparter e14c94f2b7 tests: fix TSAN warnings in atomlist test
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>
2024-06-20 15:44:46 +02:00
David Lamparter 4836ac0714 tests: silence TSAN warning on test_seqlock exit
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>
2024-06-20 11:16:10 +02:00
David Lamparter 8aeac1f005 tests/lib: fix seqlock test
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: 6046b690b5 ("lib/seqlock: avoid syscalls in no-waiter cases")
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-06-20 11:02:19 +02:00
Jafar Al-Gharaibeh 2e02bd2366
Merge pull request #16184 from LabNConsulting/chopps/fe-notify-select
mgmtd: add notification selection to front-end API
2024-06-13 00:20:09 -05:00
Christian Hopps e14781eb1d lib: darr: add free with element cleanup functions
- `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>
2024-06-06 22:38:48 -04:00
Mike RE Mallin f450332476 tests: Extend prefix_sg print UT for IPv6
Signed-off-by: Mike RE Mallin <mremallin@gmail.com>
2024-05-31 10:27:22 -04:00
Christian Hopps 07a084f921 tests: embed YANG in mgmtd unit-test bin
`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>
2024-05-17 00:54:20 -04:00
Igor Ryzhov 03883ee431 tests: add test for NB RPC callback
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-04-22 16:36:22 +03:00
Christian Hopps 043a4183c2 grpc: fix grpc for various failures
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>
2024-03-21 15:57:01 +00:00
David Lamparter 91fdb7366c tests: exercise %w/%wf printfrr modifiers
Added by ISO C23 / N2680, implementation imported from FreeBSD.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-03-10 15:29:17 +01:00
Christian Hopps 8d6e7a350f tests: fix grpc test
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-02-12 07:48:50 -05:00
Igor Ryzhov cb781f6097 staticd: fix NB dependency hack
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>
2024-02-02 00:57:59 +02:00
Christian Hopps 32a4c4019e lib: implement missing YANG choice/case statements.
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-11 13:38:57 +00:00
Donald Sharp 848dcf3d03 *: remove sys/stat.h from zebra.h
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-09 12:39:23 -05:00
Christian Hopps b8b5290105 lib: fixes required after rebasing
lib: fix checkpatch warnings
lib: darr: disable check
mgmtd: fix initialization

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-28 18:17:24 +00:00
Christian Hopps f3d6edc7ee lib: darr: add new access and str functions
- darr_last(), and darr_strdup_cap().
- strcat, strdup, strlen, strnul equivs.

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-28 17:52:57 +00:00
Donald Lee fca8ee275c lib: Update int and ll decoders with new MTYPE
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>
2023-11-20 20:45:02 -05:00
Donald Lee d2acf63f16 lib: Create encoders for int and rename stuff
Create encoders/decoders for int and rename current int encoders
/decoders to long long.

Signed-off-by: Donald Lee <dlqs@gmx.com>
2023-11-20 20:45:02 -05:00
Donald Sharp 2a65f05d77 lib: Remove unused WQ_RETRY_XXX enums
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>
2023-11-03 18:06:01 +00:00
Christian Hopps 8e630c2946 tests: have unit-test check more paths for the grpc.so module
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-10-26 21:39:13 -04:00
David Lamparter 48eee77b51 tests: exercise %b printfrr format specifier
Added by ISO C23 / N2630, implementation imported from FreeBSD.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-09-03 23:34:03 +02:00
Donald Sharp 77014daf3a
Merge pull request #14016 from mjstapp/event_exec_ptr
* : include event ptr in event_execute api
2023-08-15 11:52:49 -04:00
Donatas Abraitis 27dbf81a73 lib: Do not use time_t as a special Lua encoder/decoder
This is purely an integer (long long/long), and causes issues for 32-bit systems.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-08-01 14:08:25 +03:00
Mark Stapp adca5c22c5 * : include event ptr in event_execute api
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>
2023-07-25 10:17:48 -04:00
Quentin Young 64c549e68c tests: fix strncpy warning
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>
2023-07-24 19:03:24 -04:00
Rajesh Gangam 509c7e5cd9 tests: Fix Compilation Error and RuntimePath changes for test_grpc
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>
2023-07-14 01:17:35 +00:00
Christian Hopps e6e0c5bd25 lib: add dynamic array type
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-06-27 18:00:56 -04:00
Christian Hopps df0173ceeb mgmtd: KISS the locking code
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>
2023-06-19 00:13:28 -04:00
Eugene Crosser 5b2ee104c2 tests: Fix out of tree build for lua scripting
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>
2023-05-09 02:05:44 +02:00