# set our bridges to promisc mode.
device_set_promisc "${zone}" on
- # Bring up all ports
- zone_ports_create "${zone}"
- zone_ports_up "${zone}"
-
# Bring up all configurations
zone_configs_up "${zone}"
case "$(hotplug_action)" in
add)
+ # Attach all ports when zone is coming up
+ if hotplug_event_interface_is_zone "${zone}"; then
+ # Bring up all ports
+ local port
+ for port in $(zone_get_ports "${zone}"); do
+ log DEBUG "Trying to attach port ${port} to ${zone}"
+
+ hook_port_up "${zone}" "${port}"
+ done
+
# Handle ports of this zone that have just been added
- if hotplug_event_interface_is_port_of_zone "${zone}"; then
- # Bring up the zone if it is enabled but not active, yet.
- if zone_is_enabled "${zone}" && ! zone_is_active "${zone}"; then
- zone_start "${zone}"
+ elif hotplug_event_interface_is_port_of_zone "${zone}"; then
+ # Attach the device if the parent bridge is up
+ if zone_is_active "${zone}"; then
+ hook_port_up "${zone}" "${INTERFACE}"
fi
-
- hook_port_up "${zone}" "${INTERFACE}"
fi
;;
remove)
+ if hotplug_event_interface_is_zone "${zone}"; then
+ # Bring down/destroy all ports
+ local port
+ for port in $(zone_get_ports "${zone}"); do
+ log DEBUG "Trying to detach port ${port} from ${zone}"
+
+ hook_port_down "${zone}" "${port}"
+ done
+
# Handle ports of this zone that have just been removed
- if hotplug_event_interface_is_port_of_zone "${zone}"; then
+ elif hotplug_event_interface_is_port_of_zone "${zone}"; then
hook_port_down "${zone}" "${INTERFACE}"
fi
;;
PRIORITY="$(cli_get_val "${arg}")"
;;
esac
- done <<< "$(args $@)"
+ done <<< "$(args "$@")"
if ! zone_port_settings_write "${zone}" "${port}"; then
exit ${EXIT_ERROR}
}
hook_port_edit() {
- hook_port_attach $@
+ hook_port_attach "$@"
}
hook_port_up() {
if ! device_exists "${port}"; then
port_create "${port}"
- exit ${EXIT_OK}
+ return ${EXIT_OK}
fi
# Read configuration values
zone_port_settings_read "${zone}" "${port}" ${HOOK_PORT_SETTINGS}
+ # Make sure that the port is up
+ port_up "${port}"
+
# Attach the port to the bridge
bridge_attach_device "${zone}" "${port}"
stp_port_set_cost "${zone}" "${port}" "${COST}"
fi
- # TODO Apply priority (#10609)
-
- # Make sure that the port is up
- port_up "${port}"
+ if isset PRIORITY; then
+ stp_port_set_priority "${zone}" "${port}" "${PRIORITY}"
+ fi
- exit ${EXIT_OK}
+ return ${EXIT_OK}
}
hook_port_down() {
port_down "${port}"
fi
- exit ${EXIT_OK}
+ return ${EXIT_OK}
}
hook_port_status() {