]> git.ipfire.org Git - people/stevee/network.git/blobdiff - src/functions/functions.hotplug
Add hotplugging for zones (and ports of those)
[people/stevee/network.git] / src / functions / functions.hotplug
index 6e71e0c4814cfb4c9f5f41df6ea70f9639583363..80089ac3821ef668e5b236dbf2a54c67b2acf66f 100644 (file)
@@ -50,6 +50,26 @@ function hotplug_propagate_all_ports() {
        done
 }
 
+function hotplug_propagate_all_zones() {
+       hotplug_assert_in_hotplug_event
+
+       local zone
+       for zone in $(zones_get_all); do
+               zone_hotplug_event "${zone}"
+               local ret="${?}"
+
+               # Log warning for crashed hooks
+               case "${ret}" in
+                       ${EXIT_OK}|${EXIT_NOT_HANDLED})
+                               : # do nothing
+                               ;;
+                       *)
+                               log WARNING "Unknown exit code for zone '${zone}': ${ret}"
+                               ;;
+               esac
+       done
+}
+
 function hotplug_event_port_is_interface() {
        hotplug_assert_in_hotplug_event
 
@@ -59,7 +79,7 @@ function hotplug_event_port_is_interface() {
        [ "${port}" = "${INTERFACE}" ]
 }
 
-function hotplug_event_port_is_slave() {
+function hotplug_event_interface_is_slave_of_port() {
        hotplug_assert_in_hotplug_event
 
        local port="${1}"
@@ -69,7 +89,20 @@ function hotplug_event_port_is_slave() {
        isset INTERFACE || return ${EXIT_FALSE}
 
        local slaves="$(port_get_slaves "${port}")"
-       list_match "${INTERFACE}" ${SLAVES}
+       list_match "${INTERFACE}" ${slaves}
+}
+
+function hotplug_event_interface_is_port_of_zone() {
+       hotplug_assert_in_hotplug_event
+
+       local zone="${1}"
+       assert isset zone
+
+       # Return false if INTERFACE is not set
+       isset INTERFACE || return ${EXIT_FALSE}
+
+       local ports="$(zone_get_ports "${zone}")"
+       list_match "${INTERFACE}" ${ports}
 }
 
 function hotplug_event_port_uses_phy() {