]> git.ipfire.org Git - people/ms/network.git/blobdiff - src/hooks/ports/ethernet
network-hotplug: Try to use fewer checks when deleting a device
[people/ms/network.git] / src / hooks / ports / ethernet
index b782e52fe2f8ff2cff11642be7e2ddab29a6a462..cdc3dec7d2c7e98279a48604c4d5cb7d4c6b8d08 100644 (file)
@@ -24,7 +24,7 @@
 # DEVICE equals the actual MAC address of the device.
 # If ADDRESS is set, the device will get ADDRESS set for its MAC address.
 
-HOOK_SETTINGS="HOOK ADDRESS ADVERTISED_LINK_SPEEDS DEVICE OFFLOADING MTU"
+HOOK_SETTINGS="ADDRESS ADVERTISED_LINK_SPEEDS DEVICE OFFLOADING MTU"
 
 hook_check_settings() {
        assert ismac DEVICE
@@ -83,8 +83,11 @@ hook_parse_cmdline() {
 
                                if enabled OFFLOADING; then
                                        OFFLOADING="on"
-                               else
+                               elif disabled OFFLOADING; then
                                        OFFLOADING="off"
+                               else
+                                       error "Invalid value for offloading: ${OFFLOADING}"
+                                       return ${EXIT_ERROR}
                                fi
                                ;;
 
@@ -97,6 +100,25 @@ hook_parse_cmdline() {
        done
 }
 
+# This function is only called automatically by hotplug to create
+# a new ethernet port.
+hook_new() {
+       local port="${1}"
+       assert isset port
+
+       local device="${2}"
+       assert isset device
+
+       local DEVICE="$(device_get_address "${device}")"
+
+       if ! port_settings_write "${port}" ${HOOK_SETTINGS}; then
+               log ERROR "Could not write settings for port ${port}"
+               return ${EXIT_ERROR}
+       fi
+
+       return ${EXIT_OK}
+}
+
 hook_create() {
        return ${EXIT_OK}
 }