Skip to content

Commit d5b0c76

Browse files
authored
Merge pull request #16183 from LabNConsulting/chopps/notif-doc-update
mgmtd: add empty notif xpath map for completeness
2 parents 19c3e0e + 491e608 commit d5b0c76

File tree

3 files changed

+87
-8
lines changed

3 files changed

+87
-8
lines changed

doc/developer/mgmtd-dev.rst

+48-5
Original file line numberDiff line numberDiff line change
@@ -317,12 +317,25 @@ Likewise the client should be cleaned up in the daemon cleanup routine.
317317
Back-End XPATH mappings
318318
^^^^^^^^^^^^^^^^^^^^^^^
319319

320-
In order for ``mgmtd`` to direct configuration to your daemon you need to add
320+
In order for ``mgmtd`` to direct YANG modeled data to your daemon you should add
321321
some XPATH mappings to ``mgmtd/mgmt_be_adapter.c``. These XPATHs determine which
322-
configuration changes get sent over the *back-end* interface to your daemon.
323-
There are 2 arrays to update the first for config support and the second for
324-
operational state.
325-
322+
YANG modeled data (e.g., config changes) get sent over the *back-end* interface
323+
to your daemon. There are 4 arrays to possibly update: configuration,
324+
operational, notification, and RPC. You only need to add entries to the array
325+
that you require mapping for.
326+
327+
Additionally the back-end client can specify these XPATH mappings when it
328+
first connects to mgmtd using it's initial ``SUBSCRIBE`` message.
329+
330+
NOTE: the notif array (``be_client_notif_xpaths``), is a slightly different from
331+
the other 3 types (config, oper and rpc) in that it maps xpaths the back-end
332+
client wishes to *receive* notifications for, not the ones it may generate.
333+
Normally a back-end client is generating notifications; however, mgmtd supports
334+
back-end clients also "subscribing" to receive these notifications as well from
335+
other back-end clients through notif_xpath maps.
336+
337+
Config Map Example
338+
""""""""""""""""""
326339
Below are the strings added for staticd config support:
327340

328341
.. code-block:: c
@@ -342,6 +355,9 @@ Below are the strings added for staticd config support:
342355
#endif
343356
};
344357
358+
359+
Operational Map Example
360+
"""""""""""""""""""""""
345361
Below are the strings added for zebra operational state support (note zebra is
346362
not conditionalized b/c it should always be present):
347363

@@ -358,6 +374,33 @@ not conditionalized b/c it should always be present):
358374
[MGMTD_BE_CLIENT_ID_ZEBRA] = zebra_oper_xpaths,
359375
};
360376
377+
378+
RPC Map Example
379+
"""""""""""""""
380+
Below is the string added for ripd RPC support:
381+
382+
.. code-block:: c
383+
384+
static const char *const ripd_rpc_xpaths[] = {
385+
"/frr-ripd",
386+
NULL,
387+
};
388+
389+
static const char *const *be_client_rpc_xpaths[MGMTD_BE_CLIENT_ID_MAX] = {
390+
#ifdef HAVE_RIPD
391+
[MGMTD_BE_CLIENT_ID_RIPD] = ripd_rpc_xpaths,
392+
#endif
393+
};
394+
395+
396+
Notification Map Example
397+
""""""""""""""""""""""""
398+
There are no current back-end daemons that wish to receive other back-end
399+
notifications so the array is empty. This may change in the future, and of
400+
course any back-end daemon can utilize the connect (``BeSubscribeReq``) messages
401+
as well.
402+
403+
361404
MGMTD Internals
362405
---------------
363406

doc/user/mgmtd.rst

+28-3
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,23 @@ Following are some of the management operations supported:
9797
- Currently committing configurations from Candidate to Running database
9898
is only allowed, and not vice versa.
9999

100+
Front-End Native Protobuf API
101+
"""""""""""""""""""""""""""""
100102
The exact set of message-based APIs are represented as Google Protobuf
101103
messages and can be found in the following file distributed with FRR codebase.
102104

103105
.. code-block:: frr
104106
105107
lib/mgmt.proto
106108
109+
Front-End Native (non-protobuf) API
110+
"""""""""""""""""""""""""""""""""""
111+
Additionally there exists a "native" API that does not utilize ``protobuf``s
112+
this native API and the front-end messages and structures it supports are
113+
documented in the header file ``lib/mgmt_msg_native.h``.
114+
115+
Connecting to MGMTd
116+
"""""""""""""""""""
107117
The MGMT daemon implements a MGMT Frontend Server that opens a UNIX
108118
socket-based IPC channel on the following path to listen for incoming
109119
connections from all possible Frontend clients:
@@ -124,7 +134,9 @@ specification of this library can be found at:
124134
125135
lib/mgmt_fe_client.h
126136
127-
Following is a list of message types supported on the MGMT Frontend Interface:
137+
Following is a list of protobuf message types supported on the MGMT Frontend
138+
Interface:
139+
128140
- SESSION_REQ<Client-Connection-Id, Destroy>
129141
- SESSION_REPLY<Client-Connection-Id, Destroy, Session-Id>
130142
- LOCK_DB_REQ <Session-Id, Database-Id>
@@ -139,8 +151,21 @@ Following is a list of message types supported on the MGMT Frontend Interface:
139151
- COMMIT_CONFIG_REPLY <Session-Id, Source-Db-id, Dest-Db-Id, Status>
140152
- GET_DATA_REQ <Session-Id, Database-Id, Base-Yang-Xpath>
141153
- GET_DATA_REPLY <Session-Id, Database-id, Base-Yang-Xpath, Yang-Data-Set>
142-
- REGISTER_NOTIFY_REQ <Session-Id, Database-Id, Base-Yang-Xpath>
143-
- DATA_NOTIFY_REQ <Database-Id, Base-Yang-Xpath, Yang-Data-Set>
154+
155+
Following is a list of native messages types supported by the MGMTd Front-End
156+
API:
157+
158+
- ERROR (receive) - received in response to any sent native message.
159+
- TREE_DATA (receive) - returned data from a datastore
160+
- GET_DATA (send) - get a tree of data
161+
- NOTIFY (receive) - a notification received from mgmtd
162+
- EDIT (send) - edit configuration datastore
163+
- EDIT_REPLY (receive) - reply for an edit operation
164+
- RPC (send) - sending (invoking) an RPC.
165+
- RPC_REPLY (receive) - reply from invoking an RPC
166+
- NOTIFY_SELECT (send) - specify the sub-set of notifications the front-end
167+
wishes to receive, rather than the default of receiving all.
168+
144169

145170
Please refer to the MGMT Frontend Client Developers Reference and Guide
146171
(coming soon) for more details.

mgmtd/mgmt_be_adapter.c

+11
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ static const char *const *be_client_oper_xpaths[MGMTD_BE_CLIENT_ID_MAX] = {
155155
[MGMTD_BE_CLIENT_ID_ZEBRA] = zebra_oper_xpaths,
156156
};
157157

158+
static const char *const *be_client_notif_xpaths[MGMTD_BE_CLIENT_ID_MAX] = {
159+
};
160+
158161
static const char *const *be_client_rpc_xpaths[MGMTD_BE_CLIENT_ID_MAX] = {
159162
#ifdef HAVE_RIPD
160163
[MGMTD_BE_CLIENT_ID_RIPD] = ripd_rpc_xpaths,
@@ -298,6 +301,13 @@ static void mgmt_be_xpath_map_init(void)
298301
MGMT_BE_XPATH_SUBSCR_TYPE_OPER);
299302
}
300303

304+
/* Initialize the common NOTIF init map */
305+
for (init = be_client_notif_xpaths[id]; init && *init; init++) {
306+
__dbg(" - NOTIF XPATH: '%s'", *init);
307+
mgmt_register_client_xpath(id, *init,
308+
MGMT_BE_XPATH_SUBSCR_TYPE_NOTIF);
309+
}
310+
301311
/* Initialize the common RPC init map */
302312
for (init = be_client_rpc_xpaths[id]; init && *init; init++) {
303313
__dbg(" - RPC XPATH: '%s'", *init);
@@ -308,6 +318,7 @@ static void mgmt_be_xpath_map_init(void)
308318

309319
__dbg("Total Cfg XPath Maps: %u", darr_len(be_cfg_xpath_map));
310320
__dbg("Total Oper XPath Maps: %u", darr_len(be_oper_xpath_map));
321+
__dbg("Total Noitf XPath Maps: %u", darr_len(be_notif_xpath_map));
311322
__dbg("Total RPC XPath Maps: %u", darr_len(be_rpc_xpath_map));
312323
}
313324

0 commit comments

Comments
 (0)