]> git.ipfire.org Git - network.git/commitdiff
device_get_speed(): Break if speed is not readable
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 13 Jun 2017 18:24:41 +0000 (19:24 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 13 Jun 2017 18:24:41 +0000 (19:24 +0100)
This is usually the case when a device has no link
(i.e. the speed is unknown).

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/functions/functions.device

index 32108bb047bad16b38128a6befa7ae393f65f878..ac6ace5b627b10691501413005d32af94f146cae 100644 (file)
@@ -862,6 +862,9 @@ device_get_speed() {
 
        local speed=$(__device_get_file ${device} speed)
 
+       # Exit for no output (i.e. no link detected)
+       isset speed || return ${EXIT_ERROR}
+
        # Don't return anything for negative values
        [ ${speed} -lt 0 ] && return ${EXIT_ERROR}