ia64/xen-unstable

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