ia64/xen-unstable
changeset 7826:bb270cb5d2e8
Added link_exists function, for neatness. Check for the existence of the pdev
before issuing the diagnostic about the missing vdev. Having a pdev but no
vdev is a strong indicator that the network-bridge script has run once already,
and so there is nothing to worry about. Having the vdev and no corresponding
pdev is still diagnosed.
Signed-off-by: Ewan Mellor <ewan@xensource.com>
before issuing the diagnostic about the missing vdev. Having a pdev but no
vdev is a strong indicator that the network-bridge script has run once already,
and so there is nothing to worry about. Having the vdev and no corresponding
pdev is still diagnosed.
Signed-off-by: Ewan Mellor <ewan@xensource.com>
author | emellor@leeni.uk.xensource.com |
---|---|
date | Tue Nov 15 15:54:51 2005 +0100 (2005-11-15) |
parents | 6d981d34cf52 |
children | 60bf9aa39043 |
files | tools/examples/network-bridge |
line diff
1.1 --- a/tools/examples/network-bridge Mon Nov 14 12:28:47 2005 +0100 1.2 +++ b/tools/examples/network-bridge Tue Nov 15 15:54:51 2005 +0100 1.3 @@ -138,6 +138,23 @@ transfer_routes () { 1.4 }" | sh -e 1.5 } 1.6 1.7 + 1.8 +## 1.9 +# link_exists interface 1.10 +# 1.11 +# Returns 0 if the interface named exists (whether up or down), 1 otherwise. 1.12 +# 1.13 +link_exists() 1.14 +{ 1.15 + if ip link show "$1" >&/dev/null 1.16 + then 1.17 + return 0 1.18 + else 1.19 + return 1 1.20 + fi 1.21 +} 1.22 + 1.23 + 1.24 # Usage: create_bridge bridge 1.25 create_bridge () { 1.26 local bridge=$1 1.27 @@ -193,8 +210,12 @@ op_start () { 1.28 return 1.29 fi 1.30 1.31 - if ! ip link show 2>/dev/null | grep -q "^[0-9]*: ${vdev}"; then 1.32 - echo " 1.33 + if ! link_exists "$vdev"; then 1.34 + if link_exists "$pdev"; then 1.35 + # The device is already up. 1.36 + return 1.37 + else 1.38 + echo " 1.39 Link $vdev is missing. 1.40 This may be because you have reached the limit of the number of interfaces 1.41 that the loopback driver supports. If the loopback driver is a module, you 1.42 @@ -202,12 +223,13 @@ may raise this limit by passing it as a 1.43 driver is compiled statically into the kernel, then you may set the parameter 1.44 using loopback.nloopbacks=<N> on the domain 0 kernel command line. 1.45 " >&2 1.46 - exit 1 1.47 + exit 1 1.48 + fi 1.49 fi 1.50 1.51 create_bridge ${bridge} 1.52 1.53 - if ip link show ${vdev} 2>/dev/null >/dev/null; then 1.54 + if link_exists "$vdev"; then 1.55 mac=`ip link show ${netdev} | grep 'link\/ether' | sed -e 's/.*ether \(..:..:..:..:..:..\).*/\1/'` 1.56 preiftransfer ${netdev} 1.57 transfer_addrs ${netdev} ${vdev} 1.58 @@ -260,11 +282,11 @@ op_stop () { 1.59 if [ "${bridge}" == "null" ]; then 1.60 return 1.61 fi 1.62 - if ! ip link show ${bridge} >/dev/null 2>&1; then 1.63 + if ! link_exists "$bridge"; then 1.64 return 1.65 fi 1.66 1.67 - if ip link show ${pdev} 2>/dev/null >/dev/null; then 1.68 + if link_exists "$pdev"; then 1.69 ip link set dev ${vif0} down 1.70 mac=`ip link show ${netdev} | grep 'link\/ether' | sed -e 's/.*ether \(..:..:..:..:..:..\).*/\1/'` 1.71 transfer_addrs ${netdev} ${pdev}