From a3b6ea9e1027fa193171a1c268cb64ab72460869 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Mon, 11 May 2020 14:38:38 +0200 Subject: [PATCH] New clixon-config@2020-04-23.yang revision * Removed xml-stats non-config data (replaced by rpc `stats` in clixon-lib.yang) * Added option `CLICON_YANG_UNKNOWN_ANYDATA` to treat unknown XML (wrt YANG) as anydata. --- CHANGELOG.md | 9 ++- lib/clixon/clixon_xml_bind.h | 2 +- lib/src/clixon_err.c | 2 +- lib/src/clixon_xml_bind.c | 4 +- test/test_cli.sh | 1 + yang/clixon/Makefile.in | 4 +- yang/clixon/clixon-config@2020-02-22.yang | 39 +++++++--- ...-11.yang => clixon-config@2020-04-23.yang} | 76 ++++++++++++++++++- yang/clixon/clixon-lib@2019-08-13.yang | 66 ---------------- 9 files changed, 115 insertions(+), 88 deletions(-) rename yang/clixon/{clixon-config@2019-09-11.yang => clixon-config@2020-04-23.yang} (87%) delete mode 100644 yang/clixon/clixon-lib@2019-08-13.yang diff --git a/CHANGELOG.md b/CHANGELOG.md index 7581d1ca..4f976799 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,11 +38,14 @@ Expected: May 2020 ### API changes on existing protocol/config features (You may have have to change how you use Clixon) * Stricter validation detecting duplicate container or leaf in XML. - * Eg `` is invalid if `a` is anything else than leaf or leaf-list + * Eg `` is invalid if `a` is a leaf or container. * New clixon-lib@2020-04-23.yang revision * Added: stats RPC for clixon XML and memory statistics. * Added: restart-plugin RPC for restarting individual plugins without restarting backend. -* xml-stats moved from clixon-config.yang as state data to an rpc `datastats` in clixon-lib.yang +* New clixon-config@2020-04-23.yang revision + * Removed xml-stats non-config data (replaced by rpc `stats` in clixon-lib.yang) + * Added option `CLICON_YANG_UNKNOWN_ANYDATA` to treat unknown XML (wrt YANG) as anydata. + * This is a way to loosen sanity checks if you need to accept eg unsynchronized YANG and XML * Stricter incoming RPC sanity checking, error messages may have changed. * Changed output of `clixon_cli -G` option to show generated CLI spec original text instead of resulting parse-tree, which gives better detail from a debugging perspective. @@ -59,8 +62,6 @@ Expected: May 2020 * Added decriptive error message when plugins produce invalid state XML. * Example: `operation-failedmystateNo such yang module. Internal error, state callback returned invalid XML: example_backend` -* Added option `CLICON_YANG_UNKNOWN_ANYDATA` to treat unknown XML (wrt YANG) as anydata. - * This is a way to loosen sanity checks if you need to accept eg unsynchronized YANG and XML * Compile-time option: `USE_CLIGEN44` for running clixon-45 with cligen-44. * Temporary fix since cligen-45 have some non-backward compatible behaviour. * Optimizations diff --git a/lib/clixon/clixon_xml_bind.h b/lib/clixon/clixon_xml_bind.h index 55818d81..06a3b762 100644 --- a/lib/clixon/clixon_xml_bind.h +++ b/lib/clixon/clixon_xml_bind.h @@ -43,7 +43,7 @@ /* * Prototypes */ -int xml_bind_yang_unknown_anydata(int bool); +int xml_bind_yang_unknown_anydata(int val); int xml_bind_yang_rpc(cxobj *xrpc, yang_stmt *yspec, cxobj **xerr); int xml_bind_yang_rpc_reply(cxobj *xrpc, char *name, yang_stmt *yspec, cxobj **xerr); int xml_bind_yang0(cxobj *xt, yang_bind yb, yang_stmt *yspec, cxobj **xerr); diff --git a/lib/src/clixon_err.c b/lib/src/clixon_err.c index f2c97f64..a99bdc0a 100644 --- a/lib/src/clixon_err.c +++ b/lib/src/clixon_err.c @@ -141,7 +141,7 @@ clicon_err_reset(void) * @param[in] fn Inline function name (when called from clicon_err() macro) * @param[in] line Inline file line number (when called from clicon_err() macro) * @param[in] category Clixon error category, See enum clicon_err - * @param[in] errno Error number, typically errno + * @param[in] suberr Error number, typically errno * @param[in] reason Error string, format with argv * @see clicon_err_reser Resetting the global error variables. */ diff --git a/lib/src/clixon_xml_bind.c b/lib/src/clixon_xml_bind.c index 98cd10c7..3bb46ab3 100644 --- a/lib/src/clixon_xml_bind.c +++ b/lib/src/clixon_xml_bind.c @@ -88,9 +88,9 @@ static int _yang_unknown_anydata = 0; * The problem with this is that its global and shuld be bound to a handle */ int -xml_bind_yang_unknown_anydata(int bool) +xml_bind_yang_unknown_anydata(int val) { - _yang_unknown_anydata = bool; + _yang_unknown_anydata = val; return 0; } diff --git a/test/test_cli.sh b/test/test_cli.sh index eec5a924..6a088e15 100755 --- a/test/test_cli.sh +++ b/test/test_cli.sh @@ -80,6 +80,7 @@ expectfn "$clixon_cli -1 -f $cfg set interfaces interface eth/0/0 ipv4 address 1 new "cli configure ip descr" expectfn "$clixon_cli -1 -f $cfg set interfaces interface eth/0/0 description mydesc" 0 "^$" + new "cli configure ip type" expectfn "$clixon_cli -1 -f $cfg set interfaces interface eth/0/0 type ex:eth" 0 "^$" diff --git a/yang/clixon/Makefile.in b/yang/clixon/Makefile.in index 188e22f8..513c2642 100644 --- a/yang/clixon/Makefile.in +++ b/yang/clixon/Makefile.in @@ -3,7 +3,7 @@ # # Copyright (C) 2009-2016 Olof Hagsand and Benny Holmgren # Copyright (C) 2017-2019 Olof Hagsand -# Copyright (C) 2020 Olof Hagsand and Rubicon Communications, LLC(Netgate)# +# Copyright (C) 2020 Olof Hagsand and Rubicon Communications, LLC(Netgate) # This file is part of CLIXON # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -42,7 +42,7 @@ datarootdir = @datarootdir@ # See also OPT_YANG_INSTALLDIR for the standard yang files YANG_INSTALLDIR = @YANG_INSTALLDIR@ -YANGSPECS = clixon-config@2020-02-22.yang +YANGSPECS = clixon-config@2020-04-23.yang YANGSPECS += clixon-lib@2020-04-23.yang YANGSPECS += clixon-rfc5277@2008-07-01.yang YANGSPECS += clixon-xml-changelog@2019-03-21.yang diff --git a/yang/clixon/clixon-config@2020-02-22.yang b/yang/clixon/clixon-config@2020-02-22.yang index 22103e74..aa08151f 100644 --- a/yang/clixon/clixon-config@2020-02-22.yang +++ b/yang/clixon/clixon-config@2020-02-22.yang @@ -40,8 +40,6 @@ module clixon-config { ***** END LICENSE BLOCK *****"; - /* Deleted: clixon-stats state for clixon XML and memory statistics. (moved to clixon-lib) - */ revision 2020-02-22 { description "Added: search index extension, @@ -314,14 +312,6 @@ module clixon-config { Some yang specs seem not to fulfil this. However, if you reset this, there may be follow-up errors due to code that assumes a configuration list has keys"; } - leaf CLICON_YANG_UNKNOWN_ANYDATA{ - type boolean; - default false; - description - "Treat unknown XML/JSON nodes as anydata. - This does not apply to namespaces, which means a top-level node: xxx:yyy - is accepted only if yyy is unknown, not xxx"; - } leaf CLICON_BACKEND_DIR { type string; description @@ -728,4 +718,33 @@ module clixon-config { } } + container clixon-stats{ + config false; + description "Clixon backend statistics."; + container global{ + description "Clixon global statistics"; + leaf xmlnr{ + description "Number of XML objects. That is number of residing xml/json objects + in the internal 'cxobj' representation."; + type uint64; + } + } + list datastore{ + description "Datastore statistics"; + key "name"; + leaf name{ + description "name of datastore (eg running)."; + type string; + } + leaf nr{ + description "Number of XML objects. That is number of residing xml/json objects + in the internal 'cxobj' representation."; + type uint64; + } + leaf size{ + description "Size in bytes of internal datastore cache of datastore tree."; + type uint64; + } + } + } } diff --git a/yang/clixon/clixon-config@2019-09-11.yang b/yang/clixon/clixon-config@2020-04-23.yang similarity index 87% rename from yang/clixon/clixon-config@2019-09-11.yang rename to yang/clixon/clixon-config@2020-04-23.yang index 1a9ed51e..aa75bc91 100644 --- a/yang/clixon/clixon-config@2019-09-11.yang +++ b/yang/clixon/clixon-config@2020-04-23.yang @@ -13,6 +13,7 @@ module clixon-config { "Clixon configuration file ***** BEGIN LICENSE BLOCK ***** Copyright (C) 2009-2019 Olof Hagsand + Copyright (C) 2020 Olof Hagsand and Rubicon Communications, LLC(Netgate) This file is part of CLIXON @@ -39,6 +40,22 @@ module clixon-config { ***** END LICENSE BLOCK *****"; + /* Deleted: clixon-stats state for clixon XML and memory statistics. (moved to clixon-lib) + */ + revision 2020-04-23 { + description + "Added: CLICON_YANG_UNKNOWN_ANYDATA to treat unknown XML (wrt YANG) as anydata. + Deleted: xml-stats non-config data (replaced by rpc stats in clixon-lib.yang)"; + } + revision 2020-02-22 { + description + "Added: search index extension, + Added: clixon-stats state for clixon XML and memory statistics. + Added: CLICON_CLI_BUF_START and CLICON_CLI_BUF_THRESHOLD for quadratic and linear + growth of CLIgen buffers (cbuf:s) + Added: CLICON_VALIDATE_STATE_XML for controling validation of user state XML + Added: CLICON_CLICON_YANG_LIST_CHECK to skip list key checks"; + } revision 2019-09-11 { description "Added: CLICON_BACKEND_USER: drop of privileges to user, @@ -67,6 +84,10 @@ module clixon-config { description "Released in Clixon 3.8"; } + extension search_index { + description "This list argument acts as a search index using optimized binary search. + "; + } typedef startup_mode{ description "Which method to boot/start clicon backend. @@ -289,6 +310,23 @@ module clixon-config { There is a 'good-enough' posix translation mode and a complete libxml2 mode"; } + leaf CLICON_YANG_LIST_CHECK { + type boolean; + default true; + description + "If false, skip Yang list check sanity checks from RFC 7950, Sec 7.8.2: + The 'key' statement, which MUST be present if the list represents configuration. + Some yang specs seem not to fulfil this. However, if you reset this, there may + be follow-up errors due to code that assumes a configuration list has keys"; + } + leaf CLICON_YANG_UNKNOWN_ANYDATA{ + type boolean; + default false; + description + "Treat unknown XML/JSON nodes as anydata. + This does not apply to namespaces, which means a top-level node: xxx:yyy + is accepted only if yyy is unknown, not xxx"; + } leaf CLICON_BACKEND_DIR { type string; description @@ -440,6 +478,25 @@ module clixon-config { Also, if CLICON_CLI_HIST_FILE is set, also the size in lines of the saved history."; } + leaf CLICON_CLI_BUF_START { + type uint32; + default 256; + description + "CLIgen buffer (cbuf) initial size. + When the buffer needs to grow, the allocation grows quadratic up to a threshold + after which linear growth continues. + See CLICON_CLI_BUF_THRESHOLD"; + } + leaf CLICON_CLI_BUF_THRESHOLD { + type uint32; + default 65536; + description + "CLIgen buffer (cbuf) threshold size. + When the buffer exceeds the threshold, the allocation grows by adding the threshold + value to the buffer length. + If 0, the growth continues with quadratic growth. + See CLICON_CLI_BUF_THRESHOLD"; + } leaf CLICON_SOCK_FAMILY { type string; default "UNIX"; @@ -552,6 +609,20 @@ module clixon-config { If CLICON_XML_CHANGELOG is true, Clixon reads the module changelog from this file."; } + leaf CLICON_VALIDATE_STATE_XML { + type boolean; + default false; + description + "Validate user state callback content. + Users may register state callbacks using ca_statedata callback + When set, the XML returned from the callback is validated after merging with + the running db. If it fails, an internal error is returned to the originating + user. + If the option is not set, the XML returned by the user is not validated. + Note that enabling currently causes a large performance overhead for large + lists, therefore it is recommended to enable it during development and debugging + but disable it in production, until this has been resolved."; + } leaf CLICON_STARTUP_MODE { type startup_mode; description "Which method to boot/start clicon backend"; @@ -560,7 +631,9 @@ module clixon-config { type boolean; default false; description "If set, modifications in validation and commit - callbacks are written back into the datastore"; + callbacks are written back into the datastore. + This is a bad idea and therefore obsoleted."; + status obsolete; } leaf CLICON_NACM_MODE { type nacm_mode; @@ -659,6 +732,5 @@ module clixon-config { data to store before dropping. 0 means no retention"; } - } } diff --git a/yang/clixon/clixon-lib@2019-08-13.yang b/yang/clixon/clixon-lib@2019-08-13.yang deleted file mode 100644 index 20cbc9e3..00000000 --- a/yang/clixon/clixon-lib@2019-08-13.yang +++ /dev/null @@ -1,66 +0,0 @@ -module clixon-lib { - yang-version 1.1; - namespace "http://clicon.org/lib"; - prefix cl; - - organization - "Clicon / Clixon"; - - contact - "Olof Hagsand "; - - description - "Clixon Netconf extensions for communication between clients and backend. - - ***** BEGIN LICENSE BLOCK ***** - Copyright (C) 2009-2019 Olof Hagsand and Benny Holmgren - - This file is part of CLIXON - - Licensed under the Apache License, Version 2.0 (the \"License\"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an \"AS IS\" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - Alternatively, the contents of this file may be used under the terms of - the GNU General Public License Version 3 or later (the \"GPL\"), - in which case the provisions of the GPL are applicable instead - of those above. If you wish to allow use of your version of this file only - under the terms of the GPL, and not to allow others to - use your version of this file under the terms of Apache License version 2, - indicate your decision by deleting the provisions above and replace them with - the notice and other provisions required by the GPL. If you do not delete - the provisions above, a recipient may use your version of this file under - the terms of any one of the Apache License version 2 or the GPL. - - ***** END LICENSE BLOCK *****"; - - revision 2019-08-13 { - description - "No changes (reverted change)"; - } - revision 2019-06-05 { - description - "ping rpc added for liveness"; - } - revision 2019-01-02 { - description - "Released in Clixon 3.9"; - } - rpc debug { - description "Set debug level of backend."; - input { - leaf level { - type uint32; - } - } - } - rpc ping { - description "Check aliveness of backend daemon."; - } -}