]> git.ipfire.org Git - people/ms/network.git/commitdiff
network-hotplug: Try to use fewer checks when deleting a device
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 23 Sep 2018 18:06:42 +0000 (20:06 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 23 Sep 2018 18:06:42 +0000 (20:06 +0200)
This code basically does the same but runs fewer checks to
find the right device type

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/udev/network-hotplug

index 873238f6b934005145ada6848f49115b6555a27c..6f009ececd4924f5aa391758651f5c9d311f3fe8 100644 (file)
@@ -85,6 +85,7 @@ case "${SUBSYSTEM}" in
                                        case "${INTERFACE}" in
                                                gre0|ip6gre0|ip6tnl0|ip6_vti0|ip_vti0)
                                                        log DEBUG "Ignoring special device ${INTERFACE}"
+                                                       exit ${EXIT_OK}
                                                        ;;
                                        esac
 
@@ -92,20 +93,28 @@ case "${SUBSYSTEM}" in
 
                                        # Try to remove the device again
 
-                                       TYPE="$(device_get_type "${INTERFACE}")"
-                                       case "${TYPE}" in
-                                               bonding)
-                                                       bonding_remove "${INTERFACE}"
-                                                       ;;
-                                               dummy)
-                                                       dummy_remove "${INTERFACE}"
-                                                       ;;
-                                               wireless)
-                                                       wireless_remove "${INTERFACE}"
-                                                       ;;
-                                               *)
-                                                       device_delete "${INTERFACE}"
-                                       esac
+                                       # Bonding
+                                       if device_is_bonding "${INTERFACE}"; then
+                                               bonding_remove "${INTERFACE}"
+
+                                       # Dummy
+                                       elif device_is_dummy "${INTERFACE}"; then
+                                               dummy_remove "${INTERFACE}"
+
+                                       # Wireless
+                                       elif device_is_wireless "${INTERFACE}"; then
+                                               wireless_remove "${INTERFACE}"
+
+                                       # Everything else
+                                       else
+                                               device_delete "${INTERFACE}"
+                                       fi
+
+                                       # Check if the device still exists and if so, log an error
+                                       if device_exists "${INTERFACE}"; then
+                                               log ERROR "Could not delete ${INTERFACE}"
+                                               exit ${EXIT_ERROR}
+                                       fi
 
                                        exit ${EXIT_OK}
                                        ;;