From: Michael Tremer Date: Sat, 6 Sep 2014 16:07:37 +0000 (+0200) Subject: zone: Don't handle hotplug events for zones X-Git-Url: http://git.ipfire.org/?p=people%2Fstevee%2Fnetwork.git;a=commitdiff_plain;h=fb8c7c92b8a9e98e62aea610c068d04a9084baf3 zone: Don't handle hotplug events for zones --- diff --git a/src/functions/functions.zone b/src/functions/functions.zone index c6c9f388..49194982 100644 --- a/src/functions/functions.zone +++ b/src/functions/functions.zone @@ -98,6 +98,28 @@ function zone_reload() { service_reload "network@${zone}.service" } +function zone_hotplug_event() { + local zone="${1}" + assert zone_exists "${zone}" + + # If the zone has already been started, we + # will reload it so the current configuration + # is re-applied. + if zone_is_active "${zone}"; then + zone_reload "${zone}" + return ${?} + + # If the zone is still down, but in auto-start mode, + # we will start it. + elif zone_is_enabled "${zone}"; then + zone_start "${zone}" + return ${?} + fi + + # Otherwise, nothing will be done. + return ${EXIT_OK} +} + function zone_enable() { # This function will enable the zone # with help of systemd. diff --git a/src/udev/network-hotplug b/src/udev/network-hotplug index 24681251..9767ac59 100644 --- a/src/udev/network-hotplug +++ b/src/udev/network-hotplug @@ -52,8 +52,14 @@ fi case "${ACTION}" in add|register) - # Check, if there is a configuration for that device. - if port_exists ${INTERFACE}; then + # Handle hotplug events for zones. + if zone_exists "${INTERFACE}"; then + # TODO When e.g. a wireless device is plugged in, + # the right zone needs to be searched and started. + exit ${EXIT_OK} + + # Check, if there is a port configuration for that device. + elif port_exists ${INTERFACE}; then port=${INTERFACE} # Create new configuration for _real_ network devices. @@ -106,18 +112,12 @@ case "${ACTION}" in exit ${EXIT_OK} fi - zone=$(port_zone ${port}) - # Check, if the device is configured in a zone. # If not, there is nothing to do. - isset zone || exit ${EXIT_OK} - - # If the zone is already up or enabled for auto-start, - # we add the device to the zone. - if zone_is_active "${zone}"; then - zone_reload "${zone}" - elif zone_is_enabled "${zone}"; then - zone_start "${zone}" + zone=$(port_zone "${port}") + if isset zone; then + zone_hotplug_event "${zone}" + exit ${?} fi ;;