summaryrefslogtreecommitdiff
path: root/lib/yang.c
AgeCommit message (Collapse)Author
2024-06-13lib: fix incorrect use of error checking macroChristian Hopps
Signed-off-by: Christian Hopps <chopps@labn.net> (cherry picked from commit 07090ccf5a3c81f650faef914a646f0e31a26fc8)
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-15lib: actually create the tree for the conversionChristian Hopps
Before this fix would always return empty results b/c there was no libyang tree to print to output format. Signed-off-by: Christian Hopps <chopps@labn.net> (cherry picked from commit dff28248c3c1dee0d1c9f9225dab66224c6aac54)
2024-02-15lib: fix memleak on successChristian Hopps
Signed-off-by: Christian Hopps <chopps@labn.net> (cherry picked from commit b8e07049a8ee684eaa8df48bef6e7bfbc853644d)
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-02-04lib: add ietf-yang-metadata to the list of built-in modulesIgor Ryzhov
We don't need to manually load built-in modules. This fixes the following warning in mgmtd: ``` YANG model "ietf-yang-metadata@*" "*@*"not embedded, trying external file ``` 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: fix yang_dnode_dupIgor Ryzhov
When duplicating nodes, we should always keep flags, especially the LYD_NEW flag that indicates not validated data. This allows to select a new choice's case without the need to explicitly remove the existing one. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-28lib: add support for "features" when loading YANG modulesIgor Ryzhov
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-27build: homologize path handlingDavid Lamparter
Use consistent `e_somepath` names for expanded versions of `somepath`. Also remove all paths from `config.h` and put them into `lib/config_paths.h` - this is to make more obvious when someone is doing something probably not quite properly structured. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-01-26lib: add yang function for counting data nodesIgor Ryzhov
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-14lib: fix yang_lyd_trim_xpathIgor Ryzhov
We should traverse all top-level siblings, not only the first one. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-11lib: fix coverity issuesChristian Hopps
** 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-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: fixes required after rebasingChristian Hopps
lib: fix checkpatch warnings lib: darr: disable check mgmtd: fix initialization 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-11-15lib: fix printing multiple yang errorsIgor Ryzhov
When printing multiple YANG errors, we should print paths for all of them, not only for the last one. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-11-06lib: yang: restore old API use now that it's fixedChristian Hopps
This also avoids a bug in the workaround function if the set variable wasn't set to NULL the Debug version of libyang would sigsegv. 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-21mgmtd: Add MGMT Transaction FrameworkYash Ranjan
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-02-17Merge pull request #12780 from opensourcerouting/spdx-license-idDonald Sharp
*: convert to SPDX License identifiers
2023-02-09lib,yang,zebra: add affinity-map supportLouis Scalbert
Add the affinity-map global command to zebra. The syntax is: > affinity-map NAME bit-position (0-1023) Signed-off-by: Louis Scalbert <louis.scalbert@6wind.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>
2022-01-17lib: avoid pointless search for built-in IETF YANGDavid Lamparter
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>
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>
2021-03-17*: require semicolon after DEFINE_MTYPE & coDavid Lamparter
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>
2020-12-18pathd: New SR-TE policy management daemonSebastien Merle
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>
2020-12-09lib: prevent libyang abstraction memory leakRafael Zalamena
Call `ly_set_free()` on `YANG_ITER_STOP` as well. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
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-10-23lib: fix iteration over schema nodes of a single YANG moduleRenato Westphal
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>
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: add yang modules to native module listChirag Shah
Signed-off-by: Chirag Shah <chirag@nvidia.com>
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: suppress formatting on yang.c module arraynb_conversionsQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-16yang: add zebra model in makefileChirag Shah
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2020-04-16lib: vrf northbound callbacksChirag Shah
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-09vrrpd: northbound conversionQuentin Young
Convert VRRPD to use the northbound API. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
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-10-16lib: Let libyang log everything possibleGalaxyGorilla
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>