Skip to contentSkip to conversation

tst_net.sh: Allow execution if xfrm is disabled

PATCH New Joerg Vehlow 2 participants 3 messages Oct 9, 2019 – Oct 31, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tst_net.sh: Allow execution if xfrm is disabled

From: Joerg Vehlow <[email protected]>

If the kernel is configured without xfrm support, the setup of the interfaces for communication between local and remote host fails, because it tries to flush xfrm state and policy.
There is no need to flush, if the system doesn't even support xfrm.

---
 testcases/lib/tst_net.sh | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
testcases/lib/tst_net.sh +8 -4
index 6c3ae708d..3aaf21cb5 100644
@@ -430,8 +430,10 @@ tst_init_iface()
 	tst_res_ TINFO "initialize '$type' '$iface' interface"
 
 	if [ "$type" = "lhost" ]; then
-		ip xfrm policy flush || return $?
-		ip xfrm state flush || return $?
+		if ip xfrm state 1>/dev/null 2>&1; then
+			ip xfrm policy flush || return $?
+			ip xfrm state flush || return $?
+		fi
 		ip link set $iface down || return $?
 		ip route flush dev $iface || return $?
 		ip addr flush dev $iface || return $?
@@ -439,8 +441,10 @@ tst_init_iface()
 		return $?
 	fi
 
-	tst_rhost_run -c "ip xfrm policy flush" || return $?
-	tst_rhost_run -c "ip xfrm state flush" || return $?
+	if tst_rhost_run -c "ip xfrm state 1>/dev/null 2>&1"; then
+		tst_rhost_run -c "ip xfrm policy flush" || return $?
+		tst_rhost_run -c "ip xfrm state flush" || return $?
+	fi
 	tst_rhost_run -c "ip link set $iface down" || return $?
 	tst_rhost_run -c "ip route flush dev $iface" || return $?
 	tst_rhost_run -c "ip addr flush dev $iface" || return $?
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/1 tst_net.sh: Allow execution if xfrm is disabled

Hi Joerg,

Quoted 8 lines

From: Joerg Vehlow <[email protected]>

If the kernel is configured without xfrm support, the setup of the interfaces for communication between local and remote host fails, because it tries to flush xfrm state and policy.
There is no need to flush, if the system doesn't even support xfrm.

Quoted 24 lines
---
 testcases/lib/tst_net.sh | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
testcases/lib/tst_net.sh +4 -2
index 6c3ae708d..3aaf21cb5 100644
@@ -430,8 +430,10 @@ tst_init_iface()
 	tst_res_ TINFO "initialize '$type' '$iface' interface"
 
 	if [ "$type" = "lhost" ]; then
-		ip xfrm policy flush || return $?
-		ip xfrm state flush || return $?
+		if ip xfrm state 1>/dev/null 2>&1; then
+			ip xfrm policy flush || return $?
+			ip xfrm state flush || return $?
+		fi
 		ip link set $iface down || return $?
 		ip route flush dev $iface || return $?
 		ip addr flush dev $iface || return $?
@@ -439,8 +441,10 @@ tst_init_iface()
 		return $?
 	fi

testcases/lib/tst_net.sh tst_init_iface() · line 450

Quoted 10 lines
testcases/lib/tst_net.sh +4 -2
 
-	tst_rhost_run -c "ip xfrm policy flush" || return $?
-	tst_rhost_run -c "ip xfrm state flush" || return $?
+	if tst_rhost_run -c "ip xfrm state 1>/dev/null 2>&1"; then
+		tst_rhost_run -c "ip xfrm policy flush" || return $?
+		tst_rhost_run -c "ip xfrm state flush" || return $?
+	fi
 	tst_rhost_run -c "ip link set $iface down" || return $?
 	tst_rhost_run -c "ip route flush dev $iface" || return $?
 	tst_rhost_run -c "ip addr flush dev $iface" || return $?

Kind regards,
Petr

#2 lore raw

PATCH 1/1 tst_net.sh: Allow execution if xfrm is disabled

Hi Joerg,

Quoted 9 lines
Quoted 8 lines

From: Joerg Vehlow <[email protected]>

If the kernel is configured without xfrm support, the setup of the interfaces for communication between local and remote host fails, because it tries to flush xfrm state and policy.
There is no need to flush, if the system doesn't even support xfrm.

Thanks, merged!

Kind regards,
Petr