debuggers.hg
changeset 21075:9300248eaad2
hotplug: Avoid race condition when creating or destroying network bridges
I saw the following message when I created or destroyed two bridges by
using network-bridge script at same time. Of course names of the
bridges are different. But, a temporal name "tmpbridge" is used by
the script to create or destroy the bridges. I think that the message
was shown by "tmpbridge".
SIOCSIFNAME: File exists
This patch avoids race condition when creating or destroying the
bridges.
Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
I saw the following message when I created or destroyed two bridges by
using network-bridge script at same time. Of course names of the
bridges are different. But, a temporal name "tmpbridge" is used by
the script to create or destroy the bridges. I think that the message
was shown by "tmpbridge".
SIOCSIFNAME: File exists
This patch avoids race condition when creating or destroying the
bridges.
Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
author | Keir Fraser <keir.fraser@citrix.com> |
---|---|
date | Mon Mar 15 13:16:35 2010 +0000 (2010-03-15) |
parents | 4152a3ce90a7 |
children | bce90bb3ce2c |
files | tools/hotplug/Linux/network-bridge |
line diff
1.1 --- a/tools/hotplug/Linux/network-bridge Thu Mar 11 17:40:35 2010 +0000 1.2 +++ b/tools/hotplug/Linux/network-bridge Mon Mar 15 13:16:35 2010 +0000 1.3 @@ -50,8 +50,10 @@ 1.4 1.5 1.6 dir=$(dirname "$0") 1.7 +. "$dir/logging.sh" 1.8 . "$dir/xen-script-common.sh" 1.9 . "$dir/xen-network-common.sh" 1.10 +. "$dir/locking.sh" 1.11 1.12 findCommand "$@" 1.13 evalVariables "$@" 1.14 @@ -219,6 +221,8 @@ op_start () { 1.15 return 1.16 fi 1.17 1.18 + claim_lock "network-bridge" 1.19 + 1.20 create_bridge ${tdev} 1.21 1.22 preiftransfer ${netdev} 1.23 @@ -249,6 +253,8 @@ op_start () { 1.24 if [ ${antispoof} = 'yes' ] ; then 1.25 antispoofing 1.26 fi 1.27 + 1.28 + release_lock "network-bridge" 1.29 } 1.30 1.31 op_stop () { 1.32 @@ -259,6 +265,8 @@ op_stop () { 1.33 return 1.34 fi 1.35 1.36 + claim_lock "network-bridge" 1.37 + 1.38 transfer_addrs ${bridge} ${pdev} 1.39 if ! ifdown ${bridge}; then 1.40 get_ip_info ${bridge} 1.41 @@ -274,6 +282,8 @@ op_stop () { 1.42 do_ifup ${netdev} 1.43 1.44 brctl delbr ${tdev} 1.45 + 1.46 + release_lock "network-bridge" 1.47 } 1.48 1.49 # adds $dev to $bridge but waits for $dev to be in running state first