#
 # vswitch
 #
-# chkconfig: 2345 05 95
+# chkconfig: 2345 09 91
 # description: Manage vswitch kernel modules and user-space daemon
 #
 
         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 "$PRIORITY" $strace_opt $valgrind_opt $VSWITCH_BASE/vswitchd/vswitchd -P/var/run/vswitchd.pid $daemonize_opt -vANY:CONSOLE:EMER $syslog_opt $logfile_level_opt $logfile_file_opt --brcompat $leak_opt "$VSWITCHD_CONF"
-       if [ "$1" = "update-modules" ]; then
-               sleep 2    # Give time for vswitch to get up and running.
+    #[ "$1" = "update-modules" ] || [ "$1" = "restart" ] || clear_old_bridge_ports
+    action "Starting vswitchd" nice -n "$PRIORITY" $strace_opt $valgrind_opt $VSWITCH_BASE/vswitchd/vswitchd -P/var/run/vswitchd.pid $daemonize_opt -vANY:CONSOLE:EMER $syslog_opt $logfile_level_opt $logfile_file_opt --brcompat $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
-                       local intf=$(dp_intf $dp)
-                       if [ -e "/etc/sysconfig/network-scripts/ifcfg-$intf" ]; then
-                               action "Bringing up datapath interface: $intf" ifup "$intf"
-                       fi
-               done
-       fi
+        local intf=$(dp_intf $dp)
+        if [ -e "/etc/sysconfig/network-scripts/ifcfg-$intf" ]; then
+            action "Bringing up datapath interface: $intf" ifup "$intf"
+        fi
+    done
 }
 
 function stop {
-       if [ -f /var/run/vswitchd.pid ]; then
+    if [ -f /var/run/vswitchd.pid ]; then
         local pid=$(cat /var/run/vswitchd.pid)
-               action "Killing vswitchd ($pid)" kill -TERM $pid
-       fi
-       if [ -e /var/run/vswitchd.pid ]; then
-               rm -f /var/run/vswitchd.pid
-       fi
-       if [ "$1" = "update-modules" ]; then
+        action "Killing vswitchd ($pid)" kill -TERM $pid
+    fi
+    if [ -e /var/run/vswitchd.pid ]; then
+        rm -f /var/run/vswitchd.pid
+    fi
+    if [ "$1" = "update-modules" ]; then
         for dp in $(dp_list); do
-                       local intf=$(dp_intf $dp)
-                       action "Removing datapath: $dp" $VSWITCH_BASE/utilities/dpctl deldp $dp
-                       if [ -e "/etc/sysconfig/network-scripts/ifcfg-$intf" ]; then
-                               action "Shutting down datapath interface: $intf" ifdown "$intf"
-                       fi
-               done
-               action "Removing brcompat module" rmmod brcompat_mod.ko
-               action "Removing openflow module" rmmod openflow_mod.ko
-       fi
+            local intf=$(dp_intf $dp)
+            action "Removing datapath: $dp" $VSWITCH_BASE/utilities/dpctl deldp $dp
+            if [ -e "/etc/sysconfig/network-scripts/ifcfg-$intf" ]; then
+                action "Shutting down datapath interface: $intf" ifdown "$intf"
+            fi
+        done
+        action "Removing brcompat module" rmmod brcompat_mod.ko
+        action "Removing openflow module" rmmod openflow_mod.ko
+    fi
 }
 
 case "$1" in
-       start)
-               start
-               ;;
-       stop)
-               stop
-               ;;
-       restart)
-               stop
-               start restart
-               ;;
+    start)
+        start
+        ;;
+    stop)
+        stop
+        ;;
+    restart)
+        stop
+        start restart
+        ;;
     restart-strace)
         shift
         stop
         stop update-modules
         start update-modules
         ;;
-       reload)
-               if [ -f /var/run/vswitchd.pid ]; then
-                       kill -HUP $(cat /var/run/vswitchd.pid)
-               fi
-               ;;
+    reload)
+        if [ -f /var/run/vswitchd.pid ]; then
+            kill -HUP $(cat /var/run/vswitchd.pid)
+        fi
+        ;;
     strace)
         shift
         strace -p $(cat /var/run/vswitchd.pid) "$@"
         ;;
-       unload)
-               stop update-modules
-               ;;
-       status)
-               status -p vswitchd.pid vswitchd
-               ;;
+    unload)
+        stop update-modules
+        ;;
+    status)
+        status -p vswitchd.pid vswitchd
+        ;;
     version)
         "$VSWITCH_BASE"/vswitchd/vswitchd -V
         ;;