summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2024-03-22mgmtd: fix a couple of log messagesIgor Ryzhov
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com> (cherry picked from commit 988d4444d44814fa3325795154911f420319ac76)
2024-03-22grpc: fix grpc for various failuresChristian Hopps
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> (cherry picked from commit 043a4183c2f10e6117695dec7a0373c1b0a63808)
2024-03-18zebra: fix route deletion during zebra shutdownAlexander Skorichenko
Split zebra's vrf_terminate() into disable() and delete() stages. The former enqueues all events for the dplane thread. Memory freeing is performed in the second stage. Signed-off-by: Alexander Skorichenko <askorichenko@netgate.com> (cherry picked from commit 444ce317b2af491b5cdc321286772627a5d4c8ea)
2024-03-12lib: Fix unknown sig_atomic_t compile errorDonatas Abraitis
This is happening for Alpine Linux. ``` 26 64.59 ./lib/sigevent.h:23:18: error: unknown type name 'sig_atomic_t' 26 64.59 23 | volatile sig_atomic_t caught; /* private member */ 26 64.59 | ^~~~~~~~~~~~ 26 64.60 In file included from ./lib/libfrr.h:12, 26 64.60 from ./lib/vty.h:28, 26 64.60 from ./lib/command.h:11, 26 64.60 from ./lib/debug.h:11, 26 64.60 from ./mgmtd/mgmt.h:12, 26 64.60 from mgmtd/mgmt_history.c:14: 26 64.60 ./lib/sigevent.h:23:18: error: unknown type name 'sig_atomic_t' 26 64.60 23 | volatile sig_atomic_t caught; /* private member */ 26 64.60 | ^~~~~~~~~~~~ ``` Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org> (cherry picked from commit f03b0bfaa4225182064d7749808b49760a618d29)
2024-03-08lib: fix order of interfaces in the configIgor Ryzhov
Add missing cli_cmp callback. Without it, interfaces are not sorted and printed in order they were created. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com> (cherry picked from commit 18da7369490af6bfb88431ad3f2c3a2934865f17)
2024-03-06lib: fix apply_finish callback in northboundIgor Ryzhov
When a node is top-level, we shouldn't stop the whole processing, we should just skip this single node. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com> (cherry picked from commit 8287fbe453d150a5e129ed204d89a4dce9b6982f)
2024-03-05lib: fix infinite loop in __darr_in_vsprintfIgor Ryzhov
`darr_avail` returns the available capacity excluding the already existing terminating NULL byte. Take this into account when using `darr_avail`. Otherwise, if the error length is a power of 2, the capacity is never enough and the function stucks in an infinite loop. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com> (cherry picked from commit cb6032d6b3d9fc1198f61ac343ec22b456a8896e)
2024-03-05lib: fix __darr_in_vsprintfIgor Ryzhov
If the initial darr capacity is not enough for the output, the `ap` is reused multiple times, which is wrong, because it may be altered by `vsnprintf`. Make a copy of `ap` each time instead of reusing. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com> (cherry picked from commit ee0c1cc1e4b87bde73f1eba3212ab93b1c379c6c)
2024-02-27Merge pull request #15437 from FRRouting/mergify/bp/dev/10.0/pr-15427Russ White
lib: fix access/prefix-list entry update (backport #15427)
2024-02-27Merge pull request #15412 from FRRouting/mergify/bp/dev/10.0/pr-15377Russ White
lib: Do not convert EVPN prefixes into IPv4/IPv6 if not needed (backport #15377)
2024-02-27lib: fix prefix-list entry updateIgor Ryzhov
When a prefix-list entry is updated, current NB code calls the replacement code multiple times, once per each updated field. It means that when multiple fields of an entry are changed in a single commit, the replacement is done with an interim state of a prefix-list instead of a final one. To fix the issue, we should call the replacement code once, after all fields of an entry are updated. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com> (cherry picked from commit 0bc2ab8598fa1418d3a45499e4f047622d21d6b4)
2024-02-27lib: fix access-list entry updateIgor Ryzhov
When an access-list entry is updated, current NB code calls notification hooks for each updated field. It means that when multiple fields of an entry are changed in a single commit, the hooks are run with an interim state of an access-list instead of a final one. To fix the issue, we should call the hooks once, after all fields of an entry are updated. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com> (cherry picked from commit a9460ae713a43285a972070d925ce38eaa5e363a)
2024-02-26lib: fix setting temporary log options for libyangIgor Ryzhov
By calling `ly_log_options` with `LY_LOSTORE`, the current code effectively disables libyang logging and never enables it back. The call is done to get the current logging options, but we don't really need that. When looking for a schema node, we don't want neither to log nor to store the error, so simply set the temporary options to 0. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com> (cherry picked from commit 3cd6ddaec6fd41ac84ef23595ffc7e3d18334839)
2024-02-25lib: fix nb callbacks for containers inside choice caseIgor Ryzhov
Containers inside a choice's case must be treated as presence containers as they can be explicitly created and deleted. They must have `create` and `destroy` callbacks, otherwise the internal data they represent may never be deleted. The issue can be reproduced with the following steps: - create an access-list with destination-network params ``` # access-list test seq 1 permit ip any 10.10.10.0 0.0.0.255 ``` - delete the `destination-network` container ``` # mgmt delete-config /frr-filter:lib/access-list[name='test'][type='ipv4']/entry[sequence='1']/destination-network # mgmt commit apply MGMTD: No changes found to be committed! ``` As the `destination-network` container is non-presence, and all its leafs are mandatory, mgmtd doesn't see any changes to be commited and simply updates its YANG data tree without passing any updates to backend daemons. This commit fixes the issue by requiring `create` and `destroy` callbacks for containers inside choice's cases. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com> (cherry picked from commit 0b905f740459291bca12e552aea4975fb46e9d98)
2024-02-25lib: fix order of northbound operationsIgor Ryzhov
When ordering operations, destroys must always come before other operations, to correctly cover the change of a "case" in a "choice". The problem can be reproduced with the following commands: ``` access-list test seq 1 permit 10.0.0.0/8 access-list test seq 1 permit host 10.0.0.1 access-list test seq 1 permit 10.0.0.0/8 ``` Before this commit, the order of changes would be the following: - `access-list test seq 1 permit 10.0.0.0/8` - `modify` for `ipv4-prefix` - `access-list test seq 1 permit host 10.0.0.1` - `destroy` for `ipv4-prefix` - `modify` for `host` - `access-list test seq 1 permit 10.0.0.0/8` - `modify` for `ipv4-prefix` - `destroy` for `host` As `destroy` for `host` is called last, it rewrites the fields that were filled by `modify` callback of `ipv4-prefix`. This commit fixes this problem by always calling `destroy` callbacks first. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com> (cherry picked from commit 38b85e0c2bc555b8827dbd2cb6515b6febf548b4)
2024-02-23lib: fix processing of notifications on mgmt fe clientIgor Ryzhov
Notifications are sent by mgmtd for each session of a client, so they should be processed once per each session. Also, add session_id parameter to an async_notification callback as all other callbacks have this parameter. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com> (cherry picked from commit 13359c5cc9b8fd84c62b30443e063d96e9a73034)
2024-02-23lib: Do not convert EVPN prefixes into IPv4/IPv6 if not neededDonatas Abraitis
Convert only when this is really needed, e.g. `match ip address prefix-list ...`. Otherwise, we can't have mixed match clauses, like: ``` match ip address prefix-list p1 match evpn route-type prefix ``` This won't work, because the prefix is already converted, and we can't extract route type, vni, etc. from the original EVPN prefix. Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org> (cherry picked from commit 439b739495e86912c8b9ec36b84e55311c549ba0)
2024-02-21lib: fix order of northbound callbacksIgor Ryzhov
When ordering the NB callbacks according to their priorities, if the operation is "destroy" we should reverse the order, to destroy the dependants before the dependencies. This fixes the crash, that can be reproduced with the following steps: ``` frr# conf term file-lock frr(config)# affinity-map map bit-position 10 frr(config)# interface test frr(config-if)# link-params frr(config-link-params)# affinity map frr(config-link-params)# exit frr(config-if)# exit frr(config)# mgmt commit apply frr(config)# no affinity-map map frr(config)# interface test frr(config-if)# link-params frr(config-link-params)# no affinity map frr(config-link-params)# exit frr(config-if)# exit frr(config)# mgmt commit apply ``` Signed-off-by: Igor Ryzhov <iryzhov@nfware.com> (cherry picked from commit 01f371a677dc52ff888b14360f6ffd63b91f3845)
2024-02-21lib: add missing priority for affinity map callbacksIgor Ryzhov
Other objects depend on affinity-maps being created before them by using leafref with require-instance true. Set the priority to ensure that. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com> (cherry picked from commit 323caf1d7013c4787b30ee34b3c53dd4bf0a92aa)
2024-02-20lib: mgmtd: add xpath arg to notification messageChristian Hopps
Signed-off-by: Christian Hopps <chopps@labn.net> (cherry picked from commit 4a93d171c2e3ec1ff6c4fc553d6acf42e035e0d4)
2024-02-20lib: always call new notification hooks tooChristian Hopps
- call the new notification hooks when backends call the old notification posting API. Signed-off-by: Christian Hopps <chopps@labn.net> (cherry picked from commit 1d4ea437e4a4fced3fce6e441952fdea8d94af80)
2024-02-15lib: actually create the tree for the conversionChristian Hopps
Before this fix would always return empty results b/c there was no libyang tree to print to output format. Signed-off-by: Christian Hopps <chopps@labn.net> (cherry picked from commit dff28248c3c1dee0d1c9f9225dab66224c6aac54)
2024-02-15lib: fix memleak on successChristian Hopps
Signed-off-by: Christian Hopps <chopps@labn.net> (cherry picked from commit b8e07049a8ee684eaa8df48bef6e7bfbc853644d)
2024-02-13Merge pull request #15320 from donaldsharp/vtysh_limit_fdsRuss White
lib, ospfclient, vtysh: Allow for a minimum fd poll size
2024-02-11lib, mgmtd: rework processing of yang notificationsIgor Ryzhov
Currently, YANG notification processing is done using a special type of callbacks registered in backend clients. In this commit, we start using regular northbound infrastructure instead, because it already has a convenient way of registering xpath-specific callbacks without the need for creating additional structures for each necessary notification. We also now pass a notification data to the callback, instead of a plain JSON. This allows to use regular YANG library functions for inspecting notification fields, instead of manually parsing the JSON. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-02-10lib, mgmtd: fix processing of yang notificationsIgor Ryzhov
Current code assumes that notification is always sent in stripped JSON format and therefore notification xpath starts at the third symbol of notification data. Assuming JSON is more or less fine, because this representation is internal to FRR, but the assumption about the xpath is wrong, because it won't work for not top-level notifications. YANG allows to define notification as a child for some data node deep into the tree and in this case notification data contains not only the notification node itself, but also all its parents. To fix the issue, parse the notification data and get its xpath from its schema node. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-02-08Merge pull request #15325 from opensourcerouting/fix/show_getsockoptDonald Sharp
bgpd: Do not show TCP MSS if the socket is broken
2024-02-07Merge pull request #15286 from idryzhov/fix-mgmt-startupChristian Hopps
Fix conflict in mgmtd on startup
2024-02-07bgpd: Do not show TCP MSS if the socket is brokenDonatas Abraitis
Just avoid calling for TCP MSS socket option if it's not in use. Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-02-07vtysh: remove resync workaround when exiting to config nodeIgor Ryzhov
When exiting from a level below the config node, like `router rip`, vtysh executes a resync by sending "end" and "conf term [file-lock]" commands to all the daemons. As statet in the description comment, it's done "in case one of the daemons is somewhere else". I don't think this actually ever happens, but even if it is, it is a bug in a daemon that needs to be fixed. This resync was okay before the introduction of mgmtd, but now it unlocks and locks back the datastores during the configuration reading process, which can lead to a failure which is explained in the previous commit. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-02-07lib, ospfclient, tests, vtysh: Allow for a minimum fd poll sizeDonald Sharp
There exists cases where just honoring the FD_LIMIT size as given to us by the operating system makes no sense. Let's just make a switch to allow for this for things like vtysh and ospfclient which will never have 1k files open at any given time. Fixes: #15315 Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-02-05Merge pull request #15294 from okda-networks/sysrepo_set_sess_errDonald Sharp
lib: set change errmsg in sysrepo session
2024-02-05Merge pull request #15291 from idryzhov/mgmtd-yang-embedDonald Sharp
lib, mgmtd: fix missing embedded modules
2024-02-05Merge pull request #15297 from idryzhov/mgmtd--nDonald Sharp
mgmtd: fix missing -n flag and help
2024-02-04lib: add ietf-yang-metadata to the list of built-in modulesIgor Ryzhov
We don't need to manually load built-in modules. This fixes the following warning in mgmtd: ``` YANG model "ietf-yang-metadata@*" "*@*"not embedded, trying external file ``` Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-02-04*: use af-specific autocompletion for prefix-lists when possibleIgor Ryzhov
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-02-04lib: fix autocompletion for prefix-listsIgor Ryzhov
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-02-04lib: fix autocompletion for access-listsIgor Ryzhov
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-02-04lib, mgmtd: don't register NB config callbacks in mgmtdIgor Ryzhov
mgmtd is supposed to only register CLI callbacks. If configuration callbacks are registered, they are getting called on startup when mgmtd reads config files, and they can use infrastructure that is not initialized on mgmtd, or allocate some memory that is never freed. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-02-03lib: Actually create the rcu and save it before using itDonald Sharp
In a non-controlled startup, the rcu data structures were not being created until after logging could happen. This is bad. Move it so that the rcu data structures are created first, before logging( HA! ) can happen. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-02-03lib: set change errmsg in sysrepo sessionali-aqrabawi
this will enable sysrepo based cli users to know what went wrong when config change fails Signed-off-by: ali-aqrabawi <aaqrabaw@okdanetworks.com>
2024-02-03Merge pull request #15265 from louis-6wind/fix-rpki-logsDonald Sharp
bgpd,lib: fix logging from rpki_create_socket()
2024-02-02Merge pull request #10151 from pguibert6WIND/ensure_routing_protocols_good_bwDonald Sharp
zebra: avoid having speed set to UINT32_MAX
2024-02-02Merge pull request #15279 from idryzhov/staticd-fixesDonald Sharp
several fixes for staticd configuration
2024-02-02Merge pull request #15278 from idryzhov/fix-no-vrfDonatas Abraitis
lib: fix "no vrf" command
2024-02-02Merge pull request #15282 from donaldsharp/poll_infoDonatas Abraitis
lib: Warn operator when fd limit is set too large
2024-02-02lib: add ability to log from external pthreadLouis Scalbert
External libraries can re-enter the FRR code through a hook function. A crash occurs when logging from this hook function if the library has initiated a new pthread, as the FRR RCU context is not initialized for this thread. Add frr_pthread_non_controlled_startup() function to initialize a valid RCU context within a FRR pthread context, originating from an external pthread. Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-02-01lib: Warn operator when fd limit is set too largeDonald Sharp
It's unlikely that an operator will ever set a fd limit of over 100k. Let's warn the operator that things are in a bit of a wonky state. Fixes: #15280 Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-02-02lib: fix "no vrf" commandIgor Ryzhov
Remove operational data check from CLI command. It never works in mgmtd and it is not needed in backend daemons because it's done in `lib_vrf_destroy` callback. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-02-02staticd: fix NB dependency hackIgor Ryzhov
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>