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

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