Add isolated_loopback support in vservers at creation-time.
authorStephen Soltesz <soltesz@cs.princeton.edu>
Thu, 12 May 2011 21:46:38 +0000 (17:46 -0400)
committerStephen Soltesz <soltesz@cs.princeton.edu>
Thu, 12 May 2011 21:46:38 +0000 (17:46 -0400)
   if the slice is not created with this option, it will not be reset @
   runtime.

python/vserver.py
scripts/vuseradd

index a4e828d..dea58c6 100644 (file)
@@ -233,11 +233,11 @@ class VServer:
         for ip in addresses:
             vserverimpl.netadd(self.ctx, ip)
 
-    def set_ipaddresses_config(self, addresses):
+    def set_ipaddresses_config(self, addresses, add_loopback=True):
         ip_addresses = addresses.split(",")
 
         # add looopback interface
-        if not ip_addresses.__contains__("127.0.0.1"):
+        if not ip_addresses.__contains__("127.0.0.1") and add_loopback:
             ip_addresses.append("127.0.0.1")
 
         i = 0
@@ -246,7 +246,7 @@ class VServer:
             # create emtpy nodev files to silent "No device specified for" warnings
             self.config.update("interfaces/%d/nodev" % i, "")
             i += 1
-        while self.config.unset("interfaces/%d/ip" % i) and self.config.update("interfaces/%d/nodev" % i):
+        while self.config.unset("interfaces/%d/ip" % i) and self.config.update("interfaces/%d/nodev" % i, ""):
             i += 1
         self.set_ipaddresses(ip_addresses)
 
index c49fdd4..f64d62d 100755 (executable)
@@ -39,11 +39,15 @@ usage()
 }
 
 # Get options
-while getopts "t:" opt ; do
+ISOLATE=false
+while getopts "it:" opt ; do
     case $opt in
        t)
            TYPE="$OPTARG"
            ;;
+       i)
+           ISOLATE=true
+           ;;
        *)
            usage
            ;;
@@ -77,10 +81,17 @@ if [ ! -d $__CONFDIR/$NAME ] ; then
        HAS_VSERVERDIR=0
     fi
 
-    $_VSERVER $NAME build -m skeleton --context $USERID \
+    if [ "$ISOLATE" = "true" ] ; then
+        $_VSERVER $NAME build -m skeleton --context $USERID \
+               --interface nodev:`hostname -i` \
+               --flags persistent,~info_init
+    else 
+        $_VSERVER $NAME build -m skeleton --context $USERID \
                --interface nodev:`hostname -i` \
-                --interface nodev:127.0.0.1 \
+               --interface nodev:127.0.0.1 \
                --flags persistent,~info_init
+    fi
+
     RETVAL=$?
     DIR=$__CONFDIR/$NAME
     if [ $RETVAL -ne 0 ] ; then
@@ -91,7 +102,11 @@ if [ ! -d $__CONFDIR/$NAME ] ; then
     echo default > $DIR/apps/init/mark
 
     # Set persistent for the network context
-    echo persistent,lback_allow > $DIR/nflags
+    if [ "$ISOLATE" = "true" ]; then
+        echo persistent,lback_allow,hide_lback,lback_remap > $DIR/nflags
+    else 
+        echo persistent,lback_allow > $DIR/nflags
+    fi
 
     # Set default capabilities
     echo "CAP_NET_RAW" > $DIR/bcapabilities