]> git.ipfire.org Git - people/ms/network.git/commitdiff
Speed-up finding the device type if the device does not exist
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 23 Dec 2014 00:51:36 +0000 (00:51 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 23 Dec 2014 00:51:36 +0000 (00:51 +0000)
src/functions/functions.device

index f5c150dd22cd0c120ee941a53266ce021bb16fc1..97eb17f794bd174f8c42a69eef005ceca7b49cb4 100644 (file)
@@ -349,7 +349,12 @@ function device_is_ethernet() {
 function device_get_type() {
        local device=${1}
 
-       if device_is_vlan ${device}; then
+       # If the device does not exist (happens on udev remove events),
+       # we do not bother to run all checks.
+       if ! device_exists "${device}"; then
+               echo "unknown"
+
+       elif device_is_vlan ${device}; then
                echo "vlan"
 
        elif device_is_bonding ${device}; then