diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2008-07-14 10:04:41 +0100 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2008-07-14 10:04:41 +0100 |
commit | 96f900ef40028defeff979e28121e48a46941157 (patch) | |
tree | b8d837fdc0f6d442319ea0dabbcb44f81fde1e44 /tools/examples | |
parent | 121068a2ce684723ea7b6aca4b5c15b418c86784 (diff) | |
download | xen-96f900ef40028defeff979e28121e48a46941157.tar.gz xen-96f900ef40028defeff979e28121e48a46941157.tar.bz2 xen-96f900ef40028defeff979e28121e48a46941157.zip |
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>
Diffstat (limited to 'tools/examples')
-rwxr-xr-x | tools/examples/network-bridge | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/tools/examples/network-bridge b/tools/examples/network-bridge index 245f7ce9f0..9d7be4e2e5 100755 --- a/tools/examples/network-bridge +++ b/tools/examples/network-bridge @@ -60,7 +60,18 @@ is_network_root () { local rootfs=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $3; }}' /etc/mtab) local rootopts=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $4; }}' /etc/mtab) - [[ "$rootfs" =~ "^nfs" ]] || [[ "$rootopts" =~ "_netdev" ]] && return 0 || return 1 + [[ "$rootfs" =~ "^nfs" ]] || [[ "$rootopts" =~ "_netdev" ]] && has_nfsroot=1 || has_nfsroot=0 + if [ $has_nfsroot -eq 1 ]; then + local bparms=$(cat /proc/cmdline) + for p in $bparms; do + local ipaddr=$(echo $p | awk /nfsroot=/'{ print substr($1,9,index($1,":")-9) }') + if [ "$ipaddr" != "" ]; then + local nfsdev=$(ip route get $ipaddr | awk /$ipaddr/'{ print $3 }') + [[ "$nfsdev" == "$netdev" ]] && return 0 || return 1 + fi + done + fi + return 1 } find_alt_device () { |