diff options
author | Igor Ryzhov <iryzhov@nfware.com> | 2024-02-09 23:58:49 +0100 |
---|---|---|
committer | Igor Ryzhov <iryzhov@nfware.com> | 2024-02-10 00:00:24 +0100 |
commit | d94f80fbc4347cbbf5ee6ecbdf3682329db832dc (patch) | |
tree | dab7de197df1ae57c726701d24e8eaeb918a2a00 /lib/yang.h | |
parent | Merge pull request #15327 from routingrocks/pim_evpn_traffic_loss (diff) | |
download | frr-d94f80fbc4347cbbf5ee6ecbdf3682329db832dc.tar.xz frr-d94f80fbc4347cbbf5ee6ecbdf3682329db832dc.zip |
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>
Diffstat (limited to 'lib/yang.h')
-rw-r--r-- | lib/yang.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/yang.h b/lib/yang.h index 4ed0a39ba..9c221445c 100644 --- a/lib/yang.h +++ b/lib/yang.h @@ -607,6 +607,19 @@ extern struct ly_ctx *yang_ctx_new_setup(bool embedded_modules, */ extern void yang_debugging_set(bool enable); +/* + * Parse a YANG notification. + * + * Args: + * format: LYD_FORMAT of input data. + * data: input data. + * notif: pointer to the libyang data tree to store the parsed notification. + * If the notification is not on the top level of the yang model, + * the pointer to the notification node is still returned, but it's + * part of the full data tree with all its parents. + */ +extern LY_ERR yang_parse_notification(LYD_FORMAT format, const char *data, + struct lyd_node **notif); /* * "Print" the yang tree in `root` into dynamic sized array. |