done
}
+hotplug_event_interface_is_zone() {
+ hotplug_assert_in_hotplug_event
+
+ local zone="${1}"
+ assert isset zone
+
+ log DEBUG "${zone}= ${INTERFACE}?"
+
+ [ "${zone}" = "${INTERFACE}" ]
+}
+
hotplug_event_port_is_interface() {
hotplug_assert_in_hotplug_event
# 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
+ 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
;;
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
;;
if ! device_exists "${port}"; then
port_create "${port}"
- exit ${EXIT_OK}
+ return ${EXIT_OK}
fi
# Read configuration values
# Make sure that the port is up
port_up "${port}"
- exit ${EXIT_OK}
+ return ${EXIT_OK}
}
hook_port_down() {
port_down "${port}"
fi
- exit ${EXIT_OK}
+ return ${EXIT_OK}
}
hook_port_status() {
net)
assert isset INTERFACE
- # Don't do anything for zones
- if zone_exists "${INTERFACE}"; then
- exit ${EXIT_OK}
-
# Stop processing rules for the loopback device
- elif device_is_loopback ${INTERFACE}; then
+ if device_is_loopback ${INTERFACE}; then
exit ${EXIT_OK}
# Stop processing rules for wireless monitoring devices
fi
# Did we get called for a non-existing interface?
- if ! port_exists "${INTERFACE}"; then
+ if ! zone_exists "${INTERFACE}" && ! port_exists "${INTERFACE}"; then
case "${ACTION}" in
add)
log WARNING "Got to hotplug event for a port which does not exist: ${INTERFACE}"