libnetconf2 icon indicating copy to clipboard operation
libnetconf2 copied to clipboard

Issue with nc_clb_default_get_schema Format Option in libnetconf2

Open nbiskup-eridan opened this issue 1 year ago • 9 comments

Hi,

I'm encountering an issue with nc_clb_default_get_schema when I set the format option to yang. It expects a prefix before the format name.

I'm curious why the prefix is required, especially since the same prefix was removed in this commit ( cd4a72de957d9fb093e732c64a05eae497ef353f ) within Netopeer for the get-schema RPC. Could you provide more information on this behavior?

/* check format */
if (!format || !strcmp(format, "ietf-netconf-monitoring:yang")) {
    outformat = LYS_OUT_YANG;
} else if (!strcmp(format, "ietf-netconf-monitoring:yin")) {
    outformat = LYS_OUT_YIN;
} else {
    err = nc_err(session->ctx, NC_ERR_INVALID_VALUE, NC_ERR_TYPE_APP);
    nc_err_set_msg(err, "The requested format is not supported.", "en");
    return nc_server_reply_err(err);
}

Thank you.

nbiskup-eridan avatar Oct 08 '24 13:10 nbiskup-eridan

The commit you referenced has been later reverted, to some extent. The format node is an identityref, whose canonical value always includes the module prefix, in all reasonably recent libyang versions.

michalvasko avatar Oct 08 '24 13:10 michalvasko

Thank you for your response.

I am sending the following RPC, which you can see below. In this case, I receive the value for the format as just "yang". Could you assist me in understanding how the correct RPC should look to resolve this issue?

Here is the RPC I'm currently sending:

<nc:rpc xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:a539b3ee-98eb-47f5-9096-0688933aaebd">
  <ncm:get-schema xmlns:ncm="urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring">
	  <ncm:identifier>ietf-netconf</ncm:identifier>
	  <ncm:format>ncm:yang</ncm:format>
  </ncm:get-schema>
</nc:rpc>

nbiskup-eridan avatar Oct 08 '24 14:10 nbiskup-eridan

The RPC looks fine, what libyang version are you using? That may be the issue.

michalvasko avatar Oct 09 '24 06:10 michalvasko

I am using version v2.1.111 due to system dependencies.

nbiskup-eridan avatar Oct 09 '24 06:10 nbiskup-eridan

The compatible version of netopeer2 with that is 2.1.71, which actually has that format check different and it should work. You need to use compatible versions of the projects based on netopeer2 releases or you risk similar problems.

michalvasko avatar Oct 09 '24 06:10 michalvasko

We are not using Netopeer2, but instead have our own implementation that relies on nc_clb_default_get_schema provided by libnetconf2, which is currently not working for us. We are using the same versions of libyang (v2.1.111), libnetconf2 (v2.1.37), and sysrepo (v2.2.105) as in Netopeer2 version 2.1.71.

I mention this in case we might have misunderstood each other.

nbiskup-eridan avatar Oct 09 '24 08:10 nbiskup-eridan

Thanks, considering these versions, looking at the libyang code, it seems it generates identity values without prefix for local identities. But libnetconf2 expects it there so that is a bug. One possible fix is to use and manually apply the commit you referenced.

michalvasko avatar Oct 09 '24 08:10 michalvasko

Thank you for the information. I'm still not entirely sure if this issue has been fixed in the newer versions, and if so, could you please let me know from which version it has been resolved?

nbiskup-eridan avatar Oct 10 '24 13:10 nbiskup-eridan

You need to use compatible versions of libyang and libnetconf2 for it to work properly. The safest thing to do is to use the latest or one of the few most recent releases, I am not exactly sure when it was fixed (but I would hope it works in all the other versions except for those mentioned here).

michalvasko avatar Oct 10 '24 13:10 michalvasko