cdown / rpms / util-linux

Forked from rpms/util-linux 2 years ago
Clone

Blame SOURCES/0010-tests-make-lsns-netnsid-portable.patch

069435
From b48e972b3aa32710ed0495c35b2184f5d3ec9eb0 Mon Sep 17 00:00:00 2001
069435
From: Karel Zak <kzak@redhat.com>
069435
Date: Fri, 30 Nov 2018 12:24:15 +0100
069435
Subject: [PATCH 10/14] tests: make lsns-netnsid portable
069435
069435
It seems ip(8) link-show command does not provide link-netnsid in all
069435
cases (versions ?). Let's try to use "ip netns list-id" as fallback.
069435
069435
This commit also add possibility to debug the script by $LOG variable.
069435
069435
Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=1656437
069435
Upstream: http://github.com/karelzak/util-linux/commit/0d79f5805ff2d7651ec70b06753e908cc782857a
069435
Signed-off-by: Karel Zak <kzak@redhat.com>
069435
---
069435
 tests/ts/lsns/netnsid | 26 +++++++++++++++++++++++++-
069435
 1 file changed, 25 insertions(+), 1 deletion(-)
069435
069435
diff --git a/tests/ts/lsns/netnsid b/tests/ts/lsns/netnsid
069435
index 72c14de6c..9d04f28f0 100755
069435
--- a/tests/ts/lsns/netnsid
069435
+++ b/tests/ts/lsns/netnsid
069435
@@ -36,6 +36,7 @@ vethb=lsns-vethb
069435
 NS=LSNS-TEST-NETNSID-NS
069435
 FIFO=$TS_OUTDIR/FIFO-NETNSID
069435
 NULL=/dev/null
069435
+LOG=/dev/null #/root/foo.log
069435
 
069435
 function cleanup {
069435
 	ip link delete $vetha 2> $NULL || :
069435
@@ -43,24 +44,47 @@ function cleanup {
069435
 	rm -f $FIFO
069435
 }
069435
 
069435
+echo "==Cleanup" >> $LOG
069435
 cleanup
069435
+
069435
+echo "==Create FIFO" >> $LOG
069435
 mkfifo $FIFO
069435
 
069435
+echo "==Netns ADD" >> $LOG
069435
 if ip netns add $NS &&
069435
 	ip link add name $vetha type veth peer name $vethb &&
069435
 	ip link set $vethb netns $NS; then
069435
+    echo "===Netns EXEC" >> $LOG
069435
     ip netns exec $NS dd if=$FIFO bs=1 count=2 of=$NULL 2> $NULL &
069435
     PID=$!
069435
+    echo "====PID=$PID" >> $LOG
069435
 else
069435
     cleanup
069435
     ts_skip "failed to initialize"
069435
 fi
069435
 {
069435
+    echo "==Write to FIFO" >> $LOG
069435
     dd if=/dev/zero bs=1 count=1 2> $NULL
069435
     {
069435
-	ip -o link show dev $vetha > $NULL
069435
+	echo "===IP output" >> $LOG
069435
+	ip -o link show dev $vetha >> $LOG
069435
+
069435
 	IP_ID=$(ip -o link show dev $vetha | sed -ne 's/.* *link-netnsid *\([0-9]*\)/\1/p')
069435
+	echo "====ip show: IP_ID=$IP_ID" >> $LOG
069435
+
069435
+	if [ "x$IP_ID" = "x" ]; then
069435
+		echo "===IP output list id" >> $LOG
069435
+		ip netns list-id >> $LOG
069435
+
069435
+		IP_ID=$(ip netns list-id | awk "/name: $NS/ { print \$2 }")
069435
+		echo "====ip list-id: IP_ID=$IP_ID" >> $LOG
069435
+	fi
069435
+
069435
+	echo "===LSNS output" >> $LOG
069435
+	$TS_CMD_LSNS -o+NETNSID,NSFS --type net >> $LOG
069435
+
069435
 	LSNS_ID=$($TS_CMD_LSNS -n -o NETNSID --type net --task $PID | { read VAL; echo $VAL; } )
069435
+	echo "===LSNS_ID=$LSNS_ID" >> $LOG
069435
     }
069435
     dd if=/dev/zero bs=1 count=1 2> $NULL
069435
 } > $FIFO
069435
-- 
069435
2.17.2
069435