/[vps]/baselayout-vserver/branches/baselayout-1_12/net-scripts/net.modules.d/bonding
Gentoo

Contents of /baselayout-vserver/branches/baselayout-1_12/net-scripts/net.modules.d/bonding

Parent Directory Parent Directory | Revision Log Revision Log


Revision 206 - (show annotations) (download)
Sun Jan 15 10:27:03 2006 UTC (8 years, 11 months ago) by phreak
File size: 2550 byte(s)
Merging r1822 for branches/baselayout-1_12
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 slaves=( "${!slaves}" )
44
45 # Support space seperated slaves
46 [[ ${#slaves[@]} == 1 ]] && slaves=( ${slaves} )
47
48 interface_exists "${iface}" true || return 1
49
50 if ! bonding_exists "${iface}" ; then
51 eerror "${iface} is not capable of bonding"
52 return 1
53 fi
54
55 ebegin "Adding slaves to ${iface}"
56 eindent
57 einfo "${slaves[@]}"
58
59 # Check that our slaves exist
60 for s in "${slaves[@]}" ; do
61 interface_exists "${s}" true || return 1
62 done
63
64 # Must force the slaves to a particular state before adding them
65 for s in "${slaves[@]}" ; do
66 interface_del_addresses "${s}"
67 interface_up "${s}"
68 done
69
70 # now force the master to up
71 interface_up "${iface}"
72
73 # finally add in slaves
74 eoutdent
75 eval /sbin/ifenslave "${iface}" "${slaves[@]}" >/dev/null
76 eend $?
77
78 return 0 #important
79 }
80
81 # bool bonding_stop(void)
82 # Unbonds bonded interfaces
83 #
84 # Always returns 0 (true)
85 bonding_stop() {
86 local iface="$1" slaves s
87
88 # return silently if this is not a bonding interface
89 ! bonding_exists "${iface}" && return 0
90
91 # don't trust the config, get the active list instead
92 slaves="$( \
93 sed -n -e 's/^Slave Interface: //p' /proc/net/bonding/${iface} | xargs \
94 )"
95 [[ -z ${slaves} ]] && return 0
96
97 # remove all slaves
98 ebegin "Removing slaves from ${iface}"
99 eindent
100 einfo "${slaves}"
101 eoutdent
102 /sbin/ifenslave -d "${iface}" ${slaves}
103
104 # reset all slaves
105 for s in ${slaves}; do
106 if interface_exists "${s}" ; then
107 interface_del_addresses "${s}"
108 interface_down "${s}"
109 fi
110 done
111
112 eend 0
113 return 0
114 }
115
116 # vim:ts=4

  ViewVC Help
Powered by ViewVC 1.1.20