From 1fc4b3cac15c709b3a6f4a3171265a5cff793f47 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Mon, 24 Sep 2018 23:17:30 +0200 Subject: [PATCH] bridge: Reorder functions into the common order Signed-off-by: Michael Tremer --- src/hooks/zones/bridge | 96 +++++++++++++++++++++--------------------- 1 file changed, 49 insertions(+), 47 deletions(-) diff --git a/src/hooks/zones/bridge b/src/hooks/zones/bridge index d610814a..fb81673c 100644 --- a/src/hooks/zones/bridge +++ b/src/hooks/zones/bridge @@ -172,53 +172,6 @@ hook_up() { exit ${EXIT_OK} } -hook_hotplug() { - local zone="${1}" - assert isset 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 - 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 - 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 - elif hotplug_event_interface_is_port_of_zone "${zone}"; then - hook_port_down "${zone}" "${INTERFACE}" - fi - ;; - *) - exit ${EXIT_NOT_HANDLED} - ;; - esac - - exit ${EXIT_OK} -} - hook_down() { local zone="${1}" assert isset zone @@ -294,6 +247,55 @@ hook_status() { exit ${EXIT_OK} } +hook_hotplug() { + local zone="${1}" + assert isset 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 + 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 + 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 + elif hotplug_event_interface_is_port_of_zone "${zone}"; then + hook_port_down "${zone}" "${INTERFACE}" + fi + ;; + + *) + exit ${EXIT_NOT_HANDLED} + ;; + esac + + exit ${EXIT_OK} +} + hook_check_port_settings() { if isset COST; then assert isinteger COST -- 2.39.2