aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoriap10@freefall.cl.cam.ac.uk <iap10@freefall.cl.cam.ac.uk>2005-08-13 22:02:54 +0000
committeriap10@freefall.cl.cam.ac.uk <iap10@freefall.cl.cam.ac.uk>2005-08-13 22:02:54 +0000
commit141ec0c6391b4d5d38dbb66369cea38373d0b7df (patch)
treef8ddfdc4c7270dce7e168d5d88f5bac3b79b34b6
parent38e8f172c3fb44eb738bc21cdfafa34b25d12e17 (diff)
downloadxen-141ec0c6391b4d5d38dbb66369cea38373d0b7df.tar.gz
xen-141ec0c6391b4d5d38dbb66369cea38373d0b7df.tar.bz2
xen-141ec0c6391b4d5d38dbb66369cea38373d0b7df.zip
New 'network-bridge' script that uses ifdown/ifup to configure the interface rather than trying to transfer addresses and routes. (Suggested by Gerd Knorr)
Although Li Ge has had problems with this script he had trouble with the previous too. I think this new one should work for more people, particularly those using DHCP on their primary dom0 interface. Debugging is currently enabled ("sh -x") so a log of the script's execution is output to /var/log/xend.log Signed-off-by: ian@xensource.com --HG-- rename : tools/examples/network => tools/examples/network-bridge
-rwxr-xr-xtools/examples/network-bridge (renamed from tools/examples/network)50
-rw-r--r--tools/examples/xend-config.sxp2
2 files changed, 33 insertions, 19 deletions
diff --git a/tools/examples/network b/tools/examples/network-bridge
index 537bbe3dab..d9fc2d855f 100755
--- a/tools/examples/network
+++ b/tools/examples/network-bridge
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/sh -x
#============================================================================
# Default Xen network start/stop script.
# Xend calls a network script when it starts.
@@ -176,26 +176,40 @@ op_start () {
fi
if ifconfig veth0 2>/dev/null | grep -q veth0 ; then
- # Propagate MAC address and ARP responsibilities to virtual interface.
- mac=`ifconfig ${netdev} | grep HWadd | sed -e 's/.*\(..:..:..:..:..:..\).*/\1/'`
- ifconfig veth0 down
- ifconfig veth0 hw ether ${mac}
- ifconfig veth0 arp up
- transfer_addrs ${netdev} veth0
- transfer_routes ${netdev} veth0
- del_addrs ${netdev}
- ifconfig ${netdev} -arp down
- ifconfig ${netdev} hw ether fe:ff:ff:ff:ff:ff up
- # Bring up second half of virtual device and attach it to the bridge.
- ifconfig vif0.0 up
- add_to_bridge ${bridge} vif0.0
+ mac=`ifconfig ${netdev} | grep HWadd | sed -e 's/.*\(..:..:..:..:..:..\).*/\1/'`
+ if ! ifdown ${netdev} ; then
+ # if ifup didn't work, see if we have an ip= on cmd line
+ if egrep 'ip=[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+:' /proc/cmdline ;
+ then
+ kip=`sed -e 's!.*ip=\([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\):.*!\1!' /proc/cmdline`
+ kmask=`sed -e 's!.*ip=[^:]*:[^:]*:[^:]*:\([^:]*\):.*!\1!' /proc/cmdline`
+ kgate=`sed -e 's!.*ip=[^:]*:[^:]*:\([^:]*\):.*!\1!' /proc/cmdline`
+ ifconfig ${netdev} 0.0.0.0 down
+ fi
+ fi
+ ip link set ${netdev} name p${netdev}
+ ip link set veth0 name eth0
+ ifconfig p${netdev} -arp down
+ ifconfig p${netdev} hw ether fe:ff:ff:ff:ff:ff
+ ifconfig ${netdev} hw ether ${mac}
+ add_to_bridge ${bridge} vif0.0
+ add_to_bridge ${bridge} p${netdev}
+ ip link set vif0.0 up
+ ip link set p${netdev} up
+ if ! ifup ${netdev} ; then
+ if [ ${kip} ] ; then
+ # use the addresses we grocked from /proc/cmdline
+ ifconfig ${netdev} ${kip}
+ [ ${kmask} ] && ifconfig ${netdev} netmask ${kmask}
+ ifconfig ${netdev} up
+ [ ${kgate} ] && ip route add default via ${kgate}
+ fi
+ fi
else
- transfer_addrs ${netdev} ${bridge}
+ # old style without veth0
+ transfer_addrs ${netdev} ${bridge}
transfer_routes ${netdev} ${bridge}
fi
-
- # Attach the real interface to the bridge.
- add_to_bridge ${bridge} ${netdev}
if [ ${antispoof} == 'yes' ] ; then
antispoofing ${netdev} ${bridge}
diff --git a/tools/examples/xend-config.sxp b/tools/examples/xend-config.sxp
index d8914d320d..249cdce507 100644
--- a/tools/examples/xend-config.sxp
+++ b/tools/examples/xend-config.sxp
@@ -28,7 +28,7 @@
## Use the following if VIF traffic is bridged.
# The script used to start/stop networking for xend.
-(network-script network)
+(network-script network-bridge)
# The default bridge that virtual interfaces should be connected to.
(vif-bridge xen-br0)
# The default script used to control virtual interfaces.