return ${EXIT_OK}
fi
+ # Make sure that the MTU of the device that is to be attached
+ # to the bridge matches the MTU of the bridge.
+ device_adjust_mtu "${device}" "${bridge}"
+
# Actually connect bridge and device.
cmd_quiet ip link set ${device} master ${bridge}
local ret=$?
return ${ret}
}
+function device_adjust_mtu() {
+ assert [ $# -eq 2 ]
+
+ local device="${1}"
+ local other_device="${2}"
+
+ local mtu="$(device_get_mtu "${other_device}")"
+ device_set_mtu "${device}" "${mtu}"
+}
+
function device_discover() {
local device=${1}
local port=${1}
assert isset port
+ if ! device_exists "${port}"; then
+ log WARNING "Cannot bring up port '${port}' which does not exist"
+ exit ${EXIT_OK}
+ fi
+
# Read in the confguration file.
port_settings_read "${port}" ${HOOK_SETTINGS}
fi
# Bring up the device.
- device_set_up ${port}
+ device_set_up "${port}"
exit ${EXIT_OK}
}
local zone="${1}"
local port="${2}"
- zone_port_settings_read "${zone}" "${port}" ${HOOK_PORT_SETTINGS}
-
+ # Try bringing up the port
port_up "${port}"
- # Set same MTU to device that the bridge has got
- device_set_mtu "${port}" $(device_get_mtu "${zone}")
+ # If the port could not be brought up, we will
+ # log an error message and exit.
+ if ! device_exists "${port}"; then
+ log WARNING "Port '${port}' cannot be attached to zone '${zone}' as it does not exist"
+ exit ${EXIT_OK}
+ fi
+
+ # Read configuration values
+ zone_port_settings_read "${zone}" "${port}" ${HOOK_PORT_SETTINGS}
+ # Attach the port to the bridge
bridge_attach_device "${zone}" "${port}"
+ # Set STP configuration
if isset COST; then
stp_port_set_cost "${zone}" "${port}" "${COST}"
fi