/[baselayout]/trunk/net-scripts/net.modules.d/bonding
Gentoo

Contents of /trunk/net-scripts/net.modules.d/bonding

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1798 - (show annotations) (download)
Tue Jan 10 12:43:34 2006 UTC (8 years, 9 months ago) by uberlord
File size: 2459 byte(s)
Fixed bonding module, improved wireless with rt2500 and WPA
1 #!/bin/bash
2 # Copyright (c) 2004-2006 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4
5 # Contributed by Roy Marples (uberlord@gentoo.org)
6
7 # void bonding_depend(void)
8 #
9 # Sets up the dependancies for the module
10 bonding_depend() {
11 after interface macnet
12 before vlan dhcp bridge
13 functions interface_exists interface_up interface_down \
14 interface_del_addresses
15 variables slaves
16 }
17
18 # bool bonding_check_installed(void)
19 #
20 # Returns 0 if ifenslave is installed, otherwise 1
21 bonding_check_installed() {
22 [[ -x /sbin/ifenslave ]] && return 0
23 ${1:-false} && eerror "For link aggregation (bonding) support, emerge net-misc/ifenslave"
24 return 1
25 }
26
27 # bonding_exists(char *interface)
28 #
29 # Returns 0 if we are a bonded interface, otherwise 1
30 bonding_exists() {
31 [[ -f "/proc/net/bonding/$1" ]]
32 }
33
34 # bool bonding_post_start(char *iface)
35 #
36 # Bonds the interface
37 bonding_pre_start() {
38 local iface="$1" s ifvar=$( bash_variable "$1" )
39 local -a slaves
40
41 slaves="slaves_${ifvar}[@]"
42 [[ -z ${!slaves} ]] && return 0
43
44 interface_exists "${iface}" true || return 1
45
46 if ! bonding_exists "${iface}" ; then
47 eerror "${iface} is not capable of bonding"
48 return 1
49 fi
50
51 ebegin "Adding slaves to ${iface}"
52 eindent
53 einfo "${!slaves}"
54
55 # Check that our slaves exist
56 for s in ${!slaves} ; do
57 interface_exists "${s}" && continue
58 ewarn "interface ${s} does not exist"
59 return 1
60 done
61
62 # Must force the slaves to a particular state before adding them
63 for s in ${!slaves} ; do
64 interface_del_addresses "${s}"
65 interface_up "${s}"
66 done
67
68 # now force the master to up
69 interface_up "${iface}"
70
71 # finally add in slaves
72 eoutdent
73 eval /sbin/ifenslave "${iface}" "${!slaves}" >/dev/null
74 eend $?
75
76 return 0 #important
77 }
78
79 # bool bonding_stop(void)
80 # Unbonds bonded interfaces
81 #
82 # Always returns 0 (true)
83 bonding_stop() {
84 local iface="$1" slaves s
85
86 # return silently if this is not a bonding interface
87 ! bonding_exists "${iface}" && return 0
88
89 # don't trust the config, get the active list instead
90 slaves=$( sed -n -e 's/^Slave Interface: //p' "/proc/net/bonding/${iface}" )
91 [[ -z ${slaves} ]] && return 0
92
93 # remove all slaves
94 ebegin "Removing slaves from ${iface}"
95 eindent
96 einfo "${slaves}"
97 eoutdent
98 /sbin/ifenslave -d "${iface}" ${slaves}
99
100 # reset all slaves
101 for s in ${slaves}; do
102 if interface_exists "${s}" ; then
103 interface_del_addresses "${s}"
104 interface_down "${s}"
105 fi
106 done
107
108 eend 0
109 return 0
110 }
111
112 # vim:ts=4

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.20