From 5c2976b9a6b517168af275c67498db0ad88a16b3 Mon Sep 17 00:00:00 2001 From: Keith Amidon Date: Thu, 19 Mar 2009 09:55:50 -0700 Subject: [PATCH] Change init script to interact with xapi better at boot. It seems that with a controller specified in vswitchd, previously there was a bad interaction between vswitchd and xapi during boot that prevented the management interface from ever coming up. The solution here is to force all bridge interfaces up when vswitchd starts, so they are already up when xapi attempts to bring them up. Since the interfaces are coming up earlier as a result, we move vswitch back in the boot sequence after iptables starts. This patch also contains a bunch of lines that have only changed in whitespace because half the indentation in this file was done using tabs and the other half was done with spaces... --- vswitchd/etc/init.d/vswitch | 96 ++++++++++++++++++------------------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/vswitchd/etc/init.d/vswitch b/vswitchd/etc/init.d/vswitch index e4443ce7..7a4f7641 100755 --- a/vswitchd/etc/init.d/vswitch +++ b/vswitchd/etc/init.d/vswitch @@ -2,7 +2,7 @@ # # vswitch # -# chkconfig: 2345 05 95 +# chkconfig: 2345 09 91 # description: Manage vswitch kernel modules and user-space daemon # @@ -80,51 +80,51 @@ 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 "$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 @@ -139,21 +139,21 @@ case "$1" in 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 ;; -- 2.30.2