[Linux-cluster] Workaround for breakage caused by xend bridged networking

Ryan McCabe rmccabe at redhat.com
Mon Apr 23 18:04:42 UTC 2007


Hi,

Attached (and inline for review) is a proposed patch to work around the
problems xend's bridged networking startup causes for RHCS as a result
of the init script ordering and the network disruption caused by the code
that creates the bridge interfaces used by xend.

If xend will start in the current runlevel and is and configured to
use bridged networking, the cman init script will run
'/etc/xen/scripts/network-bridge start' before doing anything else. This
will create the network bridges early--a process that entails briging down
and renaming interfaces, which causes all kinds of breakage currently--before
openais starts.

xend doesn't mind if the network bridges are setup before it starts, and
the bridges need not be removed by the cman init script when cman stops:
xend will remove them when it stops.


Ryan


Index: cman
===================================================================
RCS file: /cvs/cluster/cluster/cman/init.d/cman,v
retrieving revision 1.26.4.2
diff -u -r1.26.4.2 cman
--- cman	15 Nov 2006 16:55:16 -0000	1.26.4.2
+++ cman	23 Apr 2007 17:46:03 -0000
@@ -132,6 +132,47 @@
     return 0
 }
 
+xend_bridged_net_enabled() {
+    current_runlevel=$(/sbin/runlevel 2>/dev/null | awk '{ print $2 }' 2>/dev/null)
+    if [ -z "$current_runlevel" ]; then
+        errmsg='Unable to determine the current runlevel'
+        return 1
+    fi
+
+    /sbin/chkconfig --levels "$current_runlevel" xend 2>/dev/null
+    if [ $? -ne 0 ]; then
+        # xend doesn't start at this runlevel.
+        return 1
+    fi
+
+    if [ ! -f /etc/xen/xend-config.sxp ]; then
+        # xend isn't configured to use bridged networking.
+        return 1
+    fi
+
+    egrep "^[[:blank:]]*\([[:blank:]]*network-script[[:blank:]]+network-bridge([[:blank:]]*\)|[[:blank:]]+)" /etc/xen/xend-config.sxp 2>/dev/null
+    if [ $? -ne 0 ]; then
+        # xend isn't configured to use bridged networking.
+        return 1
+    fi
+    return 0
+}
+
+xend_bridged_net_start() {
+    if [ ! -x /etc/xen/scripts/network-bridge ]; then
+        if [ -f /etc/xen/scripts/network-bridge ]; then
+            errmsg='The xend bridged network script cannot be run'
+        else
+            errmsg='The xend bridged network script is missing'
+        fi
+        return 1
+    fi
+
+    /sbin/modprobe netbk >& /dev/null
+    /sbin/modprobe netloop >& /dev/null
+    errmsg=$(/etc/xen/scripts/network-bridge start 2>&1) || return 1
+    return 0
+}
 
 fence_xvmd_enabled()
 {
@@ -163,6 +204,20 @@
 start()
 {
     echo "Starting cluster: "
+
+    xend_bridged_net_enabled
+    if [ $? -eq 0 ]
+    then
+        echo -n "   Enabling workaround for Xend bridged networking... "
+        xend_bridged_net_start
+        if [ $? -eq 0 ] 
+        then
+            echo "done"
+        else
+            echo "failed: $errmsg"
+			return 1
+        fi
+    fi
     echo -n "   Loading modules... "
     ulimit -c unlimited
     load_modules
-------------- next part --------------
? cman-init.diff
Index: cman
===================================================================
RCS file: /cvs/cluster/cluster/cman/init.d/cman,v
retrieving revision 1.26.4.2
diff -u -r1.26.4.2 cman
--- cman	15 Nov 2006 16:55:16 -0000	1.26.4.2
+++ cman	23 Apr 2007 17:46:03 -0000
@@ -132,6 +132,47 @@
     return 0
 }
 
+xend_bridged_net_enabled() {
+    current_runlevel=$(/sbin/runlevel 2>/dev/null | awk '{ print $2 }' 2>/dev/null)
+    if [ -z "$current_runlevel" ]; then
+        errmsg='Unable to determine the current runlevel'
+        return 1
+    fi
+
+    /sbin/chkconfig --levels "$current_runlevel" xend 2>/dev/null
+    if [ $? -ne 0 ]; then
+        # xend doesn't start at this runlevel.
+        return 1
+    fi
+
+    if [ ! -f /etc/xen/xend-config.sxp ]; then
+        # xend isn't configured to use bridged networking.
+        return 1
+    fi
+
+    egrep "^[[:blank:]]*\([[:blank:]]*network-script[[:blank:]]+network-bridge([[:blank:]]*\)|[[:blank:]]+)" /etc/xen/xend-config.sxp 2>/dev/null
+    if [ $? -ne 0 ]; then
+        # xend isn't configured to use bridged networking.
+        return 1
+    fi
+    return 0
+}
+
+xend_bridged_net_start() {
+    if [ ! -x /etc/xen/scripts/network-bridge ]; then
+        if [ -f /etc/xen/scripts/network-bridge ]; then
+            errmsg='The xend bridged network script cannot be run'
+        else
+            errmsg='The xend bridged network script is missing'
+        fi
+        return 1
+    fi
+
+    /sbin/modprobe netbk >& /dev/null
+    /sbin/modprobe netloop >& /dev/null
+    errmsg=$(/etc/xen/scripts/network-bridge start 2>&1) || return 1
+    return 0
+}
 
 fence_xvmd_enabled()
 {
@@ -163,6 +204,20 @@
 start()
 {
     echo "Starting cluster: "
+
+    xend_bridged_net_enabled
+    if [ $? -eq 0 ]
+    then
+        echo -n "   Enabling workaround for Xend bridged networking... "
+        xend_bridged_net_start
+        if [ $? -eq 0 ] 
+        then
+            echo "done"
+        else
+            echo "failed: $errmsg"
+			return 1
+        fi
+    fi
     echo -n "   Loading modules... "
     ulimit -c unlimited
     load_modules


More information about the Linux-cluster mailing list