/[baselayout]/trunk/net.Linux/bonding.sh
Gentoo

Contents of /trunk/net.Linux/bonding.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2547 - (show annotations) (download) (as text)
Thu Apr 5 11:18:42 2007 UTC (10 years, 10 months ago) by uberlord
File MIME type: text/x-sh
File size: 1756 byte(s)
    Rewrite the core parts in C. We now provide librc so other programs can
    query runlevels, services and state without using bash. We also provide
    libeinfo so other programs can easily use our informational functions.

    As such, we have dropped the requirement of using bash as the init script
    shell. We now use /bin/sh and have strived to make the scripts as portable
    as possible. Shells that work are bash and dash. busybox works provided
    you disable s-s-d. If you have WIPE_TMP set to yes in conf.d/bootmisc you
    should disable find too.
    zsh and ksh do not work at this time.

    Networking support is currently being re-vamped also as it was heavily bash
    array based. As such, a new config format is available like so
    config_eth0="1.2.3.4/24 5.6.7.8/16"
    or like so
    config_eth0="'1.2.3.4 netmask 255.255.255.0' '5.6.7.8 netmask 255.255.0.0'"

    We will still support the old bash array format provided that /bin/sh IS
    a link it bash.

    ChangeLog for baselayout-1 can be found in our SVN repo.
1 # Copyright 2004-2007 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 bonding_depend() {
5 before interface macchanger
6 program /sbin/ifenslave
7 }
8
9 _config_vars="$_config_vars slaves"
10
11 _is_bond() {
12 [ -f "/proc/net/bonding/${IFACE}" ]
13 }
14
15 bonding_pre_start() {
16 local s= slaves=
17
18 eval $(_get_array "slaves_${IFACE}")
19 [ $# = "0" ] && return 0
20
21 # Load the kernel module if required
22 if [ ! -d /proc/net/bonding ] ; then
23 if ! modprobe bonding ; then
24 eerror "Cannot load the bonding module"
25 return 1
26 fi
27 fi
28
29 # We can create the interface name we like now, but this
30 # requires sysfs
31 if ! _exists && [ -d /sys/class/net ] ; then
32 echo "+${IFACE}" > /sys/class/net/bonding_masters
33 fi
34 _exists true || return 1
35
36 if ! _is_bond ; then
37 eerror "${IFACE} is not capable of bonding"
38 return 1
39 fi
40
41 ebegin "Adding slaves to ${IFACE}"
42 eindent
43 einfo "$@"
44
45 # Check that our slaves exist
46 (
47 for IFACE in "$@" ; do
48 _exists true || return 1
49 done
50
51 # Must force the slaves to a particular state before adding them
52 for IFACE in "$@" ; do
53 _delete_addresses
54 _up
55 done
56 )
57
58 # now force the master to up
59 _up
60
61 # finally add in slaves
62 eoutdent
63 /sbin/ifenslave "${IFACE}" $@ >/dev/null
64 eend $?
65
66 return 0 #important
67 }
68
69 bonding_stop() {
70 _is_bond || return 0
71
72 local slaves= s=
73 slaves=$( \
74 sed -n -e 's/^Slave Interface: //p' "/proc/net/bonding/${IFACE}" \
75 | tr '\n' ' ' \
76 )
77 [ -z "${slaves}" ] && return 0
78
79 # remove all slaves
80 ebegin "Removing slaves from ${IFACE}"
81 eindent
82 einfo "${slaves}"
83 eoutdent
84 /sbin/ifenslave -d "${IFACE}" ${slaves}
85
86 # reset all slaves
87 (
88 for IFACE in ${slaves}; do
89 if _exists ; then
90 _delete_addresses
91 _down
92 fi
93 done
94 )
95
96 eend 0
97 return 0
98 }
99
100 # vim: set ts=4 :

  ViewVC Help
Powered by ViewVC 1.1.20