Commit Graph

55 Commits

Author SHA1 Message Date
Donald Sharp
24a58196dd *: Convert event.h to frrevent.h
We should probably prevent any type of namespace collision
with something else.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp
cd9d053741 *: Convert struct event_master to struct event_loop
Let's find a better name for it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp
2453d15dbf *: Convert struct thread_master to struct event_master and it's ilk
Convert the `struct thread_master` to `struct event_master`
across the code base.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp
cb37cb336a *: Rename thread.[ch] to event.[ch]
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>
2023-03-24 08:32:16 -04:00
Christian Hopps
39c329bbd1 lib: staticd: vtysh: apply frrbot style requirements
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-03-22 05:22:56 +00:00
Yash Ranjan
74335ceb27 mgmtd: Add MGMT Transaction Framework
This commit introduces the MGMT Transaction framework that takes
management requests from one (or more) frontend client sessions,
translates them into transactions and drives them to completion
in co-oridination with one (or more) backend client daemons
involved in the request.

This commit includes the following functionalities in the changeset:
1. Introduces the actual Transaction module. Commands added related to
   transaction are:
   a. show mgmt transaction all
2. Adds support for commit rollback feature which stores upto the 10
   commit buffers. Each commit has a commit-id which can be used to
   rollback to the exact configuration state.
   Commands supported for this feature are:
   a. show mgmt commit-history
   b. mgmt rollback commit-id COMMIT_ID
3. Add hidden commands to enable record various performance metrics:
   a. mgmt performance-measurement
   b. mgmt reset-statistic

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>
2023-03-21 22:08:32 -04:00
Christian Hopps
7d65b7b7f4 mgmtd: Add MGMT Backend Interface Framework
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>
2023-03-21 22:08:32 -04:00
Christian Hopps
ef43a6329b mgmtd: Add MGMT Frontend Interface Framework
This commit introduces the Frontend Interface which can be used
by front-end management clients like Netconf server, Restconf
Server and CLI to interact with new FRR Management daemon (MGMTd)
to access and sometimes modify FRR management data.

This commit includes the following functionalities in the changeset:
1. Add new Frontend server for clients connect to.
2. Add a C-based Frontend client library which can be used by Frontend
   clients to communicate with MGMTd via the Frontend interface.
3. Maintain a frontend adapter for each connection from an appropriate
   Frontend client to facilitate client requests and track one or more
   client sessions across it.
4. Define the protobuf message format for messages to be exchanged
   between MGMTd Frontend module and the Frontend client.
5. This changeset also introduces an instance of MGMT Frontend client
   embedded within the lib/vty module that can be leveraged by any FRR
   daemon to connect to MGMTd's Frontend interface. The same has been
   integrated with and initialized within the MGMTd daemon's process
   context to implement a bunch of 'set-config', 'commit-apply',
   'get-config' and 'get-data' commands via VTYSH

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>
2023-03-21 22:08:32 -04:00
Christian Hopps
1c84efe4fa mgmtd: Bringup MGMTD daemon and datastore module support
Features added in this commit:
1. Bringup/shutdown new management daemon 'mgmtd' along with FRR.
2. Support for Startup, Candidate and Running DBs.
3. Lock/Unlock DS feature using pthread lock.
4. Load config from a JSON file onto candidate DS.
5. Save config to a JSON file from running/candidate DS.
6. Dump candidate or running DS contents on the terminal or a file in
   JSON/XML format.
7. Maintaining commit history (Full rollback support to be added in
   future commits).
8. Addition of debug commands.

Co-authored-by: Yash Ranjan <ranjany@vmware.com>
Co-authored-by: Abhinay Ramesh <rabhinay@vmware.com>
Co-authored-by: Ujwal P <ujwalp@vmware.com>
Signed-off-by: Pushpasis Sarkar <pushpasis@gmail.com>
2023-03-21 22:08:32 -04:00
Christian Hopps
41ef7327e3 lib: fix init. use of nb_context to be by value not by reference
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>
2023-02-23 20:59:17 -05:00
David Lamparter
acddc0ed3c *: auto-convert to SPDX License IDs
Done with a combination of regex'ing and banging my head against a wall.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-02-09 14:09:11 +01:00
Igor Ryzhov
2560505196 lib: northbound cli show/cmd functions must not modify data nodes
To ensure this, add a const modifier to functions' arguments. Would be
great do this initially and avoid this large code change, but better
late than never.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-10-13 20:12:35 +03:00
Christian Hopps
fd396924d6 northbound: KISS always batch yang config (file read), it's faster
The backoff code assumed that yang operations always completed quickly.
It checked for > 100 YANG modeled commands happening in under 1 second
to enable batching. If 100 yang modeled commands always take longer than
1 second batching is never enabled. This is the exact opposite of what
we want to happen since batching speeds the operations up.

Here are the results for libyang2 code without and with batching.

| action        |  1K rts |  2K rts | 1K rts | 2K rts | 20k rts |
|               | nobatch | nobatch |  batch |  batch |   batch |
| Add IPv4      |    .881 |    1.28 |   .703 |   1.04 |    8.16 |
| Add Same IPv4 |    28.7 |     113 |   .590 |   .860 |    6.09 |
| Rem 1/2 IPv4  |    .376 |    .442 |   .379 |   .435 |    1.44 |
| Add Same IPv4 |    28.7 |     113 |   .576 |   .841 |    6.02 |
| Rem All IPv4  |    17.4 |    71.8 |   .559 |   .813 |    5.57 |

(IPv6 numbers are basically the same as iPv4, a couple percent slower)

Clearly we need this. Please note the growth (1K to 2K) w/o batching is
non-linear and 100 times slower than batched.

Notes on code: The use of the new `nb_cli_apply_changes_clear_pending`
is to commit any pending changes (including the current one). This is
done when the code would not correctly handle a single diff that
included the current changes with possible following changes. For
example, a "no" command followed by a new value to replace it would be
merged into a change, and the code would not deal well with that. A good
example of this is BGP neighbor peer-group changing. The other use is
after entering a router level (e.g., "router bgp") where the follow-on
command handlers expect that router object to now exists. The code
eventually needs to be cleaned up to not fail in these cases, but that
is for future NB cleanup.

Signed-off-by: Christian Hopps <chopps@labn.net>
2021-06-02 14:05:26 +00:00
Christian Hopps
3bb513c399 lib: adapt to version 2 of libyang
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>
2021-05-13 16:24:48 -04:00
Igor Ryzhov
c6f1f711bf lib: add ability to sort CLI commands printed by NB layer
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-03-23 16:24:40 +03:00
David Lamparter
8451921b70 *: require semicolon after DEFINE_HOOK & co.
See previous commit.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-17 06:18:17 +01:00
Igor Ryzhov
f182d8d8a2 lib: add ability to register dependencies between northbound nodes
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-02-22 18:53:24 +03:00
Chirag Shah
f4eac84c5a yang: nbr plist nb conversion for more afi-safis
Signed-off-by: Chirag Shah <chirag@nvidia.com>
2021-01-09 23:06:02 -08:00
Sebastien Merle
efba0985fc pathd: Add optional support for PCEP to pathd
This new dynamic module makes pathd behave as a PCC for dynamic candidate path
using the external library pcpelib https://github.com/volta-networks/pceplib .

The candidate paths defined as dynamic will trigger computation requests to the
configured PCE, and the PCE response will be used to update the policy.

It supports multiple PCE. The one with smaller precedence will be elected
as the master PCE, and only if the connection repeatedly fails, the PCC will
switch to another PCE.

Example of configuration:

segment-routing
 traffic-eng
  pcep
   pce-config CONF
    source-address ip 10.10.10.10
    sr-draft07
   !
   pce PCE1
    config CONF
    address ip 1.1.1.1
   !
   pce PCE2
    config CONF
    address ip 2.2.2.2
   !
   pcc
    peer PCE1 precedence 10
    peer PCE2 precedence 20
   !
  !
 !
!

Co-authored-by: Brady Johnson <brady@voltanet.io>
Co-authored-by: Emanuele Di Pascale <emanuele@voltanet.io>
Co-authored-by: GalaxyGorilla <sascha@netdef.org>
Co-authored-by: Javier Garcia <javier.garcia@voltanet.io>
Co-authored-by: Renato Westphal <renato@opensourcerouting.org>
Co-authored-by: Sebastien Merle <sebastien@netdef.org>
Signed-off-by: Sebastien Merle <sebastien@netdef.org>
2020-12-18 16:47:52 +01:00
Renato Westphal
59e85ca1ba lib: add API to load YANG modules on demand
Make it possible to load YANG modules outside the main northbound
initialization. The primary use case is to support YANG modules
that are specific to an FRR plugin. Example: only load the PCEP
YANG module when the corresponding FRR plugin is loaded. Other use
cases might arise in the future.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-10-23 18:18:22 -03:00
Chirag Shah
f63f5f1947 *: add errmsg to nb rpc
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>
2020-10-05 13:15:59 -07:00
Chirag Shah
a363b4b49b lib: increase the size of northbound max module
Increase the size of frr_yang_module_info
macro to accomodate bgp module list.

root@bharat:~/stash/frr# egrep "xpath" bgpd/bgp_nb.c | wc -l
1150

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2020-10-03 11:25:37 -07:00
Chirag Shah
390a886277 *: record transaction based on control flag
In case of config rollback is enabled,
record northbound transaction based on a control flag.
The actual frr daemons would set the flag to true via
nb_init from frr_init.
This will allow test daemon to bypass recording
transacation to db.

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2020-08-20 14:12:04 -07:00
Renato Westphal
0fe5b904b7 lib: don't ignore error messages generated during the commit apply phase
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>
2020-08-14 21:37:14 -03:00
GalaxyGorilla
b112b1abb4 lib: add possibility to search non-recursively for NB node entries
Signed-off-by: GalaxyGorilla <sascha@netdef.org>
2020-08-07 11:08:49 +02:00
Santosh P K
57dd2f0097
Merge pull request #6414 from opensourcerouting/nb-error-handling
NB context + enhanced error handling
2020-06-10 22:47:07 +05:30
Quentin Young
f7c20aa1fd lib: move all userdata when changing node xpath
All userdata pointers need to be rekeyed to their new xpaths, not just
the one associated with the dnode being moved.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-06-04 20:24:52 -04:00
Renato Westphal
1abe6c535e lib: detect and log unexpected return values from northbound callbacks
Each northbound callback has a set of valid return values, some of
which might depend on the transaction phase. The valid return values
for each callback are documented in the northbound main header.

Add some code to detect when a callback returns an unexpected value
and log the occurrence. This should help us to identify and fix
such problems.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-05-28 19:22:54 -03:00
Renato Westphal
df5eda3d87 lib: return human-readable error messages to the northbound clients
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>
2020-05-28 19:22:54 -03:00
Renato Westphal
13d6b9c134 lib: introduce the northbound context structure
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>
2020-05-28 19:22:54 -03:00
Renato Westphal
1be4decb04 lib: northbound style fixes
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-05-28 19:22:53 -03:00
Renato Westphal
60ee8be107 *: change the signature of the northbound callbacks to be more flexible
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-23 10:14:32 -03:00
Renato Westphal
dc397e4c0a lib: consolidate flexible array hack in a single place
Old gcc versions (< 5.x) have a bug that prevents C99 flexible
arrays from working properly on shared libraries.

We already have a hack in place to work around this problem, but it
needs to be replicated in every declaration of a frr_yang_module_info
variable within libfrr. This clearly isn't a good solution if we
consider that many more libfrr YANG modules are about to come in
the future.

This commit introduces a different workaround that operates within
the northbound layer itself, such that implementers of libfrr YANG
modules won't need to worry about this problem anymore.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-04-03 22:34:55 -03:00
David Lamparter
0d8c7a26a1 *: make frr_yang_module_info const
Signed-off-by: David Lamparter <equinox@diac24.net>
2019-11-30 00:38:32 +01:00
Renato Westphal
0de19c0e0a lib: reduce memory allocation when processing large config transactions
Remove the xpath field from the nb_config_cb structure in order
to reduce its size. This allows the northbound to spend less time
allocating memory during the processing of large configuration
transactions.

To make this work, use yang_dnode_get_path() to obtain the xpath
from the dnode field whenever necessary.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-10-11 21:18:36 -03:00
Renato Westphal
6b5d6e2dbc lib: fix ordering issues in the northbound
When a configuration transaction is being performed, the northbound
uses a red-black tree to store the configuration changes that need to
be processed. The problem is that we were sorting the configuration
changes based on their XPaths (and callback priorities). This means
the original order of the changes wasn't being respected, which is
a problem for lists that use the "ordered-by user" statement. To
fix this, add a new "seq" member to the "nb_config_cb" structure
so that we can preserve the order of the configuration changes as
told by libyang.

Since none of the FRR modules use "ordered-by user" lists so far,
no daemon was affected by this problem.

Reported-by: Martin Winter <mwinter@opensourcerouting.org>
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-09-18 14:35:10 -03:00
Renato Westphal
8685be73e0 Revert "lib: introduce a read-write lock for northbound configurations"
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 83981138fe.
2019-09-18 14:35:10 -03:00
Renato Westphal
34224f0c5c lib: introduce new 'pre_validate' northbound callback
This callback can be used to validate subsections of the
configuration being committed before validating the configuration
changes themselves. It's useful to perform more complex validations
that depend on the relationship between multiple nodes.

Only YANG-level validation (performed by libyang) and the
NB_EV_VALIDATE validation (that can be used to validate individual
configuration changes) proved to be insufficient in some cases.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-09-18 13:38:28 -03:00
Renato Westphal
681b22affa lib: fix doc comment of the "cli_show_end" northbound callback
The 'show_defaults' parameter is present on the "cli_show" callback
only.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-08-21 00:53:00 -03:00
Rafael Zalamena
a4d3c1d41d lib: northbound cli support to end config nodes
Some more complex CLI usages will require northbound to support
signalizing a custom configuration node end.

For an example:

```
router bgp 100
 bgp router-id 10.254.254.1
 neighbor 10.0.0.100 remote-as 200
 !
 address-family ipv4 unicast
  network 10.0.1.0/24
  network 10.0.2.0/24
  network 10.0.3.0/24
 exit-address-family
 !
 address-family ipv6 unicast
  neighbor 10.0.0.100 activate
 exit-address-family
!
```

This commit implements a new callback called `cli_show_end` which
complements `cli_show` and is only called at the end of processing the
yang configuration node. It will be used to write the configuration
node termination like: "!" or "exit-address-family".

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-06-22 10:08:33 -03:00
Renato Westphal
ec2ac5f28a lib: add new gRPC-based northbound plugin
This is an experimental plugin for now. Full documentation will
come later.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-04-26 18:15:32 -03:00
Renato Westphal
83981138fe lib: introduce a read-write lock for northbound configurations
The upcoming gRPC-based northbound plugin will run on a separate
pthread, and it will need to have access to the running configuration
global variable.  Introduce a rw-lock to control concurrent access
to the running configuration. Add the lock inside the "nb_config"
structure so that it can be used to protect candidate configurations
as well (this might be necessary depending on the threading scheme
of future northbound plugins).

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-04-26 18:04:22 -03:00
Renato Westphal
364ad673c8 lib: add API to allow northbound clients to lock/unlock the running configuration
The ability to lock the running configuration to prevent other users
from changing it is a very important one. We already supported
the "configure exclusive" command but the lock was applied to
the CLI users only (other clients like ConfD could still commit
configuration transactions, ignoring the CLI lock). This commit
introduces a global lock for the running configuration that is
shared by all northbound clients, and provides a public API to
manipulate it. This way other northbound clients will also be able
to lock/unlock the running configuration if required (the upcoming
gRPC northbound plugin will have RPCs for that).

NOTE: this is a management-level lock for the running configuration,
not to be confused with low-level locks used to avoid data races.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-04-26 18:04:22 -03:00
Renato Westphal
ccd43ada17 lib: rework management of user pointers in the northbound layer
Introduce a hash table to keep track of user pointers associated
to configuration entries. The previous strategy was to embed
the user pointers inside libyang data nodes, but this solution
incurred a substantial performance overhead. The user pointers
embedded in candidate configurations could be lost while the
configuration was being edited, so they needed to be regenerated
before the candidate could be committed.  This was done by the
nb_candidate_restore_priv_pointers() function, which was extremely
expensive for large configurations. The new hash table solves this
performance problem.

The yang_dnode_[gs]et_entry() functions were renamed and moved from
yang.[ch] to northbound.[ch], which is a more appropriate place
for them. This patch also introduces the nb_running_unset_entry()
function, the counterpart of nb_running_set_entry() (unsetting
user pointers was done automatically before, now it needs to be
done manually).

As a consequence of these changes, we shouldn't need support for
libyang private pointers anymore (-DENABLE_LYD_PRIV=ON). But it's
probably a good idea to keep requiring this feature as we might
need it in the future for other things (e.g. disable configuration
settings without removing them).

Fixes #4136.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-04-18 11:56:45 -03:00
Renato Westphal
9eb2c0a1dc lib: add fine-grained debugging in the northbound
Split the "debug northbound" command into the following commands:
* debug northbound callbacks configuration
* debug northbound callbacks state
* debug northbound callbacks rpc
* debug northbound notifications
* debug northbound events
* debug northbound client confd
* debug northbound client sysrepo

If "debug northbound" is entered alone, all of its suboptions
are enabled.

This commit also adds code to debug state/rpc callbacks and
notifications (only configuration callbacks were logged before).

Use the debugging infrastructure from "lib/debug.h" in order to
benefit from its facilities (e.g. MT-safe debugging) and avoid
code duplication.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-04-15 15:59:38 -03:00
Renato Westphal
5e2444690b lib: add extern "C" {} blocks to all libfrr headers
These are necessary to use functions defined in these headers from C++.

Signed-off-by: David Lamparter <equinox@diac24.net>
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-02-11 22:34:12 -02:00
Mark Stapp
95ce849b58 libs, rip, isis: change northbound operation enum to DESTROY
Change the northbound lib operation from DELETE to DESTROY;
make the required changes in the users of the northbound, in
the cli, rip, ripng, and isis.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-02-11 15:49:49 -02:00
Mark Stapp
d01b92fd75 libs, daemons: changes to permit c++ compilation
Some misc changes to resolve some c++ compilation errors.
The goal is only to permit an external module - a plugin,
for example - to see frr headers, not to support or encourage
contributions in c++. The changes include: avoiding use
of keywords like 'new', 'delete'; cleaning up implicit
type-casting from 'void *' in several places.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-02-11 15:49:49 -02:00
Renato Westphal
99fb518fef lib, tests: add support for keyless YANG lists
YANG allows lists without keys for operational data, in which case
the list elements are uniquely identified using a positional index
(starting from one).

This commit does the following:
* Remove the need to implement the 'get_keys' and 'lookup_entry'
  callbacks for keyless lists.
* Extend nb_oper_data_iter_list() so that it special-cases keyless
  lists appropriately. Since both the CLI and the sysrepo plugin
  use nb_oper_data_iterate() to fetch operational data, both these
  northbound clients automatically gain the ability to understand
  keyless lists without additional changes.
* Extend the confd plugin to special-case keyless lists as well. This
  was a bit painful to implement given ConfD's clumsy API, but
  keyless lists should work ok now.
* Update the "test_oper_data" unit test to test keyless YANG lists in
  addition to regular lists.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-12-09 13:58:53 -02:00
Renato Westphal
fbdc1c0a84 lib: add support for confirmed commits
Confirmed commits allow the user to request an automatic rollback to
the previous configuration if the commit operation is not confirmed
within a number of minutes. This is particularly useful when the user
is accessing the CLI through the network (e.g. using SSH) and any
configuration change might cause an unexpected loss of connectivity
between the user and the managed device (e.g. misconfiguration of a
routing protocol). By using a confirmed commit, the user can rest
assured the connectivity will be restored after the given timeout
expires, avoiding the need to access the router physically to fix
the problem.

When "commit confirmed TIMEOUT" is used, a new "commit" command is
expected to confirm the previous commit before the given timeout
expires. If "commit confirmed TIMEOUT" is used while there's already
a confirmed-commit in progress, the confirmed-commit timeout is
reset to the new value.

In the current implementation, if other users perform commits while
there's a confirmed-commit in progress, all commits are rolled back
when the confirmed-commit timeout expires. It's recommended to use
the "configure exclusive" configuration mode to prevent unexpected
outcomes when using confirmed commits.

When an user exits from the configuration mode while there's a
confirmed-commit in progress, the commit is automatically rolled
back and the user is notified about it. In the future we might
want to prompt the user if he or she really wants to exit from the
configuration mode when there's a pending confirmed commit.

Needless to say, confirmed commit only work for configuration
commands converted to the new northbound model. vtysh support will
be implemented at a later time.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-12-07 11:11:33 -02:00