]>
Commit | Line | Data |
---|---|---|
d61a01d4 MT |
1 | #!/bin/bash |
2 | ############################################################################### | |
3 | # # | |
4 | # IPFire.org - A linux based firewall # | |
5 | # Copyright (C) 2010 Michael Tremer & Christian Schmidt # | |
6 | # # | |
7 | # This program is free software: you can redistribute it and/or modify # | |
8 | # it under the terms of the GNU General Public License as published by # | |
9 | # the Free Software Foundation, either version 3 of the License, or # | |
10 | # (at your option) any later version. # | |
11 | # # | |
12 | # This program is distributed in the hope that it will be useful, # | |
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of # | |
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # | |
15 | # GNU General Public License for more details. # | |
16 | # # | |
17 | # You should have received a copy of the GNU General Public License # | |
18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. # | |
19 | # # | |
20 | ############################################################################### | |
21 | ||
22 | function bonding_create() { | |
23 | local device=${1} | |
24 | local mac=${2} | |
25 | ||
26 | [ -z "${mac}" ] && mac=$(mac_generate) | |
27 | ||
28 | log INFO "Creating bonding device '${device}' (${mac})." | |
29 | ||
30 | echo "+${device}" > /sys/class/net/bonding_masters | |
31 | device_set_address ${mac} | |
32 | device_set_up ${device} | |
33 | } | |
34 | ||
35 | function bonding_remove() { | |
36 | local device=$(devicify ${1}) | |
37 | ||
38 | log INFO "Remove bonding device '${device}'." | |
39 | ||
40 | device_set_down ${device} | |
41 | echo "-${device}" > /sys/class/net/bonding_masters | |
42 | } | |
43 | ||
44 | function bonding_set_mode() { | |
45 | local device=${1} | |
46 | local mode=${2} | |
47 | ||
48 | log INFO "Setting bonding mode on '${device}' '${mode}'." | |
49 | ||
50 | echo "${mode}" > /sys/class/net/${device}/bonding/mode | |
51 | } | |
52 | ||
53 | function bonding_enslave_device() { | |
54 | local device=$(devicify ${1}) | |
55 | local slave=$(devicify ${2}) | |
56 | shift 2 | |
57 | ||
58 | log INFO "Enslaving slave '${slave}' to '${device}'." | |
59 | ||
60 | device_set_down ${slave} | |
61 | echo "+${slave}" > /sys/class/net/${device}/bonding/slaves | |
62 | } |