mwan3: Ping IPv6 hosts using address not interface
authorBrian J. Murrell <redacted>
Fri, 13 Mar 2020 13:58:10 +0000 (09:58 -0400)
committerFlorian Eckert <redacted>
Fri, 13 Mar 2020 14:24:57 +0000 (15:24 +0100)
Pinging IPv6 hosts using an interface as a source specifier seems
troublesome.  See https://bugs.openwrt.org/index.php?do=details&task_id=2897
for more detail.

Use the desired source interface's IP address instead.

Signed-off-by: Brian J. Murrell <redacted>
net/mwan3/Makefile
net/mwan3/files/usr/sbin/mwan3track

index 9815663fc57cfcab8e3a491de9c2d6d81beeba78..c5d870cbac37604e893c169c6b766cf44c271053 100644 (file)
@@ -8,7 +8,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=mwan3
-PKG_VERSION:=2.8.2
+PKG_VERSION:=2.8.3
 PKG_RELEASE:=2
 PKG_MAINTAINER:=Florian Eckert <fe@dev.tdt.de>
 PKG_LICENSE:=GPL-2.0
index a88708f063a71a86ada11e24fdeabf32965a7a19..2485d9c7377f375c8fa32170c52dab3ab204c891 100755 (executable)
@@ -132,11 +132,17 @@ main() {
                        if [ $host_up_count -lt $reliability ]; then
                                case "$track_method" in
                                        ping)
+                                               # pinging IPv6 hosts with an interface is troublesome
+                                               # https://bugs.openwrt.org/index.php?do=details&task_id=2897
+                                               # so get the IP address of the interface and use that instead                              
+                                               if echo $track_ip | grep -q ':'; then
+                                                    ADDR=$(ip -6 addr ls dev "$DEVICE" | sed -ne 's/ *inet6 \([^ \/]*\).* scope global.*/\1/p')
+                                               fi
                                                if [ $check_quality -eq 0 ]; then
-                                                       ping -I $DEVICE -c $count -W $timeout -s $size -t $max_ttl -q $track_ip &> /dev/null
+                                                       ping -I ${ADDR:-$DEVICE} -c $count -W $timeout -s $size -t $max_ttl -q $track_ip &> /dev/null
                                                        result=$?
                                                else
-                                                       ping_result="$(ping -I $DEVICE -c $count -W $timeout -s $size -t $max_ttl -q $track_ip | tail -2)"
+                                                       ping_result="$(ping -I ${ADDR:-$DEVICE} -c $count -W $timeout -s $size -t $max_ttl -q $track_ip | tail -2)"
                                                        loss="$(echo "$ping_result" | grep "packet loss" |  cut -d "," -f3 | awk '{print $1}' | sed -e 's/%//')"
                                                        if [ "$loss" -eq 100 ]; then
                                                                latency=999999
git clone https://git.99rst.org/PROJECT