WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] [NW scripts] Choose alternative interface

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] [NW scripts] Choose alternative interface if NFSroot is used.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 05 Oct 2007 08:40:07 -0700
Delivery-date: Fri, 05 Oct 2007 08:40:25 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# 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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] [NW scripts] Choose alternative interface if NFSroot is used., Xen patchbot-unstable <=