This patch has 4 files..

check_netns_enabled.c - checks for the network ns is enabled initialize.sh - Initializes the common functions and variables
Makefile  - Makefile
runnetnstest.sh - Creates a batch file to run the tests.







Signed off by Veerendra C <[EMAIL PROTECTED]>
ACKed by Serge Hallyn <[EMAIL PROTECTED]>

Included the netns subdir in the Makefile
--- containers.old/Makefile	2008-09-10 21:33:32.000000000 +0530
+++ containers/Makefile	2008-09-10 21:43:10.000000000 +0530
@@ -18,7 +18,7 @@
 ##                                                                            ##
 ################################################################################
 
-SUBDIRS := libclone utsname sysvipc pidns
+SUBDIRS := libclone utsname sysvipc pidns netns
 
 all: check_for_unshare
 	@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i $@; done

Modified the script to get the dynamic eth device name.
Also to restore the values of ip_forward and arpproxy
values after executing the test.

--- containers.old/netns/initialize.sh	2008-09-08 17:18:28.000000000 +0530
+++ containers/netns/initialize.sh	2008-09-10 01:06:42.000000000 +0530
@@ -30,15 +30,29 @@ DEBUG=0
         tst_resm TFAIL "Please set the LTP root env variable, and retry again"
         exit -1
     fi
-    mkfifo /tmp/FIFO1 /tmp/FIFO2 /tmp/FIFO3 /tmp/FIFO4 /tmp/FIFO5 /tmp/FIFO6 2> /dev/null
-
 
     IPver=`ip -V | awk  -F"-" ' {  print $2 } '` ;
     if [[ ${IPver} < "ss080417" ]] ; then
-        tst_resm "ip version should be atleast ss080417"
+        tst_resm  TINFO "ip version should be atleast ss080417"
+        exit -1
+    fi
+    mkfifo /tmp/FIFO1 /tmp/FIFO2 /tmp/FIFO3 /tmp/FIFO4 /tmp/FIFO5 /tmp/FIFO6 2> /dev/null
+
+    netdev=`ip addr show | awk '/^[0-9]*:.*UP/ { a=$2 } /inet / { b=$2 ; \
+            if ( a !~ /lo/  && b ! NULL ) {  print a ; exit 0 } } ' `
+    netdev=`basename $netdev ":"`
+    if [ -z $netdev ] ; then
+        tst_resm  TINFO "Not able to determine the ethernet dev name"
         exit -1
     fi
 
+    # copying the values for restoring it later.
+    ipfwd=`cat /proc/sys/net/ipv4/ip_forward`
+    if [ -f /proc/sys/net/ipv4/conf/$netdev/proxy_arp ] ; then
+        arpproxy=`cat /proc/sys/net/ipv4/conf/$netdev/proxy_arp`
+    else
+	arpproxy=0
+    fi
 cleanup()
 {
    if [ $# == 2 ]; then
@@ -49,12 +63,17 @@ cleanup()
     debug "INFO: doing cleanup operation "
     # Delete the veth pair:
     (ip link delete $netdev) 2> /dev/null
-    # Disable ip forwarding:
-    echo 0 > /proc/sys/net/ipv4/ip_forward
     sleep 1
+
+    #Restoring the orignial values .
+    echo $ipfwd > /proc/sys/net/ipv4/ip_forward > /dev/null
+    if [ -f /proc/sys/net/ipv4/conf/$netdev/proxy_arp ] ; then
+    	echo $arpproxy > /proc/sys/net/ipv4/conf/$netdev/proxy_arp > /dev/null
+    fi
     ( kill -9 $pid ) 2> /dev/null
-    rm -f /tmp/FIFO1 /tmp/FIFO2 /tmp/FIFO3 /tmp/FIFO4 /tmp/FIFO5 /tmp/FIFO6 > /dev/null
-    rm -f /tmp/net1 /tmp/net2 > /dev/null
+    rm -f /tmp/FIFO1 /tmp/FIFO2 /tmp/FIFO3 /tmp/FIFO4 \
+	  /tmp/FIFO5 /tmp/FIFO6 > /dev/null
+    rm -f /tmp/net1 /tmp/net2 > /dev/null || true
 }
 
 debug()
@@ -75,3 +94,6 @@ create_veth()
     dev0=${dev[0]}
     dev1=${dev[1]}
 }
+
+
+
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to