Hi all,

I hope this is the right place to post this. I have adjusted the /etc/sysconfig/network-devices/ifup script from LFS 6.2 a bit so that it can handle network bonding (with dhcp), because the hint on bonding at http://www.linuxfromscratch.org/hints/downloads/files/ethernet-bonding.txt dates back to 2003 and as far as I can tell it doesn't work with LFS 6.2 and DHCP. The attached script could use some adjustments (so it will work with every kind of service not only dhclient). I have attached my adjusted script to this mail. It hope it helps someone and I would very much like for it to be included with the next LFS release.

Basically the script ignores the slave bonding devices until the master is set. Then the script checks using ethtool if a device is a bonding device and if so it will find the config files that reference to that bonding device as their master and enslave them to the bonding master. Therefore the bonding slaves should have a config similar as follows:

[EMAIL PROTECTED] /etc/sysconfig/network-devices] cat ifconfig.wan0/dhclient
MASTER="bond0"
ONBOOT="yes"

Please let me know if you would like to include it in a new version and if you have comments/suggestions to make it better.

Thanks!

--
Philox, Ltd
Jonathan Salomon
#!/bin/sh
########################################################################
# Begin $network_devices/ifup
#
# Description : Interface Up
#
# Authors     : Nathan Coulson - [EMAIL PROTECTED]
#               Kevin P. Fleming - [EMAIL PROTECTED]
#
# Version     : 00.00
#
# Notes       : the IFCONFIG variable is passed to the scripts found
#               in the services directory, to indicate what file the
#               service should source to get environmental variables.
#
########################################################################

. /etc/sysconfig/rc 
. ${rc_functions} 

# Collect a list of configuration files for our interface
if [ -n "${2}" ]; then
        for file in [EMAIL PROTECTED] # All parameters except $1
  do
                FILES="${FILES} ${network_devices}/ifconfig.${1}/${file}"
        done
elif [ -d "${network_devices}/ifconfig.${1}" ]; then
        FILES=`echo ${network_devices}/ifconfig.${1}/*`
else 
        FILES="${network_devices}/ifconfig.${1}"
fi

boot_mesg "Bringing up the ${1} interface..."
boot_mesg_flush

# Process each configruation file
for file in ${FILES}; do
        # skip backup files
        if [ "${file}" != "${file%""~""}" ]; then
                continue
        fi

        if [ ! -f "${file}" ]; then
                boot_mesg "${file} is not a network configuration file or 
directory." ${WARNING}
                echo_warning
                continue
        fi

        (
                . ${file}

                # Will not process this service if started by boot, and ONBOOT
                # is not set to yes
                if [ "${IN_BOOT}" = "1" -a "${ONBOOT}" != "yes" ]; then
                        continue
                fi
                # Will not process this service if started by hotplug, and 
                # ONHOTPLUG is not set to yes
                if [ "${IN_HOTPLUG}" = "1" -a "${ONHOTPLUG}" != "yes" -a 
"${HOSTNAME}" != "(none)" ]; then
                         continue
                fi

                # Skip if device is a bonding slave because master must be 
initialized first
                if $(grep -q "MASTER" $file); then
                        exit 
                fi

                if [ -n "${SERVICE}" -a -x 
"${network_devices}/services/${SERVICE}" ]; then
                        if [ -z "${CHECK_LINK}" -o "${CHECK_LINK}" = "y" -o 
"${CHECK_LINK}" = "yes" -o "${CHECK_LINK}" = "1" ]; then
                                if ip link show ${1} > /dev/null 2>&1; then
                                        link_status=`ip link show ${1} 2> 
/dev/null`
                                        if [ -n "${link_status}" ]; then
                                                if ! echo "${link_status}" | 
grep -q UP; then
                                                        ip link set ${1} up
                                                fi
                                        fi
                                else
                                        boot_mesg "Interface ${1} doesn't 
exist." ${WARNING}
                                        echo_warning
                                        continue
                                fi
                        fi

                        # Enslave the bonding slaves to the master
                        if /sbin/ethtool -i ${1} 2>/dev/null| grep -q "driver: 
bonding" ; then
                                for device in `egrep -l 
"^[[:space:]]*MASTER=[\"]?${1}[\"]?" ${network_devices}/ifconfig.*/${SERVICE}`; 
do
                                        SLAVE=$(echo $device | egrep -o 
"ifconfig.[^/]+" | sed s/'ifconfig.'//g)
                                        if [ -x /sbin/ifenslave ]; then
                                                boot_mesg "Enslaving ${SLAVE} 
to ${1}"
                                                ifenslave "${1}" "${SLAVE}" 
>/dev/null 2>&1
                                        fi

                                done
                        fi

                        IFCONFIG=${file} ${network_devices}/services/${SERVICE} 
${1} up
                else
                        boot_mesg "Unable to process ${file}.  Either" 
${FAILURE}
                        boot_mesg " the SERVICE variable was not set,"
                        boot_mesg " or the specified service cannot be 
executed."
                        echo_failure
                        continue
                fi
        )
done

# End $network_devices/ifup

-- 
http://linuxfromscratch.org/mailman/listinfo/lfs-dev
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page

Reply via email to