ia64/xen-unstable

changeset 18045:e2cec6725280

Choice of network interface for establishing a bridge on if NFSROOT is used

This patch fixes a problem related to machines that are booted using
nfsroot ( '/' provided via nfs). Previously the code was assuming that
nfsroot would be provided via eth0. Now this additional code checks
over which interface the nfsroot is provided after detecting that
nfsroot is actually being used. To determine from where nfsroot is
mounted I am reading the kernel command line (/proc/cmdline) and
filter for an argument starting with 'nfsroot=' and determine the nfs
server's IP address by assuming the format 'nfsroot=<ip
adddress>:<path to root>' - if there's a better way of doing this,
please let me know. After that I determine the interface over which
this IP address would be accessed using 'ip route get <address>'. Then
I compare that interface against a previously determined default
interface and if they are equal return a value that causes an
alternative interface to be chosen.

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Jul 14 10:04:41 2008 +0100 (2008-07-14)
parents b01303f59872
children d14c017e8163
files tools/examples/network-bridge
line diff
     1.1 --- a/tools/examples/network-bridge	Mon Jul 14 10:03:09 2008 +0100
     1.2 +++ b/tools/examples/network-bridge	Mon Jul 14 10:04:41 2008 +0100
     1.3 @@ -60,7 +60,18 @@ is_network_root () {
     1.4      local rootfs=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $3; }}' /etc/mtab)
     1.5      local rootopts=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $4; }}' /etc/mtab)
     1.6  
     1.7 -    [[ "$rootfs" =~ "^nfs" ]] || [[ "$rootopts" =~ "_netdev" ]] && return 0 || return 1
     1.8 +    [[ "$rootfs" =~ "^nfs" ]] || [[ "$rootopts" =~ "_netdev" ]] && has_nfsroot=1 || has_nfsroot=0
     1.9 +    if [ $has_nfsroot -eq 1 ]; then
    1.10 +        local bparms=$(cat /proc/cmdline)
    1.11 +        for p in $bparms; do
    1.12 +            local ipaddr=$(echo $p | awk /nfsroot=/'{ print substr($1,9,index($1,":")-9) }')
    1.13 +            if [ "$ipaddr" != "" ]; then
    1.14 +                local nfsdev=$(ip route get $ipaddr | awk /$ipaddr/'{ print $3 }')
    1.15 +                [[ "$nfsdev" == "$netdev" ]] && return 0 || return 1
    1.16 +            fi
    1.17 +        done
    1.18 +    fi
    1.19 +    return 1
    1.20  }
    1.21  
    1.22  find_alt_device () {