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