]>
git.ipfire.org Git - people/ms/network.git/blob - src/hooks/ports/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 .
/usr
/lib
/network
/header-port
24 HOOK_SETTINGS
="HOOK ADDRESS MIIMON MODE SLAVES"
26 ADDRESS
=$
(mac_generate
)
30 function hook_check
() {
35 assert isinteger MIIMON
38 function hook_create
() {
42 function hook_edit
() {
47 while [ $# -gt 0 ]; do
50 ADDRESS
=$
(cli_get_val
${1})
53 MIIMON
=$
(cli_get_val
${1})
56 MODE
=$
(cli_get_val
${1})
59 slave
=$
(cli_get_val
${1})
60 SLAVES
="${SLAVES} ${slave}"
63 warning
"Unknown argument '${1}'"
71 # XXX think this must move to _check()
72 if ! isset DEVICE
; then
73 error
"You must set a device name."
77 if ! isset SLAVES
; then
78 error
"You need to specify at least one slave port (e.g. --slave=port0)."
83 for slave
in $
(unquote
${SLAVES}); do
84 if ! device_is_ethernet
${slave}; then
85 error
"Slave device '${slave}' is not an ethernet device."
90 # Remove any whitespace
91 SLAVES
=$
(echo ${SLAVES})
93 port_settings_write
"${port}" ${HOOK_SETTINGS}
102 port_settings_read
"${device}" ${HOOK_SETTINGS}
104 if device_exists
${device}; then
105 log DEBUG
"Bonding device '${device}' does already exist."
107 device_set_address
${device} ${ADDRESS}
108 device_set_up
${device}
113 bonding_create
${device} --address="${ADDRESS}" --mode="${MODE}"
116 [ ${ret} -eq ${EXIT_OK} ] || exit ${EXIT_ERROR}
118 bonding_set_miimon ${device} ${MIIMON}
119 device_set_up ${device}
122 for slave in $(unquote ${SLAVES}); do
123 if ! device_exists ${slave}; then
124 warning_log "${device}: configured slave
'${slave}' is not available.
"
128 bonding_enslave_device ${device} ${slave}
131 # Bring up the device.
132 device_set_up ${device}
137 function hook_down() {
140 bonding_remove ${device}
143 for slave in ${SLAVES}; do
144 device_set_down ${slave}