Merge branch 'master' into develop

This commit is contained in:
Olof hagsand 2019-04-02 11:46:54 +02:00
commit 4f9e942103
9 changed files with 134 additions and 118 deletions

View file

@ -200,7 +200,7 @@ startup_common(clicon_handle h,
/* Handcraft transition with with only add tree */ /* Handcraft transition with with only add tree */
td->td_target = xt; td->td_target = xt;
x = NULL; x = NULL;
while ((x = xml_child_each(xt, x, CX_ELMNT)) != NULL){ while ((x = xml_child_each(td->td_target, x, CX_ELMNT)) != NULL){
if (cxvec_append(x, &td->td_avec, &td->td_alen) < 0) if (cxvec_append(x, &td->td_avec, &td->td_alen) < 0)
goto done; goto done;
} }
@ -313,15 +313,6 @@ startup_commit(clicon_handle h,
/* 10. Call plugin transaction end callbacks */ /* 10. Call plugin transaction end callbacks */
plugin_transaction_end(h, td); plugin_transaction_end(h, td);
/* 11. Copy running back to candidate in case end functions updated running
* XXX: room for improvement: candidate and running may be equal.
* Copy only diffs?
*/
if (xmldb_copy(h, "running", "candidate") < 0){
/* ignore errors or signal major setback ? */
clicon_log(LOG_NOTICE, "Error in rollback, trying to continue");
goto done;
}
retval = 1; retval = 1;
done: done:
if (td) if (td)
@ -494,15 +485,6 @@ candidate_commit(clicon_handle h,
/* 9. Call plugin transaction end callbacks */ /* 9. Call plugin transaction end callbacks */
plugin_transaction_end(h, td); plugin_transaction_end(h, td);
/* 8. Copy running back to candidate in case end functions updated running
* XXX: room for improvement: candidate and running may be equal.
* Copy only diffs?
*/
if (xmldb_copy(h, "running", candidate) < 0){
/* ignore errors or signal major setback ? */
clicon_log(LOG_NOTICE, "Error in rollback, trying to continue");
goto done;
}
retval = 1; retval = 1;
done: done:
/* In case of failure (or error), call plugin transaction termination callbacks */ /* In case of failure (or error), call plugin transaction termination callbacks */

View file

@ -1652,7 +1652,7 @@ xml_default(cxobj *xt,
} }
} }
} }
xml_sort(xt, NULL); // xml_sort(xt, NULL);
retval = 0; retval = 0;
done: done:
return retval; return retval;

View file

@ -146,11 +146,11 @@ real ({digit}+[.]{digit}*)|({digit}*[.]{digit}+)
<TOKEN>. { fprintf(stderr,"LEXICAL ERROR\n"); return -1; } <TOKEN>. { fprintf(stderr,"LEXICAL ERROR\n"); return -1; }
<QLITERAL>\" { BEGIN(TOKEN); return QUOTE; } <QLITERAL>\" { BEGIN(TOKEN); return QUOTE; }
<QLITERAL>. { clixon_xpath_parselval.string = strdup(yytext); <QLITERAL>[^"]+ { clixon_xpath_parselval.string = strdup(yytext);
return CHAR;} return CHARS;}
<ALITERAL>\' { BEGIN(TOKEN); return APOST; } <ALITERAL>\' { BEGIN(TOKEN); return APOST; }
<ALITERAL>. { clixon_xpath_parselval.string = strdup(yytext); <ALITERAL>[^']+ { clixon_xpath_parselval.string = strdup(yytext);
return CHAR;} return CHARS;}
%% %%

View file

@ -59,7 +59,7 @@
%token <string> X_EOF %token <string> X_EOF
%token <string> QUOTE %token <string> QUOTE
%token <string> APOST %token <string> APOST
%token <string> CHAR %token <string> CHARS
%token <string> NAME %token <string> NAME
%token <string> NODETYPE %token <string> NODETYPE
%token <string> DOUBLEDOT %token <string> DOUBLEDOT
@ -276,14 +276,14 @@ args : args ',' expr { $$=xp_new(XP_EXP,A_NAN,0.0,NULL,NULL,$1, $3);
clicon_debug(2,"args -> expr "); } clicon_debug(2,"args -> expr "); }
; ;
string : string CHAR { string : string CHARS {
int len = strlen($1); int len = strlen($1);
$$ = realloc($1, len+strlen($2) + 1); $$ = realloc($1, len+strlen($2) + 1);
sprintf($$+len, "%s", $2); sprintf($$+len, "%s", $2);
free($2); free($2);
clicon_debug(2,"string-> string CHAR"); clicon_debug(2,"string-> string CHAR");
} }
| CHAR { clicon_debug(2,"string-> "); } | CHARS { clicon_debug(2,"string-> "); }
; ;

View file

@ -1132,6 +1132,7 @@ leaf_list_substmt : when_stmt { clicon_debug(2,"leaf-list-substmt -> when
| type_stmt { clicon_debug(2,"leaf-list-substmt -> type-stmt"); } | type_stmt { clicon_debug(2,"leaf-list-substmt -> type-stmt"); }
| units_stmt { clicon_debug(2,"leaf-list-substmt -> units-stmt"); } | units_stmt { clicon_debug(2,"leaf-list-substmt -> units-stmt"); }
| must_stmt { clicon_debug(2,"leaf-list-substmt -> must-stmt"); } | must_stmt { clicon_debug(2,"leaf-list-substmt -> must-stmt"); }
| default_stmt { clicon_debug(2,"leaf-list-substmt -> default-stmt"); }
| config_stmt { clicon_debug(2,"leaf-list-substmt -> config-stmt"); } | config_stmt { clicon_debug(2,"leaf-list-substmt -> config-stmt"); }
| min_elements_stmt { clicon_debug(2,"leaf-list-substmt -> min-elements-stmt"); } | min_elements_stmt { clicon_debug(2,"leaf-list-substmt -> min-elements-stmt"); }
| max_elements_stmt { clicon_debug(2,"leaf-list-substmt -> max-elements-stmt"); } | max_elements_stmt { clicon_debug(2,"leaf-list-substmt -> max-elements-stmt"); }

View file

@ -52,12 +52,10 @@ Run all tests but continue after errors and only print a summary test output ide
``` ```
## Memory leak test ## Memory leak test
These tests use valgrind to check for memory leaks: The `mem.sh` runs memory checks using valgrind. Start it with no arguments to test all components (backend, restconf, cli, netconf), or specify which components to run:
``` ```
mem.sh cli mem.sh # All components
mem.sh netconf mem.sh restconf backend # Only backend and cli
mem.sh backend
mem.sh restconf
``` ```
## Site.sh ## Site.sh

View file

@ -41,7 +41,7 @@ module scaling{
EOF EOF
cat <<EOF > $cfg cat <<EOF > $cfg
<config> <clixon-config xmlns="http://clicon.org/config">
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE> <CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
<CLICON_YANG_DIR>$dir</CLICON_YANG_DIR> <CLICON_YANG_DIR>$dir</CLICON_YANG_DIR>
<CLICON_YANG_DIR>/usr/local/share/clixon</CLICON_YANG_DIR> <CLICON_YANG_DIR>/usr/local/share/clixon</CLICON_YANG_DIR>
@ -53,7 +53,7 @@ cat <<EOF > $cfg
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR> <CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
<CLICON_XMLDB_PLUGIN>/usr/local/lib/xmldb/text.so</CLICON_XMLDB_PLUGIN> <CLICON_XMLDB_PLUGIN>/usr/local/lib/xmldb/text.so</CLICON_XMLDB_PLUGIN>
<CLICON_XMLDB_PRETTY>false</CLICON_XMLDB_PRETTY> <CLICON_XMLDB_PRETTY>false</CLICON_XMLDB_PRETTY>
</config> </clixon-config>
EOF EOF
new "test params: -f $cfg -y $fyang" new "test params: -f $cfg -y $fyang"

View file

@ -1,53 +1,52 @@
#!/bin/bash #!/bin/bash
# Run valgrind leak test for cli, restconf, netconf or background. # Run valgrind leak test for cli, restconf, netconf or background.
# Stop on first error # Stop on first error
#
if [ $# -ne 1 ]; then
echo "usage: $0 cli|netconf|restconf|backend" # valgrind memleak checks
exit -1
fi
PROGRAM=$1
valgrindfile=$(mktemp) # Run valgrindtest once, args:
echo "valgrindfile:$valgrindfile" # what: cli|netconf|restconf|backend
memonce(){
what=$1
case "$PROGRAM" in valgrindfile=$(mktemp)
echo "valgrindfile:$valgrindfile"
case "$what" in
'cli') 'cli')
valgrindtest=1 valgrindtest=1
RCWAIT=1 : ${RCWAIT:=5} # valgrind backend needs some time to get up
clixon_cli="/usr/bin/valgrind --leak-check=full --show-leak-kinds=all --suppressions=./valgrind-clixon.supp --track-fds=yes --trace-children=no --child-silent-after-fork=yes --log-file=$valgrindfile clixon_cli" clixon_cli="/usr/bin/valgrind --leak-check=full --show-leak-kinds=all --suppressions=./valgrind-clixon.supp --track-fds=yes --trace-children=no --child-silent-after-fork=yes --log-file=$valgrindfile clixon_cli"
;; ;;
'netconf') 'netconf')
valgrindtest=1 valgrindtest=1
RCWAIT=1 : ${RCWAIT:=5} # valgrind backend needs some time to get up
clixon_netconf="/usr/bin/valgrind --leak-check=full --show-leak-kinds=all --suppressions=./valgrind-clixon.supp --track-fds=yes --trace-children=no --child-silent-after-fork=yes --log-file=$valgrindfile clixon_netconf" clixon_netconf="/usr/bin/valgrind --leak-check=full --show-leak-kinds=all --suppressions=./valgrind-clixon.supp --track-fds=yes --trace-children=no --child-silent-after-fork=yes --log-file=$valgrindfile clixon_netconf"
;; ;;
'backend') 'backend')
valgrindtest=2 # This means backend valgrind test valgrindtest=2 # This means backend valgrind test
RCWAIT=10 # valgrind backend needs some time to get up : ${RCWAIT:=10} # valgrind backend needs some time to get up
perfnr=100 # test_perf.sh restconf put more or less stops perfnr=100 # test_perf.sh restconf put more or less stops
perfreq=10 perfreq=10
clixon_backend="/usr/bin/valgrind --leak-check=full --show-leak-kinds=all --suppressions=./valgrind-clixon.supp --track-fds=yes --trace-children=yes --log-file=$valgrindfile clixon_backend" clixon_backend="/usr/bin/valgrind --leak-check=full --show-leak-kinds=all --suppressions=./valgrind-clixon.supp --track-fds=yes --trace-children=yes --log-file=$valgrindfile clixon_backend"
;; ;;
'restconf') 'restconf')
valgrindtest=3 # This means backend valgrind test valgrindtest=3 # This means backend valgrind test
sudo chmod 660 $valgrindfile sudo chmod 660 $valgrindfile
sudo chown www-data $valgrindfile sudo chown www-data $valgrindfile
RCWAIT=5 # valgrind restconf needs some time to get up : ${RCWAIT:=5} # valgrind backend needs some time to get up
clixon_restconf="/usr/bin/valgrind --leak-check=full --show-leak-kinds=all --suppressions=./valgrind-clixon.supp --track-fds=yes --trace-children=no --child-silent-after-fork=yes --log-file=$valgrindfile /www-data/clixon_restconf" clixon_restconf="/usr/bin/valgrind --leak-check=full --show-leak-kinds=all --suppressions=./valgrind-clixon.supp --track-fds=yes --trace-children=no --child-silent-after-fork=yes --log-file=$valgrindfile /www-data/clixon_restconf"
;; ;;
*) *)
echo "usage: $0 cli|netconf|restconf|backend" # valgrind memleak checks echo "usage: $0 cli|netconf|restconf|backend" # valgrind memleak checks
rm -f $valgrindfile rm -f $valgrindfile
exit -1 exit -1
;; ;;
esac esac
err=0 err=0
testnr=0 for test in test_*.sh; do
for test in test_*.sh; do if [ $testnr != 0 ]; then echo; fi
testfile=$test testfile=$test
. ./$test . ./$test
errcode=$? errcode=$?
@ -57,9 +56,34 @@ for test in test_*.sh; do
echo -ne "\e[0m" echo -ne "\e[0m"
exit $errcode exit $errcode
fi fi
done done
if [ $valgrindtest -eq 1 ]; then if [ $valgrindtest -eq 1 ]; then
checkvalgrind checkvalgrind
sudo rm -f $valgrindfile sudo rm -f $valgrindfile
fi
}
if [ -z "$*" ]; then
cmds="backend restconf cli netconf"
else
cmds=$*
fi fi
# First run sanity
for c in $cmds; do
if [ $c != cli -a $c != netconf -a $c != restconf -a $c != backend ]; then
echo "c:$c"
echo "usage: $0 [cli|netconf|restconf|backend]+"
echo " with no args run all"
exit -1
fi
done
# Then actual run
testnr=0
for c in $cmds; do
if [ $testnr != 0 ]; then echo; fi
echo "Mem test for $c"
echo "================="
memonce $c
done

View file

@ -35,14 +35,15 @@ cat <<EOF > $cfg
<clixon-config xmlns="http://clicon.org/config"> <clixon-config xmlns="http://clicon.org/config">
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE> <CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
<CLICON_YANG_DIR>$YANGMODELS/standard/ietf/RFC</CLICON_YANG_DIR> <CLICON_YANG_DIR>$YANGMODELS/standard/ietf/RFC</CLICON_YANG_DIR>
<CLICON_YANG_DIR>$YANGMODELS/standard/ieee/draft</CLICON_YANG_DIR> <CLICON_YANG_DIR>$YANGMODELS/standard/ieee/draft/802.1</CLICON_YANG_DIR>
<CLICON_YANG_DIR>$YANGMODELS/standard/ieee/802.1/draft</CLICON_YANG_DIR> <CLICON_YANG_DIR>$YANGMODELS/standard/ieee/draft/802</CLICON_YANG_DIR>
<CLICON_YANG_DIR>/usr/local/share/clixon</CLICON_YANG_DIR> <CLICON_YANG_DIR>/usr/local/share/clixon</CLICON_YANG_DIR>
<CLICON_CLISPEC_DIR>/usr/local/lib/$APPNAME/clispec</CLICON_CLISPEC_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_DIR>/usr/local/lib/$APPNAME/cli</CLICON_CLI_DIR>
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE> <CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK> <CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
<CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE> <CLICON_BACKEND_PIDFILE>/usr/local/var/$APPNAME/$APPNAME.pidfile</CLICON_BACKEND_PIDFILE>
<CLICON_CLI_GENMODEL>1</CLICON_CLI_GENMODEL>
<CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION> <CLICON_CLI_GENMODEL_COMPLETION>1</CLICON_CLI_GENMODEL_COMPLETION>
<CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR> <CLICON_XMLDB_DIR>/usr/local/var/$APPNAME</CLICON_XMLDB_DIR>
<CLICON_XMLDB_PLUGIN>/usr/local/lib/xmldb/text.so</CLICON_XMLDB_PLUGIN> <CLICON_XMLDB_PLUGIN>/usr/local/lib/xmldb/text.so</CLICON_XMLDB_PLUGIN>
@ -55,24 +56,51 @@ new "yangmodels parse: -f $cfg"
new "yangmodel Experimental IEEE 802.1: $YANGMODELS/experimental/ieee/802.1" new "yangmodel Experimental IEEE 802.1: $YANGMODELS/experimental/ieee/802.1"
expectfn "$clixon_cli -D $DBG -1f $cfg -o CLICON_YANG_MAIN_DIR=$YANGMODELS/experimental/ieee/802.1 -p $YANGMODELS/experimental/ieee/1588 show version" 0 "3." expectfn "$clixon_cli -D $DBG -1f $cfg -o CLICON_YANG_MAIN_DIR=$YANGMODELS/experimental/ieee/802.1 -p $YANGMODELS/experimental/ieee/1588 show version" 0 "3."
# experimental 802.3 dir is empty
#new "yangmodel Experimental IEEE 802.3: $YANGMODELS/experimental/ieee/802.3"
#expectfn "$clixon_cli -D $DBG -1f $cfg -o CLICON_YANG_MAIN_DIR=$YANGMODELS/experimental/ieee/802.3 show version" 0 "3."
new "yangmodel Experimental IEEE 1588: $YANGMODELS/experimental/ieee/1588" new "yangmodel Experimental IEEE 1588: $YANGMODELS/experimental/ieee/1588"
expectfn "$clixon_cli -D $DBG -1f $cfg -o CLICON_YANG_MAIN_DIR=$YANGMODELS/experimental/ieee/1588 show version" 0 "3." expectfn "$clixon_cli -D $DBG -1f $cfg -o CLICON_YANG_MAIN_DIR=$YANGMODELS/experimental/ieee/1588 show version" 0 "3."
# Standard IEEE # Standard IEEE
new "yangmodel Standard IEEE 802.1: $YANGMODELS/standard/ieee/802.1/draft" new "yangmodel Standard IEEE 802.1: $YANGMODELS/standard/ieee/draft/802.1"
expectfn "$clixon_cli -D $DBG -1f $cfg -o CLICON_YANG_MAIN_DIR=$YANGMODELS/standard/ieee/802.1/draft show version" 0 "3." expectfn "$clixon_cli -D $DBG -1f $cfg -o CLICON_YANG_MAIN_DIR=$YANGMODELS/standard/ieee/draft/802.1 show version" 0 "3."
new "yangmodel Standard IEEE 802.3: $YANGMODELS/standard/ieee/802.3/draft" new "yangmodel Standard IEEE 802.3: $YANGMODELS/standard/ieee/draft/802.3"
expectfn "$clixon_cli -D $DBG -1f $cfg -o CLICON_YANG_MAIN_DIR=$YANGMODELS/standard/ieee/802.3/draft show version" 0 "3." expectfn "$clixon_cli -D $DBG -1f $cfg -o CLICON_YANG_MAIN_DIR=$YANGMODELS/standard/ieee/draft/802.3 show version" 0 "3."
# Standard IETF # Standard IETF
new "yangmodel Standard IETF: $YANGMODELS/standard/ietf/RFC" new "yangmodel Standard IETF: $YANGMODELS/standard/ietf/RFC"
expectfn "$clixon_cli -D $DBG -1f $cfg -o CLICON_YANG_MAIN_DIR=$YANGMODELS/standard/ietf/RFC show version" 0 "3." expectfn "$clixon_cli -D $DBG -1f $cfg -o CLICON_YANG_MAIN_DIR=$YANGMODELS/standard/ietf/RFC show version" 0 "3."
# 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"
expectfn "$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 -o CLICON_CLI_GENMODEL=0 show version" 0 "3."
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 if false; then
# vendor/cisco/xr # vendor/cisco/xr
new "yangmodel vendor cisco xr 623: $YANGMODELS/vendor/cisco/xr/623" new "yangmodel vendor cisco xr 623: $YANGMODELS/vendor/cisco/xr/623"
@ -88,22 +116,5 @@ new "yangmodel vendor cisco xr 651: $YANGMODELS/vendor/cisco/xr/651"
expectfn "$clixon_cli -D $DBG -1f $cfg -o CLICON_YANG_MAIN_DIR=$YANGMODELS/vendor/cisco/xr/651 show version" 0 "3." expectfn "$clixon_cli -D $DBG -1f $cfg -o CLICON_YANG_MAIN_DIR=$YANGMODELS/vendor/cisco/xr/651 show version" 0 "3."
fi ### cisco fi ### cisco
# 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
new "yangmodel vendor junos: $YANGMODELS/vendor/juniper/18.2/18.2R1/junos/conf/"
expectfn "$clixon_cli -D $DBG -1f $cfg -o CLICON_YANG_MAIN_FILE=$YANGMODELS/vendor/juniper/18.2/18.2R1/junos/conf/junos-conf-interfaces@2018-01-01.yang -p $YANGMODELS/vendor/juniper/18.2/18.2R1/junos/conf -p $YANGMODELS/vendor/juniper/18.2/18.2R1/common show version" 0 "3."
# breaks memory and cpu limits,...
#new "yangmodel vendor junos: $YANGMODELS/vendor/juniper/18.2/18.2R1/junos/conf"
#expectfn "$clixon_cli -D $DBG -1f $cfg -o CLICON_YANG_MAIN_DIR=$YANGMODELS/vendor/juniper/18.2/18.2R1/junos/conf -p $YANGMODELS/vendor/juniper/18.2/18.2R1/common show version" 0 "3."
#new "yangmodel vendor junos: $YANGMODELS/vendor/juniper/18.2/18.2R1/junos/rpc"
#expectfn "$clixon_cli -D $DBG -1f $cfg -o CLICON_YANG_MAIN_DIR=$YANGMODELS/vendor/juniper/18.2/18.2R1/junos/rpc -p $YANGMODELS/vendor/juniper/18.2/18.2R1/common show version" 0 "3."
rm -rf $dir rm -rf $dir