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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2616 - (show annotations) (download) (as text)
Tue Apr 17 11:27:47 2007 UTC (7 years, 4 months ago) by uberlord
File MIME type: text/x-sh
File size: 1756 byte(s)
Fix bridge, vlan and bonding modules to work together, #174792.
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_${IFVAR}")
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