Re: [LTP] [patch 8/9] Network NS - sysfsview.patch
Quoting CAI Qian ([EMAIL PROTECTED]): Hi, --- Veerendra [EMAIL PROTECTED] wrote: This patch addresses the comments if any, on the below files child_propogate.sh - Propagates the contents of the child sysfs to parentNS. parent_share.sh - Creates a sharable volume of the sysfs for child to access. parent_view.sh - Parent NS verifies the contents of the child sysfs. sysfsview.c - Basic program to create namespaces for sysfs checking Signed off by Veerendra C [EMAIL PROTECTED] ACKed by Serge Hallyn [EMAIL PROTECTED] Renamed the file to child_propagate.sh to address the spelling change ! --- containers.old/netns/child_propogate.sh 2008-09-08 17:18:28.0 +0530 +++ containers/netns/child_propogate.sh 1970-01-01 05:30:00.0 +0530 @@ -1,47 +0,0 @@ -#!/bin/bash -# This script propogates the child sysfs contents to be visible for parent -# Also it will check the parent sysfs contents are visible. -#Propogate child sys directory - -# The test case ID, the test case count and the total number of test case -TCID=${TCID:-child_propogate.sh} -TST_TOTAL=1 -TST_COUNT=1 -#set -x -export TCID -export TST_COUNT -export TST_TOTAL - -ret=0 -PROPOGATE=`cat /tmp/FIFO4` -debug INFO: CHILD propopagated.. -mount -t sysfs none /sys || ret=1 -mkdir -p /tmp/mnt/sys || ret=1 -mount --bind /sys /tmp/mnt/sys /dev/null || ret=1 - -if [ $ret -ne 0 ]; then -status=1 -tst_resm TFAIL error while doing bind mount -exit $status -fi -#Capture childs sysfs contents -ls /sys/class/net /tmp/child_sysfs -echo propogated /tmp/FIFO5 - -#Capture parent sysfs in child -ls /tmp/par_sysfs/class/net /tmp/parent_sysfs_in_child -diff /tmp/parent_sysfs_in_child /tmp/parent_sysfs /dev/null 21 -if [ $? -eq 0 ] -then -tst_resm TINFO Pass:Child is able to view parent sysfs -status=0 -else -tst_resm TFAIL Fail:Child view of sysfs is not same as parent sysfs -status=1 -fi - -echo $status /tmp/FIFO6 - -#cleanup -rm -f /tmp/parent_sysfs_in_child /tmp/parent_sysfs -umount /tmp/mnt/sys --- containers.old/netns/child_propagate.sh 1970-01-01 05:30:00.0 +0530 +++ containers/netns/child_propagate.sh 2008-09-10 01:06:42.0 +0530 @@ -0,0 +1,46 @@ +#!/bin/bash +# This script propagates the child sysfs contents to be visible for parent +# Also it will check the parent sysfs contents are visible. +#Propagate child sys directory + +# The test case ID, the test case count and the total number of test case +TCID=${TCID:-child_propagate.sh} +TST_TOTAL=1 +TST_COUNT=1 +#set -x +export TCID +export TST_COUNT +export TST_TOTAL + +ret=0 +PROPAGATE=`cat /tmp/FIFO4` +debug INFO: CHILD propagated.. +mount -t sysfs none /sys || ret=1 The test will fail if sysfs has been mounted by default in test systems. IIUC this will be the first task in the child network namespace. So sys needs to be remounted. The fact that it has been mounted on the host is not a problem. It will choose a new super-block and mount that. The mount shouldn't fail, else something was actually wrong. Moreover, users will also see the confusing error message error while doing bind mount later. What do you mean, could you elaborate? Cai Qian +mkdir -p /tmp/mnt/sys || ret=1 +mount --bind /sys /tmp/mnt/sys /dev/null || ret=1 + +if [ $ret -ne 0 ]; then +status=1 +tst_resm TFAIL error while doing bind mount +exit $status +fi +#Capture childs sysfs contents +ls /sys/class/net /tmp/child_sysfs +echo propagated /tmp/FIFO5 + +#Capture parent sysfs in child +ls /tmp/par_sysfs/class/net /tmp/parent_sysfs_in_child +diff /tmp/parent_sysfs_in_child /tmp/parent_sysfs /dev/null 21 +if [ $? -eq 0 ] +then +tst_resm TINFO Pass:Child is able to view parent sysfs +status=0 +else +tst_resm TFAIL Fail:Child view of sysfs is not same as parent sysfs +status=1 +fi + +#cleanup +rm -f /tmp/parent_sysfs_in_child /tmp/parent_sysfs +umount /tmp/mnt/sys +rm -rf /tmp/mnt /dev/null 21 || true Addressing the spelling error and also removed the redundant entry of passing status value. --- containers.old/netns/parent_view.sh 2008-09-08 17:18:28.0 +0530 +++ containers/netns/parent_view.sh 2008-09-10 01:06:42.0 +0530 @@ -13,9 +13,9 @@ export TST_TOTAL debug INFO: Parent SYSFS view ls /sys/class/net /tmp/parent_sysfs -echo PROPOGATE /tmp/FIFO4 +echo PROPAGATE /tmp/FIFO4 -PROPOGATED=`cat /tmp/FIFO5` +PROPAGATED=`cat /tmp/FIFO5`
Re: [LTP] [patch 8/9] Network NS - sysfsview.patch
Hi, --- Serge E. Hallyn [EMAIL PROTECTED] wrote: Quoting CAI Qian ([EMAIL PROTECTED]): Hi, --- Veerendra [EMAIL PROTECTED] wrote: This patch addresses the comments if any, on the below files child_propogate.sh - Propagates the contents of the child sysfs to parentNS. parent_share.sh - Creates a sharable volume of the sysfs for child to access. parent_view.sh - Parent NS verifies the contents of the child sysfs. sysfsview.c - Basic program to create namespaces for sysfs checking Signed off by Veerendra C [EMAIL PROTECTED] ACKed by Serge Hallyn [EMAIL PROTECTED] Renamed the file to child_propagate.sh to address the spelling change ! --- containers.old/netns/child_propogate.sh 2008-09-08 17:18:28.0 +0530 +++ containers/netns/child_propogate.sh 1970-01-01 05:30:00.0 +0530 @@ -1,47 +0,0 @@ -#!/bin/bash -# This script propogates the child sysfs contents to be visible for parent -# Also it will check the parent sysfs contents are visible. -#Propogate child sys directory - -# The test case ID, the test case count and the total number of test case -TCID=${TCID:-child_propogate.sh} -TST_TOTAL=1 -TST_COUNT=1 -#set -x -export TCID -export TST_COUNT -export TST_TOTAL - -ret=0 -PROPOGATE=`cat /tmp/FIFO4` -debug INFO: CHILD propopagated.. -mount -t sysfs none /sys || ret=1 -mkdir -p /tmp/mnt/sys || ret=1 -mount --bind /sys /tmp/mnt/sys /dev/null || ret=1 - -if [ $ret -ne 0 ]; then -status=1 -tst_resm TFAIL error while doing bind mount -exit $status -fi -#Capture childs sysfs contents -ls /sys/class/net /tmp/child_sysfs -echo propogated /tmp/FIFO5 - -#Capture parent sysfs in child -ls /tmp/par_sysfs/class/net /tmp/parent_sysfs_in_child -diff /tmp/parent_sysfs_in_child /tmp/parent_sysfs /dev/null 21 -if [ $? -eq 0 ] -then -tst_resm TINFO Pass:Child is able to view parent sysfs -status=0 -else -tst_resm TFAIL Fail:Child view of sysfs is not same as parent sysfs -status=1 -fi - -echo $status /tmp/FIFO6 - -#cleanup -rm -f /tmp/parent_sysfs_in_child /tmp/parent_sysfs -umount /tmp/mnt/sys --- containers.old/netns/child_propagate.sh 1970-01-01 05:30:00.0 +0530 +++ containers/netns/child_propagate.sh 2008-09-10 01:06:42.0 +0530 @@ -0,0 +1,46 @@ +#!/bin/bash +# This script propagates the child sysfs contents to be visible for parent +# Also it will check the parent sysfs contents are visible. +#Propagate child sys directory + +# The test case ID, the test case count and the total number of test case +TCID=${TCID:-child_propagate.sh} +TST_TOTAL=1 +TST_COUNT=1 +#set -x +export TCID +export TST_COUNT +export TST_TOTAL + +ret=0 +PROPAGATE=`cat /tmp/FIFO4` +debug INFO: CHILD propagated.. +mount -t sysfs none /sys || ret=1 The test will fail if sysfs has been mounted by default in test systems. IIUC this will be the first task in the child network namespace. So sys needs to be remounted. The fact that it has been mounted on the host is not a problem. It will choose a new super-block and mount that. The mount shouldn't fail, else something was actually wrong. OK. Moreover, users will also see the confusing error message error while doing bind mount later. What do you mean, could you elaborate? mount -t sysfs none /sys || ret=1 When it failed, ret become 1. Then, it propagated to the error handling, if [ $ret -ne 0 ]; then status=1 tst_resm TFAIL error while doing bind mount exit $status fi The error messages do not exactly match the failure. Cai Qian Cai Qian +mkdir -p /tmp/mnt/sys || ret=1 +mount --bind /sys /tmp/mnt/sys /dev/null || ret=1 + +if [ $ret -ne 0 ]; then +status=1 +tst_resm TFAIL error while doing bind mount +exit $status +fi +#Capture childs sysfs contents +ls /sys/class/net /tmp/child_sysfs +echo propagated /tmp/FIFO5 + +#Capture parent sysfs in child +ls /tmp/par_sysfs/class/net /tmp/parent_sysfs_in_child +diff /tmp/parent_sysfs_in_child /tmp/parent_sysfs /dev/null 21 +if [ $? -eq 0 ] +then +tst_resm TINFO Pass:Child is able to view parent sysfs +status=0 +else +tst_resm TFAIL Fail:Child view of sysfs is not same as parent sysfs +status=1 +fi + +#cleanup +rm -f /tmp/parent_sysfs_in_child /tmp/parent_sysfs +umount /tmp/mnt/sys +rm -rf /tmp/mnt /dev/null 21 || true Addressing the
Re: [LTP] [patch 8/9] Network NS - sysfsview.patch
Hi, --- Veerendra [EMAIL PROTECTED] wrote: This patch addresses the comments if any, on the below files child_propogate.sh - Propagates the contents of the child sysfs to parentNS. parent_share.sh - Creates a sharable volume of the sysfs for child to access. parent_view.sh - Parent NS verifies the contents of the child sysfs. sysfsview.c - Basic program to create namespaces for sysfs checking Signed off by Veerendra C [EMAIL PROTECTED] ACKed by Serge Hallyn [EMAIL PROTECTED] Renamed the file to child_propagate.sh to address the spelling change ! --- containers.old/netns/child_propogate.sh 2008-09-08 17:18:28.0 +0530 +++ containers/netns/child_propogate.sh 1970-01-01 05:30:00.0 +0530 @@ -1,47 +0,0 @@ -#!/bin/bash -# This script propogates the child sysfs contents to be visible for parent -# Also it will check the parent sysfs contents are visible. -#Propogate child sys directory - -# The test case ID, the test case count and the total number of test case -TCID=${TCID:-child_propogate.sh} -TST_TOTAL=1 -TST_COUNT=1 -#set -x -export TCID -export TST_COUNT -export TST_TOTAL - -ret=0 -PROPOGATE=`cat /tmp/FIFO4` -debug INFO: CHILD propopagated.. -mount -t sysfs none /sys || ret=1 -mkdir -p /tmp/mnt/sys || ret=1 -mount --bind /sys /tmp/mnt/sys /dev/null || ret=1 - -if [ $ret -ne 0 ]; then -status=1 -tst_resm TFAIL error while doing bind mount -exit $status -fi -#Capture childs sysfs contents -ls /sys/class/net /tmp/child_sysfs -echo propogated /tmp/FIFO5 - -#Capture parent sysfs in child -ls /tmp/par_sysfs/class/net /tmp/parent_sysfs_in_child -diff /tmp/parent_sysfs_in_child /tmp/parent_sysfs /dev/null 21 -if [ $? -eq 0 ] -then -tst_resm TINFO Pass:Child is able to view parent sysfs -status=0 -else -tst_resm TFAIL Fail:Child view of sysfs is not same as parent sysfs -status=1 -fi - -echo $status /tmp/FIFO6 - -#cleanup -rm -f /tmp/parent_sysfs_in_child /tmp/parent_sysfs -umount /tmp/mnt/sys --- containers.old/netns/child_propagate.sh 1970-01-01 05:30:00.0 +0530 +++ containers/netns/child_propagate.sh 2008-09-10 01:06:42.0 +0530 @@ -0,0 +1,46 @@ +#!/bin/bash +# This script propagates the child sysfs contents to be visible for parent +# Also it will check the parent sysfs contents are visible. +#Propagate child sys directory + +# The test case ID, the test case count and the total number of test case +TCID=${TCID:-child_propagate.sh} +TST_TOTAL=1 +TST_COUNT=1 +#set -x +export TCID +export TST_COUNT +export TST_TOTAL + +ret=0 +PROPAGATE=`cat /tmp/FIFO4` +debug INFO: CHILD propagated.. +mount -t sysfs none /sys || ret=1 The test will fail if sysfs has been mounted by default in test systems. Moreover, users will also see the confusing error message error while doing bind mount later. Cai Qian +mkdir -p /tmp/mnt/sys || ret=1 +mount --bind /sys /tmp/mnt/sys /dev/null || ret=1 + +if [ $ret -ne 0 ]; then +status=1 +tst_resm TFAIL error while doing bind mount +exit $status +fi +#Capture childs sysfs contents +ls /sys/class/net /tmp/child_sysfs +echo propagated /tmp/FIFO5 + +#Capture parent sysfs in child +ls /tmp/par_sysfs/class/net /tmp/parent_sysfs_in_child +diff /tmp/parent_sysfs_in_child /tmp/parent_sysfs /dev/null 21 +if [ $? -eq 0 ] +then +tst_resm TINFO Pass:Child is able to view parent sysfs +status=0 +else +tst_resm TFAIL Fail:Child view of sysfs is not same as parent sysfs +status=1 +fi + +#cleanup +rm -f /tmp/parent_sysfs_in_child /tmp/parent_sysfs +umount /tmp/mnt/sys +rm -rf /tmp/mnt /dev/null 21 || true Addressing the spelling error and also removed the redundant entry of passing status value. --- containers.old/netns/parent_view.sh 2008-09-08 17:18:28.0 +0530 +++ containers/netns/parent_view.sh 2008-09-10 01:06:42.0 +0530 @@ -13,9 +13,9 @@ export TST_TOTAL debug INFO: Parent SYSFS view ls /sys/class/net /tmp/parent_sysfs -echo PROPOGATE /tmp/FIFO4 +echo PROPAGATE /tmp/FIFO4 -PROPOGATED=`cat /tmp/FIFO5` +PROPAGATED=`cat /tmp/FIFO5` ls /tmp/mnt/sys/class/net /tmp/child_sysfs_in_parent diff /tmp/child_sysfs_in_parent /tmp/child_sysfs if [ $? -eq 0 ] @@ -27,14 +27,11 @@ export TST_TOTAL status=-1 fi -stat=`cat /tmp/FIFO6` -if [ $stat != 0 ] ; then -status=$stat -fi - #cleanup temp files + rm -f /tmp/child_sysfs_in_parent /tmp/child_sysfs umount /tmp/par_sysfs umount /tmp/mnt sleep 1 rm -rf /tmp/par_sysfs /tmp/mnt /dev/null
Re: [LTP] [patch 8/9] Network NS - sysfsview.patch
This patch addresses the comments if any, on the below files child_propogate.sh - Propagates the contents of the child sysfs to parentNS. parent_share.sh - Creates a sharable volume of the sysfs for child to access. parent_view.sh - Parent NS verifies the contents of the child sysfs. sysfsview.c - Basic program to create namespaces for sysfs checking Signed off by Veerendra C [EMAIL PROTECTED] ACKed by Serge Hallyn [EMAIL PROTECTED] Acked-by: Benjamin Thery [EMAIL PROTECTED] Renamed the file to child_propagate.sh to address the spelling change ! --- containers.old/netns/child_propogate.sh 2008-09-08 17:18:28.0 +0530 +++ containers/netns/child_propogate.sh 1970-01-01 05:30:00.0 +0530 @@ -1,47 +0,0 @@ -#!/bin/bash -# This script propogates the child sysfs contents to be visible for parent -# Also it will check the parent sysfs contents are visible. -#Propogate child sys directory - -# The test case ID, the test case count and the total number of test case -TCID=${TCID:-child_propogate.sh} -TST_TOTAL=1 -TST_COUNT=1 -#set -x -export TCID -export TST_COUNT -export TST_TOTAL - -ret=0 -PROPOGATE=`cat /tmp/FIFO4` -debug INFO: CHILD propopagated.. -mount -t sysfs none /sys || ret=1 -mkdir -p /tmp/mnt/sys || ret=1 -mount --bind /sys /tmp/mnt/sys /dev/null || ret=1 - -if [ $ret -ne 0 ]; then -status=1 -tst_resm TFAIL error while doing bind mount -exit $status -fi -#Capture childs sysfs contents -ls /sys/class/net /tmp/child_sysfs -echo propogated /tmp/FIFO5 - -#Capture parent sysfs in child -ls /tmp/par_sysfs/class/net /tmp/parent_sysfs_in_child -diff /tmp/parent_sysfs_in_child /tmp/parent_sysfs /dev/null 21 -if [ $? -eq 0 ] -then -tst_resm TINFO Pass:Child is able to view parent sysfs -status=0 -else -tst_resm TFAIL Fail:Child view of sysfs is not same as parent sysfs -status=1 -fi - -echo $status /tmp/FIFO6 - -#cleanup -rm -f /tmp/parent_sysfs_in_child /tmp/parent_sysfs -umount /tmp/mnt/sys --- containers.old/netns/child_propagate.sh 1970-01-01 05:30:00.0 +0530 +++ containers/netns/child_propagate.sh 2008-09-10 01:06:42.0 +0530 @@ -0,0 +1,46 @@ +#!/bin/bash +# This script propagates the child sysfs contents to be visible for parent +# Also it will check the parent sysfs contents are visible. +#Propagate child sys directory + +# The test case ID, the test case count and the total number of test case +TCID=${TCID:-child_propagate.sh} +TST_TOTAL=1 +TST_COUNT=1 +#set -x +export TCID +export TST_COUNT +export TST_TOTAL + +ret=0 +PROPAGATE=`cat /tmp/FIFO4` +debug INFO: CHILD propagated.. +mount -t sysfs none /sys || ret=1 +mkdir -p /tmp/mnt/sys || ret=1 +mount --bind /sys /tmp/mnt/sys /dev/null || ret=1 + +if [ $ret -ne 0 ]; then +status=1 +tst_resm TFAIL error while doing bind mount +exit $status +fi +#Capture childs sysfs contents +ls /sys/class/net /tmp/child_sysfs +echo propagated /tmp/FIFO5 + +#Capture parent sysfs in child +ls /tmp/par_sysfs/class/net /tmp/parent_sysfs_in_child +diff /tmp/parent_sysfs_in_child /tmp/parent_sysfs /dev/null 21 +if [ $? -eq 0 ] +then +tst_resm TINFO Pass:Child is able to view parent sysfs +status=0 +else +tst_resm TFAIL Fail:Child view of sysfs is not same as parent sysfs +status=1 +fi + +#cleanup +rm -f /tmp/parent_sysfs_in_child /tmp/parent_sysfs +umount /tmp/mnt/sys +rm -rf /tmp/mnt /dev/null 21 || true Addressing the spelling error and also removed the redundant entry of passing status value. --- containers.old/netns/parent_view.sh 2008-09-08 17:18:28.0 +0530 +++ containers/netns/parent_view.sh 2008-09-10 01:06:42.0 +0530 @@ -13,9 +13,9 @@ export TST_TOTAL debug INFO: Parent SYSFS view ls /sys/class/net /tmp/parent_sysfs -echo PROPOGATE /tmp/FIFO4 +echo PROPAGATE /tmp/FIFO4 -PROPOGATED=`cat /tmp/FIFO5` +PROPAGATED=`cat /tmp/FIFO5` ls /tmp/mnt/sys/class/net /tmp/child_sysfs_in_parent diff /tmp/child_sysfs_in_parent /tmp/child_sysfs if [ $? -eq 0 ] @@ -27,14 +27,11 @@ export TST_TOTAL status=-1 fi -stat=`cat /tmp/FIFO6` -if [ $stat != 0 ] ; then -status=$stat -fi - #cleanup temp files + rm -f /tmp/child_sysfs_in_parent /tmp/child_sysfs umount /tmp/par_sysfs umount /tmp/mnt sleep 1 rm -rf /tmp/par_sysfs /tmp/mnt /dev/null 21 || true +cleanup $sshpid $vnet0 Modified to include the filename change and to return proper return value. --- containers.old/netns/sysfsview.c 2008-09-08 17:18:28.0
Re: [LTP] [patch 8/9] Network NS - sysfsview.patch
This patch addresses the comments if any, on the below files child_propogate.sh - Propagates the contents of the child sysfs to parentNS. parent_share.sh - Creates a sharable volume of the sysfs for child to access. parent_view.sh - Parent NS verifies the contents of the child sysfs. sysfsview.c - Basic program to create namespaces for sysfs checking Signed off by Veerendra C [EMAIL PROTECTED] ACKed by Serge Hallyn [EMAIL PROTECTED] Renamed the file to child_propagate.sh to address the spelling change ! --- containers.old/netns/child_propogate.sh 2008-09-08 17:18:28.0 +0530 +++ containers/netns/child_propogate.sh 1970-01-01 05:30:00.0 +0530 @@ -1,47 +0,0 @@ -#!/bin/bash -# This script propogates the child sysfs contents to be visible for parent -# Also it will check the parent sysfs contents are visible. -#Propogate child sys directory - -# The test case ID, the test case count and the total number of test case -TCID=${TCID:-child_propogate.sh} -TST_TOTAL=1 -TST_COUNT=1 -#set -x -export TCID -export TST_COUNT -export TST_TOTAL - -ret=0 -PROPOGATE=`cat /tmp/FIFO4` -debug INFO: CHILD propopagated.. -mount -t sysfs none /sys || ret=1 -mkdir -p /tmp/mnt/sys || ret=1 -mount --bind /sys /tmp/mnt/sys /dev/null || ret=1 - -if [ $ret -ne 0 ]; then -status=1 -tst_resm TFAIL error while doing bind mount -exit $status -fi -#Capture childs sysfs contents -ls /sys/class/net /tmp/child_sysfs -echo propogated /tmp/FIFO5 - -#Capture parent sysfs in child -ls /tmp/par_sysfs/class/net /tmp/parent_sysfs_in_child -diff /tmp/parent_sysfs_in_child /tmp/parent_sysfs /dev/null 21 -if [ $? -eq 0 ] -then -tst_resm TINFO Pass:Child is able to view parent sysfs -status=0 -else -tst_resm TFAIL Fail:Child view of sysfs is not same as parent sysfs -status=1 -fi - -echo $status /tmp/FIFO6 - -#cleanup -rm -f /tmp/parent_sysfs_in_child /tmp/parent_sysfs -umount /tmp/mnt/sys --- containers.old/netns/child_propagate.sh 1970-01-01 05:30:00.0 +0530 +++ containers/netns/child_propagate.sh 2008-09-10 01:06:42.0 +0530 @@ -0,0 +1,46 @@ +#!/bin/bash +# This script propagates the child sysfs contents to be visible for parent +# Also it will check the parent sysfs contents are visible. +#Propagate child sys directory + +# The test case ID, the test case count and the total number of test case +TCID=${TCID:-child_propagate.sh} +TST_TOTAL=1 +TST_COUNT=1 +#set -x +export TCID +export TST_COUNT +export TST_TOTAL + +ret=0 +PROPAGATE=`cat /tmp/FIFO4` +debug INFO: CHILD propagated.. +mount -t sysfs none /sys || ret=1 +mkdir -p /tmp/mnt/sys || ret=1 +mount --bind /sys /tmp/mnt/sys /dev/null || ret=1 + +if [ $ret -ne 0 ]; then +status=1 +tst_resm TFAIL error while doing bind mount +exit $status +fi +#Capture childs sysfs contents +ls /sys/class/net /tmp/child_sysfs +echo propagated /tmp/FIFO5 + +#Capture parent sysfs in child +ls /tmp/par_sysfs/class/net /tmp/parent_sysfs_in_child +diff /tmp/parent_sysfs_in_child /tmp/parent_sysfs /dev/null 21 +if [ $? -eq 0 ] +then +tst_resm TINFO Pass:Child is able to view parent sysfs +status=0 +else +tst_resm TFAIL Fail:Child view of sysfs is not same as parent sysfs +status=1 +fi + +#cleanup +rm -f /tmp/parent_sysfs_in_child /tmp/parent_sysfs +umount /tmp/mnt/sys +rm -rf /tmp/mnt /dev/null 21 || true Addressing the spelling error and also removed the redundant entry of passing status value. --- containers.old/netns/parent_view.sh 2008-09-08 17:18:28.0 +0530 +++ containers/netns/parent_view.sh 2008-09-10 01:06:42.0 +0530 @@ -13,9 +13,9 @@ export TST_TOTAL debug INFO: Parent SYSFS view ls /sys/class/net /tmp/parent_sysfs -echo PROPOGATE /tmp/FIFO4 +echo PROPAGATE /tmp/FIFO4 -PROPOGATED=`cat /tmp/FIFO5` +PROPAGATED=`cat /tmp/FIFO5` ls /tmp/mnt/sys/class/net /tmp/child_sysfs_in_parent diff /tmp/child_sysfs_in_parent /tmp/child_sysfs if [ $? -eq 0 ] @@ -27,14 +27,11 @@ export TST_TOTAL status=-1 fi -stat=`cat /tmp/FIFO6` -if [ $stat != 0 ] ; then -status=$stat -fi - #cleanup temp files + rm -f /tmp/child_sysfs_in_parent /tmp/child_sysfs umount /tmp/par_sysfs umount /tmp/mnt sleep 1 rm -rf /tmp/par_sysfs /tmp/mnt /dev/null 21 || true +cleanup $sshpid $vnet0 Modified to include the filename change and to return proper return value. --- containers.old/netns/sysfsview.c 2008-09-08 17:18:28.0 +0530 +++ containers/netns/sysfsview.c 2008-09-10 21:55:00.0 +0530 @@ -24,7 +24,7 @@ * Also it checks the sysfs contents of the child are visible from the parent NS. * On Success it returns PASS else returns FAIL * -*
[LTP] [patch 8/9] Network NS - sysfsview.patch
This patch consists of the files child_propogate.sh - Propagates the contents of the child sysfs to parentNS. parent_share.sh - Creates a sharable volume of the sysfs for child to access. parent_view.sh - Parent NS verifies the contents of the child sysfs. sysfsview.c - Basic program to create namespaces for sysfs checking Signed-off-by: Veerendra C [EMAIL PROTECTED] Index: containers/netns/child_propogate.sh === --- /dev/null +++ containers/netns/child_propogate.sh @@ -0,0 +1,47 @@ +#!/bin/bash +# This script propogates the child sysfs contents to be visible for parent +# Also it will check the parent sysfs contents are visible. +#Propogate child sys directory + +# The test case ID, the test case count and the total number of test case +TCID=${TCID:-child_propogate.sh} +TST_TOTAL=1 +TST_COUNT=1 +#set -x +export TCID +export TST_COUNT +export TST_TOTAL + +ret=0 +PROPOGATE=`cat /tmp/FIFO4` +debug INFO: CHILD propopagated.. +mount -t sysfs none /sys || ret=1 +mkdir -p /tmp/mnt/sys || ret=1 +mount --bind /sys /tmp/mnt/sys /dev/null || ret=1 + +if [ $ret -ne 0 ]; then +status=1 +tst_resm TFAIL error while doing bind mount +exit $status +fi +#Capture childs sysfs contents +ls /sys/class/net /tmp/child_sysfs +echo propogated /tmp/FIFO5 + +#Capture parent sysfs in child +ls /tmp/par_sysfs/class/net /tmp/parent_sysfs_in_child +diff /tmp/parent_sysfs_in_child /tmp/parent_sysfs /dev/null 21 +if [ $? -eq 0 ] +then +tst_resm TINFO Pass:Child is able to view parent sysfs +status=0 +else +tst_resm TFAIL Fail:Child view of sysfs is not same as parent sysfs +status=1 +fi + +echo $status /tmp/FIFO6 + +#cleanup +rm -f /tmp/parent_sysfs_in_child /tmp/parent_sysfs +umount /tmp/mnt/sys Index: containers/netns/parent_share.sh === --- /dev/null +++ containers/netns/parent_share.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# This script is executed in the parent NS. +# It binds and does sharable mount of sysfs . +# +#For child to refer parent sys +# set -x + +# The test case ID, the test case count and the total number of test case +TCID=${TCID:-parent_share.sh} +TST_TOTAL=1 +TST_COUNT=1 +export TCID +export TST_COUNT +export TST_TOTAL +ret=0 +source initialize.sh + +mkdir -p /tmp/par_sysfs /tmp/mnt || ret=1 +mount --bind /sys /tmp/par_sysfs || ret=1 + +#share parent namespace +mount --bind /tmp/mnt /tmp/mnt || ret=1 +#mount --make-shared /mnt +$smount /tmp/mnt shared /dev/null || ret=1 +if [ $ret -ne 0 ] ; then +tst_resm TFAIL Error while doing shared mount +exit -1 +fi Index: containers/netns/parent_view.sh === --- /dev/null +++ containers/netns/parent_view.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# This script verifies the contents of child sysfs is visible in parent NS. + +# The test case ID, the test case count and the total number of test case +TCID=${TCID:-parent_view.sh} +TST_TOTAL=1 +TST_COUNT=1 +export TCID +export TST_COUNT +export TST_TOTAL + +#capture parent /sys contents + +debug INFO: Parent SYSFS view +ls /sys/class/net /tmp/parent_sysfs +echo PROPOGATE /tmp/FIFO4 + +PROPOGATED=`cat /tmp/FIFO5` +ls /tmp/mnt/sys/class/net /tmp/child_sysfs_in_parent +diff /tmp/child_sysfs_in_parent /tmp/child_sysfs +if [ $? -eq 0 ] +then +tst_resm TINFO Pass: Parent is able to view child sysfs +status=0 +else +tst_resm TFAIL Fail: Parent is not able to view Child-NS sysfs +status=-1 +fi + +stat=`cat /tmp/FIFO6` +if [ $stat != 0 ] ; then +status=$stat +fi + +#cleanup temp files +rm -f /tmp/child_sysfs_in_parent /tmp/child_sysfs +umount /tmp/par_sysfs +umount /tmp/mnt +sleep 1 +rm -rf /tmp/par_sysfs /tmp/mnt /dev/null 21 || true Index: containers/netns/sysfsview.c === --- /dev/null +++ containers/netns/sysfsview.c @@ -0,0 +1,70 @@ + +/* +* Copyright (c) International Business Machines Corp., 2008 +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +* the GNU General Public License for more details. +* You should have received a copy of the GNU General Public License +* along with