summaryrefslogtreecommitdiff
path: root/lib/yang.h
AgeCommit message (Collapse)Author
2024-02-20lib: mgmtd: add xpath arg to notification messageChristian Hopps
Signed-off-by: Christian Hopps <chopps@labn.net> (cherry picked from commit 4a93d171c2e3ec1ff6c4fc553d6acf42e035e0d4)
2024-02-10lib, mgmtd: fix processing of yang notificationsIgor Ryzhov
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-01-30lib: mgmtd: add YANG notification supportChristian Hopps
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-28lib: add support for "features" when loading YANG modulesIgor Ryzhov
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-26lib: add yang function for counting data nodesIgor Ryzhov
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-07lib: use libyang functions if they are presentChristian Hopps
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-07lib: mgmtd: implement full XPath 1.0 predicate functionalityChristian Hopps
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>
2023-12-28lib: yang: add yang_get_node_keys() functionChristian Hopps
- comment out unused mem-leaking function. - improve yang_dnode_get_path return type Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-28lib: yang: add new functionsChristian Hopps
- yang_get_key_preds - yang_lyd_new_list A function like new_list was added recently to libyang, this is a compat version. Signed-off-by: Christian Hopps <chopps@labn.net>
2023-12-26lib: yang: add tree "printing" utility functionsChristian Hopps
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-04-17lib: add and use new yang function for finding schema nodesChristian Hopps
Add a wrapper around lys_find_xpath which has an unfortunate API returning an allocated set of schema nodes when we only ever expect and want one. Another libyang function `lys_find_path` returns a single node; however, that function can assert/abort on invalid path values so is unsuitable for user input. Replace previous uses of `lys_find_path` with new API when dealing with possible invalid path values (i.e., from a user). Signed-off-by: Christian Hopps <chopps@labn.net>
2023-03-24*: Rename `struct thread` to `struct event`Donald Sharp
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-02-09*: auto-convert to SPDX License IDsDavid Lamparter
Done with a combination of regex'ing and banging my head against a wall. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-01-27*: apply proper format string attributesDavid Lamparter
So that we get warnings about broken format strings. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-10-22lib: finish fixing spelling in lib filesewlumpkin
Signed-off-by: ewlumpkin <ewlumpkin@gmail.com>
2021-05-13lib: adapt to version 2 of libyangChristian Hopps
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>
2020-11-19Merge pull request #6145 from patrasar/pim_nb_code_upstreamDonald Sharp
pimd: northbound backend code
2020-11-06pimd: Northbound implementation for msdp mesh group, msdp peer commandsSarita Patra
ip_msdp_peer no_ip_msdp_peer ip_msdp_mesh_group_member no_ip_msdp_mesh_group_member ip_msdp_mesh_group_source no_ip_msdp_mesh_group_source no_ip_msdp_mesh_group Yang Model: augment /frr-routing:routing/frr-routing:control-plane-protocols/frr-routing:control-plane-protocol: +--rw pim +--rw address-family* [address-family] +--rw address-family identityref +--rw msdp-mesh-group! | +--rw mesh-group-name? string | +--rw member-ip* ietf-inet-types:ip-address | +--rw source-ip? ietf-inet-types:ip-address +--rw msdp-peer* [peer-ip] | +--rw peer-ip ietf-inet-types:ip-address | +--rw source-ip? ietf-inet-types:ip-address Signed-off-by: Sarita Patra <saritap@vmware.com>
2020-10-23lib: combine two YANG schema iteration functions into oneRenato Westphal
Combine yang_snodes_iterate_module() and yang_snodes_iterate_all() into an unified yang_snodes_iterate() function, where the first "module" parameter is optional. There's no point in having two separate YANG schema iteration functions anymore now that they are too similar. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-09-11lib: better support for nested YANG augmentationsRenato Westphal
Change the way the YANG schema node iteration functions work so that the northbound layer won't have issues with more complex YANG modules that contain multiple levels of YANG augmentations or modules that augment themselves indirectly (by augmenting groupings). Summary of the changes: * Change the yang_snodes_iterate_subtree() function to always follow augmentations and add an optional "module" parameter to narrow down the iteration to nodes of a single module (which is necessary in some cases). Also, remove the YANG_ITER_ALLOW_AUGMENTATIONS flag as it's no longer necessary. * Change yang_snodes_iterate_all() to do a DFS iteration on the resolved YANG data hierarchy instead of iterating over each module and their augmentations sequentially. Reported-by: Rafael Zalamena <rzalamena@opensourcerouting.org> Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-08-20lib: adapt plugin to use new Sysrepo versionRenato Westphal
Sysrepo recently underwent a complete rewrite, where some substantial architectural changes were made (the most important one being the extinction of the sysrepod daemon). While most of the existing API was preserved, quite a few backward-incompatible changes [1] were introduced (mostly simplifications). This commit adapts our sysrepo northbound plugin to those API changes in order for it to be compatible with the latest Sysrepo version. Additional notes: * The old Sysrepo version is EOL and not supported anymore. * The new Sysrepo version requires libyang 1.x. Closes #6936 [1] https://github.com/sysrepo/sysrepo/blob/devel/CHANGES Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-08-07Merge pull request #6517 from vishaldhingra/submoduleDonald Sharp
lib: Add support to load submodules in embedded modules framework
2020-07-28lib: Add support to load submodules in embedded modules frameworkvdhingra
BGP Yang is using sub modules and at present FRR is not processing submodules in embedded framework yang Signed-off-by: VishalDhingra <vdhingra@vmware.com>
2020-07-16lib : Yang wrappersvdhingra
1. To get the parent node 2. To auto delete the parent when last node in list gets deleted Signed-off-by: VishalDhingra <vdhingra@vmware.com>
2020-06-10Merge pull request #6414 from opensourcerouting/nb-error-handlingSantosh P K
NB context + enhanced error handling
2020-06-05lib: introduce the yang_dnode_iterate helperRenato Westphal
Implement helper function that iterates over data nodes that satisfy XPath query. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-05-28lib: return human-readable error messages to the northbound clientsRenato Westphal
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-04-16lib: increase xpath maxlenChirag Shah
Certain xpath are well 256 characters, increasing to 512. Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2020-04-03lib, tools: silence harmless warnings in the northbound toolsRenato Westphal
Our two northbound tools don't have embedded YANG modules like the other FRR binaries. As such, ly_ctx_set_module_imp_clb() shouldn't be called when the YANG subsystem it being initialized by a northbound tool. To make that possible, add a new "embedded_modules" parameter to the yang_init() function to control whether libyang should look for embedded modules or not. With this fix, "gen_northbound_callbacks" and "gen_yang_deviations" won't emit "YANG model X not embedded, trying external file" warnings anymore. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-12-19lib: fix build of the northbound pluginsRenato Westphal
Commit 1b3e9a21dd4 removed the global visibility of the yang_modules variable, breaking the build of all northbound plugins. Revert a small part of that commit to fix this issue. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-12-13lib: make some variables staticDavid Lamparter
Signed-off-by: David Lamparter <equinox@diac24.net>
2019-10-16lib, vtysh: add new libyang option to the "debug northbound" commandRenato Westphal
Guard the libyang debug messages under this command so that only people interested on those messages will see them. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-06-21lib: use MTYPE_STATICDavid Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-04-18lib: rework management of user pointers in the northbound layerRenato Westphal
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-03-29Merge remote-tracking branch 'frr/master' into rip-vrfRenato Westphal
Merge commit to solve a bunch of conflicts with other PRs that were merged in the previous weeks. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-02-19lib: yang: use common yang_ctx_new_setup()David Lamparter
After creating a libyang context, we need to hook up our callback to use embedded built-in modules. I hadn't added this to the yang translator code. Also, ly_ctx_new fails if the search directory doesn't exist. Since that's not a hard error for us, work around that and ignore inaccessible YANG_MODELS_DIR. (This is needed for snap packages.) Signed-off-by: David Lamparter <equinox@diac24.net>
2019-02-11lib: add extern "C" {} blocks to all libfrr headersRenato Westphal
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-01-18lib: introduce new YANG helper functionRenato Westphal
One use case for the new yang_data_list_find() function is to find input parameters in RPC northbound callbacks easily, without the need to iterate over the input parameters manually. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-11-29Merge pull request #3342 from opensourcerouting/nb-operational-dataRuss White
Northbound: improved support for YANG-modeled operational data
2018-11-26lib: add support for YANG lists with mixed config and state dataRenato Westphal
A YANG list that contains both configuration and state data must have the following callbacks: create(), delete(), get_next(), get_keys() and lookup_entry(). Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-11-26lib: rework the yang schema node iteration functionsRenato Westphal
* Rename yang_snodes_iterate() to yang_snodes_iterate_subtree() and expose it in the public API. * Rename yang_module_snodes_iterate() to yang_snodes_iterate_module(). * Rename yang_all_snodes_iterate() to yang_snodes_iterate_all(). * Make it possible to stop the iteration at any time by returning YANG_ITER_STOP in the iteration callbacks. * Make the iteration callbacks accept only one user argument and not two. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-11-26lib: introduce function that loads all FRR native YANG modulesRenato Westphal
In some cases it will be necessary to load all FRR native modules. Examples: * vtysh needs to load all YANG modules so that it can manipulate data from all daemons. * The gen_northbound_callbacks tool will need to load all YANG modules since augmentations from one module can have an effect in the required northbound callbacks of other modules. The new yang_module_load_all() function provides this functionality. As a side note, the "frr_native_modules" will need to be updated every time we add a new YANG module to FRR. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-11-26lib: make it possible to create YANG data nodes containing state dataRenato Westphal
By default the data nodes created by yang_dnode_new() could contain only configuration data (LYD_OPT_CONFIG). Add a 'config_only' option to yang_dnode_new() so that it can create data nodes containing both configuration and state data. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-11-26lib: don't fetch schema information when creating yang_data structuresRenato Westphal
Prefetching the schema node when creating yang_data structures is expensive, and in most cases we don't need that information. In that case, fetch the schema information only when necessary to improve performance when fetching operational data. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-11-26lib: make yang_dnode_get_entry() more flexibleRenato Westphal
Add the "abort_if_not_found" parameter to the yang_dnode_get_entry() function instead of always aborting when an user pointer is not found. This will make it possible, for example, to use this function during the validation phase of a configuration transaction. Callers will only need to check if the function returned NULL or not, since new configuration objects (if any) won't be created until the NB_EV_APPLY phase of the transaction. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-11-26lib: introduce function to retrieve the schema name of a data nodeRenato Westphal
In some cases it might be desirable to obtain the schema name of a libyang data node. Introduce the yang_dnode_get_schema_name() function for this purpose. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-11-19yang: embed models into binariesDavid Lamparter
This bakes our YANG models straight into the library/daemons, so they don't need to be loaded from /usr/share/yang. This makes the installation quite a bit more robust, as well as gets us halfway to running uninstalled. (The other half is baking in the extension type module.) The /usr/share/yang directory is still searched as a fallback, as well as for the experimental YANG model translator. This is likely to stay as is for the time being. Signed-off-by: David Lamparter <equinox@diac24.net>
2018-10-27lib: introduce new northbound APIRenato Westphal
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>