From c0a79c3e0025993136a5e24f881bab1f3712d650 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Fri, 27 Sep 2024 14:19:07 +0200 Subject: [PATCH 1/4] test: return None instead of 404 Exception for missing XPaths Fixes to following exception calling iface.interface_exist(target, veth0): requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://[fe80::2a0:85ff:fe00:201%d2a]:443/restconf/ds/ietf-datastores%3Aoperational/ietf-interfaces%3Ainterfaces/interface=veth0a/name Removing interface veth0a, and then checking operational if it has been properly removed, should not cause an exception. Better to return None object instead. Signed-off-by: Joachim Wiberg --- test/infamy/restconf.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/infamy/restconf.py b/test/infamy/restconf.py index 32eed443..387657a2 100644 --- a/test/infamy/restconf.py +++ b/test/infamy/restconf.py @@ -207,7 +207,13 @@ class Device(Transport): dspath = f"{dspath}/{path}" url = f"{self.restconf_url}{dspath}" - return self._get_raw(url, parse) + try: + return self._get_raw(url, parse) + except requests.exceptions.HTTPError as e: + if e.response.status_code == 404: + return None + else: + raise e def get_running(self, path=None): """Wrapper function to get running datastore""" From 6521de28e7e6e5b8ce6c0e020dbb75b8b058dc3c Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Fri, 27 Sep 2024 16:22:45 +0200 Subject: [PATCH 2/4] confd: check for control-plane-protocol before migration Refactor 0f9d429 to first check if the .cfg file has any routing protocol active before converting the type's value. This fixes a regression in the release cycle that otherwise would cause a fresh startup-config, created from a plain factory-config from v24.08, to be converted to an empty file. Inspired by this fix, the same mitigation, albeit highyl unlikely, has been applied to the v1.0 user shell type migration. Signed-off-by: Joachim Wiberg --- .../share/migrate/1.0/10-infix-shell-type.sh | 9 +++++---- .../migrate/1.1/10-infix-routing-type.sh | 20 +++++++++++++++---- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/confd/share/migrate/1.0/10-infix-shell-type.sh b/src/confd/share/migrate/1.0/10-infix-shell-type.sh index 1289f5b0..ee588b17 100644 --- a/src/confd/share/migrate/1.0/10-infix-shell-type.sh +++ b/src/confd/share/migrate/1.0/10-infix-shell-type.sh @@ -2,8 +2,9 @@ # Migrate infix-shell-type:bash -> infix-system:bash file=$1 -temp=$1.tmp - -jq '.["ietf-system:system"].authentication.user |= map(.["infix-system:shell"] |= gsub("infix-shell-type:"; ""))' "$file" > "$temp" -mv "$temp" "$file" +temp=${file}.tmp +if jq -e '.["ietf-system:system"]?.authentication?.user? | length > 0' "$file" > /dev/null 2>&1; then + jq '.["ietf-system:system"].authentication.user |= map(.["infix-system:shell"] |= gsub("infix-shell-type:"; ""))' "$file" > "$temp" + mv "$temp" "$file" +fi diff --git a/src/confd/share/migrate/1.1/10-infix-routing-type.sh b/src/confd/share/migrate/1.1/10-infix-routing-type.sh index dfcd62c4..cca5275e 100644 --- a/src/confd/share/migrate/1.1/10-infix-routing-type.sh +++ b/src/confd/share/migrate/1.1/10-infix-routing-type.sh @@ -1,7 +1,19 @@ #!/bin/sh # migrate ietf-routing-type => infix-routing-type -file=$1 -temp=$1.tmp -jq '(.["ietf-routing:routing"]."control-plane-protocols"."control-plane-protocol"[] | select(.type == "ietf-ospf:ospfv2").type) |= "infix-routing:ospfv2"' "$file" > "$temp" -jq '(.["ietf-routing:routing"]."control-plane-protocols"."control-plane-protocol"[] | select(.type == "static").type) |= "infix-routing:static"' "$temp" > "$file" +migrate_routing_type() +{ + file=$1 + match=$2 + replace=$3 + + if jq -e '.["ietf-routing:routing"]?."control-plane-protocols"?."control-plane-protocol"?[] | length > 0' "$file" > /dev/null 2>&1; then + jq --arg match "${match}" --arg replace "${replace}" ' + (.["ietf-routing:routing"]."control-plane-protocols"."control-plane-protocol"[] | + select(.type == $match).type) |= $replace' "${file}" > "${file}.tmp" + mv "${file}.tmp" "${file}" + fi +} + +migrate_routing_type "$1" "ietf-ospf:ospfv2" "infix-routing:ospfv2" +migrate_routing_type "$1" "static" "infix-routing:static" From 015946219ba1d53c199263d05cb40c700aa153bf Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Fri, 27 Sep 2024 16:43:42 +0200 Subject: [PATCH 3/4] confd: fix possible NULL ptr deref Introduced in 35eeae55. Signed-off-by: Joachim Wiberg --- src/confd/src/ietf-interfaces.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/confd/src/ietf-interfaces.c b/src/confd/src/ietf-interfaces.c index 750267bd..d2245654 100644 --- a/src/confd/src/ietf-interfaces.c +++ b/src/confd/src/ietf-interfaces.c @@ -1657,7 +1657,7 @@ static int netdag_gen_iface_del(struct dagger *net, struct lyd_node *dif, if (dagger_should_skip_current(net, ifname)) return 0; - if (!strcmp(iftype, "infix-if-type:veth")) { + if (iftype && !strcmp(iftype, "infix-if-type:veth")) { struct lyd_node *node; const char *peer; From bac957d1bf9f500c7e39ea356fc41292ce7568d6 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Fri, 27 Sep 2024 16:53:32 +0200 Subject: [PATCH 4/4] cli: minor, fix tcpdump permissions from exec as admin Signed-off-by: Joachim Wiberg --- doc/ChangeLog.md | 2 ++ src/klish-plugin-infix/xml/infix.xml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/ChangeLog.md b/doc/ChangeLog.md index 582d86a1..621c4b07 100644 --- a/doc/ChangeLog.md +++ b/doc/ChangeLog.md @@ -83,6 +83,8 @@ documentation for details. interface changes (tries to delete both ends of the pair) - Spellcheck path to `/var/lib/containers` when unpacking OCI archives on container upgrade +- cli: restore `tcpdump` permissions for administrator level users, + regression introduced in v24.08.0 - The timeout before giving up on loading the `startup-config` at boot is now 1 minute, just like operations via other front-ends (NETCONF and RESTCONF). This was previously (incorrectly) set to 10 seconds diff --git a/src/klish-plugin-infix/xml/infix.xml b/src/klish-plugin-infix/xml/infix.xml index fd29468e..2ceb890f 100644 --- a/src/klish-plugin-infix/xml/infix.xml +++ b/src/klish-plugin-infix/xml/infix.xml @@ -528,7 +528,7 @@ count=${KLISH_PARAM_cnt:+-c $KLISH_PARAM_cnt} size=${KLISH_PARAM_sz:+-s $KLISH_PARAM_sz} verbose=${KLISH_PARAM_verbose:+-vvv} - tcpdump -ln $count $size $verbose -i $KLISH_PARAM_iface $KLISH_PARAM_expr + doas tcpdump -ln $count $size $verbose -i $KLISH_PARAM_iface $KLISH_PARAM_expr