From a7e0a30938d59da18501dddd4c73d5ba41cd68c3 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Tue, 24 Mar 2020 16:41:30 +0100 Subject: [PATCH] Fixes for 4.4 release --- CHANGELOG.md | 3 ++- apps/cli/cli_main.c | 4 ++++ lib/src/clixon_err.c | 8 ++++---- lib/src/clixon_netconf_lib.c | 11 ++++++++--- lib/src/clixon_options.c | 1 + test/test_cli.sh | 2 +- test/test_identity.sh | 4 ++-- 7 files changed, 22 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e194713..3f82de24 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ features include optimized search functions and a repair callback. [search](https://clixon-docs.readthedocs.io/en/latest/xml.html#searching-in-xml) ### API changes on existing protocol/config features +* Obsolete configuration options present in clixon configuration file will cause clixon application to exit at startup. * JSON * Empty values in JSON has changed to comply to RFC 7951 * empty values of yang type `empty` are encoded as: `{"x":[null]}` @@ -69,7 +70,7 @@ features include optimized search functions and a repair callback. * On failed validation of leafrefs, error message changed from: `No such leaf` to `No leaf matching path `. * CLI Error message (clicon_rpc_generate_error()) changed when backend returns netconf error to be more descriptive: * Original: `Config error: Validate failed. Edit and try again or discard changes: Invalid argument` - * New (example): `Netconf error: application operation-failed Identityref validation failed, undefined not derived from acl-base . Validate failed. Edit and try again or discard changes" + * New (example): `Validate failed. Edit and try again or discard changes: application operation-failed Identityref validation failed, undefined not derived from acl-base" ### C-API changes on existing features (you may need to change your plugin C-code) * `xml_new()` changed from `xml_new(name, xp, ys)` to `xml_new(name, xp, type)` diff --git a/apps/cli/cli_main.c b/apps/cli/cli_main.c index 654d317b..ab7fad6c 100644 --- a/apps/cli/cli_main.c +++ b/apps/cli/cli_main.c @@ -587,7 +587,11 @@ main(int argc, char **argv) restarg = clicon_strjoin(argc, argv, " "); /* If several cligen object variables match same preference, select first */ +#if 0 /* New cligen version (not in 4.4) */ + cligen_preference_mode_set(cli_cligen(h), 1); +#else cligen_match_cgvar_same(1); +#endif /* Call start function in all plugins before we go interactive */ diff --git a/lib/src/clixon_err.c b/lib/src/clixon_err.c index 08225503..b8c5bf26 100644 --- a/lib/src/clixon_err.c +++ b/lib/src/clixon_err.c @@ -77,8 +77,8 @@ struct err_state{ /* * Variables */ -int clicon_errno = 0; /* See enum clicon_err */ -int clicon_suberrno = 0; /* Corresponds to errno.h */ +int clicon_errno = 0; /* See enum clicon_err XXX: hide this and change to err_category */ +int clicon_suberrno = 0; /* Corresponds to errno.h XXX: change to errno */ char clicon_err_reason[ERR_STRLEN] = {0, }; /* @@ -147,7 +147,7 @@ clicon_err_reset(void) int clicon_err_fn(const char *fn, const int line, int category, - int err, + int suberr, char *format, ...) { va_list args; @@ -157,7 +157,7 @@ int clicon_err_fn(const char *fn, /* Set the global variables */ clicon_errno = category; - clicon_suberrno = errno; + clicon_suberrno = suberr; /* first round: compute length of error message */ va_start(args, format); diff --git a/lib/src/clixon_netconf_lib.c b/lib/src/clixon_netconf_lib.c index 75d316d1..02b9cefb 100644 --- a/lib/src/clixon_netconf_lib.c +++ b/lib/src/clixon_netconf_lib.c @@ -3,7 +3,8 @@ ***** BEGIN LICENSE BLOCK ***** Copyright (C) 2009-2016 Olof Hagsand and Benny Holmgren - Copyright (C) 2017-2020 Olof Hagsand + Copyright (C) 2017-2019 Olof Hagsand + Copyright (C) 2020 Olof Hagsand and Rubicon Communications, LLC This file is part of CLIXON. @@ -48,6 +49,7 @@ #include #include #include +#include /* cligen */ #include @@ -1535,8 +1537,11 @@ clixon_netconf_error_fn(const char *fn, } if (netconf_err2cb(xerr, cb) < 0) goto done; - - clicon_err_fn(fn, line, category, 0, "%s", cbuf_get(cb)); +#if 0 /* More verbose output for debugging */ + clicon_log(LOG_ERR, "%s: %d: %s", fn, line, cbuf_get(cb)); +#else + clicon_log(LOG_ERR, "%s", cbuf_get(cb)); +#endif retval = 0; done: if (cb) diff --git a/lib/src/clixon_options.c b/lib/src/clixon_options.c index 79d2c488..3c50e11b 100644 --- a/lib/src/clixon_options.c +++ b/lib/src/clixon_options.c @@ -245,6 +245,7 @@ parse_configfile(clicon_handle h, } if (netconf_err2cb(xerr, cbret) < 0) goto done; + /* Here one could make it more relaxing to not quit on unrecognized option? */ clixon_netconf_error(OE_CFG, xerr, NULL, NULL); goto done; } diff --git a/test/test_cli.sh b/test/test_cli.sh index 2ad9f3dc..4d38da35 100755 --- a/test/test_cli.sh +++ b/test/test_cli.sh @@ -73,7 +73,7 @@ new "cli configure using encoded chars name <&" expectfn "$clixon_cli -1 -f $cfg set interfaces interface fddi&< type ianaift:ethernetCsmacd" 0 "" new "cli failed validate" -expectpart "$($clixon_cli -1 -f $cfg -l o validate)" 255 "Netconf error: Validate failed. Edit and try again or discard changes: application missing-element Mandatory variable type" +expectpart "$($clixon_cli -1 -f $cfg -l o validate)" 255 "Validate failed. Edit and try again or discard changes: application missing-element Mandatory variable type" new "cli configure ip addr" expectfn "$clixon_cli -1 -f $cfg set interfaces interface eth/0/0 ipv4 address 1.2.3.4 prefix-length 24" 0 "^$" diff --git a/test/test_identity.sh b/test/test_identity.sh index 3e47824f..57725b07 100755 --- a/test/test_identity.sh +++ b/test/test_identity.sh @@ -253,14 +253,14 @@ new "CLI set wrong acl-type" expectfn "$clixon_cli -1 -f $cfg -l o set acls acl x type undefined" 0 "^$" new "cli validate acl-type" -expectpart "$($clixon_cli -1 -f $cfg -l o validate)" 255 " Netconf error: Validate failed. Edit and try again or discard changes: application operation-failed Identityref validation failed, undefined not derived from acl-base" +expectpart "$($clixon_cli -1 -f $cfg -l o validate)" 255 "Validate failed. Edit and try again or discard changes: application operation-failed Identityref validation failed, undefined not derived from acl-base" # test empty identityref list new "cli set empty" expectfn "$clixon_cli -1 -f $cfg -l o set e undefined" 0 "^$" new "cli validate empty" -expectpart "$($clixon_cli -1 -f $cfg -l o validate)" 255 "Netconf error: Validate failed. Edit and try again or discard changes: application operation-failed Identityref validation failed, undefined not derived from acl-base" +expectpart "$($clixon_cli -1 -f $cfg -l o validate)" 255 "Validate failed. Edit and try again or discard changes: application operation-failed Identityref validation failed, undefined not derived from acl-base" new "netconf discard-changes" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$"