summaryrefslogtreecommitdiffstats
path: root/lib/northbound_grpc.cpp (follow)
Commit message (Collapse)AuthorAgeFilesLines
* *: Convert event.h to frrevent.hDonald Sharp2023-03-241-1/+1
| | | | | | | 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-241-2/+2
| | | | | | Let's find a better name for it. 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-241-2/+2
| | | | | | | Convert the `struct thread_master` to `struct event_master` across the code base. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* *: Convert thread_add_XXX functions to event_add_XXXDonald Sharp2023-03-241-3/+2
| | | | Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* *: Rename `struct thread` to `struct event`Donald Sharp2023-03-241-5/+5
| | | | | | | | | 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-241-1/+1
| | | | | | | | | | | 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>
* mgmtd: Add MGMT Backend Interface FrameworkChristian Hopps2023-03-221-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit introduces the MGMT Backend Interface which can be used by back-end management client daemons like BGPd, Staticd, Zebra to connect with new FRR Management daemon (MGMTd) and utilize the new FRR Management Framework to let any Frontend clients to retrieve any operational data or manipulate any configuration data owned by the individual Backend daemon component. This commit includes the following functionalities in the changeset: 1. Add new Backend server for Backend daemons connect to. 2. Add a C-based Backend client library which can be used by daemons to communicate with MGMTd via the Backend interface. 3. Maintain a backend adapter for each connection from an appropriate Backend client to facilitate client requests and track one or more transactions initiated from Frontend client sessions that involves the backend client component. 4. Add the following commands to inspect various Backend client related information a. show mgmt backend-adapter all b. show mgmt backend-yang-xpath-registry c. show mgmt yang-xpath-subscription Co-authored-by: Pushpasis Sarkar <pushpasis@gmail.com> Co-authored-by: Abhinay Ramesh <rabhinay@vmware.com> Co-authored-by: Ujwal P <ujwalp@vmware.com> Signed-off-by: Yash Ranjan <ranjany@vmware.com>
* lib: fix init. use of nb_context to be by value not by referenceChristian Hopps2023-02-241-2/+2
| | | | | | | | | | | | | | | | | | | | | | Pass context argument by value on initialization to be clear that the value is used/saved but not a pointer to the value. Previously the northbound code was incorrectly holding a pointer to stack allocated context structs. However, the structure definition also had some musings (ifdef'd out code) and a comment that might be taken to imply that user data could follow the structure and thus be maintained by the code; it won't; so it can't; so get rid of the disabled misleading code/text from the structure definition. The common use case worked b/c the transaction which cached the pointer was created and freed inside a single function call (`nb_condidate_commit`) that executed below the stack allocation. All other use cases (grpc, confd, sysrepo, and -- coming soon -- mgmtd) were bugs. Signed-off-by: Christian Hopps <chopps@labn.net>
* *: manual SPDX License ID conversionsDavid Lamparter2023-02-091-14/+1
| | | | | | | | | | The files converted in this commit either had some random misspelling or formatting weirdness that made them escape automated replacement, or have a particularly "weird" licensing setup (e.g. dual-licensed.) This also marks a bunch of "public domain" files as SPDX License "NONE". Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib, vrrpd: Use THREAD_ARGDonald Sharp2022-07-211-1/+1
| | | | | | | Don't auto set the thread->arg pointer. It is private and should be only accessed through the THREAD_ARG pointer. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* lib: grpc: fix covevrity warningsChristian Hopps2022-03-161-1/+3
| | | | | | | One uninit warning and one missing lock warning, both were OK but let's make the tool happy. Signed-off-by: Christian Hopps <chopps@labn.net>
* lib: grpc: rework RPC handlers improve code clarityChristian Hopps2022-03-141-475/+337
| | | | | | | | | | | | | | | - split NewRpcState object into 2, a Unary and a Streaming variant, which then allows for the next. - move all state machine details inside these new state objects - use a template arg to allow for Streaming state tracking object creation and deletion w/o requiring this in each specific RPC hander. - Code is more rugged by design now. Thanks to Rafael Zalamena <rzalamena@opensourcerouting.org> for the cleanup ideas/motivation. Signed-off-by: Christian Hopps <chopps@labn.net>
* lib: grpc: use candiate ID to delete rather than pointer to candiateChristian Hopps2022-03-141-7/+15
| | | | | | - also be consistent in candidate IDs being uint64_t Signed-off-by: Christian Hopps <chopps@labn.net>
* lib: call protobuf clean up on exitRafael Zalamena2022-03-141-0/+5
| | | | | | | Let's clean up the valgrind output even more by calling the protobuf shutdown function that deallocates all library used memory. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
* Merge pull request #10741 from LabNConsulting/chopps/critfixgrpcDonald Sharp2022-03-071-50/+92
|\ | | | | critical fixes for grpc
| * lib: grpc: fix handling of "empty" yang typeChristian Hopps2022-03-061-5/+5
| | | | | | | | | | | | | | | | | | - rather than coerce `const char *` to std:string&, just pass the C ptr, as that's what is used anyway. fixes #10578 Signed-off-by: Christian Hopps <chopps@labn.net>
| * lib: grpc: fix shutdown codeChristian Hopps2022-03-061-39/+80
| | | | | | | | | | | | fixes #9732 Signed-off-by: Christian Hopps <chopps@labn.net>
| * lib: grpc: initialize uninitialized member variablesChristian Hopps2022-03-061-5/+4
| | | | | | | | | | | | fixes #9732, fixes #10578 Signed-off-by: Christian Hopps <chopps@labn.net>
| * lib: grpc: do not remove candidate entry too soonChristian Hopps2022-03-061-1/+1
| | | | | | | | | | | | Fix from Rafael Zalamena <rzalamena@opensourcerouting.org> Signed-off-by: Christian Hopps <chopps@labn.net>
| * lib: tweak northbound gRPC default timeoutRafael Zalamena2022-03-061-0/+2
| | | | | | | | | | | | | | | | | | | | | | Don't let open sockets hang for too long. This will fix an issue where a improperly coded client (e.g. socat) could exaust the amount of open file descriptors. Documentation: https://grpc.github.io/grpc/cpp/md_doc_keepalive.html Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
* | *: Change thread->func to return void instead of intDonald Sharp2022-02-241-5/+4
|/ | | | | | | The int return value is never used. Modify the code base to just return a void instead. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* lib: prevent gRPC assert on missing YANG nodeRafael Zalamena2021-10-051-0/+4
| | | | | | | | | | | | `yang_dnode_get` will `assert` if no YANG node/model exist, so lets test for its existence first before trying to access it. This `assert` is only acceptable for internal FRR usage otherwise we might miss typos or unmatching YANG models nodes/leaves. For gRPC usage we should let users attempt to use non existing models without `assert`ing. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
* lib: cleanup and stop grpc pthreadMark Stapp2021-06-151-12/+30
| | | | | | | At shutdown, try to stop the grpc module and its dedicated pthread cleanly. Signed-off-by: Mark Stapp <mjs@voltanet.io>
* lib: fix threading bug in GRPC codeChristian Hopps2021-06-011-1175/+1138
| | | | | | | | | | The code that actually calls FRR northbound functions needs to be running in the master thread. The previous code was running on a GRPC pthread. While fixing moved to more functional vs OOP to make this easier to see. Also fix ly merge to merge siblings not throw the originals away. Signed-off-by: Christian Hopps <chopps@labn.net>
* lib: libyang2 add missed conversionChristian Hopps2021-05-181-44/+56
| | | | Signed-off-by: Christian Hopps <chopps@labn.net>
* lib: adapt to version 2 of libyangChristian Hopps2021-05-131-1/+1
| | | | | | | | | Compile with v2.0.0 tag of `libyang2` branch of: https://github.com/CESNET/libyang staticd init load time of 10k routes now 6s vs ly1 time of 150s Signed-off-by: Christian Hopps <chopps@labn.net>
* build: make builddir include path consistentDavid Lamparter2021-04-211-1/+1
| | | | | | | ... by referencing all autogenerated headers relative to the root directory. (90% of the changes here is `version.h`.) Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* *: require semicolon after FRR_DAEMON_INFO & co.David Lamparter2021-03-171-1/+2
| | | | | | ... again ... Signed-off-by: David Lamparter <equinox@diac24.net>
* *: add errmsg to nb rpcChirag Shah2020-10-051-1/+2
| | | | | | | | | | | | | | | Display human readable error message in northbound rpc transaction failure. In case of vtysh nb client, the error message will be displayed to user. Testing: bharat# clear evpn dup-addr vni 1002 ip 11.11.11.11 Error type: generic error Error description: Requested IP's associated MAC aa:aa:aa:aa:aa:aa is still in duplicate state Signed-off-by: Chirag Shah <chirag@nvidia.com>
* Merge pull request #6945 from qlyoung/nb-more-messagesRenato Westphal2020-08-201-0/+11
|\ | | | | More gRPC logging + errmsg for no changes
| * lib: fill nb errmsg when no changes during prepQuentin Young2020-08-191-14/+6
| | | | | | | | | | | | | | During the prep phase to apply a northbound commit, if no changes were detected make sure we fill the error message buffer to explain this. Signed-off-by: Quentin Young <qlyoung@nvidia.com>
| * lib: add better zlogging to gRPC Commit RPCQuentin Young2020-08-181-0/+19
| | | | | | | | Signed-off-by: Quentin Young <qlyoung@nvidia.com>
* | lib: don't ignore error messages generated during the commit apply phaseRenato Westphal2020-08-151-3/+10
|/ | | | | | | | | | | | | | | | | | | | | While a configuration transaction can't be rejected once it reaches the APPLY phase, we should allow NB callbacks to generate error or warning messages when a configuration change is being applied. That should be useful, for example, to return warnings back to the user informing that the applied configuration has some kind of inconsistency or is missing something in order to be effectively activated. The infrastructure for this was already present, but the northbound layer was ignoring all errors/warnings generated during the apply/abort phases instead of returning them to the user. This commit changes that. In the gRPC plugin, extend the Commit() RPC adding a new "error_message" field to the response type. This is necessary to allow errors/warnings to be returned even when the commit operation succeeds (since grpc::Status::OK doesn't support error messages like the other status codes). Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* lib: fix issue were a few gRPC RPCs were being logged twiceRenato Westphal2020-05-291-15/+14
| | | | Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* lib: return human-readable error messages to the northbound clientsRenato Westphal2020-05-291-53/+36
| | | | | | | | | | Instead of returning only error codes (e.g. NB_ERR_VALIDATION) to the northbound clients, do better than that and also return a human-readable error message. This should make FRR more automation-friendly since operators won't need to dig into system logs to find out what went wrong in the case of an error. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* lib: introduce the northbound context structureRenato Westphal2020-05-291-4/+8
| | | | | | | | | | | | | | | | | | | | | | The new northbound context structure contains information about the client performing a configuration transaction. This information will be made available to all configuration callbacks through the args->context parameter. The usefulness of this structure comes from the fact that it can be used as a communication channel (both input and output) between the northbound callbacks and the northbound clients. This can be done through its "client_data" field which contains client-specific data. This should cover some very specific scenarios where a northbound callback should perform an action only if the configuration change is coming from a given client. An example would be sending a PCEP response to a PCE when an SR-TE policy is created or modified through the PCEP northbound client (for that to happen, the northbound callbacks need to have access to the PCEP request ID, which needs to be available). Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* lib: remove unnecessary rpc request in grpcQuentin Young2020-05-111-41/+18
| | | | | | Bit of leftover copypaste code there. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* lib: fix undue warning during gRPC module initializationRenato Westphal2020-05-091-0/+2
| | | | | | | This warning only shows up when a daemon is started with --log=stdout. Fix it. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* lib: convert GRPC plugin to asyncQuentin Young2020-05-081-423/+894
| | | | | | | | | Synchronous GRPC services are called from arbitrary threads. This makes access to anything outside the GRPC module unsafe. We need to convert the plugin to use the async model that allows us to control our own threads. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* lib: use frr_pthread to spawn grpc pthreadChirag Shah2020-05-081-4/+21
| | | | | | | | | | start grpc thread with frr_pthread library callbacks to integrate with rcu infrastructure. If a thread is created using native pthread callbacks and if zlog is used then it leads to crash. Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
* lib: create a wrapper function for all northbound callbacksRenato Westphal2020-04-231-1/+2
| | | | | | | | The intention here is to keep the code more organized. These wrappers should be used by the northbound clients only, and never directly by any YANG backend code. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* lib: defer grpc plugin initialization to post forkQuentin Young2020-03-301-5/+16
| | | | | | | | | | | | When using the GRPC northbound plugin, initialization occurs at the frr_late_init hook. This is called before fork() when daemonizing (using -d). Because the GRPC library internally creates threads, this means our threads go away in the child process, so GRPC doesn't work when used with -d. Rectify this situation by deferring plugin init to after fork by scheduling a task on the threadmaster, since those are executed by the child. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* lib: silence compiler warning in the gRPC pluginRenato Westphal2019-10-161-0/+5
| | | | Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* lib: fix gRPC northbound plugin buildQuentin Young2019-10-081-3/+2
| | | | | | | Some issues with our internal vector type being typedef'd as `vector`, which conflicts with the C++ standard vector class... Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* Revert "lib: introduce a read-write lock for northbound configurations"Renato Westphal2019-09-181-14/+5
| | | | | | | | | | | | | | | | | Adding a lock to protect the global running configuration doesn't help much since the FRR daemons are not prepared to process configuration changes in a pthread that is not the main one (a whole lot of new protections would be necessary to prevent race conditions). This means the lock added by commit 83981138 only adds more complexity for no benefit. Remove it now to simplify the code. All northbound clients, including the gRPC one, should either run in the main pthread or use synchronization primitives to process configuration transactions in the main pthread. This reverts commit 83981138fe8c1e0a40b8dede74eca65449dda5de.
* lib: add new gRPC-based northbound pluginRenato Westphal2019-04-261-0/+936
This is an experimental plugin for now. Full documentation will come later. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>