clixon-config.yang: Added CLICON_DEBUG, Removed: CLICON_NETCONF_DUPLICATE_ALLOW

Rearranged and grouped options
clixon-lib.yang: Added debug types
Removed git reliance in test - moved to configure script
This commit is contained in:
Olof hagsand 2024-05-21 13:02:20 +02:00
parent c8a8197e92
commit b6480ac07d
15 changed files with 320 additions and 174 deletions

View file

@ -29,13 +29,15 @@ Expected: June 2024
* CLI support for multiple inline commands separated by semi-colon
* New `clixon-config@2024-04-01.yang` revision
* Added options:
- `CLICON_DEBUG`: Debug flags, partly implemented.
- `CLICON_YANG_SCHEMA_MOUNT_SHARE`: Share same YANGs of several moint-points
- `CLICON_SOCK_PRIO`: Enable socket event priority
- `CLICON_XMLDB_MULTI`: Split datastore into multiple sub files
- `CLICON_NETCONF_DUPLICATE_ALLOW`: Disable duplicate check in NETCONF messages
- `CLICON_CLI_OUTPUT_FORMAT`: Default CLI output format
- `CLICON_AUTOLOCK`: Implicit locks
* New `clixon-lib@2024-04-01.yang` revision
- Added: debug bits type
- Added: xmldb-split extension
- Added: Default format
### API changes on existing protocol/config features

View file

@ -644,10 +644,7 @@ from_client_edit_config(clixon_handle h,
*/
if ((ret = xml_yang_validate_minmax(xc, 1, &xret)) < 0)
goto done;
/* Disable duplicate check in NETCONF messages.*/
if (clicon_option_bool(h, "CLICON_NETCONF_DUPLICATE_ALLOW"))
;
else if (ret == 1 && (ret = xml_yang_validate_unique_recurse(xc, &xret)) < 0)
if (ret == 1 && (ret = xml_yang_validate_unique_recurse(xc, &xret)) < 0)
goto done;
/* xmldb_put (difflist handling) requires list keys */
if (ret == 1 && (ret = xml_yang_validate_list_key_only(xc, &xret)) < 0)

View file

@ -632,6 +632,17 @@ cli_del(clixon_handle h,
return retval;
}
/*! Get debug level of CLI client
*/
int
cli_debug_show(clixon_handle h,
cvec *cvv,
cvec *argv)
{
cligen_output(stdout, "CLI debug:0x%x\n", clixon_debug_get());
return 0;
}
/*! Set debug level on CLI client (not backend daemon)
*
* @param[in] h Clixon handle
@ -736,7 +747,6 @@ cli_debug_restconf(clixon_handle h,
return retval;
}
/*! Set syntax mode
*
* @param[in] h Clixon handle

View file

@ -751,6 +751,7 @@ main(int argc,
break;
}
}
argc -= optind;
argv += optind;
@ -761,6 +762,24 @@ main(int argc,
/* Defer: Wait to the last minute to print help message */
if (help)
usage(h, argv[0]);
/* Unless -D, set debug level to CLICON_DEBUG set
* Only works for one value.
*/
{
char *dstr;
int d = 0;
dstr = clicon_option_str(h, "CLICON_DEBUG");
if (dbg == 0 && dstr && strlen(dstr)){
if ((d = clixon_debug_str2key(dstr)) < 0 &&
sscanf(optarg, "%d", &d) != 1){
clixon_err(OE_CFG, 0, "Parsing CLICON_DEBUG: %s", dstr);
goto done;
}
clixon_debug_init(h, d);
clixon_log_init(h, __PROGRAM__, d?LOG_DEBUG:LOG_INFO, logdst);
}
}
/* Split remaining argv/argc into <cmd> and <extra-options> */
if (options_split(h, argv0, argc, argv, &restarg) < 0)

View file

@ -91,6 +91,7 @@ int cli_merge(clixon_handle h, cvec *vars, cvec *argv);
int cli_create(clixon_handle h, cvec *vars, cvec *argv);
int cli_remove(clixon_handle h, cvec *vars, cvec *argv);
int cli_del(clixon_handle h, cvec *vars, cvec *argv);
int cli_debug_show(clixon_handle h, cvec *cvv, cvec *argv);
int cli_debug_cli(clixon_handle h, cvec *vars, cvec *argv);
int cli_debug_backend(clixon_handle h, cvec *vars, cvec *argv);
int cli_debug_restconf(clixon_handle h, cvec *vars, cvec *argv);

3
configure vendored
View file

@ -2814,7 +2814,8 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
CLIXON_VERSION_MAJOR="7"
CLIXON_VERSION_MINOR="1"
CLIXON_VERSION_PATCH="0"
CLIXON_VERSION="\"${CLIXON_VERSION_MAJOR}.${CLIXON_VERSION_MINOR}.${CLIXON_VERSION_PATCH}.PRE\""
# Use GIT, if this does not work, need a fallback mechanism
CLIXON_VERSION="$(git log --pretty="format:%(describe) %ci" -n1)"
# Debug flag
# Check whether --enable-debug was given.

View file

@ -51,7 +51,8 @@ AC_CONFIG_AUX_DIR(config-aux)
CLIXON_VERSION_MAJOR="7"
CLIXON_VERSION_MINOR="1"
CLIXON_VERSION_PATCH="0"
CLIXON_VERSION="\"${CLIXON_VERSION_MAJOR}.${CLIXON_VERSION_MINOR}.${CLIXON_VERSION_PATCH}.PRE\""
# Use GIT, if this does not work, need a fallback mechanism
CLIXON_VERSION="$(git log --pretty="format:%(describe) %ci" -n1)"
# Debug flag
AC_ARG_ENABLE(debug, AS_HELP_STRING([--enable-debug],[Build with debug symbols, default: no]),[

View file

@ -86,6 +86,9 @@ show("Show a particular state of the system"){
auto("Show expand x"){
@datamodelshow, cli_show_auto("candidate", "default", true, false, "report-all");
}
debug("Show debug"), cli_debug_show();{
cli("Show cli debug"), cli_debug_show();
}
xpath("Show configuration") <xpath:string>("XPATH expression")
[<ns:string>("Namespace")], show_conf_xpath("candidate");
version("Show version"), cli_show_version("candidate", "text", "/");

View file

@ -48,13 +48,14 @@
/* Debug flags are seperated into subject areas and detail
* @see dbgmap Symbolic mapping (if you change here you may need to change dbgmap)
* @see clixon_debug in clixon-lib.yang
*/
/* Detail level */
#define CLIXON_DBG_ALWAYS 0x00000000 /* Unconditionally logged */
#define CLIXON_DBG_DETAIL 0x01000000 /* Details: traces, parse trees, etc */
#define CLIXON_DBG_DETAIL2 0x02000000 /* Extra details */
#define CLIXON_DBG_DETAIL3 0x03000000 /* Probably more detail than you want */
#define CLIXON_DBG_DMASK 0x03000000 /* Detail mask */
#define CLIXON_DBG_DETAIL3 0x04000000 /* Probably more detail than you want */
#define CLIXON_DBG_DMASK 0x07000000 /* Detail mask */
#define CLIXON_DBG_DSHIFT 24
/* Subject area */
@ -71,11 +72,11 @@
#define CLIXON_DBG_SNMP 0x00000400 /* SNMP frontend */
#define CLIXON_DBG_NACM 0x00000800 /* NACM processing */
#define CLIXON_DBG_PROC 0x00001000 /* Process handling */
#define CLIXON_DBG_DATASTORE 0x00002000 /* Datastore management */
#define CLIXON_DBG_DATASTORE 0x00002000 /* Datastore xmldb management */
#define CLIXON_DBG_EVENT 0x00004000 /* Event processing */
#define CLIXON_DBG_RPC 0x00008000 /* RPC handling */
#define CLIXON_DBG_STREAM 0x00010000 /* Notification streams */
#define CLIXON_DBG_PARSE 0x00020000 /* Parser */
#define CLIXON_DBG_PARSE 0x00020000 /* Parser: XML,YANG, etc */
/* External applications */
#define CLIXON_DBG_APP 0x00100000 /* External application */

View file

@ -1589,8 +1589,8 @@ yang_enum2int(yang_stmt *ytype,
}
/*! Given a YANG (bits) type node and a bit string, return the bit position.
* Example:
*
* Example:
* type bits {
* bit stateA {
* position "0"; << This one
@ -1603,7 +1603,7 @@ yang_enum2int(yang_stmt *ytype,
* If the position is not specified, it will be automatically assigned as defined
* in RFC7950, section 9.7.4.2
*
* @param[in] ytype YANG type noden
* @param[in] ytype YANG type node
* @param[in] bitstr bit (flag) string
* @param[out] bitpos position for the given bit (flag)
* @retval 1 OK, result in flagpos
@ -1653,8 +1653,7 @@ yang_bits_pos(yang_stmt *ytype,
goto done;
}
/*! Given a YANG (bits) type node and string value, return the
* SNMP value for all bits (flags) that are set.
/*! Given a YANG (bits) type node and string value, return SNMP value for bits set.
*
* @param[in] h Clixon handle
* @param[in] ytype YANG type noden
@ -1665,6 +1664,7 @@ yang_bits_pos(yang_stmt *ytype,
* @retval 0 Invalid, not found
* @retval -1 Error
* @see yang_val2bitsstr
* XXX de-snmp:ize
*/
int
yang_bitsstr2val(clixon_handle h,
@ -1739,6 +1739,7 @@ yang_bitsstr2val(clixon_handle h,
* @retval 0 Invalid, not found
* @retval -1 Error
* @see yang_bitsstr2val
* XXX de-snmp:ize
*/
int
yang_val2bitsstr(clixon_handle h,

View file

@ -78,6 +78,8 @@ CLIXON_CONFIG_REV="2024-04-01"
CLIXON_RESTCONF_REV="2022-08-01"
CLIXON_EXAMPLE_REV="2022-11-01"
CLIXON_VERSION="@CLIXON_VERSION@"
# Length of TSL RSA key
# Problem with small key such as 1024 not allowed in centos8 for example (why is this)
# Problem with long keys are they take time to generate, eg on ARM

View file

@ -41,9 +41,6 @@ if [ -f ./config.sh ]; then
fi
fi
# Note that this relies on git being present in shell
CLIXON_VERSION="$(git log --pretty="format:%(describe) %ci" -n1)"
# Test number from start
: ${testnr:=0}

View file

@ -84,6 +84,13 @@ expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS>
new "Set cli debug using cli"
expectpart "$($clixon_cli -1 -f $cfg -l o debug cli 1)" 0 "^$"
# Run cli debug
new "get cli debug, expect 0"
expectpart "$($clixon_cli -1 -f $cfg show debug cli)" 0 "CLI debug:0x0"
new "get cli debug expect 2"
expectpart "$($clixon_cli -1 -f $cfg -o CLICON_DEBUG=msg show debug cli)" 0 "CLI debug:0x2"
new "Set backend debug using cli"
expectpart "$($clixon_cli -1 -f $cfg -l o debug backend 1)" 0 "^$"

View file

@ -52,10 +52,10 @@ module clixon-config {
revision 2024-04-01 {
description
"Added options:
CLICON_DEBUG: Debug flags.
CLICON_YANG_SCHEMA_MOUNT_SHARE: Share same YANGs of equal moint-points.
CLICON_SOCK_PRIO: Enable socket event priority
CLICON_XMLDB_MULTI: Split datastore into multiple sub files
CLICON_NETCONF_DUPLICATE_ALLOW: Disable duplicate check in NETCONF messages.
CLICON_CLI_OUTPUT_FORMAT: Default CLI output format
CLICON_AUTOLOCK: Implicit locks
Released in Clixon 7.1";
@ -456,6 +456,14 @@ module clixon-config {
Ensure that YANG_INSTALLDIR (default
/usr/local/share/clixon) is present in the path";
}
leaf CLICON_DEBUG{
type cl:clixon_debug_t;
description
"Debug flags as bitfields.
Can also be given directly as -D <flag> to clixon commands (which overrides this)
Note only partly implemented;
- Only CLI, only single value, cannot be combined with -D, not in RPC";
}
leaf CLICON_CONFIGFILE{
type string;
description
@ -539,12 +547,6 @@ module clixon-config {
Note this is similar to what happens to YANG nodes that are disabled by a false
if-feature statement.";
}
leaf CLICON_BACKEND_DIR {
type string;
description
"Location of backend .so plugins. Load all .so
plugins in this dir as backend plugins";
}
leaf CLICON_YANG_SCHEMA_MOUNT{
type boolean;
description
@ -568,12 +570,89 @@ module clixon-config {
Only if CLICON_YANG_SCHEMA_MOUNT is enabled";
default false;
}
leaf CLICON_YANG_AUGMENT_ACCEPT_BROKEN {
type boolean;
default false;
description
"Debug option. If enabled, accept broken augments on the form:
augment <target> { ... }
where <target> is an XPath which MUST be an existing node but for many
yangmodels do not.
There are several cases why this may be the case:
- syntax errors,
- features that need to be enabled
- wrong XPaths, etc
This option should be enabled only for passing some testcases it should
normally never be enabled in system YANGs that are used in a system.";
}
leaf CLICON_YANG_LIBRARY {
type boolean;
default true;
description
"Enable YANG library support as state data according to RFC8525.
If enabled, module info will appear when doing netconf get or
restconf GET.
The module state data is on the form:
<yang-library><module-set>...
instead where the module state is on the form:
<modules-state>...
See also CLICON_XMLDB_MODSTATE where the module state info is used to tag datastores
with module information.";
}
leaf CLICON_BACKEND_DIR {
type string;
description
"Location of backend .so plugins. Load all .so
plugins in this dir as backend plugins";
}
leaf CLICON_BACKEND_REGEXP {
type string;
description
"Regexp of matching backend plugins in CLICON_BACKEND_DIR";
default "(.so)$";
}
leaf CLICON_BACKEND_USER {
type string;
description
"User name for backend (both foreground and daemonized).
If you set this value the backend if started as root will lower
the privileges after initialization.
The ownership of files created by the backend will also be set to this
user (eg datastores).
It also sets the backend unix socket owner to this user, but its group
is set by CLICON_SOCK_GROUP.
See also CLICON_BACKEND_PRIVILEGES setting";
}
leaf CLICON_BACKEND_PRIVILEGES {
type priv_mode;
default none;
description
"Backend privileges mode.
If CLICON_BACKEND_USER user is set, mode can be set to drop_perm or
drop_temp.
Drop privs may not be used together with CLICON_XMLDB_MULTI";
}
leaf CLICON_BACKEND_PIDFILE {
type string;
mandatory true;
description "Process-id file of backend daemon";
}
leaf CLICON_BACKEND_RESTCONF_PROCESS {
type boolean;
default false;
description
"If set, enable process-control of restconf daemon, ie start/stop restconf
daemon internally from backend daemon.
Also, if set, restconf daemon queries backend for its config
if not set, restconf daemon reads its config from main config file
It uses clixon-restconf.yang for config and clixon-lib.yang for RPC
Process control of restconf daemon is as follows:
- on RPC start, if enable is true, start the service, if false, error or ignore it
- on RPC stop, stop the service
- on backend start make the state as configured
- on enable change, make the state as configured
Disable if you start the restconf daemon by other means.";
}
leaf CLICON_NETCONF_DIR{
type string;
description "Location of netconf (frontend) .so plugins";
@ -616,16 +695,6 @@ module clixon-config {
RFC6242 for example.
This only applies to the external NETCONF";
}
leaf CLICON_NETCONF_DUPLICATE_ALLOW {
type boolean;
default false;
description
"Disable duplicate check in NETCONF messages.
In Clixon 7.0, a stricter check of duplicate entries in incoming NETCONF messages was made.
More specifically: lists and leaf-lists with non-unique entries.
Enable to disable this check, and to allow duplicates in incoming NETCONF messages.
Note that this is an error by such a client, but there is some legacy code that uses this";
}
leaf CLICON_NETCONF_CREATOR_ATTR {
type boolean;
default false;
@ -641,6 +710,21 @@ module clixon-config {
config";
status obsolete;
}
leaf CLICON_NETCONF_MONITORING {
type boolean;
default true;
description
"Enable Netconf monitoring support as state data according to RFC6022.
If enabled, netconf monitoring info will appear when doing netconf get or
restconf GET.";
}
leaf CLICON_NETCONF_MONITORING_LOCATION {
type string;
description
"Extra Netconf monitoring location directory where schemas can be retrieved
apart from NETCONF.
Only if CLICON_NETCONF_MONITORING";
}
leaf CLICON_RESTCONF_API_ROOT {
type string;
default "/restconf";
@ -952,48 +1036,6 @@ module clixon-config {
non-prio events is disabled
This is useful if the backend opens other sockets, such as the controller";
}
leaf CLICON_BACKEND_USER {
type string;
description
"User name for backend (both foreground and daemonized).
If you set this value the backend if started as root will lower
the privileges after initialization.
The ownership of files created by the backend will also be set to this
user (eg datastores).
It also sets the backend unix socket owner to this user, but its group
is set by CLICON_SOCK_GROUP.
See also CLICON_BACKEND_PRIVILEGES setting";
}
leaf CLICON_BACKEND_PRIVILEGES {
type priv_mode;
default none;
description
"Backend privileges mode.
If CLICON_BACKEND_USER user is set, mode can be set to drop_perm or
drop_temp.
Drop privs may not be used together with CLICON_XMLDB_MULTI";
}
leaf CLICON_BACKEND_PIDFILE {
type string;
mandatory true;
description "Process-id file of backend daemon";
}
leaf CLICON_BACKEND_RESTCONF_PROCESS {
type boolean;
default false;
description
"If set, enable process-control of restconf daemon, ie start/stop restconf
daemon internally from backend daemon.
Also, if set, restconf daemon queries backend for its config
if not set, restconf daemon reads its config from main config file
It uses clixon-restconf.yang for config and clixon-lib.yang for RPC
Process control of restconf daemon is as follows:
- on RPC start, if enable is true, start the service, if false, error or ignore it
- on RPC stop, stop the service
- on backend start make the state as configured
- on enable change, make the state as configured
Disable if you start the restconf daemon by other means.";
}
leaf CLICON_AUTOCOMMIT {
type int32;
default 0;
@ -1014,17 +1056,6 @@ module clixon-config {
Also, any edits in candidate are discarded if the client closes the connection.
This effectively disables shared candidate";
}
leaf CLICON_XMLDB_DIR {
type string;
mandatory true;
description
"Directory where datastores such as \"running\", \"candidate\" and \"startup\"
are placed.
If CLICON_XMLDB_MULTI is enabled, this is the directory where a datastore
subdir is stored, such as \"running.d/\"
";
}
leaf CLICON_DATASTORE_CACHE {
type datastore_cache;
default cache;
@ -1036,6 +1067,16 @@ module clixon-config {
Note that from 7.0 this is OBSOLETED, only datastore_cache is supported";
status obsolete;
}
leaf CLICON_XMLDB_DIR {
type string;
mandatory true;
description
"Directory where datastores such as \"running\", \"candidate\" and \"startup\"
are placed.
If CLICON_XMLDB_MULTI is enabled, this is the directory where a datastore
subdir is stored, such as \"running.d/\"
";
}
leaf CLICON_XMLDB_FORMAT {
type cl:datastore_format;
default xml;
@ -1138,21 +1179,6 @@ module clixon-config {
If true: The symbols defined by this shared object will be made available for symbol res
olution of subsequently loaded shared objects.";
}
leaf CLICON_YANG_AUGMENT_ACCEPT_BROKEN {
type boolean;
default false;
description
"Debug option. If enabled, accept broken augments on the form:
augment <target> { ... }
where <target> is an XPath which MUST be an existing node but for many
yangmodels do not.
There are several cases why this may be the case:
- syntax errors,
- features that need to be enabled
- wrong XPaths, etc
This option should be enabled only for passing some testcases it should
normally never be enabled in system YANGs that are used in a system.";
}
leaf CLICON_NAMESPACE_NETCONF_DEFAULT {
type boolean;
default false;
@ -1162,7 +1188,6 @@ module clixon-config {
If defined, top-level rpc calls need not have namespaces (eg using xmlns=<ns>)
since the default NETCONF namespace will be assumed. (This is not standard).
See rfc6241 3.1: urn:ietf:params:xml:ns:netconf:base:1.0.";
}
leaf CLICON_STARTUP_MODE {
type startup_mode;
@ -1218,20 +1243,6 @@ module clixon-config {
If this option is set, Clixon disables NACM if a datastore does NOT contain a
NACM config on load.";
}
leaf CLICON_YANG_LIBRARY {
type boolean;
default true;
description
"Enable YANG library support as state data according to RFC8525.
If enabled, module info will appear when doing netconf get or
restconf GET.
The module state data is on the form:
<yang-library><module-set>...
instead where the module state is on the form:
<modules-state>...
See also CLICON_XMLDB_MODSTATE where the module state info is used to tag datastores
with module information.";
}
leaf CLICON_MODULE_SET_ID {
type string;
default "0";
@ -1244,21 +1255,6 @@ module clixon-config {
If CLICON_MODULE_LIBRARY_RFC7895 is enabled, it sets the modules-state/module-set-id
instead";
}
leaf CLICON_NETCONF_MONITORING {
type boolean;
default true;
description
"Enable Netconf monitoring support as state data according to RFC6022.
If enabled, netconf monitoring info will appear when doing netconf get or
restconf GET.";
}
leaf CLICON_NETCONF_MONITORING_LOCATION {
type string;
description
"Extra Netconf monitoring location directory where schemas can be retrieved
apart from NETCONF.
Only if CLICON_NETCONF_MONITORING";
}
leaf CLICON_STREAM_DISCOVERY_RFC5277 {
type boolean;
default false;

View file

@ -71,7 +71,8 @@ module clixon-lib {
revision 2024-04-01 {
description
"Added: xmldb-split extension
"Added: debug bits type
Added: xmldb-split extension
Added: Default format
Released in Clixon 7.1";
}
@ -187,6 +188,113 @@ module clixon-lib {
}
}
}
typedef clixon_debug_t {
description
"Debug flags.
Flags are seperated into subject areas and detail
Can also be given directly as -D <flag> to clixon commands
Note there are also constants in the code thaht need to be in sync with these values";
type bits {
/* Subjects: */
bit default {
description "Default logs";
position 0;
}
bit msg {
description "In/out messages";
position 1;
}
bit init {
description "Initialization";
position 2;
}
bit xml {
description "XML processing";
position 3;
}
bit xpath {
description "XPath processing";
position 4;
}
bit yang {
description "YANG processing";
position 5;
}
bit backend {
description "Backend-specific";
position 6;
}
bit cli {
description "CLI frontend";
position 7;
}
bit netconf {
description "NETCONF frontend";
position 8;
}
bit restconf {
description "RESTCONF frontend";
position 9;
}
bit snmp {
description "SNMP frontend";
position 10;
}
bit nacm {
description "NACM processing";
position 11;
}
bit proc {
description "Process handling";
position 12;
}
bit datastore {
description "Datastore xmldb management";
position 13;
}
bit event {
description "Event processing";
position 14;
}
bit rpc {
description "RPC handling";
position 15;
}
bit stream {
description "Notification streams";
position 16;
}
bit parse {
description "Parser: XML,YANG, etc";
position 17;
}
bit app {
description "External applications";
position 20;
}
bit app2 {
description "External application";
position 21;
}
bit app3 {
description "External application 2";
position 22;
}
/* Detail level: */
bit detail {
description "Details: traces, parse trees, etc";
position 24;
}
bit detail2 {
description "Extra details";
position 25;
}
bit detail3 {
description "Probably more detail than you want";
position 26;
}
}
}
identity snmp {
description
"SNMP";