]>
git.ipfire.org Git - people/stevee/network.git/blob - functions.bonding
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2010 Michael Tremer & Christian Schmidt #
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. #
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. #
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/>. #
20 ###############################################################################
22 function bonding_init
() {
23 if ! grep -q "^bonding" /proc
/modules
; then
30 function bonding_create
() {
34 [ -z "${mac}" ] && mac
=$
(mac_generate
)
36 # Initialize the bonding driver just
40 log INFO
"Creating bonding device '${device}' (${mac})."
42 echo "+${device}" > /sys
/class
/net
/bonding_masters
43 device_set_address
${device} ${mac}
46 function bonding_remove
() {
50 log INFO
"Remove bonding device '${device}'."
52 device_set_down
${device}
53 echo "-${device}" > /sys
/class
/net
/bonding_masters
56 function bonding_set_mode
() {
60 log INFO
"Setting bonding mode on '${device}' '${mode}'."
62 echo "${mode}" > /sys
/class
/net
/${device}/bonding
/mode
65 function bonding_get_mode
() {
69 read mode mode_num
< ${SYS_CLASS_NET}/${device}/bonding
/mode
73 function bonding_enslave_device
() {
81 log INFO
"Enslaving slave '${slave}' to '${device}'."
83 device_set_down
${slave}
84 echo "+${slave}" > /sys
/class
/net
/${device}/bonding
/slaves
87 function bonding_get_slaves
() {
90 cat ${SYS_CLASS_NET}/${device}/bonding
/slaves
93 function bonding_get_active_slave
() {
96 cat ${SYS_CLASS_NET}/${device}/bonding
/active_slave
99 # XXX function bonding_get_lacp_rate?
101 function bonding_get_miimon
() {
104 cat ${SYS_CLASS_NET}/${device}/bonding
/miimon
107 function bonding_set_miimon
() {
111 echo "${miimon}" > ${SYS_CLASS_NET}/${device}/bonding/miimon
114 function bonding_device_print() {
117 ethernet_device_print ${device}
121 printf "${DEVICE_PRINT_LINE1}" "Mode
:" "$
(bonding_get_mode
${device})"
122 printf "${DEVICE_PRINT_LINE1}" "Slaves
:" "$
(bonding_get_slaves
${device})"
125 function bonding_slave_get_master() {
129 assert device_is_bonded ${slave}
132 for device in $(devices_get_all); do
133 if device_is_bonding ${device} && listmatch ${slave} $(bonding_get_slaves ${device}); then