From d5a8d6b6e197008ea89b6dda202c4742a485fdc5 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Wed, 10 Jan 2024 20:10:38 +0100 Subject: [PATCH] Fixed: segv on exit Test: rm openconfig-interface --- apps/backend/backend_main.c | 2 +- lib/src/clixon_datastore_write.c | 1 + test/test_openconfig_interfaces.sh | 209 ----------------------------- 3 files changed, 2 insertions(+), 210 deletions(-) delete mode 100755 test/test_openconfig_interfaces.sh diff --git a/apps/backend/backend_main.c b/apps/backend/backend_main.c index b1566ba8..6405f267 100644 --- a/apps/backend/backend_main.c +++ b/apps/backend/backend_main.c @@ -141,11 +141,11 @@ backend_terminate(clixon_handle h) unlink(pidfile); if (sockfamily==AF_UNIX && lstat(sockpath, &st) == 0) unlink(sockpath); - backend_handle_exit(h); /* Also deletes streams. Cannot use h after this. */ clixon_event_exit(); clixon_debug(CLIXON_DBG_CLIENT, "%s done", __FUNCTION__); clixon_err_exit(); clixon_log_exit(); + backend_handle_exit(h); /* Also deletes streams. Cannot use h after this. */ return 0; } diff --git a/lib/src/clixon_datastore_write.c b/lib/src/clixon_datastore_write.c index 0c755349..6650bec8 100644 --- a/lib/src/clixon_datastore_write.c +++ b/lib/src/clixon_datastore_write.c @@ -1213,6 +1213,7 @@ text_modify_top(clixon_handle h, * cbret contains netconf error message * @endcode * @note if xret is non-null, it may contain error message + * @note x1 may change as a side-effect (eg operation attributes are stripped) */ int xmldb_put(clixon_handle h, diff --git a/test/test_openconfig_interfaces.sh b/test/test_openconfig_interfaces.sh deleted file mode 100755 index 817d06c8..00000000 --- a/test/test_openconfig_interfaces.sh +++ /dev/null @@ -1,209 +0,0 @@ -#!/usr/bin/env bash -# Run a system around openconfig interface, ie: openconfig-if-ethernet -# Note first variant uses ietf-interfaces, maybe remove this? - -# Magic line must be first in script (see README.md) -s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi - -APPNAME=example - -cfg=$dir/conf_yang.xml -fyang=$dir/clixon-example.yang - -new "openconfig" -if [ ! -d "$OPENCONFIG" ]; then -# err "Hmm Openconfig dir does not seem to exist, try git clone https://github.com/openconfig/public?" - echo "...skipped: OPENCONFIG not set" - rm -rf $dir - if [ "$s" = $0 ]; then exit 0; else return 0; fi -fi - -OCDIR=$OPENCONFIG/release/models - -# Generate autocli for these modules -AUTOCLI=$(autocli_config openconfig* kw-nokey false) - -cat < $cfg - - $cfg - ietf-netconf:startup - ${YANG_INSTALLDIR} - $IETFRFC - $OCDIR - $fyang - /usr/local/lib/$APPNAME/clispec - /usr/local/lib/$APPNAME/cli - $APPNAME - $APPNAME - /usr/local/var/run/$APPNAME.sock - /usr/local/var/run/$APPNAME.pidfile - $dir - ${AUTOCLI} - -EOF - -# First using ietf-interfaces (not openconfig-interfaces) -# Example yang -cat < $fyang -module clixon-example{ - yang-version 1.1; - namespace "urn:example:example"; - prefix ex; - - import ietf-interfaces { - prefix ietf-if; - } - import openconfig-if-ethernet { - prefix oc-eth; - } - identity eth { /* Need to create an interface-type identity for leafrefs */ - base ietf-if:interface-type; - } -} -EOF - -# Example system -cat < $dir/startup_db - - - - e - - e - ex:eth - NONE - true - - - - 0 - - - - - 0 - 0 - - - - - -EOF - -if [ $BE -ne 0 ]; then - new "kill old backend" - sudo clixon_backend -zf $cfg - if [ $? -ne 0 ]; then - err - fi - sudo pkill -f clixon_backend # to be sure - - new "start backend -s startup -f $cfg" - start_backend -s startup -f $cfg -fi - -new "wait backend" -wait_backend - -new "$clixon_cli -D $DBG -1f $cfg show version" -expectpart "$($clixon_cli -D $DBG -1f $cfg show version)" 0 "${CLIXON_VERSION}" - -new "$clixon_netconf -qf $cfg" -expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "" "eeex:ethNONEtrue000" - -new "cli show configuration" -expectpart "$($clixon_cli -1 -f $cfg show conf xml)" 0 "^" --not-- "" - -# XXX THIS REQUIRES PREFIX FOR IETF-INTERFACES -#new "cli set interfaces interface complete: e" -#expectpart "$(echo "set interfaces interface " | $clixon_cli -f $cfg)" 0 "interface e" - -# XXX See https://github.com/clicon/clixon/issues/218 -#new "cli set interfaces interface e complete: not ethernet" -#expectpart "$(echo "set interfaces interface e " | $clixon_cli -f $cfg)" 0 config hold-time subinterfaces --not-- ethernet - -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 - - -# Second using openconfig-interfaces instead -# Example yang -cat < $fyang -module clixon-example{ - yang-version 1.1; - namespace "urn:example:example"; - prefix ex; - - import openconfig-vlan { - prefix oc-vlan; - } - import openconfig-if-ethernet { - prefix oc-eth; - } -} -EOF - -# Example system -cat < $dir/startup_db - - - - eth1 - - eth1 - ianaift:ethernetCsmacd - 9206 - true - oc-vlan-types:TPID_0X8100 - - - - 2c:53:4a:09:59:73 - - - - - -EOF - -if [ $BE -ne 0 ]; then - new "kill old backend" - sudo clixon_backend -zf $cfg - if [ $? -ne 0 ]; then - err - fi - sudo pkill -f clixon_backend # to be sure - - new "start backend -s startup -f $cfg" - start_backend -s startup -f $cfg -fi - -new "wait backend" -wait_backend - -new "$clixon_cli -D $DBG -1f $cfg show version" -expectpart "$($clixon_cli -D $DBG -1f $cfg show version)" 0 "${CLIXON_VERSION}" - -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 - -rm -rf $dir - -new "endtest" -endtest