Commit graph

50 commits

Author SHA1 Message Date
Olof hagsand
d84c529ff1 [Code formatting: Change indentation style to space](https://github.com/clicon/clixon/issues/379)
* Applies to all c/h/y/l/sh files and .editorconfig
2022-10-27 14:21:17 +02:00
Olof hagsand
74da966096 Fixed: [Missing/no namespace error in YANG augments with default values](https://github.com/clicon/clixon/issues/354)
Tests: ensure all netconf requests with identityref have declared namespaces.
  * This is part of fixing [Yang identityref XML encoding is not general](https://github.com/clicon/clixon/issues/90)
2022-08-18 16:38:24 +02:00
Olof hagsand
609e27e0c2 Augmented XML uses default namespace
* Instead of using prefixes for augmented XML, assign the default namespace
Test: moved datastore format tests from test_cli to new test_datastore_format
2022-06-08 11:49:48 +02:00
Olof hagsand
c038c9a27f * Implementation of "chunked framing" according to RFC6242 for Netconf 1.1.
* First hello is 1.0 EOM framing, then successing rpc is chunked framing
  * See
    * [Netconf framing](https://github.com/clicon/clixon/issues/50), and
    * [Clixon does not switch to chunked framing after NETCONF 1.1 is negotiated](https://github.com/clicon/clixon/issues/314)
* C:
  * Moved netconf framing code from netconf application to clixon lib
* Test:
  * New expecteof_netconf and adjusted other expect scripts to handle NETCONF 1.1 framing
2022-03-28 12:36:44 +02:00
Olof hagsand
dd2ac56af8 Module state upgrade: RFC7895 to RFC 8525
Changes to clixon-config:
  * Added option: 'CLICON_YANG_LIBRARY`
  * Changed default value: `CLICON_MODULE_LIBRARY_RFC7895` to false
Datastore modstate is backward compatible
Tests upgraded to RFC8525
2022-03-07 10:56:54 +01:00
Olof hagsand
4102ca8a46 * configure --with-wwwdir=<dir> is removed
* test:
  * new test_helloworld.sh smoketest added for testing basic functions
  * stripped restconf fcgi default config
  * added yang variable
2022-02-07 13:31:39 +01:00
Olof hagsand
2dcc14a0db Added error handling in yang_path_arg triggered by no filter in get paginated
Fixed cornercase of restconf error return when no body
Fixed cornercase when exactly / given as xpath
Better error message when YANG not found: added which YANG file imports it
2021-11-10 18:35:24 +01:00
Olof hagsand
a1fe080111 CLIgen mem leak, test augment 2021-11-05 14:43:28 +01:00
Olof hagsand
940f4d4fb9 * Added ordering sanity check for YANG modules and sub-modules
* If YANG sub-statements are placed in wrong order, clixon fails on error.
2021-06-24 21:56:36 +02:00
Olof hagsand
6bac41890d github actions: try docker test 2021-06-16 14:44:42 +02:00
Olof hagsand
8bd0aa82d6 github actions: debug wait backend/restconf 2021-06-16 14:39:28 +02:00
Olof hagsand
c814b809bb github actions: test backend run 2021-06-16 14:34:52 +02:00
Olof hagsand
84f5762ab5 * Most tests work with HTTP/2 support using nghttp2
* except non-ssl http/1->/2 upgrade
* Restconf: ensure HEAD method works everywhere GET does.
2021-06-08 20:53:43 +02:00
Olof hagsand
783b0a4857 * YANG when statement in conjunction with grouping/uses/augment
* Several cases were not implemented fully according to RFC 7950
    * Do not extend default values if when statements evaluate to false
    * Do not allow edit-config of nodes if when statements evaluate to false (Sec 8.3.2)
    * If a key leaf is defined in a grouping that is used in a list, the "uses" statement MUST NOT have a "when" statement. (See 7.21.5)
  * See [yang uses's substatement when has no effect #218](https://github.com/clicon/clixon/issues/2$
2021-05-13 14:26:02 +02:00
Olof hagsand
15d01c58d8 - Better restconf debug: when restconf debug flag set in datastore, ensure the process is started with -D set
- Fixed native http support for base container
- Changed test certs and restconf scripts to functions
2021-04-09 09:34:05 +02:00
Olof hagsand
244060fddc - Added specific WITH_RESTCONF compile contants for _NATIVE and _FCGI for C code
- Restconf auth=none changes
  - Load clixon-restconf and resolve features earlier so that config features work
  - Removed auth=none code from example (this was non-std half-baked basic auth)
  - Changed tests that used auth-type=none to enable feature clixon-restconf:allow-auth-none
- Moved cert creation from sub-shell to servercert function
- Fixed typos for dockerfile rename of restconf evhtp to native
2021-04-07 20:54:41 +02:00
Olof hagsand
5692072d36 * Fixed: [CLIXON is not waiting for the hello message #184](https://github.com/clicon/clixon/issues/184)
* Hello message semantics has been made stricter according to RFC 6241 Sec 8.1, for example:
  * A client MUST send a <hello> element.
  * Each peer MUST send at least the base NETCONF capability, "urn:ietf:params:netconf:base:1.1" (or 1.0 for RFC 4741)
  * The netconf client will terminate (close the socket) if the client does not comply
  * You can set `CLICON_NETCONF_HELLO_OPTIONAL` to true to use the old behavior of essentially ignoring hellos.
* New clixon-config@2020-03-08.yang revision
  * Added: `CLICON_NETCONF_HELLO_OPTIONAL`
* The base capability has been changed to "urn:ietf:params:netconf:base:1.1" following RFC6241.
2021-03-10 14:18:16 +01:00
Olof hagsand
b7991d9b39 * Made a separate Clixon datastore XML/JSON top-level symbol
* Replaces the hardcoded "config" keyword.
  * Implemented by a compile-time option called `DATASTORE_TOP_SYMBOL` option in clixon_custom.h
* Tests: added endtest to all tests. Removed all premature exits if BE=0
2021-03-05 14:15:15 +01:00
Olof hagsand
9840e248c6 * Augment target node check strict, instead of printing a warning, it will terminate with error.
* Fixed: [Augment that reference a submodule as target node fails #178](https://github.com/clicon/clixon/issues/178)
* Fixed a memory error that was reported in slack by Pawel Maslanka
  * The crash printout was: `realloc(): invalid next size Aborted`
2021-02-19 15:46:55 +01:00
Olof hagsand
c64878fd4a * RESTCONF configuration is unified and moved from clixon-config.yang to clixon-restconf.yang
* Except `CLICON_RESTCONF_DIR` which remains in clixon-config.yang due to bootstrapping
    * -d <dir> option removed
  * This applies to both evhtp and fcgi RESTCONF
    * Both can also read config from backend, and be started from backend
  * You may need to move config as follows (from clixon-config.yang to clixon-restconf.yang)
    * CLICON_RESTCONF_PRETTY -> restconf/pretty
    * CLICON_RESTCONF_PATH -> restconf/fcgi-path
2021-02-11 13:46:34 +01:00
Olof hagsand
710fc76887 * Restconf authentication callback (ca_auth) signature changed
* Not backward compatible: All uses of the ca-auth callback in restconf plugins must be changed
  * New version is: `int ca_auth(h, req, auth_type, authp, userp)`
    * where `auth_type` is the requested authentication-type (none, client-cert or user-defined)
    * `authp` is the returned authentication flag
    * `userp` is the returned associated authenticated user
    * and the return value is three-valued: -1: Error, 0: ignored, 1: OK
  * For more info see [clixon-docs](https://clixon-docs.readthedocs.io/en/latest/restconf.html)
* New clixon-restconf@2020-12-30.yang revision
2021-02-09 21:26:35 +01:00
Olof hagsand
a71e8aaceb * minor edits make datastore=nocache pass tests, and ensure generic copy-config works 2020-12-04 14:47:55 +01:00
Olof hagsand
f69daf773e more test and vagrant for nginx checks 2020-11-25 19:48:42 +01:00
Olof hagsand
0b948248e4 * Reworked evhtp restconf config to only use clixon-restconf.yang and marked local restconf options as obsolete
* Extended clicon-config with clixon-restconf for local config
* Removed obsolete CLICON_TRANSACTION_MOD
2020-11-21 13:16:29 +01:00
Olof hagsand
9016dde319 Modify tests so they all work with evhtp and backend config, eg that CLICON_RESTCONF_CONFIG is default true.
Note that some tests are forced to CLICON_RESTCONF_CONFIG is false due to test complexities.
2020-11-18 13:57:25 +01:00
Olof hagsand
daaf3f17df revert clixon-err on XML
restconf backend config
2020-11-18 13:57:25 +01:00
Olof hagsand
c616aa1569 Added support for XPATH functions:
* `contains`,
  * `derived-from` and `derived-from-or-self`
    * in particular in augment/when statements as shown in eg RFC 7950.
2020-09-22 22:40:42 +02:00
Olof hagsand
81fc7f742b * Netconf as default namespace has been disabled by default.
* Only requests on the form: `<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"><edit-config>...` will be accepted
  * All replies will be on the form: `<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">...`
  * Requests such as: `<rpc><edit-config>...` will not  be accepted.
  * You can revert this behaviour (to clixon pre-4.6 behaviour) by enabling `CLICON_NAMESPACE_NETCONF_DEFAULT`
  * This API change is a consequence of: [copy-config's RPC cxobj parameter does not contain namespace #131](https://github.com/clicon/clixon/issues/131)
2020-09-02 15:44:10 +02:00
Olof hagsand
5dc2a6387d unified curl test options 2020-07-03 14:13:15 +02:00
Olof hagsand
3af184c655 Modify restconf tests to run for both evhtp and fcgi: , curl -sik, etc 2020-06-21 15:49:46 +02:00
Olof hagsand
bab3b5ad56 * Added yang population of data in clicon_rpc_get[_config] 2020-03-04 17:31:52 +01:00
Olof hagsand
a71c256898 * New clixon-config@2020-02-22.yang revision
* C-code changes:
  - Replaced stream uri:s w constants
  - Replaced large debug print code with single clicon_log_xml
  - Restconf put and post handling refactored using new parse API
2020-02-24 15:25:06 +01:00
Olof hagsand
9fa5e216c4 * New "general-purpose" datastore upgrade callback added which i called once on startup, intended for lo
w-level general upgrades and as a complement to module-specific upgrade.
  * Called on startup after initial XML parsing, but before module-specific upgrades
  * Enabled by definign the `.ca_datastore_upgrade`
  * [General-purpose upgrade documentation](https://clixon-docs.readthedocs.io/en/latest/backend.html#ge
neral-purpose)
* JSON parse error messages change from ` on line x: syntax error,..` to `json_parse: line x: syntax err
or`
* Unknown-element error message is more descriptive, eg from `namespace is: urn:example:clixon` to: `Fai
led to find YANG spec of XML node: x with parent: xp in namespace urn:example:clixon`.
* C-API parse and validation API more capable
  * `xml_spec_populate` family of functions extended with three-value return values
    * -1: error, 0: parse OK, 1: parse and YANG binding OK.
  * `xml_parse` and `json_parse` API changes
    * Three value returns: -1: error, 0: parse OK, 1: parse and YANG binding OK.
    * Extended `xml_parse_file2` and `xml_parse_string2` extended API functions with all options available.
      * New concept called `yang_bind` that defines how XML symbols are bound to YANG after parsing
    * Existing API same except `xml_parse_file` `endtag` argument moved to `xml_parse_file2`
* C-API: Added instrumentation: `xml_size` and `xml_stats_get`.
* Fixed: Enabling modstate (CLICON_XMLDB_MODSTATE), changing a revision on a yang, and restarting made the backend daemon exit at start (thanks Matt)
  * Also: ensure to load `ietf-yang-library.yang ` if CLICON_XMLDB_MODSTATE is set
2020-02-20 14:00:01 +01:00
Olof hagsand
19e21be0bc Very large commit for upcoming 4.4 release
Major New features

* New and updated search functions using xpath, api-path and instance-id
  * New search functions using api-path and instance_id:
    * C search functions: `clixon_find_instance_id()` and `clixon_find_api_path()`
  * Binary search optimization in lists for indexed leafs in all three formats.
    * This improves search performance to O(logN) which is drastical improvements for large lists.
  * You can also register explicit indexes for making binary search (not only list keys)
  * For more info, see docs at [paths](https://clixon-docs.readthedocs.io/en/latest/paths.html) and
[search](https://clixon-docs.readthedocs.io/en/latest/xml.html#searching-in-xml)

API changes on existing features (you may need to change your code)
* On failed validation of leafrefs, error message changed from: `No such leaf` to `No leaf <name> matching path <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"

Minor changes

* Test framework
  * Added `-- -S <file>` command-line to main example to be able to return any state to main example.
  * Added `test/cicd` test scripts for running on a set of other hosts
* C-code restructuring
  * clixon_yang.c partitioned and moved code into clixon_yang_parse_lib.c and clixon_yang_module.c and move back some code from clixon_yang_type.c.
    * partly to reduce size, but most important to limit code that accesses internal yang structures, only clixon_yang.c does this now.
2020-02-02 15:52:30 +01:00
Olof hagsand
05ce6f38a3 test kill valgrind process after run 2019-12-09 21:12:39 +01:00
Olof hagsand
835f9030d2 * State callbacks provided by user are validated. If they are invalid an internal error is returned.
* Fixed multi-namespace for augmented state which was not covered in 4.2.0.
* The multi-namespace augment state may rearrange the XML namespace attributes.
* Mandatory variables can no longer be deleted.
2019-11-11 21:03:11 +01:00
Olof Hagsand
82356b7450 test scripts: separated wait of backend and restconf starts 2019-10-27 15:54:16 +00:00
Olof hagsand
8cdb0bb062 * Changed so that 400 Bad Request are for invalid api-path or unknown yang elements, 404 Not Found for valid xml when object not found. 2019-10-07 22:20:34 +02:00
Olof hagsand
d9136c8972 * Stricter handling of multi-namespace handling
* This occurs in cases where there are more than one XML namespaces in a config tree, such as `augment`:ed trees.
  * Affects all parts of the system, including datastore, backend, restconf and cli.
* Invalid api-path syntax (eg non-matching yang) error changed from 412 operation-failed to 400 Bad request invalid-value, or unknown-element.
2019-09-29 14:45:08 +02:00
User Olof
8c18f2a86d Configure and test modification for better Freebsd port 2019-09-20 06:09:48 -10:00
Olof hagsand
27fd99e7cd * Implemented backend daemon drop privileges after initialization to
run as non-privileged user
2019-09-14 18:34:32 +02:00
Olof hagsand
3d5abb77f9 * Backend daemon drops privileges after initialization (to not run as root)
* New config option `CLICON_USER` with default value `clicon`
  * Can also be set with `-U <user>` clixon_backend command-line option
2019-09-11 21:24:14 +02:00
Olof hagsand
3b93c812d4 identity restconf mapping for augment and identity tests 2019-07-29 11:34:14 +02:00
Olof hagsand
a2340c265c test scripts: replaced sleeps with wait functions 2019-07-01 10:32:48 +02:00
Olof hagsand
dc45600074 Yang 'refine' feature supported, According to RFC 7950 7.13.2 2019-06-05 10:23:49 +02:00
Olof hagsand
e29cd7cfb9 * Optimized validation by making xml_diff work on raw cache tree (not copies)
* xmldb_get() removed unnecessary config option
2019-04-07 15:55:53 +02:00
Olof hagsand
5602d3e987 forgot exit in testcase 2019-03-06 10:37:01 +01:00
Olof hagsand
8cfd72c2c5 Merge branch 'develop' 2019-03-06 09:44:43 +01:00
Olof hagsand
98fb6eceef * Clixon configuration file top-level symbols has changed to clixon-configand namespace check is enforced.
* clixon-config YAML file has new revision: 2019-03-05.
  * New URN and changed top-level symbol to `clixon-config`
* Removed obsolete `_CLICON_XML_NS_STRICT` variable and `CLICON_XML_NS_STRICT` config option.
2019-03-06 09:42:55 +01:00
Olof hagsand
01c8b0b836 * [Identityref inside augment statement](https://github.com/clicon/clixon/issues/77)
* Yang-stmt enhanced with "shortcut" to original module
2019-03-05 22:42:13 +01:00
Renamed from test/test_augment.yang (Browse further)