* 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`
This commit is contained in:
Olof hagsand 2021-02-19 15:46:55 +01:00
parent 108f94cfad
commit 9840e248c6
12 changed files with 227 additions and 130 deletions

View file

@ -259,19 +259,17 @@ if [ $RC -ne 0 ]; then
stop_restconf
fi
if [ $BE -eq 0 ]; then
exit # BE
if [ $BE -ne 0 ]; then
new "Kill backend"
# Check if premature kill
pid=`pgrep -u root -f clixon_backend`
if [ -z "$pid" ]; then
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg
fi
new "Kill backend"
# Check if premature kill
pid=`pgrep -u root -f clixon_backend`
if [ -z "$pid" ]; then
err "backend already dead"
fi
# kill backend
stop_backend -f $cfg
# unset conditional parameters
unset format

View file

@ -85,6 +85,20 @@ module ietf-interfaces {
type uint16;
}
}
/* Original choice that gets augmented */
choice target {
case stream {
leaf one{
type string;
}
}
}
notification started {
leaf id{
type string;
}
}
}
EOF
@ -145,6 +159,9 @@ module example-augment {
refine port {
default 80;
}
refine ip {
description "double refine triggered mem error";
}
}
uses localgroup {
description "Use a local grouping defining lip and lport";
@ -153,7 +170,22 @@ module example-augment {
}
}
}
/* augment choice */
augment "/if:target" {
case datastore {
leaf two{
type uint32;
}
}
}
/* augment notification */
augment "/if:started" {
leaf argument{
type string;
}
}
}
EOF
new "test params: -f $cfg"

View file

@ -66,6 +66,12 @@ module main{
type string;
}
}
/* Augment something in sub module */
augment /ex:sub2 {
leaf aug0{
type string;
}
}
}
EOF
@ -87,6 +93,18 @@ submodule sub1 {
type string;
}
}
/* Augment something in module */
augment /ex:main {
leaf aug1{
type string;
}
}
/* Augment something in another submodule */
augment /ex:sub2 {
leaf aug2{
type string;
}
}
}
EOF
@ -221,6 +239,15 @@ expectpart "$(curl $CURLOPTS -X POST -H "Content-Type: application/yang-data+jso
new "restconf check main/sub1/sub2 contents"
expectpart "$(curl $CURLOPTS -X GET $RCPROTO://localhost/restconf/data?content=config)" 0 'HTTP/1.1 200 OK' '{"data":{"main:main":{"ext":"foo","x":"foo"},"main:sub1":{"ext1":"foo","x":"foo"},"main:sub2":{"ext2":"foo","x":"foo"}'
new "restconf edit augment 0"
expectpart "$(curl $CURLOPTS -X POST -H "Content-Type: application/yang-data+json" $RCPROTO://localhost/restconf/data/main:sub2 -d '{"main:aug0":"foo"}')" 0 'HTTP/1.1 201 Created'
new "restconf edit augment 1"
expectpart "$(curl $CURLOPTS -X POST -H "Content-Type: application/yang-data+json" $RCPROTO://localhost/restconf/data/main:main -d '{"main:aug1":"foo"}')" 0 'HTTP/1.1 201 Created'
new "restconf edit augment 2"
expectpart "$(curl $CURLOPTS -X POST -H "Content-Type: application/yang-data+json" $RCPROTO://localhost/restconf/data/main:sub2 -d '{"main:aug2":"foo"}')" 0 'HTTP/1.1 201 Created'
if [ $RC -ne 0 ]; then
new "Kill restconf daemon"
stop_restconf

View file

@ -1,20 +1,10 @@
#!/usr/bin/env bash
# Parse yangmodels from https://github.com/YangModels/yang
# Parse "all" IEEE yangmodels from https://github.com/YangModels/yang/standard/ietf/RFC
# Notes:
# - Only a simple smoketest (CLI check) is made, A full system may not work
# - Env variable YANGMODELS should point to checkout place. (define it in site.sh for example)
# - Only cisco/nx/9.2-2 # Many other versions
# - Only cisco/xe/1631 # Many other versions
# - Only cisco/xr/530 # Many other versions
# - Only juniper/18.2/18.2R/junos # Many other versions and platoforms
# These are the test scripts:
#./experimental/ieee/check.sh
#./standard/ieee/check.sh
#./standard/ietf/check.sh
#./vendor/cisco/xr/check.sh
#./vendor/cisco/check.sh
#./vendor/cisco/xe/check.sh
#./vendor/cisco/nx/check.sh
# - Some FEATURES are set to make it work
# - Some DIFFs are necessary in yangmodels (see end of script)
# Magic line must be first in script (see README.md)
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
@ -35,27 +25,24 @@ cat <<EOF > $cfg
<clixon-config xmlns="http://clicon.org/config">
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
<CLICON_FEATURE>ni-ieee1588-ptp:cmlds</CLICON_FEATURE>
<CLICON_FEATURE>ietf-alarms:alarm-shelving</CLICON_FEATURE>
<CLICON_YANG_DIR>/usr/local/share/clixon</CLICON_YANG_DIR>
<CLICON_YANG_DIR>$YANGMODELS/standard/ietf/RFC</CLICON_YANG_DIR>
<CLICON_YANG_DIR>$YANGMODELS/standard/ieee/draft/802.1/Qcr</CLICON_YANG_DIR>
<CLICON_YANG_DIR>$YANGMODELS/standard/ieee/draft/802</CLICON_YANG_DIR>
<CLICON_YANG_DIR>$YANGMODELS/standard/ieee/draft/802</CLICON_YANG_DIR>
<CLICON_YANG_DIR>$YANGMODELS/standard/ieee/published/802.1</CLICON_YANG_DIR>
<CLICON_YANG_DIR>$YANGMODELS/standard/ieee/published/802</CLICON_YANG_DIR>
<CLICON_YANG_DIR>/usr/local/share/clixon</CLICON_YANG_DIR>
<CLICON_YANG_LIST_CHECK>false</CLICON_YANG_LIST_CHECK>
<CLICON_CLISPEC_DIR>/usr/local/lib/$APPNAME/clispec</CLICON_CLISPEC_DIR>
<CLICON_CLI_DIR>/usr/local/lib/$APPNAME/cli</CLICON_CLI_DIR>
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
<CLICON_MODULE_LIBRARY_RFC7895>true</CLICON_MODULE_LIBRARY_RFC7895>
</clixon-config>
EOF
new "yangmodels parse: -f $cfg"
new "yangmodel Experimental IEEE 802.1: $YANGMODELS/experimental/ieee/802.1"
expectpart "$($clixon_cli -D $DBG -1f $cfg -o CLICON_YANG_MAIN_DIR=$YANGMODELS/experimental/ieee/802.1 -p $YANGMODELS/experimental/ieee/1588 show version)" 0 "$version."
@ -85,56 +72,22 @@ expectpart "$($clixon_cli -D $DBG -1f $cfg -o CLICON_YANG_MAIN_DIR=$YANGMODELS/s
new "yangmodel Standard IEEE 802.1: $YANGMODELS/standard/ieee/published/802.3"
expectpart "$($clixon_cli -D $DBG -1f $cfg -o CLICON_YANG_MAIN_DIR=$YANGMODELS/standard/ieee/published/802.3 show version)" 0 "$version."
# Standard IETF
# XXX fails on augmenting "action"
new "yangmodel Standard IETF: $YANGMODELS/standard/ietf/RFC"
expectpart "$($clixon_cli -D $DBG -1f $cfg -o CLICON_YANG_MAIN_DIR=$YANGMODELS/standard/ietf/RFC show version)" 0 "$version."
# vendor/junos
#junos : M/MX, T/TX, Some EX platforms, ACX
#junos-es : SRX, Jseries, LN-*
#junos-ex : EX series
#junos-qfx : QFX series
#junos-nfx : NFX series
# Juniper JunOS. Junos files have 4 lines copyright, then "<space>module" on
# line 5. No sub-modules.
# NOTE: We DISABLE CLI generation, because some juniper are very large.
# and cli generation consumes memory.
# For example (100K lines):
#wc /usr/local/share/yangmodels/vendor/juniper/18.2/18.2R1/junos/conf/junos-conf-system@2018-01-01.yang
# 92853 274279 3228229 /usr/local/share/yangmodels/vendor/juniper/18.2/18.2R1/junos/conf/junos-conf-system@2018-01-01.yan
# But junos-conf-logical-systems@2018-01-01.yang takes longest time
files=$(find $YANGMODELS/vendor/juniper/18.2/18.2R1/junos/conf -name "*.yang")
let i=0;
for f in $files; do
if [ -n "$(head -5 $f|grep '^ module')" ]; then
new "$clixon_cli -1f $cfg -o CLICON_YANG_MAIN_FILE=$f -p $YANGMODELS/vendor/juniper/18.2/18.2R1/common -p $YANGMODELS/vendor/juniper/18.2/18.2R1/junos/conf show version"
expectpart "$($clixon_cli -D $DBG -1f $cfg -o CLICON_YANG_MAIN_FILE=$f -p $YANGMODELS/vendor/juniper/18.2/18.2R1/common -p $YANGMODELS/vendor/juniper/18.2/18.2R1/junos/conf -o CLICON_CLI_GENMODEL=0 show version)" 0 "$version."
let i++;
sleep 1
fi
done
# We skip CISCO because we have errors that vilates the RFC (I think)
# eg: Test 7(7) [yangmodel vendor cisco xr 623: /usr/local/share/yangmodels/vendor/cisco/xr/623]
# yang_abs_schema_nodeid: Absolute schema nodeid /bgp-rib/afi-safis/afi-safi/ipv4-unicast/loc-rib must have prefix
if false; then
# vendor/cisco/xr
new "yangmodel vendor cisco xr 623: $YANGMODELS/vendor/cisco/xr/623"
expectpart "$($clixon_cli -D $DBG -1f $cfg -o CLICON_YANG_MAIN_DIR=$YANGMODELS/vendor/cisco/xr/623 show version)" 0 "$version."
new "yangmodel vendor cisco xr 632: $YANGMODELS/vendor/cisco/xr/632"
expectpart "$($clixon_cli -D $DBG -1f $cfg -o CLICON_YANG_MAIN_DIR=$YANGMODELS/vendor/cisco/xr/632 show version)" 0 "$version."
new "yangmodel vendor cisco xr 623: $YANGMODELS/vendor/cisco/xr/642"
expectpart "$($clixon_cli -D $DBG -1f $cfg -o CLICON_YANG_MAIN_DIR=$YANGMODELS/vendor/cisco/xr/642 show version)" 0 "$version."
new "yangmodel vendor cisco xr 651: $YANGMODELS/vendor/cisco/xr/651"
expectpart "$($clixon_cli -D $DBG -1f $cfg -o CLICON_YANG_MAIN_DIR=$YANGMODELS/vendor/cisco/xr/651 show version)" 0 "$version."
fi ### cisco
rm -rf $dir
exit 0
# Diff to make it work
diff --git a/standard/ieee/published/802.3/ieee802-ethernet-pon.yang b/standard/ieee/published/802.3/ieee802-ethernet-pon.yang
index 37c54c2a..a56b5f50 100755
--- a/standard/ieee/published/802.3/ieee802-ethernet-pon.yang
+++ b/standard/ieee/published/802.3/ieee802-ethernet-pon.yang
@@ -2421,7 +2421,7 @@ module ieee802-ethernet-pon {
}
leaf mpcp-maximum-queue-count-per-report {
- when "../ompe-mode = olt'";
+ when "../ompe-mode = 'olt'";^M
type mpcp-maximum-queue-count-per-report;
config false;

65
test/test_yang_models_ietf.sh Executable file
View file

@ -0,0 +1,65 @@
#!/usr/bin/env bash
# Parse "all" IETF yangmodels from https://github.com/YangModels/yang/standard/ieee and experimental/ieee
# Notes:
# - Only a simple smoketest (CLI check) is made, A full system may not work
# - Env variable YANGMODELS should point to checkout place. (define it in site.sh for example)
# - Some FEATURES are set to make it work
# - Some DIFFs are necessary in yangmodels (see end of script)
# Magic line must be first in script (see README.md)
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
# Yang specifics: multi-keys and empty type
APPNAME=example
cfg=$dir/conf_yang.xml
fyang=$dir/test.yang
YANGMODELS=/home/olof/tmp/yang
if [ ! -d "$YANGMODELS" ]; then
# err "Hmm Yangmodels dir does not seem to exist, try git clone https://github.com/YangModels/yang?"
if [ "$s" = $0 ]; then exit 0; else return 0; fi
fi
cat <<EOF > $cfg
<clixon-config xmlns="http://clicon.org/config">
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
<CLICON_FEATURE>ietf-alarms:alarm-shelving</CLICON_FEATURE>
<CLICON_FEATURE>ietf-subscribed-notifications:configured</CLICON_FEATURE>
<CLICON_FEATURE>ietf-subscribed-notifications:replay</CLICON_FEATURE>
<CLICON_FEATURE>ietf-access-control-list:match-on-tcp</CLICON_FEATURE>
<CLICON_YANG_DIR>/usr/local/share/clixon</CLICON_YANG_DIR>
<CLICON_YANG_DIR>$YANGMODELS/standard/ieee/published/802.1</CLICON_YANG_DIR>
<CLICON_CLISPEC_DIR>/usr/local/lib/$APPNAME/clispec</CLICON_CLISPEC_DIR>
<CLICON_CLI_DIR>/usr/local/lib/$APPNAME/cli</CLICON_CLI_DIR>
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
</clixon-config>
EOF
# Standard IETF
new "yangmodel Standard IETF: $YANGMODELS/standard/ietf/RFC"
echo "$clixon_cli -D $DBG -1f $cfg -o CLICON_YANG_MAIN_DIR=$YANGMODELS/standard/ietf/RFC show version"
expectpart "$($clixon_cli -D $DBG -1f $cfg -o CLICON_YANG_MAIN_DIR=$YANGMODELS/standard/ietf/RFC show version)" 0 "$version."
rm -rf $dir
exit 0
# Diff to make it work
diff --git a/standard/ietf/RFC/ietf-mud@2019-01-28.yang b/standard/ietf/RFC/ietf-mud@2019-01-28.yang
index 1842284e..4197ad46 100644
--- a/standard/ietf/RFC/ietf-mud@2019-01-28.yang
+++ b/standard/ietf/RFC/ietf-mud@2019-01-28.yang
@@ -297,7 +297,7 @@ module ietf-mud {
}
}
augment "/acl:acls/acl:acl/acl:aces/acl:ace/acl:matches"
- + "/acl:l4/acl:tcp/acl:tcp" {
+ + "/acl:l4/acl:tcp" { /* Olof: rm extra /acl:tcp */
description
"add direction-initiated";
leaf direction-initiated {