ia64/xen-unstable

annotate tools/hotplug/Linux/xen-network-common.sh @ 19497:2f6ed9318c03

network-bridge: Fix do_ifup in the case of ${bridge} != ${netdev}

On RHEL5.2, ifup ${bridge} fails if ${bridge} != ${netdev},
because RHEL5.2's ifup ${bridge} runs the following sequence:

1. Search CONFIG that has the same mac address of ${bridge}.=20
ifcfg-${netdev} is found.
2. Run "ip link set dev ${netdev} up".
# ${bridge} is expected.
3. Output "Failed to bring up ${netdev}."
Because ${netdev} does not exist.

Thus, do_ifup() should not use ifup if ${bridge} != ${netdev}.

Signed-off-by: KUWAMURA Shin'ya <kuwa@jp.fujitsu.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Apr 02 11:48:10 2009 +0100 (2009-04-02)
parents 4bfc67b09e9c
children
rev   line source
keir@18770 1 #
keir@18770 2 # Copyright (c) 2005 XenSource Ltd.
keir@18770 3 #
keir@18770 4 # This library is free software; you can redistribute it and/or
keir@18770 5 # modify it under the terms of version 2.1 of the GNU Lesser General Public
keir@18770 6 # License as published by the Free Software Foundation.
keir@18770 7 #
keir@18770 8 # This library is distributed in the hope that it will be useful,
keir@18770 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
keir@18770 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
keir@18770 11 # Lesser General Public License for more details.
keir@18770 12 #
keir@18770 13 # You should have received a copy of the GNU Lesser General Public
keir@18770 14 # License along with this library; if not, write to the Free Software
keir@18770 15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
keir@18770 16 #
keir@18770 17
keir@18770 18
keir@18770 19 # Gentoo doesn't have ifup/ifdown, so we define appropriate alternatives.
keir@18770 20
keir@18770 21 # Other platforms just use ifup / ifdown directly.
keir@18770 22
keir@18770 23 ##
keir@18770 24 # preiftransfer
keir@18770 25 #
keir@18770 26 # @param $1 The current name for the physical device, which is also the name
keir@18770 27 # that the virtual device will take once the physical device has
keir@18770 28 # been renamed.
keir@18770 29
keir@18770 30 if ! which ifup >/dev/null 2>/dev/null
keir@18770 31 then
keir@18770 32 preiftransfer()
keir@18770 33 {
keir@18770 34 true
keir@18770 35 }
keir@18770 36 ifup()
keir@18770 37 {
keir@18770 38 false
keir@18770 39 }
keir@18770 40 ifdown()
keir@18770 41 {
keir@18770 42 false
keir@18770 43 }
keir@18770 44 else
keir@18770 45 preiftransfer()
keir@18770 46 {
keir@18770 47 true
keir@18770 48 }
keir@18770 49 fi
keir@18770 50
keir@18770 51
keir@18770 52 first_file()
keir@18770 53 {
keir@18770 54 t="$1"
keir@18770 55 shift
keir@18770 56 for file in $@
keir@18770 57 do
keir@18770 58 if [ "$t" "$file" ]
keir@18770 59 then
keir@18770 60 echo "$file"
keir@18770 61 return
keir@18770 62 fi
keir@18770 63 done
keir@18770 64 }
keir@18770 65
keir@18770 66 find_dhcpd_conf_file()
keir@18770 67 {
keir@18770 68 first_file -f /etc/dhcp3/dhcpd.conf /etc/dhcpd.conf
keir@18770 69 }
keir@18770 70
keir@18770 71
keir@18770 72 find_dhcpd_init_file()
keir@18770 73 {
keir@18770 74 first_file -x /etc/init.d/{dhcp3-server,dhcp,dhcpd}
keir@18770 75 }
keir@18770 76
keir@18770 77 find_dhcpd_arg_file()
keir@18770 78 {
keir@18770 79 first_file -f /etc/sysconfig/dhcpd /etc/defaults/dhcp /etc/default/dhcp3-server
keir@18770 80 }
keir@18770 81
keir@18770 82 # configure interfaces which act as pure bridge ports:
keir@18770 83 setup_bridge_port() {
keir@18770 84 local dev="$1"
keir@18770 85
keir@18770 86 # take interface down ...
keir@18770 87 ip link set ${dev} down
keir@18770 88
keir@18770 89 # ... and configure it
keir@18770 90 ip addr flush ${dev}
keir@18770 91 }
keir@18770 92
keir@18770 93 # Usage: create_bridge bridge
keir@18770 94 create_bridge () {
keir@18770 95 local bridge=$1
keir@18770 96
keir@18770 97 # Don't create the bridge if it already exists.
keir@18770 98 if [ ! -e "/sys/class/net/${bridge}/bridge" ]; then
keir@18770 99 brctl addbr ${bridge}
keir@18770 100 brctl stp ${bridge} off
keir@18770 101 brctl setfd ${bridge} 0
keir@18770 102 fi
keir@18770 103 }
keir@18770 104
keir@18770 105 # Usage: add_to_bridge bridge dev
keir@18770 106 add_to_bridge () {
keir@18770 107 local bridge=$1
keir@18770 108 local dev=$2
keir@18770 109
keir@18770 110 # Don't add $dev to $bridge if it's already on a bridge.
keir@18770 111 if [ -e "/sys/class/net/${bridge}/brif/${dev}" ]; then
keir@18770 112 ip link set ${dev} up || true
keir@18770 113 return
keir@18770 114 fi
keir@18770 115 brctl addif ${bridge} ${dev}
keir@18770 116 ip link set ${dev} up
keir@18770 117 }
keir@18770 118