Commit graph

249 commits

Author SHA1 Message Date
Igor Ryzhov 771c8f3b2a mgmtd: cleanup txn without scheduling
If the transaction is not cleaned up immediately, it can be still
referenced by some threds. If it's a commit thread and it's executed
before the actual cleanup, mgmtd crashes because of the missing
commit_cfg_req.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-26 12:34:46 -05:00
Igor Ryzhov 7e27469337 mgmtd: fix log type
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-26 12:34:46 -05:00
Igor Ryzhov 42b815f488 mgmtd: fix sending the same value to multiple clients
The value should not be cleared after sending it to the first client,
otherwise other clients receive an empty string.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-26 12:34:46 -05:00
Christian Hopps 63ca751c11 lib: convert filters to mgmtd
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-26 12:34:23 -05:00
Christian Hopps dabc92de9e lib: convert route-map to mgmtd
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-26 12:34:23 -05:00
Igor Ryzhov ed57daf60a mgmtd: remove unguarded debug log
The log doesn't provide any valuable information, so removing it instead
of adding a check.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-23 12:36:22 +02:00
Christian Hopps fa7ff16e2b mgmtd: remove heavy duplication in mgmtd config read
Previously each container created all it's decendents before descending into
the children and repeating the process.

Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-19 15:27:24 +00: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 9859f308d2 lib, mgmtd: add ability to request the exact node in get-data request
RESTCONF expects to receive the exact node as a result, not the whole
data tree.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-15 10:27:33 +02:00
Igor Ryzhov e1cdb38ee6 lib, mgmtd: add ability to set content type in get-data request
Like in RESTCONF GET request and NETCONF get-data request, make it
possible to request state-only, config-only, or all data.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-15 10:27:33 +02:00
Igor Ryzhov 25d79af957 lib, mgmtd: add separate get-data request for the frontend
Currently it's the same as get-tree request for the backend, but it is
going to be expanded in the following commits.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-14 20:00:22 +02:00
Igor Ryzhov 88275d392a vtysh, mgmtd: send interface commands to mgmtd
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-14 20:00:22 +02:00
Igor Ryzhov b507ad54b4 mgmtd: add option to specify netns as the vrf backend
mgmtd has to know if netns is used as the vrf backend to correctly
process interface names in northbound.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-14 20:00:22 +02:00
Christian Hopps d9d5f79610
Merge pull request #15151 from idryzhov/mgmtd-vrf
mgmtd: remove full vrf initialization
2024-01-14 12:04:46 -05:00
Donald Sharp ef0ae6e815
Merge pull request #15152 from LabNConsulting/chopps/doc-mgmtd-convert-update
doc: mgmtd: update mgmtd conversion doc to be current.
2024-01-13 20:46:36 -05:00
Donatas Abraitis fd690b9bc4
Merge pull request #15135 from idryzhov/mgmt-unused
mgmtd: remove unused/redundant variables
2024-01-13 21:08:24 +02:00
Christian Hopps a9dc7e9cc0
doc: mgmtd: update mgmtd conversion doc to be current.
Also change `be_client_xpaths` to `be_client_config_xpaths` referred in the doc
to make much clearer it's use (since there's a separate `be_client_oper_xpaths`.

Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-13 14:26:55 +00:00
Igor Ryzhov fe55bb15be mgmtd: remove full vrf initialization
We don't really need full VRF infrastructure in mgmtd. We only need to
register vty commands.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-13 15:51:59 +02:00
Donatas Abraitis d2c275a793
Merge pull request #15133 from LabNConsulting/chopps/coverity-fixes
lib: fix coverity issues
2024-01-12 16:06:26 +02:00
Igor Ryzhov 64d9f2f70d mgmtd: remove redundant next_phase variable
next_phase is always curr_phase + 1. It's not necessary to maintain it
separately. Also rename curr_phase to phase.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-12 13:29:15 +02:00
Christian Hopps 20d0d475cb
Merge pull request #14542 from idryzhov/nb-op-cb-split
Add more northbound operation types
2024-01-12 06:07:57 -05:00
Donatas Abraitis 0f5a79af96
Merge pull request #15136 from idryzhov/ignore-cbs
lib, mgmtd: rename ignore_cbs to ignore_cfg_cbs
2024-01-12 11:56:59 +02:00
Igor Ryzhov 34721972ba lib, mgmtd: rename ignore_cbs to ignore_cfg_cbs
Setting this variable to true makes NB ignore only configuration-related
callbacks. CLI-related callbacks are still loaded and executed, so
rename the variable to make it clearer.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-11 23:47:48 +02:00
Igor Ryzhov 2148f70b1a mgmtd: remove unused pending_be_proc variable
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-11 23:08:01 +02:00
Igor Ryzhov 0eac9b6f07 mgmtd: don't try to send config to disconnected clients
When determining the interested backend clients for a configuration
change, don't consider disconnected clients. This fixes a crash in
`mgmt_txn_send_be_txn_create` when trying to send data to a non-existing
adapter.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-11 22:56:42 +02:00
Christian Hopps 29f2a300a3 lib: fix coverity issues
** CID 1575504:  Insecure data handling  (TAINTED_SCALAR) (maybe)
** CID 1575505:  Integer handling issues  (CONSTANT_EXPRESSION_RESULT)
** CID 1575506:  Integer handling issues  (CONSTANT_EXPRESSION_RESULT)
** CID 1575507:  Null pointer dereferences  (REVERSE_INULL)

Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-11 18:14:58 +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
Igor Ryzhov 5d1a314038 lib: split nb_operation into two types
Currently, nb_operation enum means two different things - edit operation
type (frontend part), and callback type (backend part). These types
overlap, but they are not identical. We need to add more operation
types to support NETCONF/RESTCONF integration, so it's better to have
separate enums to identify different entities.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-11 15:06:50 +02:00
Christian Hopps 1e4229fc1f lib: use libyang functions if they are present
Add configure.ac tests for libyang functions, if not present supply the
functionality ourselves in yang.[ch]

Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-07 15:17:56 +00:00
Christian Hopps cf67a7e265 lib: mgmtd: implement full XPath 1.0 predicate functionality
Allow user to specify full YANG compatible XPath 1.0 predicates. This
allows for trimming results of generic queries using functions and other
non-key predicates from XPath 1.0

Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-07 15:17:30 +00:00
Christian Hopps 00138ffb47 lib: fix clang SA warnings
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-07 15:04:18 +00: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 30e63f2900 mgmtd: fix coverity CID 1574980
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-30 16:03:45 +00:00
Christian Hopps 913892e2ad mgmtd: fix coverity CID 1574978
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-30 16:03:45 +00:00
Christian Hopps b8b5290105 lib: fixes required after rebasing
lib: fix checkpatch warnings
lib: darr: disable check
mgmtd: fix initialization

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-28 18:17:24 +00:00
Christian Hopps ef91d34f01 zebra: add zebra to mgmtd oper-state
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-28 17:53:40 +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 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 8df542b219 mgmtd: step 5: add get-tree txn functionality
Adds the guts of the get-tree functionality that is called by or calls
the FE and BE code for get-tree processing.

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-28 10:41:54 +00:00
Christian Hopps be2424a875 mgmtd: step 4: FE adapter get-tree functionality
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-28 10:41:54 +00:00
Christian Hopps 33b9c2ef00 mgmtd: step 3: BE adapter native message handling
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-28 10:41:54 +00:00
Christian Hopps 772f6c07c7 lib: step 1: mgmtd: add FE get-tree functionality
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-28 10:41:54 +00:00
Christian Hopps 71ede2db9e mgmtd: enable conn debug when user enables mgmtd debugs
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-05 13:39:40 -05:00
Igor Ryzhov c81776c8e9 mgmtd: validate candidate yang tree before creating a config diff
The candidate yang tree should be validated before `nb_config_diff` is
called. `nb_config_diff` ignores all prohibited operations and can
provide an empty change list because of this. For example, if a user
deletes a mandatory node from the candidate datastore and tries to make
a commit, they'll receive the "No changes found to be committed!" error,
because such a change is ignored by `nb_config_diff`. Instead, mgmtd
should tell the user that their candidate datastore is not valid and
can't be commited.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-11-30 03:10:09 +02:00
Christian Hopps e7064647b9
Merge pull request #14838 from idryzhov/mgmtd-cli-out
Output configuration of mgmtd-converted daemons from mgmtd
2023-11-29 14:50:16 +01:00
Donatas Abraitis 27be058232
Merge pull request #14858 from idryzhov/mgmtd-error-msg
mgmtd: fix reply when running ds is not locked
2023-11-23 08:09:45 +02: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
Igor Ryzhov 354b3c4328 mgmtd: fix reply when running ds is not locked
At this stage, we should send a SET_CFG reply, not COMMIT_CFG reply.
Commit request is not yet initialized.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-11-21 23:18:40 +02:00
Igor Ryzhov d532771eaa mgmtd, staticd: output staticd configuration from mgmtd
As mgmtd now implements vty for staticd, it's logical to output the
configuration from there as well. Fully-converted backend daemons should
not handle vty commands at all.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-11-21 13:28:40 +02:00
Igor Ryzhov a22f5a5289 mgmtd: add node for writing configuration
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-11-21 13:13:05 +02: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
Igor Ryzhov c0568d4f9e lib, mgmtd: move common header to lib
The common header included from lib and other daemons should be located
in lib, not in mgmt directory.

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 222e5db657 mgmtd: get rid of unused init value to fix coverity warning
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-11-09 04:14:06 -05:00
Igor Ryzhov 448f75e56d
Merge pull request #14525 from LabNConsulting/chopps/mgmtd-simplify-xpaths
chopps/mgmtd simplify xpaths
2023-11-08 16:30:46 +02:00
Donald Sharp 85a80ba5aa
Merge pull request #14544 from idryzhov/mgmt-scratch-buffer
mgmt: delete candidate scratch buffer
2023-11-08 09:18:27 -05:00
Igor Ryzhov b0ce306457 mgmtd: fix local validation
When validating the config, we shouldn't also validate state.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-11-07 03:41:31 +02: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 f560807158 mgmtd: clarify the startup dance in comments
Also retry the config read vs. aborting if we haven't got a FE
client connection yet.

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-10-12 14:38:39 -04:00
Donatas Abraitis eeda9b8ae8 mgmtd: Change MGMTD_VTY_PORT to 2623
This is clashing with PIMv6 (2622).

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-10-11 13:27:28 +03:00
Igor Ryzhov a962f2949f mgmt: delete candidate scratch buffer
The code doesn't work at all. It tries to use libyang operation
metadata in a regular (not diff) data tree, and regular data trees
don't provide this data. Also, for destroy operations, it searches
for nodes in the running config, which may not have the deleted nodes
if we're not using implicit commits.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-10-06 21:18:33 +03:00
Igor Ryzhov 7a8b1875c5 mgmtd: fix crash on "show mgmtd datastore-contents"
When the command is called without specifying the datastore, it crashes.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-09-27 13:22:01 +03:00
Christian Hopps 76835fd558 lib: mgmtd: only clear pending for the in-progress command
The lock/unlocks are being done short-circuit so they are never pending;
however, the handling of the unlock notification was always resuming the command
if pending was set. In all cases pending is set for another command. For example
implicit commit locks then when notified its done unlocks which was clearing the
set-config pending flag and resuming that command incorrectly.

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-07-14 18:24:30 -04:00
anlan_cs c826c838d4 mgmtd: adjust one unnecessary bool convert
It is unnecessary to do the bool calculation for expression.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2023-07-12 17:29:28 +08:00
Christian Hopps 5447d16b73 mgmtd: convert map to darr use allowing dynamic registrations
- move from the static allocated and initialize xpath map to using the
new darr (dynamic array) code.

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-06-27 18:00:56 -04: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
Christian Hopps dbb1bc6f35 mgmtd: consolidate getcfg and getdata msgs into "get"
eliminates tons of copy and paste code.

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-06-27 18:00:56 -04:00
Christian Hopps 6267c2aaad mgmtd: inclusive language change
'cfg_btch' -> 'batch' and 'btch_list' -> 'batch_list'

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-06-27 14:03:00 -04:00
Christian Hopps 459848ded7 mgmtd: fix memleak
Use northbound functions for replace and merge when possible, rather
than duplicating the code.

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-06-19 00:13:28 -04:00
Christian Hopps df0173ceeb mgmtd: KISS the locking code
Move away from things like "lock if not locked" type code, require the
user has locked prior to geting to that point.

For now we warn if we are taking a lock we already had; however, this
should really be a failure point.

New requirements:

SETCFG -
  not implicit commit - requires user has locked candidate DS and they
    must unlock after

  implicit commit - requires user has locked candidate and running DS
    both locks will be unlocked on reply to the SETCFG

COMMITCFG -
  requires user has locked candidate and running DS and they must unlock
  after

  rollback - this code now get both locks and then does an unlock and
  early return thing on the adapter side. It needs to be un-special
  cased in follow up work that would also include tests for this
  functionality.

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-06-19 00:13:28 -04:00
Christian Hopps 04b4ede097 mgmtd: simplify locking, removing read locks
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-06-18 16:17:46 -04:00
Christian Hopps f8500d4849 lib: mgmtd: use short-circuit for locking
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-06-18 16:17:32 -04:00
Igor Ryzhov 2b21ec2c49
Merge pull request #13766 from LabNConsulting/chopps/mgmtd-cleanup
mgmtd cleanup/simplify some code
2023-06-13 22:50:39 +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 c9d153e5e9 mgmtd: complex redux in txn cleanup
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-06-12 07:23:54 -04:00
Christian Hopps 70ff6bb80b lib: mgmtd: simplify implicit commit code
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-06-12 07:22:30 -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 f0fa4c0370 mgmtd: remove unused code
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-06-12 02:32:29 -04:00
Christian Hopps 565139a6d5 mgmtd: assert an assertion for coverity
I believe coverity can't tell the length of the return value from strftime based
on the format string (like we can), so it allows `n` to be larger than it could
be which then allows `sz - n` to be negative which is size_t positive and very
large so it thinks an overrun is possible.

CID#1563211

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-06-06 15:12:58 -04:00
Donald Sharp da877b5ced
Merge pull request #13690 from LabNConsulting/chopps/mgmtd-cleanup
Chopps/mgmtd cleanup
2023-06-06 07:22:31 -04:00
Christian Hopps c6b8e95703 mgmtd: rm unused/unneeded code add couple comments
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-06-05 15:29:05 -04:00
Donald Sharp 60dc2992c9 mgmtd: Fix up some coverity issues
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-06-05 07:57:49 -04:00
Donald Sharp af001e29f9 mgmtd: xpath is already NULL in the failure path
There is no way that xpath can ever be anything but NULL
in the failure path with the goto's.  Let's just remove
the goto's and return immediately.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-05-31 07:54:10 -04:00
Donald Sharp 7470509390
Merge pull request #13632 from LabNConsulting/chopps/mgmt-avoid-race
mgmtd: fix possible race btw read config and backend connection
2023-05-31 07:28:50 -04:00
Christian Hopps 3744ad02d9 mgmtd: fix possible race btw read config and backend connection
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-05-30 11:52:19 -04:00
Donald Sharp 9be555f8d4
Merge pull request #13601 from opensourcerouting/build-yang-embed-20230525
build: fix missing YANG model embedding
2023-05-30 11:34:29 -04:00
Christian Hopps 51941c1916 mgmtd: address review comments
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-05-30 02:10:20 -04:00
Christian Hopps 0327be91d1 mgmtd: cleanup BE xpath subscription and matching code
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-05-30 02:10:20 -04:00
Christian Hopps 52a50ca1d7 lib: mgmtd: fix memleaks
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-05-30 02:10:20 -04:00
Christian Hopps 5ba5613077 lib: mgmtd: add manual vty server start option and use it
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-05-30 02:10:20 -04:00
Christian Hopps 7a0894b532 mgmtd: Add note to SETCFG_REQ and debug logging
- convert impossible situation into assert

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-05-30 02:09:51 -04:00
Christian Hopps acd7aea00e mgmtd: simplify early config build removing unused code
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-05-30 02:09:51 -04:00
Christian Hopps a1d8c7a36e mgmtd: fix reading of config file[s]
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-05-30 02:09:44 -04:00
Christian Hopps 218625aa43 mgmtd: lib: cleanup error and debug messages
- always use IDs not a mix of IDs and pointers.
- always use PRIu64 not a mix of hex and decimal for IDs

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-05-28 05:13:22 -04:00
Christian Hopps 42f4bb2b1a mgmtd: lib: move INIT to after client registers
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-05-28 05:13:22 -04:00
Christian Hopps 9405278ef2 mgmtd: send reply to SUBSCR_REQ with success or not
since we don't actually handle xpath subscriptions, reply with fail
if they are requested.

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-05-28 05:13:22 -04:00
Christian Hopps 5f05ff5821 lib: add short-circuit operation between same process
- Use a socketpair for connection, and direct (no event loop)
message sending and handling.

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-05-28 05:13:22 -04:00
Christian Hopps 08e8019c65 lib: mgmtd: add a identifying tag to the debug message
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-05-28 05:13:22 -04:00
Christian Hopps d6665cf63f lib: dont be tricky with session_id just make it a session_id
- Previously was substituting a pointer to local allocated session for the
session_id returned from the FE adapter. This complexity isn't needed.
- Get rid of "%llu" format and the casts that came with it, instead use PRIu64
and the actual (uint64_t) type.

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-05-28 05:13:22 -04:00
Christian Hopps bcc350971f mgmtd: fix cleanup of cleanup in FE adapter code
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-05-28 05:13:22 -04:00
Christian Hopps c193194905 mgmtd: eliminate unused state
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-05-28 05:13:22 -04:00
Christian Hopps e3cacd9643 mgmtd: cleanup/fix BE adapter deletion code
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-05-28 05:13:22 -04:00
Christian Hopps 6dad9b53e7 mgmtd: convert BE/FE adapter to use allocated connections
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-05-28 05:13:22 -04:00
Christian Hopps 99564edc43 lib: mgmtd: add server-side connection code to mgmt_msg
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-05-28 05:13:22 -04:00
Christian Hopps 070c5e7a91 lib: msg: refactor common connection code from mgmtd
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-05-28 05:13:22 -04:00
Christian Hopps 528b326616 lib: mgmt msg: add version to messages
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-05-28 05:13:22 -04:00
Christian Hopps fff34d7274 lib: remove write-on-off, just requeue to the back of the queue
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-05-28 05:13:22 -04:00
David Lamparter dc3cea95eb mgmtd: embed necessary YANG models
Listing `.c` files in `$(…_OBJECTS):` does not have the desired effect.

(Also CLEANFILES is not needed, yang/subdir.am already has yang/*.c in
CLEANFILES anyway.)

Fixes: #13600
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-05-25 13:47:44 +02:00
Donald Sharp df6eb0bd7b lib, mgmtd: Use short memory names so they fit within vty output
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-05-19 21:31:35 -04:00
Christian Hopps 0030b5825e mgmtd: fix uninit warning and cleanup history error messages
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-05-18 08:42:42 -04:00
Christian Hopps d31d24c488 mgmtd: simplify commit id to just be a timeval string
Also fixes coverity warning

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-05-04 14:47:55 -04:00
Christian Hopps cfa0facbf9 mgmtd: fully implement debug flags for mgmtd and clients
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-05-01 13:47:12 -04:00
Christian Hopps 9b96394d05
Merge pull request #13149 from pushpasis/mgmt_cleanup_zlog
mgmtd, lib: Cleanup zlog_err()
2023-04-24 11:00:08 -04:00
Pushpasis Sarkar 048e1e7be8 mgmtd, lib: Cleanup zlog_err()
Cleanup all zlog_err() that were meant for debug only.

Signed-off-by: Pushpasis Sarkar <pushpasis@gmail.com>
2023-04-11 22:48:52 -07:00
rgirada 83b78f43f4 mgmtd: Fixing style warnings
Description:
	Fixing the style warnings in the mgmtd code.

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2023-04-05 10:30:24 +00:00
rgirada 93d4e355d8 mgmtd: Fixing code coverity issues in mgmtd
Description:
	the following list of coverity issues seen in mgmtd code.
	1. CID 1536832:  Memory - corruptions  (OVERLAPPING_COPY)
	   /mgmtd/mgmt_history.c: 85 in mgmt_history_create_cmt_rec()
	2. CID 1536831:  Error handling issues  (NEGATIVE_RETURNS)
	   /mgmtd/mgmt_be_server.c: 123 in mgmt_be_server_start()
	3. CID 1536830:  Resource leaks  (RESOURCE_LEAK)
	   /mgmtd/mgmt_history.c: 146 in mgmt_history_read_cmt_record_index()
	4. CID 1536829:  Error handling issues  (NEGATIVE_RETURNS)
	   /mgmtd/mgmt_fe_server.c: 123 in mgmt_fe_server_start()
	5. CID 1536828:  Possible Control flow issues  (DEADCODE)
	   /mgmtd/mgmt_txn.c: 1859 in mgmt_txn_get_config()
	6. CID 1536827:  Null pointer dereferences  (NULL_RETURNS)
           /mgmtd/mgmt_ds.c: 526 in mgmt_ds_delete_data_nodes()

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2023-04-05 10:29:14 +00:00
Jafar Al-Gharaibeh 3b28a5ef6b
Merge pull request #13131 from LabNConsulting/chopps/no-startup-file
mgmtd: remove startup config feature for now
2023-04-04 08:42:04 -05:00
Christian Hopps 8033bf3976 mgmtd: lib: read transitioned daemons split config files in mgmtd
When daemons transition to mgmtd they should stop reading their split config
files, and let mgmtd do that, otherwise things can get out of sync.

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-04-01 18:06:43 -04:00
Donald Sharp acdb814dfa
Merge pull request #13171 from manojvn/13154_fix
mgmtd: Fix for issue 13154.
2023-04-01 09:18:10 -04:00
Christian Hopps 803829e41e mgmtd: remove startup config feature for now
The startup config and how it interacts with explicit commits,
commit databases and implicit commits needs to be worked out
in design first. For now remove the offending code.

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-03-31 15:21:20 -04:00
Manoj Naragund 689e1d447a mgmtd: Fix for issue 13154.
The changes involve adding show debuggin command for MGMTd which resolves
command incomplete issue.

issue #13154

Signed-off-by: Manoj Naragund <mnaragund@vmware.com>
2023-03-31 03:47:17 -07:00
Christian Hopps 204e90579c mgmtd: remove errant git added file
fixes #13156

Signed-off-by: Christian Hopps <chopps@gmail.com>
2023-03-31 00:17:09 +00:00
Donald Sharp 4261481c6d mgmtd: Remove unnecessary asserts
event_add_XXXX functions have no failure path where
if you pass in a double event pointer that it could
return without setting the pointer.  As such these
asserts make no sense and are unnecessary

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-27 08:09:42 -04:00
Jafar Al-Gharaibeh 06f54ff416
Merge pull request #12953 from donaldsharp/struct_event
Struct event
2023-03-24 13:48:53 -05:00
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 e16d030c65 *: Convert THREAD_XXX macros to EVENT_XXX macros
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 907a2395f4 *: Convert thread_add_XXX functions to event_add_XXX
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp e6685141aa *: Rename struct thread to struct event
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>
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
Loganaden Velvindron b69017f455 mgmtd: Fix fd leak.
Close fd before returning to avoid leaks.

Signed-off-by: Loganaden Velvindron <logan@cyberstorm.mu>
2023-03-23 23:07:06 +04:00
Christian Hopps 0b645fd216 lib: mgmtd: fix build warnings (as error)
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-03-22 05:22:56 +00:00
Pushpasis Sarkar 1401ee8bf7 lib, mgmtd: Add few fixes for commit-check and rollback
This commit contains fixes for the following issues found
- 'mgmt commit check' issued through 'vtysh -f' was actually commtting the changeset.
- On config validation failure backend, mgmtd was not passing the correct error-reason
  to frontend.
- 'mgmt rollback ...' was reverting the change on backend, but config on mgmtd daemon
  remains intact

Signed-off-by: Pushpasis Sarkar <pushpasis@gmail.com>
2023-03-22 05:22:56 +00:00
Christian Hopps f82370b47b mgmtd: lib: utilize msglib constructed from the removed code
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-03-22 05:22:56 +00:00
Christian Hopps d1e85e3600 mgmtd: Enroll Staticd as a backend client for MGMTD
This commmit introduces Staticd as a backend client for the MGMTd
framework. All the static commands will be diverted to the MGMT
daemon and will use the transactional model to make changes to the
internal state. Similar mechanism can be used by other daemons to use
the MGMT framework in the future.

This commit includes the following functionalities in the changeset:
1. Diverts all the staticd (config only) commands to MGMTd.
2. Enrolls staticd as a backend client to use the MGMT framework.
3. Modify the staticd NB config handlers so that they can be compiled
   into a library and loaded in the MGMTd process context.

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:09:07 -04:00
Christian Hopps fc52ca1e18 mgmtd: nb library for client front-end code
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-03-21 22:08:32 -04: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