commit | 7b191ce81ef6006c868d8be5d19970cd0fafe35b | [log] [tgz] |
---|---|---|
author | Václav Kubernát <kubernat@cesnet.cz> | Tue Jun 30 16:22:53 2020 +0200 |
committer | Václav Kubernát <kubernat@cesnet.cz> | Thu Jul 02 16:07:55 2020 +0200 |
tree | 3abad35b8399db95a570852d03f0142cf6734f85 | |
parent | e5df98f8861bc3c243988ed04c396b954c32203c [diff] |
Fix crashes on leafref value printing Okay. Right. Yeah. So... Look at the test change: what I'm doing is retrieving "/example-schema:bossPerson". Okay, so bossPerson is a leafref. Alright. Now, let's look at how impl_lyNodesToTree worked before this patch. It takes leaf.value() and leaf.value_type->base() and tries to convert that into leaf_data_. Now, let's say `leaf` in this case is our bossPerson. So we take its value() and leaf_type.base(). leaf_type.base() always tells the underlying type even through leafrefs and union so in this case it is STRING, because bossPerson person points to "/example-schema:person/name" and that is a string. Everything is fine until now. What I've found is, that there are (at least) two ways to store values, which are leafrefs. The first one is straightforward - you use value().leafref() to get the data node our node points to, and then you can go all the way, until you find something that is not leafref. Query that node's value and bam, you have your value (which would be of type STRING in the case of bossPerson). However, something is kind of weird: if that is how I'm supposed to retrieve leafref values, how come I never call this leafref() method in `leafValueFromValue`? When I added the test I was surprised that when dealing with bossPerson, the function worked fine. How? Well... There is apparently another way to store leafref values and that is DIRECTLY under the base type inside the leafref you have at the start. That's the reason the netconf test worked just like that. I suppose if you're retrieving just bossPerson and the other stuff, there's nothing to point to and libyang just stores the string. However, when using YangAccess, I do have access to the pointed-to leafs. So in that case, the value isn't stored directly, but inside the pointed-to leafs (because they are available). This is where the bug came from: the libyang::Value class stored, but I pass a STRING base type to `leafValueFromValue`. Libyang finds this mismatch and throws. So how do I check what exactly am I dealing with? Welp, the internal type can be queried by Data_Node_Leaf_List::value_type, so pass that instead of the base type. Some more info: https://github.com/CESNET/libyang/issues/1135 Change-Id: I46043e101a47fd8b11b8e2121fdf21fd73ce7cdc
This program provides an interactive console for working with YANG data. It can connect to NETCONF servers, and also talk to sysrepo locally.
For building, one needs:
Use an exact commit of any dependencies as specified in submodules/dependencies/*
.
The build process uses CMake. A quick-and-dirty build with no fancy options can be as simple as mkdir build && cd build && cmake .. && make && make install
.
Issue reporting and feature requests are welcome via Taiga.io.
We are using Gerrit for patch submission, code review and Continuous Integration (CI). Development roadmap and planning happens over Taiga.io.
Copyright © CESNET, https://www.cesnet.cz/ . Portions copyright © Faculty of Information Technology, Czech Technical University in Prague, https://fit.cvut.cz/ . Most of the code was written by Václav Kubernát (CESNET, formerly FIT ČVUT) and Jan Kundrát (CESNET). The project is distributed under the terms of the Apache 2.0 license.