From: Michael Tremer Date: Sat, 6 Sep 2014 11:15:59 +0000 (+0200) Subject: device: Rewrite batman-adv-port detection X-Git-Tag: 007~85 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7b192cf470a477d8fa1af7d21c0243e49f958d80;p=network.git device: Rewrite batman-adv-port detection 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. --- diff --git a/src/functions/functions.device b/src/functions/functions.device index 71265c40..5890ff9a 100644 --- a/src/functions/functions.device +++ b/src/functions/functions.device @@ -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