169 lines
4.4 KiB
Diff
169 lines
4.4 KiB
Diff
Index: xen-unstable/tools/examples/network-bridge
|
|
===================================================================
|
|
--- xen-unstable.orig/tools/examples/network-bridge
|
|
+++ xen-unstable/tools/examples/network-bridge
|
|
@@ -69,23 +69,6 @@ pdev="p${netdev}"
|
|
vdev="veth${vifnum}"
|
|
vif0="vif0.${vifnum}"
|
|
|
|
-get_ip_info() {
|
|
- addr_pfx=`ip addr show dev $1 | egrep '^ *inet' | sed -e 's/ *inet //' -e 's/ .*//'`
|
|
- gateway=`ip route show dev $1 | fgrep default | sed 's/default via //'`
|
|
-}
|
|
-
|
|
-do_ifup() {
|
|
- if ! ifup $1 ; then
|
|
- if [ ${addr_pfx} ] ; then
|
|
- # use the info from get_ip_info()
|
|
- ip addr flush $1
|
|
- ip addr add ${addr_pfx} dev $1
|
|
- ip link set dev $1 up
|
|
- [ ${gateway} ] && ip route add default via ${gateway}
|
|
- fi
|
|
- fi
|
|
-}
|
|
-
|
|
# Usage: transfer_addrs src dst
|
|
# Copy all IP addresses (including aliases) from device $src to device $dst.
|
|
transfer_addrs () {
|
|
@@ -203,14 +186,10 @@ using netloop.nloopbacks=<N> on the doma
|
|
|
|
if link_exists "$vdev"; then
|
|
mac=`ip link show ${netdev} | grep 'link\/ether' | sed -e 's/.*ether \(..:..:..:..:..:..\).*/\1/'`
|
|
- preiftransfer ${netdev}
|
|
+ ifup ${netdev} # To ensure there is an IP to transfer
|
|
+ preiftransfer
|
|
transfer_addrs ${netdev} ${vdev}
|
|
- if ! ifdown ${netdev}; then
|
|
- # If ifdown fails, remember the IP details.
|
|
- get_ip_info ${netdev}
|
|
- ip link set ${netdev} down
|
|
- ip addr flush ${netdev}
|
|
- fi
|
|
+ ifdown ${netdev}
|
|
ip link set ${netdev} name ${pdev}
|
|
ip link set ${vdev} name ${netdev}
|
|
|
|
@@ -221,7 +200,8 @@ using netloop.nloopbacks=<N> on the doma
|
|
ip link set ${bridge} up
|
|
add_to_bridge ${bridge} ${vif0}
|
|
add_to_bridge2 ${bridge} ${pdev}
|
|
- do_ifup ${netdev}
|
|
+ ip link set ${netdev} up
|
|
+ ifup ${hwddev}
|
|
else
|
|
ip link set ${bridge} arp on
|
|
ip link set ${bridge} multicast on
|
|
@@ -249,9 +229,7 @@ op_stop () {
|
|
ip link set dev ${vif0} down
|
|
mac=`ip link show ${netdev} | grep 'link\/ether' | sed -e 's/.*ether \(..:..:..:..:..:..\).*/\1/'`
|
|
transfer_addrs ${netdev} ${pdev}
|
|
- if ! ifdown ${netdev}; then
|
|
- get_ip_info ${netdev}
|
|
- fi
|
|
+ ifdown ${netdev}
|
|
ip link set ${netdev} down arp off
|
|
ip link set ${netdev} addr fe:ff:ff:ff:ff:ff
|
|
ip link set ${pdev} down
|
|
@@ -264,7 +242,7 @@ op_stop () {
|
|
|
|
ip link set ${netdev} name ${vdev}
|
|
ip link set ${pdev} name ${netdev}
|
|
- do_ifup ${netdev}
|
|
+ ifup ${netdev}
|
|
else
|
|
transfer_routes ${bridge} ${netdev}
|
|
ip link set ${bridge} down
|
|
Index: xen-unstable/tools/examples/xen-network-common.sh
|
|
===================================================================
|
|
--- xen-unstable.orig/tools/examples/xen-network-common.sh
|
|
+++ xen-unstable/tools/examples/xen-network-common.sh
|
|
@@ -16,57 +16,33 @@
|
|
#
|
|
|
|
|
|
-# On SuSE it is necessary to run a command before transfering addresses and
|
|
-# routes from the physical interface to the virtual. This command creates a
|
|
-# variable $HWD_CONFIG_0 that specifies the appropriate configuration for
|
|
-# ifup.
|
|
+# Reads the global variable "netdev" (which is the kernel interface name,
|
|
+# e.g., "eth0") and sets the global variable "hwddev" (which is the persistent
|
|
+# interface name, e.g., "eth-id-00:e0:81:54:12:34").
|
|
|
|
-# Gentoo doesn't have ifup/ifdown, so we define appropriate alternatives.
|
|
-
|
|
-# Other platforms just use ifup / ifdown directly.
|
|
+preiftransfer()
|
|
+{
|
|
+ local HWD_CONFIG_0
|
|
+ eval `/sbin/getcfg -d /etc/sysconfig/network/ -f ifcfg- -- "$netdev" | grep HWD_CONFIG_0=`
|
|
+ if [ -n "$HWD_CONFIG_0" ]; then
|
|
+ hwddev="$HWD_CONFIG_0"
|
|
+ fi
|
|
+}
|
|
|
|
-##
|
|
-# preiftransfer
|
|
-#
|
|
-# @param $1 The current name for the physical device, which is also the name
|
|
-# that the virtual device will take once the physical device has
|
|
-# been renamed.
|
|
-
|
|
-if [ -e /etc/SuSE-release ]
|
|
-then
|
|
- preiftransfer()
|
|
- {
|
|
- eval `/sbin/getcfg -d /etc/sysconfig/network/ -f ifcfg- -- $1`
|
|
- }
|
|
- ifup()
|
|
- {
|
|
- /sbin/ifup ${HWD_CONFIG_0} $1
|
|
- }
|
|
-elif ! which ifup >/dev/null 2>/dev/null
|
|
-then
|
|
- preiftransfer()
|
|
- {
|
|
- true
|
|
- }
|
|
- ifup()
|
|
- {
|
|
- false
|
|
- }
|
|
- ifdown()
|
|
- {
|
|
- false
|
|
- }
|
|
-else
|
|
- preiftransfer()
|
|
- {
|
|
- true
|
|
- }
|
|
-fi
|
|
+ifup()
|
|
+{
|
|
+ /sbin/ifup $1 -o rc || true
|
|
+}
|
|
|
|
+ifdown()
|
|
+{
|
|
+ /sbin/ifdown $1 -o rc
|
|
+}
|
|
|
|
first_file()
|
|
{
|
|
- t="$1"
|
|
+ local t="$1"
|
|
+ local file
|
|
shift
|
|
for file in $@
|
|
do
|
|
@@ -80,7 +56,7 @@ first_file()
|
|
|
|
find_dhcpd_conf_file()
|
|
{
|
|
- first_file -f /etc/dhcp3/dhcpd.conf /etc/dhcpd.conf
|
|
+ first_file -f /etc/dhcp3/dhcpd.conf /etc/dhcpd.conf /etc/dhcpd.conf.pxe
|
|
}
|
|
|
|
|