[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] [NW scripts] Choose alternative interface if NFSroot is used.



# HG changeset patch
# User Keir Fraser <keir@xxxxxxxxxxxxx>
# Date 1191576685 -3600
# Node ID b629d7a2bcc71370b104a89e585e7f850c9cd224
# Parent  2d761ca771fb2c19d06a4835bfaca33d76a742f4
[NW scripts] Choose alternative interface if NFSroot is used.

Allow the network bridging setup script to choose an alternative
network interface if it is determined that the root is mounted using
NFS, which is assumed to be done over the NIC serving the default
gw. In this case the prefix of the device is used to find other
devices, i.e., if eth0 is the default device an alternative device may
be an other ones starting with 'eth'.

Signed-off-by: Stefan Berger <stefanb@xxxxxxxxxx>
---
 tools/examples/network-bridge |   36 ++++++++++++++++++++++++------------
 1 files changed, 24 insertions(+), 12 deletions(-)

diff -r 2d761ca771fb -r b629d7a2bcc7 tools/examples/network-bridge
--- a/tools/examples/network-bridge     Thu Oct 04 17:58:16 2007 +0100
+++ b/tools/examples/network-bridge     Fri Oct 05 10:31:25 2007 +0100
@@ -56,8 +56,32 @@ findCommand "$@"
 findCommand "$@"
 evalVariables "$@"
 
+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
+}
+
+find_alt_device () {
+    local interf=$1
+    local prefix=${interf%[[:digit:]]}
+    local ifs=$(ip link show | grep " $prefix" |\
+                gawk '{ printf ("%s",substr($2,1,length($2)-1)) }' |\
+                sed s/$interf//)
+    echo "$ifs"
+}
+
 netdev=${netdev:-$(ip route list | awk '/^default / { print $NF }' |
                   sed 's/.* dev //')}
+if is_network_root ; then
+    altdevs=$(find_alt_device $netdev)
+    for netdev in $altdevs; do break; done
+    if [ -z "$netdev" ]; then
+        [ -x /usr/bin/logger ] && /usr/bin/logger "network-bridge: bridging 
not supported on network root; not starting"
+        exit
+    fi
+fi
 netdev=${netdev:-eth0}
 bridge=${bridge:-${netdev}}
 antispoof=${antispoof:-no}
@@ -173,21 +197,9 @@ show_status () {
     echo '============================================================'
 }
 
-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
-}
-
 op_start () {
     if [ "${bridge}" = "null" ] ; then
        return
-    fi
-
-    if is_network_root ; then
-        [ -x /usr/bin/logger ] && /usr/bin/logger "network-bridge: bridging 
not supported on network root; not starting"
-        return
     fi
 
     if link_exists "$pdev"; then

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.