Be more conservative about bringing up interfaces when vswitchd started
authorKeith Amidon <keith@nicira.com>
Tue, 14 Apr 2009 23:41:17 +0000 (16:41 -0700)
committerKeith Amidon <keith@nicira.com>
Tue, 14 Apr 2009 23:42:06 +0000 (16:42 -0700)
Previously we were starting all bridge interfaces when vswitchd
started to help resolve issues in Xen environemnts.  However, only
starting the management interface seems to be required.  The
information about which interface is the management interface is
available in /etc/xensource-inventory on Xen machines, so use that to
limit the interfaces we bring up.

vswitchd/etc/init.d/vswitch

index c6614721e5763692f50a0acfaff59b7a82bf493c..8b7d53daf59c40dce0f914a6af7ee2862eb6ce12 100755 (executable)
@@ -8,6 +8,11 @@
 
 . /etc/init.d/functions
 
+MANAGEMENT_INTERFACE=""
+if [ -f /etc/xensource-inventory ]; then
+    . /etc/xensource-inventory
+fi
+
 test -e /etc/sysconfig/vswitch && . /etc/sysconfig/vswitch
 VSWITCH_BASE="${VSWITCH_BASE:-/root/vswitch}"
 VSWITCHD_CONF="${VSWITCHD_CONF:-/etc/vswitchd.conf}"
@@ -76,15 +81,23 @@ function start {
         valgrind_opt="valgrind --log-file=$VALGRIND_LOG $VALGRIND_OPT"
         daemonize_opt=""
     fi
-    #[ "$1" = "update-modules" ] || [ "$1" = "restart" ] || clear_old_bridge_ports
     action "Starting vswitchd" nice -n "$VSWITCHD_PRIORITY" $strace_opt $valgrind_opt $VSWITCH_BASE/sbin/vswitchd -P"$VSWITCHD_PIDFILE" $daemonize_opt -vANY:CONSOLE:EMER $syslog_opt $logfile_level_opt $logfile_file_opt $leak_opt "$VSWITCHD_CONF"
-    # Always attempt to force bridge interfaces up because otherwise
-    # vswitch and XAPI interact badly on startup
     sleep 2    # Give time for vswitch to get up and running.
-        for dp in $(dp_list); do
+    # In Xen environments, always attempt to force the management
+    # bridge interface up because otherwise vswitch and XAPI interact
+    # badly on startup.
+    if [ -n "$MANAGEMENT_INTERFACE" ] && [ -e "/etc/sysconfig/network-scripts/ifcfg-$MANAGEMENT_INTERFACE" ]; then
+        action "Bringing up management interface: $MANAGEMENT_INTERFACE" ifup "$MANAGEMENT_INTERFACE" 
+    fi
+    # When attempting to restart or update modules online, bring up
+    # all bridge interfaces since presumably they were in use before
+    # we went down.
+    for dp in $(dp_list); do
         local intf=$(dp_intf $dp)
         if [ -e "/etc/sysconfig/network-scripts/ifcfg-$intf" ]; then
-            action "Bringing up datapath interface: $intf" ifup "$intf"
+            if [ "$1" == "update-modules" ]; then
+                action "Bringing up datapath interface: $intf" ifup "$intf"
+            fi
         fi
     done
 }