]> git.ipfire.org Git - people/stevee/network.git/commitdiff
device: Rewrite batman-adv-port detection
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 6 Sep 2014 11:15:59 +0000 (13:15 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 6 Sep 2014 11:15:59 +0000 (13:15 +0200)
When the batman-adv module is loaded, the batman_adv
subdirectory can be found in the sys tree of every network
device, so this check returned positive for every device.

The function has been rewritten to read the content of the
status file which will return the correct result.

src/functions/functions.device

index 71265c40bbf43e4e40e3fd40afa625e6de2c400a..5890ff9a538fb5fb6be5d9eb4d01f95a1f0f5e9c 100644 (file)
@@ -153,7 +153,22 @@ function device_is_batman_adv() {
 
 # Check if the device is a batman-adv bridge port
 function device_is_batman_adv_port() {
-       [ -d "${SYS_CLASS_NET}/${1}/batman_adv" ]
+       local device="${1}"
+
+       if [ -d "${SYS_CLASS_NET}/${device}/batman_adv" ]; then
+               local status="$(<${SYS_CLASS_NET}/${device}/batman_adv/iface_status)"
+
+               case "${status}" in
+                       "active")
+                               return ${EXIT_TRUE}
+                               ;;
+                       *)
+                               return ${EXIT_FALSE}
+                               ;;
+               esac
+       fi
+
+       return ${EXIT_FALSE}
 }
 
 # Check if the device is a bonding device