summaryrefslogtreecommitdiff
path: root/tests/lib
AgeCommit message (Collapse)Author
2020-04-24Merge pull request #6279 from opensourcerouting/nb-cb-argsDonald Sharp
*: change the signature of the northbound callbacks to be more flexible
2020-04-23Merge pull request #6262 from qlyoung/remove-sprintfDavid Lamparter
2020-04-23*: change the signature of the northbound callbacks to be more flexibleRenato Westphal
Having a fixed set of parameters for each northbound callback isn't a good idea since it makes it difficult to add new parameters whenever that becomes necessary, as several hundreds or thousands of existing callbacks need to be updated accordingly. To remediate this issue, this commit changes the signature of all northbound callbacks to have a single parameter: a pointer to a 'nb_cb_x_args' structure (where x is different for each type of callback). These structures encapsulate all real parameters (both input and output) the callbacks need to have access to. And adding a new parameter to a given callback is as simple as adding a new field to the corresponding 'nb_cb_x_args' structure, without needing to update any instance of that callback in any daemon. This commit includes a .cocci semantic patch that can be used to update old code to the new format automatically. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-04-20*: sprintf -> snprintfQuentin Young
Replace sprintf with snprintf where straightforward to do so. - sprintf's into local scope buffers of known size are replaced with the equivalent snprintf call - snprintf's into local scope buffers of known size that use the buffer size expression now use sizeof(buffer) - sprintf(buf + strlen(buf), ...) replaced with snprintf() into temp buffer followed by strlcat Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-17*: replace all random() callsRafael Zalamena
Replace all `random()` calls with a function called `frr_weak_random()` and make it clear that it is only supposed to be used for weak random applications. Use the annotation described by the Coverity Scan documentation to ignore `random()` call warnings. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-04-16Merge pull request #6135 from opensourcerouting/cli-node-cleanupDonald Sharp
*: clean up the mess that is CLI command nodes
2020-04-16Merge pull request #5451 from opensourcerouting/rcu-logSantosh P K
logging subsystem rewrite
2020-04-16*: move CLI node names to cmd_node->nameDavid Lamparter
And again for the name. Why on earth would we centralize this, just so people can forget to update it? Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16*: move CLI parent data to cmd_node->parent_nodeDavid Lamparter
Same as before, instead of shoving this into a big central list we can just put the parent node in cmd_node. Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16*: remove second parameter on install_node()David Lamparter
There is really no reason to not put this in the cmd_node. And while we're add it, rename from pointless ".func" to ".config_write". [v2: fix forgotten ldpd config_write] Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16*: clean up cmd_node initializersDavid Lamparter
... and use named assignments everywhere (so I can change the struct.) Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-08*: Do not cast to the same typeDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-04-03lib, tools: silence harmless warnings in the northbound toolsRenato Westphal
Our two northbound tools don't have embedded YANG modules like the other FRR binaries. As such, ly_ctx_set_module_imp_clb() shouldn't be called when the YANG subsystem it being initialized by a northbound tool. To make that possible, add a new "embedded_modules" parameter to the yang_init() function to control whether libyang should look for embedded modules or not. With this fix, "gen_northbound_callbacks" and "gen_yang_deviations" won't emit "YANG model X not embedded, trying external file" warnings anymore. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-04-01lib: rewrite zlog lock-free & TLS-bufferedDavid Lamparter
This is a full rewrite of the "back end" logging code. It now uses a lock-free list to iterate over logging targets, and the targets themselves are as lock-free as possible. (syslog() may have a hidden internal mutex in the C library; the file/fd targets use a single write() call which should ensure atomicity kernel-side.) Note that some functionality is lost in this patch: - Solaris printstack() backtraces are ditched (unlikely to come back) - the `log-filter` machinery is gone (re-added in followup commit) - `terminal monitor` is temporarily stubbed out. The old code had a race condition with VTYs going away. It'll likely come back rewritten and with vtysh support. - The `zebra_ext_log` hook is gone. Instead, it's now much easier to add a "proper" logging target. v2: TLS buffer to get some actual performance Signed-off-by: David Lamparter <equinox@diac24.net>
2020-03-31Merge pull request #6093 from LabNConsulting/working/lb/no-birdsDavid Lamparter
*: use the current project name (FRRouting)
2020-03-29tests: use printfrr-based printf()David Lamparter
Just a small hack to use printfrr() in tests, since otherwise the redefined PRId64 trips some warnings. Signed-off-by: David Lamparter <equinox@diac24.net>
2020-03-25*: use the current project name (FRRouting)Lou Berger
Signed-off-by: Lou Berger <lberger@labn.net>
2020-03-24lib: rewrite zlog_hexdump()David Lamparter
The old version was creating a multi-line log message, which we can't properly handle right now. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-02-03*: don't null after XFREE; XFREE does this itselfQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-12-18tests: fix endian bug in test_typelistMark Stapp
Fix a byte-swapping bug that appeared on big-endian arch but wasn't visible on little-endian runs. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-12-06lib: add frr_version_cmp()David Lamparter
This just compares 2 version strings. Signed-off-by: David Lamparter <equinox@diac24.net>
2019-12-06lib: rename memory_vty.c to lib_vty.cDavid Lamparter
And memory_init() to lib_cmd_init(). Signed-off-by: David Lamparter <equinox@diac24.net>
2019-11-30*: make frr_yang_module_info constDavid Lamparter
Signed-off-by: David Lamparter <equinox@diac24.net>
2019-09-30*: strip trailing whitespaceQuentin Young
Some of it has snuck by CI Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-09-03*: frr_elevate_privs -> frr_with_privsDavid Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-08-08Merge pull request #4497 from opensourcerouting/rcuDonald Sharp
RCU support
2019-08-07Merge pull request #4763 from opensourcerouting/ds-workDonald Sharp
lib: get rid of pqueue_*, use DECLARE_HEAP in thread.c
2019-08-06Merge pull request #4790 from opensourcerouting/ctype-castQuentin Young
*: fix ctype casts
2019-08-06*: fix ctype (isalpha & co.) castsDavid Lamparter
The correct cast for these is (unsigned char), because "char" could be signed and thus have some negative value. isalpha & co. expect an int arg that is positive, i.e. 0-255. So we need to cast to (unsigned char) when calling any of these. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-08-02all: remove logical-router functionalityIgor Ryzhov
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2019-08-01lib: remove pqueue_* (again)David Lamparter
All users of the pqueue_* implementations have been migrated to use some new data structure (TYPEDSKIP for ospf, HEAP for thread.c). Remove. Signed-off-by: David Lamparter <equinox@diac24.net>
2019-07-31tests: Add asserts to check return on list *_delStephen Worley
Add some asserts where `list_del()` is called to verify they object was found when it was deleted. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-07-31lib/seqlock: avoid syscalls in no-waiter casesDavid Lamparter
When we have no contention on the seqlock, we shouldn't incur the cost of syscalls. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-07-15tests: remove strlen assert in inet_ntop testsQuentin Young
Some platform libc's like to render some v6 addresses as v4 mapped where others render the same addresses as v6 with leading zeroes. Binary equivalence checks pass but strlen checks sometimes fail here. Remove assert causing the failure. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-06-17Merge pull request #4514 from opensourcerouting/warnings-20190612Donald Sharp
*: kill more warnings
2019-06-14eliminate snprintf from AF_INET/AF_INET6 prefix2str, add prefix2str test (#4521)David Lamparter
eliminate snprintf from AF_INET/AF_INET6 prefix2str, add prefix2str test
2019-06-13tests: add prefix2str testQuentin Young
Only tests IPv4 and IPv6 right now. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-06-13Merge pull request #4509 from opensourcerouting/spanish-intquisitionQuentin Young
lib: make printfrr int64_t usable
2019-06-13*: config.h or zebra.h is the first #includeDavid Lamparter
This is mostly relevant for Solaris, where config.h sets up some #define that affect overall header behaviour, so it needs to be before anything else. Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-12lib: make "%Ld" work for int64_tDavid Lamparter
... without compiler plugins. Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-11lib: const-unaware container_of for C++David Lamparter
This version of container_of() should work on C++, by ditching the unavailable builtins (at the cost of no longer checking for "const" violations.) Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-06tests: exercise frr_inet_ntop()David Lamparter
Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-03tests: exercise printfrr()David Lamparter
Signed-off-by: David Lamparter <equinox@diac24.net>
2019-05-31lib: Add '--command-log-always` to all daemons startupDonald Sharp
Add 'no log commands' cli and at the same time add a --command-log-always to the daemon startup cli. If --command-log-always is specified then all commands are auto-logged and the 'no log commands' form of the command is now ignored. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-05-21tests: update list of headers in the cxx compat testRenato Westphal
Now, whenever a new header is added to libfrr, this test needs to be updated manually (unless we automate this somehow in the future). Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-05-21*: rename new ForEach macros from the typesafe APIRenato Westphal
This is necessary to avoid a name collision with std::for_each from C++. Fixes the compilation of the gRPC northbound module. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-05-21tests: more datastructure testsDavid Lamparter
A little something for everybody in here. Signed-off-by: David Lamparter <equinox@diac24.net>
2019-05-21tests: extend DECLARE_* testsDavid Lamparter
The unsorted datastructures (LIST, DLIST) had no test before this. Also add a hash check (mostly to make testing the unsorted lists easier.) Signed-off-by: David Lamparter <equinox@diac24.net>
2019-05-21tests: test DECLARE_HASH with good and bad hashfnDavid Lamparter
The hash table test was previously (intentionally) using a bad hash function to test the code in the face of hash collisions. Add a test with a good hash function to see some performance numbers. Signed-off-by: David Lamparter <equinox@diac24.net>
2019-05-14lib: hashing functions should take const argumentsQuentin Young
It doesn't make much sense for a hash function to modify its argument, so const the hash input. BGP does it in a couple places, those cast away the const. Not great but not any worse than it was. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>