]> git.ipfire.org Git - people/stevee/network.git/commitdiff
zone: Don't handle hotplug events for zones
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 6 Sep 2014 16:07:37 +0000 (18:07 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 6 Sep 2014 16:07:37 +0000 (18:07 +0200)
src/functions/functions.zone
src/udev/network-hotplug

index c6c9f38874d9f0c28ab0532b24cdf57a9da802db..491949829925751c3fbea9e318d3bad913a26504 100644 (file)
@@ -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.
index 246812511970f13b40919d5c3b27a4d059aa6cf2..9767ac59b6a36560b56c1f26bab5706ad862b675 100644 (file)
@@ -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
                ;;