summaryrefslogtreecommitdiffstats
path: root/lib/yang.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* lib: avoid pointless search for built-in IETF YANGDavid Lamparter2022-01-171-0/+5
| | | | | | | This causes confusing/annoying log messages at startup otherwise: `YANG model "ietf-inet-types@*" "*@*"not embedded, trying external file` Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib: adapt to version 2 of libyangChristian Hopps2021-05-131-190/+210
| | | | | | | | | 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>
* *: require semicolon after DEFINE_MTYPE & coDavid Lamparter2021-03-171-2/+2
| | | | | | | | | | | | | | | | | Back when I put this together in 2015, ISO C11 was still reasonably new and we couldn't require it just yet. Without ISO C11, there is no "good" way (only bad hacks) to require a semicolon after a macro that ends with a function definition. And if you added one anyway, you'd get "spurious semicolon" warnings on some compilers... With C11, `_Static_assert()` at the end of a macro will make it so that the semicolon is properly required, consumed, and not warned about. Consistently requiring semicolons after "file-level" macros matches Linux kernel coding style and helps some editors against mis-syntax'ing these macros. Signed-off-by: David Lamparter <equinox@diac24.net>
* pathd: New SR-TE policy management daemonSebastien Merle2020-12-181-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This new daemon manages Segment-Routing Traffic-Engineering (SR-TE) Policies and installs them into zebra. It provides the usual yang support and vtysh commands to define or change SR-TE Policies. In a nutshell SR-TE Policies provide the possibility to steer traffic through a (possibly dynamic) list of Segment Routing segments to the endpoint of the policy. This list of segments is part of a Candidate Path which again belongs to the SR-TE Policy. SR-TE Policies are uniquely identified by their color and endpoint. The color can be used to e.g. match BGP communities on incoming traffic. There can be multiple Candidate Paths for a single policy, the active Candidate Path is chosen according to certain conditions of which the most important is its preference. Candidate Paths can be explicit (fixed list of segments) or dynamic (list of segment comes from e.g. PCEP, see below). Configuration example: segment-routing traffic-eng segment-list SL index 10 mpls label 1111 index 20 mpls label 2222 ! policy color 4 endpoint 10.10.10.4 name POL4 binding-sid 104 candidate-path preference 100 name exp explicit segment-list SL candidate-path preference 200 name dyn dynamic ! ! ! There is an important connection between dynamic Candidate Paths and the overall topic of Path Computation. Later on for pathd a dynamic module will be introduced that is capable of communicating via the PCEP protocol with a PCE (Path Computation Element) which again is capable of calculating paths according to its local TED (Traffic Engineering Database). This dynamic module will be able to inject the mentioned dynamic Candidate Paths into pathd based on calculated paths from a PCE. https://tools.ietf.org/html/draft-ietf-spring-segment-routing-policy-06 Co-authored-by: Sebastien Merle <sebastien@netdef.org> Co-authored-by: Renato Westphal <renato@opensourcerouting.org> Co-authored-by: GalaxyGorilla <sascha@netdef.org> Co-authored-by: Emanuele Di Pascale <emanuele@voltanet.io> Signed-off-by: Sebastien Merle <sebastien@netdef.org>
* lib: prevent libyang abstraction memory leakRafael Zalamena2020-12-091-1/+1
| | | | | | Call `ly_set_free()` on `YANG_ITER_STOP` as well. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
* Merge pull request #6145 from patrasar/pim_nb_code_upstreamDonald Sharp2020-11-191-4/+2
|\ | | | | pimd: northbound backend code
| * pimd: Northbound implementation for msdp mesh group, msdp peer commandsSarita Patra2020-11-061-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | lib: combine two YANG schema iteration functions into oneRenato Westphal2020-10-231-21/+2
| | | | | | | | | | | | | | | | | | | | 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>
* | lib: fix iteration over schema nodes of a single YANG moduleRenato Westphal2020-10-231-13/+14
|/ | | | | | | | | | | | | | | | | | | | | The only safe way to iterate over all schema nodes of a given YANG module is by iterating over all schema nodes of all YANG modules and filter out the nodes that belong to other modules. The original yang_snodes_iterate_module() code did the following: 1 - Iterate over all top-level schema nodes of the given module; 2 - Iterate over all augmentations of the given module. While that iteration strategy is more efficient, it does't handle well more complex YANG hierarchies containing nested augmentations or self-augmenting modules. Any iteration that isn't done on the resolved YANG data hierarchy is fragile and prone to errors. Fixes regression introduced by commit 8a923b48513316b where the gen_northbound_callbacks tool was generating duplicate callbacks for certain modules. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* lib: better support for nested YANG augmentationsRenato Westphal2020-09-111-11/+18
| | | | | | | | | | | | | | | | | | | | 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>
* lib: add yang modules to native module listChirag Shah2020-08-201-0/+3
| | | | Signed-off-by: Chirag Shah <chirag@nvidia.com>
* Merge pull request #6517 from vishaldhingra/submoduleDonald Sharp2020-08-071-10/+18
|\ | | | | lib: Add support to load submodules in embedded modules framework
| * lib: Add support to load submodules in embedded modules frameworkvdhingra2020-07-281-10/+18
| | | | | | | | | | | | | | 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>
* | lib : Yang wrappersvdhingra2020-07-161-0/+144
|/ | | | | | | 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>
* Merge pull request #6414 from opensourcerouting/nb-error-handlingSantosh P K2020-06-101-0/+28
|\ | | | | NB context + enhanced error handling
| * lib: return human-readable error messages to the northbound clientsRenato Westphal2020-05-291-0/+28
| | | | | | | | | | | | | | | | | | | | 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>
* | lib: introduce the yang_dnode_iterate helperRenato Westphal2020-06-051-0/+26
|/ | | | | | | Implement helper function that iterates over data nodes that satisfy XPath query. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* lib: suppress formatting on yang.c module arrayQuentin Young2020-04-161-0/+2
| | | | Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* yang: add zebra model in makefileChirag Shah2020-04-161-0/+1
| | | | Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
* lib: vrf northbound callbacksChirag Shah2020-04-161-0/+1
| | | | Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
* lib, tools: silence harmless warnings in the northbound toolsRenato Westphal2020-04-041-4/+7
| | | | | | | | | | | | | | | 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>
* vrrpd: northbound conversionQuentin Young2019-12-091-0/+1
| | | | | | Convert VRRPD to use the northbound API. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* lib, vtysh: add new libyang option to the "debug northbound" commandRenato Westphal2019-10-161-4/+11
| | | | | | | 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>
* lib: Let libyang log everything possibleGalaxyGorilla2019-10-161-3/+6
| | | | | | | | | | | | | | | Currently libyang logs errors only (LY_LLERR by default), independent of FRR's log level. This commit lets libyang log everything including all sorts of debug logs (when libyang is built in 'Debug' mode). FRR's logging infrastructure filters logs out according to the configured log level. There is a very small performance overhead involved, even when libyang is build in 'Release' mode. This overhead is mainly affecting config processing and barely measurable being around 0-3% of the processing time without this change. Signed-off-by: Sascha Kattelmann <sascha@netdef.org>
* lib: use MTYPE_STATICDavid Lamparter2019-06-211-2/+2
| | | | Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib, yang: disable libyang custom user types temporarilyRenato Westphal2019-05-071-45/+0
| | | | | | | | | | | | | | | | | | libyang 1.0 introduced a few changes in the user types API, and these changes made FRR incompatible with libyang 1.x. In order to ease our migration from libyang 0.x to libyang 1.x, let's disable our libyang custom user types temporarily so that FRR can work with both libyang 0.x and libyang 1.x. This should be especially helpful to the CI systems during the transition. Once the migration to libyang 1.x is complete, this commit will be reverted. Disabling our libyang custom user types should have only minimal performance implications when processing configuration transactions. The user types infrastructure should be more important in the future to perform canonization of YANG data values when necessary. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* Merge pull request #4161 from opensourcerouting/nb-performanceQuentin Young2019-04-221-43/+0
|\ | | | | lib: rework management of user pointers in the northbound layer
| * lib: rework management of user pointers in the northbound layerRenato Westphal2019-04-181-43/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | lib: move zlog() prototype back to the public logging APIRenato Westphal2019-04-181-1/+0
|/ | | | | | | | zlog() should be part of the public logging API as it's useful in the cases where the logging priority isn't known at compile time (i.e. it depends on a variable). Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* Merge remote-tracking branch 'frr/master' into rip-vrfRenato Westphal2019-03-291-3/+47
|\ | | | | | | | | | | | | 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>
| * lib: yang: use common yang_ctx_new_setup()David Lamparter2019-02-191-3/+24
| | | | | | | | | | | | | | | | | | | | | | | | 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>
| * build, lib/yang: bake in extensions if possibleDavid Lamparter2019-01-241-0/+23
| | | | | | | | | | | | | | | | | | | | Starting with libyang 0.16.74, we can load internally embedded yang extensions instead of going through the file system/dlopen. Detect support for this at build time and use if available. NB: the fallback mechanism will go away in a short while. Signed-off-by: David Lamparter <equinox@diac24.net>
* | lib: introduce new YANG helper functionRenato Westphal2019-01-181-0/+19
|/ | | | | | | | 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>
* lib: add frr-isisd to the native modelsEmanuele Di Pascale2018-12-181-1/+2
| | | | Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
* yang, ripngd: add 'frr-ripngd.yang' and associated stub callbacksRenato Westphal2018-12-031-0/+1
| | | | | | | | | | | | | | | | | | | | | | Introduce frr-ripngd.yang, which defines a model for managing the FRR ripngd daemon. Update the 'frr_yang_module_info' array of ripngd with the new 'frr-ripngd' module. Add two new files (ripng_cli.[ch]) which should contain all ripngd commands converted to the new northbound model. Centralizing all commands in a single place will facilitate the process of moving the CLI to a separate program in the future. Add automatically generated stub callbacks in ripng_northbound.c. These callbacks will be implemented gradually in the following commits. Add the confd.frr-ripngd.yang YANG module with annotations specific to the ConfD daemon. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* Merge pull request #3342 from opensourcerouting/nb-operational-dataRuss White2018-11-291-46/+64
|\ | | | | Northbound: improved support for YANG-modeled operational data
| * lib: add support for YANG lists with mixed config and state dataRenato Westphal2018-11-261-1/+2
| | | | | | | | | | | | | | | | 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>
| * lib: rework the yang schema node iteration functionsRenato Westphal2018-11-261-26/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
| * lib: introduce function that loads all FRR native YANG modulesRenato Westphal2018-11-261-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * lib: remove entire data tree on yang_dnode_free()Renato Westphal2018-11-261-0/+2
| | | | | | | | | | | | | | | | | | | | For convenience, make yang_dnode_free() remove the entire data tree and not only the data node given as a parameter. Also, add a null-pointer check on nb_config_replace() before calling yang_dnode_free(). Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
| * lib, tools: use CHECK_FLAG/SET_FLAG more often in the northbound codeRenato Westphal2018-11-261-5/+5
| | | | | | | | | | | | Cosmetic change to improve code readability a bit. No binary changes. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
| * lib: make it possible to create YANG data nodes containing state dataRenato Westphal2018-11-261-2/+8
| | | | | | | | | | | | | | | | | | 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>
| * lib: don't fetch schema information when creating yang_data structuresRenato Westphal2018-11-261-12/+0
| | | | | | | | | | | | | | | | | | 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>
* | lib: make yang_dnode_get_entry() more flexibleRenato Westphal2018-11-261-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* | lib: introduce function to retrieve the schema name of a data nodeRenato Westphal2018-11-261-0/+23
| | | | | | | | | | | | | | | | 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>
* | lib: set YANG search directory when creating libyang contextRenato Westphal2018-11-261-2/+2
|/ | | | | | Minor code simplification. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* yang: embed models into binariesDavid Lamparter2018-11-191-0/+40
| | | | | | | | | | | | | | 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>
* lib: introduce new northbound APIRenato Westphal2018-10-271-0/+618
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>