From c2a71bffee2d8fd3e044b660f64a373539916a7c Mon Sep 17 00:00:00 2001 From: Keith Amidon Date: Sat, 14 Mar 2009 10:02:23 -0700 Subject: [PATCH] Hack vswitchd init script to remove bridge ports at startup XAPI will recreate all the bridges and reconnect the interfaces at startup, so this is safe in the Xen environment. If we don't do this stale vifs hang around in the configuration file. This is a hack and not a true solution because it doesn't handle port-related configuration, etc. A better solution needs to be implemented in the future. --- vswitchd/etc/init.d/vswitch | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/vswitchd/etc/init.d/vswitch b/vswitchd/etc/init.d/vswitch index a2f6f68d..0c185a63 100755 --- a/vswitchd/etc/init.d/vswitch +++ b/vswitchd/etc/init.d/vswitch @@ -22,6 +22,11 @@ function dp_intf { $VSWITCH_BASE/utilities/dpctl show nl:$1 | grep '^ LOCAL(' | cut -d'(' -f2 | cut -d')' -f1 } +function clear_old_bridge_ports { + mv $VSWITCHD_CONF $VSWITCHD_CONF.prev + grep -v '^bridge\.[^.]\+\.port[ \t]*=' $VSWITCHD_CONF.prev > $VSWITCHD_CONF +} + function start { if ! lsmod | grep -q "openflow_mod"; then action "Inserting openflow module" insmod $VSWITCH_BASE/datapath/linux-2.6/openflow_mod.ko @@ -41,9 +46,10 @@ function start { if [ -n "$MEMLEAK_LOG" ]; then leak_opt="--check-leaks=$MEMLEAK_LOG" if [ -e "$MEMLEAK_LOG" ]; then - mv "$MEMLEAK_LOG" "$MEMLEAK_LOG.last" + mv "$MEMLEAK_LOG" "$MEMLEAK_LOG.prev" fi fi + [ "$1" = "restart" ] || clear_old_bridge_ports PATH=$VSWITCH_BASE/secchan:$PATH action "Starting vswitchd" nice -n "$PRIORITY" $VSWITCH_BASE/vswitchd/vswitchd -P/var/run/vswitchd.pid -D -vANY:CONSOLE:EMER $syslog_opt $logfile_level_opt $logfile_file_opt --brcompat $leak_opt "$VSWITCHD_CONF" if [ "$1" = "restart" ]; then sleep 2 # Give time for vswitch to get up and running. -- 2.30.2