Don't try to add the same interface to the bridge twice, and clean up old routing...
authorQuentin Smith <quentin@mit.edu>
Sun, 2 Jan 2011 05:44:58 +0000 (00:44 -0500)
committerQuentin Smith <quentin@mit.edu>
Sun, 2 Jan 2011 05:45:43 +0000 (00:45 -0500)
vif-invirtroute

index 83a1e08..f473ac9 100755 (executable)
@@ -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