|
|
|
|
|
|
|
|
|
|
xen-changelog
[Xen-changelog] Flush the addresses from the new eth0 before trying to a
# HG changeset patch
# User emellor@xxxxxxxxxxxxxxxxxxxxxx
# Node ID 52f214d983fb3edf2e265984ed9fe103dd7d2440
# Parent e64e28e36e02ddcef1e5f0d398f649e2d869302e
Flush the addresses from the new eth0 before trying to add the new address to
it, when using ip on the kernel command line and not using the installed ifup /
ifdown. This stops the script bailing out if there is already an address
attached to that device, which was leaving the device without routing (since
this has already been removed).
Fix the stop action under the same circumstances. No attempt was made to
restore the kernel command line details to the interfaces if the ifdown failed
in that case.
Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx>
diff -r e64e28e36e02 -r 52f214d983fb tools/examples/network-bridge
--- a/tools/examples/network-bridge Thu Dec 8 15:54:35 2005
+++ b/tools/examples/network-bridge Thu Dec 8 16:11:48 2005
@@ -87,6 +87,31 @@
done
echo "ERROR converting netmask $mask to prefix"
exit 1
+}
+
+parse_kernel_ip() {
+ 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`
+ fi
+}
+
+do_ifup() {
+ if ! ifup $1 ; then
+ if [ ${kip} ] ; then
+ # use the addresses we grocked from /proc/cmdline
+ if [ -z "${kmask}" ]; then
+ PREFIX=32
+ else
+ legacy_mask_to_prefix ${kmask}
+ fi
+ ip addr flush $1
+ ip addr add ${kip}/${PREFIX} dev $1
+ ip link set dev $1 up
+ [ ${kgate} ] && ip route add default via ${kgate}
+ fi
+ fi
}
# Usage: transfer_addrs src dst
@@ -234,14 +259,11 @@
preiftransfer ${netdev}
transfer_addrs ${netdev} ${vdev}
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`
- ip link set ${netdev} down
- ip addr flush ${netdev}
- fi
+ # If ifdown fails, take the IP details from the kernel command
+ # line.
+ parse_kernel_ip
+ ip link set ${netdev} down
+ ip addr flush ${netdev}
fi
ip link set ${netdev} name ${pdev}
ip link set ${vdev} name ${netdev}
@@ -253,20 +275,8 @@
add_to_bridge ${bridge} ${pdev}
ip link set ${bridge} up
ip link set ${vif0} up
- ip link set ${pdev} up
- if ! ifup ${netdev} ; then
- if [ ${kip} ] ; then
- # use the addresses we grocked from /proc/cmdline
- if [ -z "${kmask}" ]; then
- PREFIX=32;
- else
- legacy_mask_to_prefix ${kmask};
- fi
- ip addr add ${kip}/${PREFIX} dev ${netdev}
- ip link set dev ${netdev} up
- [ ${kgate} ] && ip route add default via ${kgate}
- fi
- fi
+ ip link set ${pdev} up
+ do_ifup ${netdev}
else
# old style without ${vdev}
transfer_addrs ${netdev} ${bridge}
@@ -290,7 +300,9 @@
ip link set dev ${vif0} down
mac=`ip link show ${netdev} | grep 'link\/ether' | sed -e 's/.*ether
\(..:..:..:..:..:..\).*/\1/'`
transfer_addrs ${netdev} ${pdev}
- ifdown ${netdev}
+ if ! ifdown ${netdev}; then
+ parse_kernel_ip
+ fi
ip link set ${netdev} down arp off
ip link set ${netdev} addr fe:ff:ff:ff:ff:ff
ip link set ${pdev} down
@@ -303,8 +315,7 @@
ip link set ${netdev} name ${vdev}
ip link set ${pdev} name ${netdev}
- ifup ${netdev}
-
+ do_ifup ${netdev}
else
transfer_routes ${bridge} ${netdev}
ip link set ${bridge} down
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|
<Prev in Thread] |
Current Thread |
[Next in Thread> |
- [Xen-changelog] Flush the addresses from the new eth0 before trying to add the new address to,
Xen patchbot -unstable <=
|
|
|
|
|