Commit graph

71 commits

Author SHA1 Message Date
Christian Hopps 94f70c2100 lib: mgmt_be_client handles datastore notification using CBs
Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-18 16:13:54 +00:00
Christian Hopps 5f2a927d7b lib: northbound/mgmtd: add backend model support
Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-14 18:48:59 +00:00
Christian Hopps c88b48929c lib: fix new (incorrect) CLANG SA warnings
Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-13 23:40:52 -05:00
Christian Hopps 255026c2ce mgmtd: add notify selectors to filter datastore notifications
- Additionally push the selectors down to the backends

Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-13 23:40:52 -05:00
Donald Sharp cc07a4a200
Merge pull request #17772 from LabNConsulting/chopps/fix-oper-walk
improve error handling of operational state walk callback
2025-01-07 13:52:37 -05:00
Christian Hopps 0ca710bb5f lib: add impl of NOTIF message ops (notif, replace, delete, patch)
- needed for supporting backend datastore notifications

Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-07 05:34:09 -05:00
Christian Hopps 9aa2b04874 lib: change and improve walk finish callback function API
Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-06 08:07:41 -05:00
Igor Ryzhov 830972cab2 lib: common debug status output
Implement common code for debug status 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 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
Christian Hopps e7fc74aa14 mgmtd: fix a couple compilation warnings.
Also an empty (thus non-replace) notify selectors message shouldn't
clear the selectors, it should just do nothing.

Signed-off-by: Christian Hopps <chopps@labn.net>
2024-08-18 05:33:29 -05:00
Igor Ryzhov 5c3e95d422 lib: add native RPC processing to mgmt backend client
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-04-22 16:36:22 +03:00
Igor Ryzhov 988d4444d4 mgmtd: fix a couple of log messages
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-03-22 16:35:52 +02:00
Christian Hopps 4a93d171c2 lib: mgmtd: add xpath arg to notification message
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-02-18 18:53:37 -05:00
Christian Hopps 1d4ea437e4 lib: always call new notification hooks too
- call the new notification hooks when backends call the old notification
posting API.

Signed-off-by: Christian Hopps <chopps@labn.net>
2024-02-15 13:03:25 -05:00
Igor Ryzhov 3ac3a6605d lib, mgmtd: rework processing of yang notifications
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-11 13:26:52 +02:00
Igor Ryzhov d94f80fbc4 lib, mgmtd: fix processing of yang notifications
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-10 01:00:24 +02:00
Christian Hopps 21f3b4e5c5 mgmtd: convert MGMTD_BE_CLIENT_DBG() to debug_be_client()
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-31 20:19:23 -05:00
Christian Hopps 1e884ba12f mgmtd: backend subscriptions to notifications
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-30 15:41:26 -05:00
Christian Hopps 25bb8b203c lib: mgmtd: add YANG notification support
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-30 04:57:10 -05:00
Igor Ryzhov 05948a4d98 lib: use shared candidate between vty and mgmtd client
When the daemon is partially mgmtd-converted, it receives configuration
from vty and mgmtmd simultaneosly. This configuration must be
synchronized.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-28 23:28:40 +02:00
David Lamparter 0d5a2497ca lib, mgmtd: fix wrong mgmtd socket paths
These paths were ignoring the `-N` namespacing option.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-01-27 19:01:19 +01:00
Christian Hopps 9e34d817fc lib: better conditionalize leaf-list predicate xpath addition
If we're in the backend we already have the predicate added by mgmtd -- don't
add it again.

Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-19 15:27:24 +00:00
Igor Ryzhov d726114790 mgmt, lib: implement REPLACE operation
Replace operation removes the current data node configuration and sets
the provided value. As current northbound code works only with one
xpath at a time, the operation only makes sense to clear the config of
a container without deleting it itself. However, the next step is to
allow passing JSON-encoded complex values to northbound operations which
will make replace operation much more useful.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-11 15:06:53 +02:00
Igor Ryzhov 3c2598a26f mgmt, lib: differentiate DELETE and REMOVE operations
Currently, there's a single operation type which doesn't return error
if the object doesn't exists. To be compatible with NETCONF/RESTCONF,
we should support differentiate between DELETE (fails when object
doesn't exist) and REMOVE (doesn't fail if the object doesn't exist).

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-11 15:06:53 +02:00
Igor Ryzhov 76e4eb84dd mgmtd, lib: implement CREATE_EXCL operation
Currently, there's no difference between CREATE and MODIFY operations.
To be compatible with NETCONF/RESTCONF, add new CREATE_EXCL operation
that throws an error if the configuration data already exists.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-11 15:06:53 +02:00
Christian Hopps 39e0f331d2 lib: mgmtd: increase soft-max msg size to 64K
- remove unused mgmt client/server constants

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-30 16:03:45 +00:00
Christian Hopps 4e0147a05e lib: add dedicated API functions for native msgs
- reorg native message header

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-28 17:53:40 +00:00
Christian Hopps ad1ccb6e62 lib: northbound: add yielding and batching to oper-state queries
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-28 17:52:57 +00:00
Christian Hopps 408ee24e41 lib: create and use libyang tree during oper-state walk
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-28 17:52:57 +00:00
Christian Hopps 9cd8693363 mgmtd: step 6: remove old unfinished get-data code
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-28 10:41:54 +00:00
Christian Hopps 4fee273e9c lib: step 2: mgmtd: BE client code for get-tree functionality
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-28 10:41:54 +00:00
Christian Hopps 29340e6b06 lib: fix the ASAN OneDefinitionRule violation.
Rename global client pointer variables and make the linkage static.

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-11 19:53:03 -05:00
Christian Hopps c37c19a9ec lib: mgmtd: enable conn debugs when user enables client debug
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-05 13:39:40 -05:00
Christian Hopps 79b7b8df1f
Merge pull request #14815 from idryzhov/lib-mgmt-deps
Remove lib dependency on mgmtd
2023-11-22 10:51:40 +01:00
Christian Hopps 94659cf9e5
Merge pull request #14657 from idryzhov/mgmtd-remove-batch-ids
mgmtd, lib: remove batch ids from all messages
2023-11-18 05:59:44 +01:00
Igor Ryzhov 057f442309 lib, mgmtd: remove function duplication
And also remove lib dependency on mgmtd.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-11-17 11:27:03 +01:00
Donald Sharp c62c0181f0
Merge pull request #14768 from idryzhov/mgmtd-base-xpath
lib, mgmtd: respect base xpath in mgmtd
2023-11-13 09:19:07 -05:00
Igor Ryzhov b8a2efbf2f lib, mgmtd: respect base xpath in mgmtd
`nb_cli_apply_changes` can be called with base xpath which should be
prepended to xpaths of every change in a transaction. This base xpath is
respected by regular northbound CLI but not by mgmtd. This commit fixes
the problem.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-11-12 20:28:08 +02:00
Igor Ryzhov b3b5951ee7 mgmtd, lib: remove batch ids from all messages
Batch IDs are only used to verify that all messages were received and
processed by a backend. It's not necessary to do that as we use reliable
stream transport - messages can't be dropped or received out of order.

This commit also fixes possible race condition that can happen if
one backend process messages slower than other backends.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-11-12 03:20:54 +02:00
Christian Hopps 59beac5013 lib: mgmtd: fix debug cli commands and memleaks
- Cannot have 2 cmd_node's with same .node number. Install the mgmtd
client library debug nodes (client frontend and client backend) using
new unique node numbers. Fixes memleaks.

- Fix "debug mgmt client backend" to generate correct config (and not
for frontend).

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-11-11 19:25:03 +01:00
Christian Hopps a65cda16b2 mgmtd: simplify xpath registries
- move from client id indexed array of uints for register info
  per client to a u64 bitmask.
- add bit walking FOREACH macro

Walk the client IDs whose bits are set in a mask.

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-11-06 17:44:58 -05:00
Igor Ryzhov d2977d57c8 mgmtd, lib: remove batch ids from cfg apply reply
The config is always applied fully, all batches are included. There's no
need to pass a list of applied batches as it always contains all of
them.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-10-17 15:06:13 +03:00
Christian Hopps 70fb3910db mgmtd: remove unused "placeholder" code.
We don't need un-run/un-tested placeholder code we may never need.

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-06-27 18:00:56 -04:00
Igor Ryzhov ea4c53412e
Merge pull request #13768 from LabNConsulting/chopps/mgmt-better-logs
mgmtd: improvements in logging and commentary
2023-06-13 22:43:11 +03:00
Igor Ryzhov 5aa4dc2313
Merge pull request #13764 from LabNConsulting/chopps/robust1
lib: mgmtd: make error handling more robust
2023-06-13 22:25:13 +03:00
Christian Hopps 96f9e7853b lib: mgmtd: improvements in logging and commentary
- log names of datastores not numbers
- improve logging for mgmt_msg_read
- Rather than use a bool, instead store the pending const string name of
the command being run that has postponed the CLI. This adds some nice
information to the logging when enabled.

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-06-13 04:11:29 -04:00
Christian Hopps d694cd40f2 lib: mgmtd: make error handling more robust
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-06-12 07:21:47 -04:00
Christian Hopps 79d40972fd lib: mgmtd: fix/stdize debug message macros
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-06-12 02:32:29 -04:00
Christian Hopps 7aecb8639c lib: mgmtd: remove abstraction layer and other cleanup
Code is no longer using a global FE "client context", and instead
creates client objects, rename the structure and it's uses to reflect this.

Remove an obfuscating abstraction layer whose existence was entirely
based on using a uintptr_t rather than a pointer to an declared-only struct.

Change multi-duty "params" structure into a single duty callbacks one.

Remove unsupported API code.

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-06-04 16:41:24 -04:00