From 02f32b2977c23d75c74e4b02f6fcaafeb0277758 Mon Sep 17 00:00:00 2001 From: Quentin Smith Date: Sun, 2 Jan 2011 00:44:58 -0500 Subject: [PATCH] Don't try to add the same interface to the bridge twice, and clean up old routing table entries when taking an interface offline --- vif-invirtroute | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/vif-invirtroute b/vif-invirtroute index 83a1e08..f473ac9 100755 --- a/vif-invirtroute +++ b/vif-invirtroute @@ -14,6 +14,7 @@ # # Environment vars: # vif vif interface name (required). +# dev qemu interface name (optional) # XENBUS_PATH path to this device's details in the XenStore (required). # Read from the store: # ip list of IP networks for the vif, space-separated (default given in @@ -34,11 +35,13 @@ brname=dom${vif#vif} case "$command" in online) - setup_bridge_port ${dev} - setup_bridge_port ${vif} create_bridge ${brname} + setup_bridge_port ${dev} add_to_bridge ${brname} ${dev} - add_to_bridge ${brname} ${vif} + if [ "$dev" != "$vif" ]; then + setup_bridge_port ${vif} + add_to_bridge ${brname} ${vif} + fi ifconfig ${brname} ${main_ip} netmask 255.255.255.255 up echo 1 >/proc/sys/net/ipv4/conf/${brname}/proxy_arp echo 1 >/proc/sys/net/ipv4/conf/${brname}/rp_filter @@ -63,6 +66,9 @@ if [ ${vif_type} != "ioemu" -o x${qemu_online} = xyes ] ; then # the guest using those addresses. for addr in ${ip} ; do ${cmdprefix} ip route ${ipcmd} ${addr} dev ${brname} src ${main_ip} + if [ "$ipcmd" == "del" ]; then + do_without_error ip route del ${addr} dev ${dev} src ${main_ip} + fi if [ "$command" == "online" ]; then arpspoof -i $(invirt-getconf xen.iface) -t 18.181.0.1 ${addr}& sleep 5 -- 1.7.9.5