Skip to contentSkip to conversation

Bonding support for dracut

RFC PATCH In review Vladislav Bogdanov 2 participants 11 messages Oct 18, 2010 – Oct 28, 2010 8 messages not in the archive

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 Bonding support for dracut

Hi all,

I attach patch for bonding support in dracut.
It is against 005 (developed on fedora 13 version).
No documentation yet.
(partially) Tested to work correctly with bond0 alone and bridge on top of bond0.

Comments are welcome,

Best,
Vladislav

modules.d/40network/check +1 -1
diff -urNp dracut-005.orig/modules.d/40network/check dracut-005/modules.d/40network/check
@@ -9,7 +9,7 @@ for program in ip arping; do 
     exit 1
   fi
 done
-for program in dhclient brctl; do
+for program in dhclient brctl ifenslave tr; do
   which $program >/dev/null 2>&1
   if [ $? -ne 0 ]; then
     dwarning "Could not find program \"$program\" it might be required by network." 
modules.d/40network/ifup +67 -2

89 lines not on this page · raw message

modules.d/40network/install +2 -1
diff -urNp dracut-005.orig/modules.d/40network/install dracut-005/modules.d/40network/install
@@ -1,5 +1,5 @@
 #!/bin/bash
-dracut_install ip dhclient brctl arping
+dracut_install ip dhclient brctl arping ifenslave tr
 inst "$moddir/ifup" "/sbin/ifup"
 inst "$moddir/netroot" "/sbin/netroot"
 inst "$moddir/dhclient-script" "/sbin/dhclient-script"
@@ -8,6 +8,7 @@ inst_hook pre-udev 50 "$moddir/ifname-ge
 inst_hook pre-udev 60 "$moddir/net-genrules.sh"
 inst_hook cmdline 91 "$moddir/dhcp-root.sh"
 inst_hook cmdline 99 "$moddir/parse-ip-opts.sh"
+inst_hook cmdline 97 "$moddir/parse-bond.sh"
 inst_hook cmdline 98 "$moddir/parse-bridge.sh"
 inst_hook cmdline 99 "$moddir/parse-ifname.sh"
 inst_hook pre-pivot 10 "$moddir/kill-dhclient.sh"
modules.d/40network/installkernel +2 -0
diff -urNp dracut-005.orig/modules.d/40network/installkernel dracut-005/modules.d/40network/installkernel
@@ -15,3 +15,5 @@ instmods ecb arc4
 # bridge modules
 instmods bridge stp llc
 instmods ipv6
+# bonding
+instmods bonding
modules.d/40network/net-genrules.sh +7 -0
diff -urNp dracut-005.orig/modules.d/40network/net-genrules.sh dracut-005/modules.d/40network/net-genrules.sh
@@ -20,6 +20,13 @@ fix_bootif() {
         IFACES=$ethname
     fi
 
+    # bond: attempt only the defined interface (override bridge defines)
+    if [ -e /tmp/bond.info ]; then
+        . /tmp/bond.info
+        # It is enough to fire up only one
+        IFACES=${bondslaves%% *}
+    fi
+
     # BOOTIF says everything, use only that one
     BOOTIF=$(getarg 'BOOTIF=')
     if [ -n "$BOOTIF" ] ; then
modules.d/40network/parse-bond.sh +64 -0

64 lines not on this page · raw message

modules.d/40network/parse-bridge.sh +11 -2
diff -urNp dracut-005.orig/modules.d/40network/parse-bridge.sh dracut-005/modules.d/40network/parse-bridge.sh
@@ -4,6 +4,7 @@
 #	bridge=<bridgename>:<ethname>
 #
 #	bridge without parameters assumes bridge=br0:eth0
+#	if bonding is enabled, then $bondname will be used instead of 'eth0'
 #
 
 # return if bridge already parsed
@@ -26,7 +27,7 @@ parsebridge() {
 
     unset bridgename ethname
     case $# in
-    0)  bridgename=br0; ethname=eth0 ;;
+    0)  bridgename=br0; ethname=$iface ;;
     1)  die "bridge= requires two parameters" ;;
     2)  bridgename=$1; ethname=$2 ;;
     *)  die "bridge= requires two parameters" ;;
@@ -35,6 +36,14 @@ parsebridge() {
 
 unset bridgename ethname
 
+iface=eth0
+if [ -e /tmp/bond.info ]; then
+    . /tmp/bond.info
+    if [ -n "$bondname" ] ; then
+        iface=$bondname
+    fi
+fi
+
 # Parse bridge for bridgename and ethname
 if getarg bridge >/dev/null; then
     # Read bridge= parameters if they exist
@@ -45,7 +54,7 @@ if getarg bridge >/dev/null; then
     # Simple default bridge
     if [ -z "$bridgename" ]; then
         bridgename=br0
-        ethname=eth0
+        ethname=$iface
     fi
     echo "bridgename=$bridgename" > /tmp/bridge.info
     echo "ethname=$ethname" >> /tmp/bridge.info
modules.d/45ifcfg/write-ifcfg.sh +79 -15

120 lines not on this page · raw message

A message that is not in the archive (sent off-list or not yet received): 4CBC37E7.9010904-Awb4OmSD/[email protected]

#2 lore raw
Quoted 8 lines · Vladislav Bogdanov

Hi all,

I attach patch for bonding support in dracut.
It is against 005 (developed on fedora 13 version).
No documentation yet.
(partially) Tested to work correctly with bond0 alone and bridge on top of bond0.

Quoted 4 lines

Comments are welcome,

Best,
Vladislav

Please patch against the git version...

$ git clone git://dracut.git.sourceforge.net/gitroot/dracut/dracut

http://dracut.git.sourceforge.net/git/gitweb.cgi?p=dracut/dracut

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw
Quoted 11 lines · Harald Hoyer
Quoted 10 lines · Vladislav Bogdanov

Hi all,

I attach patch for bonding support in dracut.
It is against 005 (developed on fedora 13 version).
No documentation yet.
(partially) Tested to work correctly with bond0 alone and bridge on top of bond0.

Comments are welcome,

Quoted 8 lines
Quoted 2 lines

Best,
Vladislav

Please patch against the git version...

$ git clone git://dracut.git.sourceforge.net/gitroot/dracut/dracut

http://dracut.git.sourceforge.net/git/gitweb.cgi?p=dracut/dracut

This should be it.

modules.d/40network/check +1 -1
index 26b56b3..f575bd9 100755
@@ -15,7 +15,7 @@ for program in ip arping; do
         exit 1
     fi
 done
-for program in dhclient brctl; do
+for program in dhclient brctl ifenslave tr; do
     if ! type -P $program >/dev/null; then
         dwarning "Could not find program \"$program\" it might be required by network." 
     fi
modules.d/40network/ifup +67 -2

89 lines not on this page · raw message

modules.d/40network/install +2 -1
index a95ba2a..b22cc96 100755
@@ -1,7 +1,7 @@
 #!/bin/bash
 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
 # ex: ts=8 sw=4 sts=4 et filetype=sh
-dracut_install ip dhclient brctl arping
+dracut_install ip dhclient brctl arping ifenslave tr
 inst "$moddir/ifup" "/sbin/ifup"
 inst "$moddir/netroot" "/sbin/netroot"
 inst "$moddir/dhclient-script" "/sbin/dhclient-script"
@@ -10,6 +10,7 @@ inst_hook pre-udev 50 "$moddir/ifname-genrules.sh"
 inst_hook pre-udev 60 "$moddir/net-genrules.sh"
 inst_hook cmdline 91 "$moddir/dhcp-root.sh"
 inst_hook cmdline 99 "$moddir/parse-ip-opts.sh"
+inst_hook cmdline 97 "$moddir/parse-bond.sh"
 inst_hook cmdline 98 "$moddir/parse-bridge.sh"
 inst_hook cmdline 99 "$moddir/parse-ifname.sh"
 inst_hook pre-pivot 10 "$moddir/kill-dhclient.sh"
modules.d/40network/installkernel +2 -0
index 1c9ce7d..c5944ab 100755
@@ -18,3 +18,5 @@ instmods ecb arc4
 # bridge modules
 instmods bridge stp llc
 instmods ipv6
+# bonding
+instmods bonding
modules.d/40network/net-genrules.sh +7 -0
index f8e6056..d24a865 100755
@@ -24,6 +24,13 @@ fix_bootif() {
         IFACES=$ethname
     fi
 
+    # bond: attempt only the defined interface (override bridge defines)
+    if [ -e /tmp/bond.info ]; then
+        . /tmp/bond.info
+        # It is enough to fire up only one
+        IFACES=${bondslaves%% *}
+    fi
+
     # BOOTIF says everything, use only that one
     BOOTIF=$(getarg 'BOOTIF=')
     if [ -n "$BOOTIF" ] ; then
modules.d/40network/parse-bond.sh new file +63 -0

63 lines not on this page · raw message

modules.d/40network/parse-bridge.sh +10 -2
index 984192f..92a6a33 100755
@@ -28,7 +28,7 @@ parsebridge() {
 
     unset bridgename ethname
     case $# in
-        0)  bridgename=br0; ethname=eth0 ;;
+        0)  bridgename=br0; ethname=$iface ;;
         1)  die "bridge= requires two parameters" ;;
         2)  bridgename=$1; ethname=$2 ;;
         *)  die "bridge= requires two parameters" ;;
@@ -37,6 +37,14 @@ parsebridge() {
 
 unset bridgename ethname
 
+iface=eth0
+if [ -e /tmp/bond.info ]; then
+    . /tmp/bond.info
+    if [ -n "$bondname" ] ; then
+        iface=$bondname
+    fi
+fi
+
 # Parse bridge for bridgename and ethname
 if getarg bridge >/dev/null; then
     # Read bridge= parameters if they exist
@@ -47,7 +55,7 @@ if getarg bridge >/dev/null; then
     # Simple default bridge
     if [ -z "$bridgename" ]; then
         bridgename=br0
-        ethname=eth0
+        ethname=$iface
     fi
     echo "bridgename=$bridgename" > /tmp/bridge.info
     echo "ethname=$ethname" >> /tmp/bridge.info
modules.d/45ifcfg/write-ifcfg.sh +81 -13

122 lines not on this page · raw message

A message that is not in the archive (sent off-list or not yet received): 4CBC504A.7020002-Awb4OmSD/[email protected]

#6 lore raw
Quoted 15 lines · Vladislav Bogdanov
Quoted 14 lines · Harald Hoyer
Quoted 12 lines · Vladislav Bogdanov

Hi all,

I attach patch for bonding support in dracut.
It is against 005 (developed on fedora 13 version).
No documentation yet.
(partially) Tested to work correctly with bond0 alone and bridge on top of bond0.

Comments are welcome,

Best,
Vladislav

Quoted 7 lines
Quoted 5 lines

Please patch against the git version...

$ git clone git://dracut.git.sourceforge.net/gitroot/dracut/dracut

http://dracut.git.sourceforge.net/git/gitweb.cgi?p=dracut/dracut

This should be it.

Thanks!!

#7 lore raw
In reply to a message not in the archive
Quoted 15 lines · Vladislav Bogdanov
Quoted 14 lines · Harald Hoyer
Quoted 12 lines · Vladislav Bogdanov

Hi all,

I attach patch for bonding support in dracut.
It is against 005 (developed on fedora 13 version).
No documentation yet.
(partially) Tested to work correctly with bond0 alone and bridge on top of bond0.

Comments are welcome,

Best,
Vladislav

Quoted 7 lines
Quoted 5 lines

Please patch against the git version...

$ git clone git://dracut.git.sourceforge.net/gitroot/dracut/dracut

http://dracut.git.sourceforge.net/git/gitweb.cgi?p=dracut/dracut

This should be it.

pushed
...

http://dracut.git.sourceforge.net/git/gitweb.cgi?p=dracut/dracut;a=commitdiff;h=96fb9c8dd708dfbab9cf6515d9a450abb060e623

A message that is not in the archive (sent off-list or not yet received): [email protected]

#9 lore raw
Quoted 22 lines · Harald Hoyer
Quoted 21 lines · Vladislav Bogdanov
Quoted 19 lines · Harald Hoyer
Quoted 8 lines · Vladislav Bogdanov

Hi all,

I attach patch for bonding support in dracut.
It is against 005 (developed on fedora 13 version).
No documentation yet.
(partially) Tested to work correctly with bond0 alone and bridge on top of bond0.

Quoted 4 lines

Comments are welcome,

Best,
Vladislav

Please patch against the git version...

$ git clone git://dracut.git.sourceforge.net/gitroot/dracut/dracut

http://dracut.git.sourceforge.net/git/gitweb.cgi?p=dracut/dracut

Quoted 7 lines
Quoted 1 line

This should be it.

pushed
...

http://dracut.git.sourceforge.net/git/gitweb.cgi?p=dracut/dracut;a=commitdiff;h=96fb9c8dd708dfbab9cf6515d9a450abb060e623

Ahmmm....
So quick :)
I was ready for a long discussion :)

Some notes:

There is no documentation yet :( and it should not be forgotten to add it. I generally hate to edit XML by hands. Could someone who operates some magic XML tools do it?

Also both original patch (against 005) and commit message has a typo (in head comments):
bond=bond0:eth0,eth1:balance-rr
should be really
bond=bond0:eth0,eth1:mode=balance-rr

Patch against git has this corrected (together with one more typo - s/DEVICE/netif/)

Or even better third clause (options) should be omitted from that line:
it remained from a revision where I had mode as a separate clause. Current version leaves all options defaulting to bonding.ko (and balance-rr is its default mode btw).

One more is a mode of parse-bond.sh which should be 0755 (for consistency?).

And last, this should be tested thoroughly. I only did limited testing - not all use cases, especially not with default values. It seems to be correct, but I'm not 100% sure.

Best,
Vladislav

A message that is not in the archive (sent off-list or not yet received): 4CBC5A48.1010304-Awb4OmSD/[email protected]

#11 lore raw
Quoted 35 lines · Vladislav Bogdanov
Quoted 22 lines · Harald Hoyer
Quoted 21 lines · Vladislav Bogdanov
Quoted 19 lines · Harald Hoyer
Quoted 8 lines · Vladislav Bogdanov

Hi all,

I attach patch for bonding support in dracut.
It is against 005 (developed on fedora 13 version).
No documentation yet.
(partially) Tested to work correctly with bond0 alone and bridge on top of bond0.

Quoted 4 lines

Comments are welcome,

Best,
Vladislav

Please patch against the git version...

$ git clone git://dracut.git.sourceforge.net/gitroot/dracut/dracut

http://dracut.git.sourceforge.net/git/gitweb.cgi?p=dracut/dracut

Quoted 7 lines
Quoted 1 line

This should be it.

pushed
...

http://dracut.git.sourceforge.net/git/gitweb.cgi?p=dracut/dracut;a=commitdiff;h=96fb9c8dd708dfbab9cf6515d9a450abb060e623

Ahmmm....
So quick :)
I was ready for a long discussion :)

Quoted 5 lines

Some notes:

There is no documentation yet :( and it should not be forgotten to add it. I generally hate to edit XML by hands. Could someone who operates some magic XML tools do it?

Nice, free, open source xml editor:

http://www.syntext.com/products/serna-free/

Quoted 9 lines

Also both original patch (against 005) and commit message has a typo (in head comments):
bond=bond0:eth0,eth1:balance-rr
should be really
bond=bond0:eth0,eth1:mode=balance-rr

Patch against git has this corrected (together with one more typo - s/DEVICE/netif/)

Hmm, I took dracut-bonding-support.patch and not dracut-005-bonding-support.patch... but I might have copied the commit message from the wrong patch.

Quoted 7 lines

Or even better third clause (options) should be omitted from that line:
it remained from a revision where I had mode as a separate clause. Current version leaves all options defaulting to bonding.ko (and balance-rr is its default mode btw).

One more is a mode of parse-bond.sh which should be 0755 (for consistency?).

Already done :)
http://dracut.git.sourceforge.net/git/gitweb.cgi?p=dracut/dracut;a=commitdiff;h=57a49c67275c8ec6b3d85dc70433ffc15aec47e4

Quoted 7 lines

And last, this should be tested thoroughly. I only did limited testing - not all use cases, especially not with default values. It seems to be correct, but I'm not 100% sure.

Best,
Vladislav

A message that is not in the archive (sent off-list or not yet received): [email protected]

#13 lore raw

Hi,

copy-paste typo fix is attached

Best,
Vladislav

modules.d/45ifcfg/write-ifcfg.sh +1 -1
index 968d9f0..45fcde2 100755
@@ -50,7 +50,7 @@ for netif in $IFACES ; do
     } > /tmp/ifcfg/ifcfg-$netif
 
     # bridge needs different things written to ifcfg
-    if [ -z "$bridge" ] && if [ -z "$bond" ]; then
+    if [ -z "$bridge" ] && [ -z "$bond" ]; then
         # standard interface
         {
             echo "HWADDR=$(cat /sys/class/net/$netif/address)"

A message that is not in the archive (sent off-list or not yet received): 4CBDA315.2070603-Awb4OmSD/[email protected]

#15 lore raw

One more fix (was Re: [RFC] [PATCH] Bonding support for dracut)

Hi,

one more patch with fixes is attached.

Best,
Vladislav

modules.d/45ifcfg/write-ifcfg.sh +9 -7
index 45fcde2..022467b 100755
@@ -68,12 +68,13 @@ for netif in $IFACES ; do
         } >> /tmp/ifcfg/ifcfg-$netif
 
         for slave in $bondslaves ; do
+            # Set ONBOOT=no to prevent initscripts from trying to setup already bonded physical interface
             # write separate ifcfg file for the raw eth interface
             {
                 echo "# Generated by dracut initrd"
                 echo "DEVICE=$slave"
                 echo "TYPE=Ethernet"
-                echo "ONBOOT=yes"
+                echo "ONBOOT=no"
                 echo "NETBOOT=yes"
                 echo "HWADDR=$(cat /sys/class/net/$slave/address)"
                 echo "SLAVE=yes"
@@ -91,23 +92,24 @@ for netif in $IFACES ; do
         } >> /tmp/ifcfg/ifcfg-$netif
         if [ "$ethname" = "$bondname" ] ; then
             {
-                # This variable is an indicator of a bond interface for initscripts
+                # Set ONBOOT=no to prevent initscripts from trying to setup already bridged bond interface
                 echo "# Generated by dracut initrd"
                 echo "DEVICE=$bondname"
-                echo "ONBOOT=yes"
+                echo "ONBOOT=no"
                 echo "NETBOOT=yes"
+                # This variable is an indicator of a bond interface for initscripts
                 echo "BONDING_OPTS=\"$bondoptions\""
                 echo "BRIDGE=$netif"
                 echo "NAME=\"$bondname\"" 
             } >> /tmp/ifcfg/ifcfg-$bondname
             for slave in $bondslaves ; do
                 # write separate ifcfg file for the raw eth interface
-                # yes, duplicated code at this moment
+                # Set ONBOOT=no to prevent initscripts from trying to setup already bridged physical interface
                 {
                     echo "# Generated by dracut initrd"
                     echo "DEVICE=$slave"
                     echo "TYPE=Ethernet"
-                    echo "ONBOOT=yes"
+                    echo "ONBOOT=no"
                     echo "NETBOOT=yes"
                     echo "HWADDR=$(cat /sys/class/net/$slave/address)"
                     echo "SLAVE=yes"
@@ -121,11 +123,11 @@ for netif in $IFACES ; do
                 echo "# Generated by dracut initrd"
                 echo "DEVICE=$ethname"
                 echo "TYPE=Ethernet"
-                echo "ONBOOT=yes"
+                echo "ONBOOT=no"
                 echo "NETBOOT=yes"
                 echo "HWADDR=$(cat /sys/class/net/$ethname/address)"
                 echo "BRIDGE=$netif"
-                echo "NAME=$ethname" 
+                echo "NAME=$ethname"
             } >> /tmp/ifcfg/ifcfg-$ethname
         fi
     fi

A message that is not in the archive (sent off-list or not yet received): 4CBDAFE5.3020102-Awb4OmSD/[email protected]

#17 lore raw

Re: One more fix (was Re: [RFC] [PATCH] Bonding support for dracut)

Quoted 6 lines · Vladislav Bogdanov

Hi,

one more patch with fixes is attached.

Best,
Vladislav

pushed