Browse Source

Merge pull request #5033 from yangfl/master

net/mwan3: fix empty gateway when creating routing table
lilik-openwrt-22.03
champtar 7 years ago
committed by GitHub
parent
commit
c81a75125a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 38 deletions
  1. +1
    -1
      net/mwan3/Makefile
  2. +2
    -6
      net/mwan3/files/etc/hotplug.d/iface/15-mwan3
  3. +17
    -28
      net/mwan3/files/lib/mwan3/mwan3.sh
  4. +15
    -3
      net/mwan3/files/usr/sbin/mwan3track

+ 1
- 1
net/mwan3/Makefile View File

@ -8,7 +8,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=mwan3
PKG_VERSION:=2.6.6
PKG_VERSION:=2.6.7
PKG_RELEASE:=1
PKG_MAINTAINER:=Florian Eckert <fe@dev.tdt.de>
PKG_LICENSE:=GPLv2


+ 2
- 6
net/mwan3/files/etc/hotplug.d/iface/15-mwan3 View File

@ -26,24 +26,20 @@ if [ "$ACTION" == "ifup" ]; then
if [ "$family" = "ipv4" ]; then
ubus call network.interface.${INTERFACE}_4 status &>/dev/null
if [ "$?" -eq "0" ]; then
network_get_gateway gateway ${INTERFACE}_4
network_get_ipaddr src_ip ${INTERFACE}_4
else
network_get_gateway gateway $INTERFACE
network_get_ipaddr src_ip ${INTERFACE}
fi
[ -n "$src_ip" ] || src_ip="0.0.0.0"
elif [ "$family" = "ipv6" ]; then
ubus call network.interface.${INTERFACE}_6 status &>/dev/null
if [ "$?" -eq "0" ]; then
network_get_gateway6 gateway ${INTERFACE}_6
network_get_ipaddr6 src_ip ${INTERFACE}_6
else
network_get_gateway6 gateway ${INTERFACE}
network_get_ipaddr6 src_ip ${INTERFACE}
fi
[ -n "$src_ip" ] || src_ip="::"
fi
[ -n "$gateway" ] || exit 9
fi
if [ "$initial_state" = "offline" ]; then


+ 17
- 28
net/mwan3/files/lib/mwan3/mwan3.sh View File

@ -195,7 +195,7 @@ mwan3_set_general_iptables()
mwan3_create_iface_iptables()
{
local id family src_ip src_ipv6
local id family
config_get family $1 family ipv4
mwan3_get_iface_id id $1
@ -203,14 +203,6 @@ mwan3_create_iface_iptables()
[ -n "$id" ] || return 0
if [ "$family" == "ipv4" ]; then
ubus call network.interface.${1}_4 status &>/dev/null
if [ "$?" -eq "0" ]; then
network_get_ipaddr src_ip ${1}_4
else
network_get_ipaddr src_ip $1
fi
$IPS -! create mwan3_connected list:set
if ! $IPT4 -S mwan3_ifaces_in &> /dev/null; then
@ -237,21 +229,13 @@ mwan3_create_iface_iptables()
$IPT4 -A mwan3_ifaces_in -m mark --mark 0x0/$MMX_MASK -j mwan3_iface_in_$1
$IPT4 -F mwan3_iface_out_$1
$IPT4 -A mwan3_iface_out_$1 -s $src_ip -m mark --mark 0x0/$MMX_MASK -m comment --comment "$1" -j MARK --set-xmark $(mwan3_id2mask id MMX_MASK)/$MMX_MASK
$IPT4 -A mwan3_iface_out_$1 -o $2 -m mark --mark 0x0/$MMX_MASK -m comment --comment "$1" -j MARK --set-xmark $(mwan3_id2mask id MMX_MASK)/$MMX_MASK
$IPT4 -D mwan3_ifaces_out -m mark --mark 0x0/$MMX_MASK -j mwan3_iface_out_$1 &> /dev/null
$IPT4 -A mwan3_ifaces_out -m mark --mark 0x0/$MMX_MASK -j mwan3_iface_out_$1
fi
if [ "$family" == "ipv6" ]; then
ubus call network.interface.${1}_6 status &>/dev/null
if [ "$?" -eq "0" ]; then
network_get_ipaddr6 src_ipv6 ${1}_6
else
network_get_ipaddr6 src_ipv6 $1
fi
$IPS -! create mwan3_connected_v6 hash:net family inet6
if ! $IPT6 -S mwan3_ifaces_in &> /dev/null; then
@ -278,7 +262,7 @@ mwan3_create_iface_iptables()
$IPT6 -A mwan3_ifaces_in -m mark --mark 0x0/$MMX_MASK -j mwan3_iface_in_$1
$IPT6 -F mwan3_iface_out_$1
$IPT6 -A mwan3_iface_out_$1 -s $src_ipv6 -m mark --mark 0x0/$MMX_MASK -m comment --comment "$1" -j MARK --set-xmark $(mwan3_id2mask id MMX_MASK)/$MMX_MASK
$IPT6 -A mwan3_iface_out_$1 -o $2 -m mark --mark 0x0/$MMX_MASK -m comment --comment "$1" -j MARK --set-xmark $(mwan3_id2mask id MMX_MASK)/$MMX_MASK
$IPT6 -D mwan3_ifaces_out -m mark --mark 0x0/$MMX_MASK -j mwan3_iface_out_$1 &> /dev/null
$IPT6 -A mwan3_ifaces_out -m mark --mark 0x0/$MMX_MASK -j mwan3_iface_out_$1
@ -322,32 +306,37 @@ mwan3_create_iface_route()
[ -n "$id" ] || return 0
if [ "$family" == "ipv4" ]; then
ubus call network.interface.${1}_4 status &>/dev/null
if [ "$?" -eq "0" ]; then
if ubus call network.interface.${1}_4 status &>/dev/null; then
network_get_gateway route_args ${1}_4
else
network_get_gateway route_args $1
fi
route_args="via $route_args dev $2"
if [ -n "$route_args" -a "$route_args" != "0.0.0.0" ]; then
route_args="via $route_args"
else
route_args=""
fi
$IP4 route flush table $id
$IP4 route add table $id default $route_args
$IP4 route add table $id default $route_args dev $2
fi
if [ "$family" == "ipv6" ]; then
ubus call network.interface.${1}_6 status &>/dev/null
if [ "$?" -eq "0" ]; then
if ubus call network.interface.${1}_6 status &>/dev/null; then
network_get_gateway6 route_args ${1}_6
else
network_get_gateway6 route_args $1
fi
route_args="via $route_args dev $2"
if [ -n "$route_args" -a "$route_args" != "::" ]; then
route_args="via $route_args"
else
route_args=""
fi
$IP6 route flush table $id
$IP6 route add table $id default $route_args
$IP6 route add table $id default $route_args dev $2
fi
}


+ 15
- 3
net/mwan3/files/usr/sbin/mwan3track View File

@ -21,7 +21,10 @@ if_down() {
validate_track_method() {
case "$1" in
ping)
# Assume that ping is installed
which ping 1>/dev/null 2>&1 || {
$LOG warn "Missing ping. Please install iputils-ping package or enable ping util and recompile busybox."
return 1
}
;;
arping)
which arping 1>/dev/null 2>&1 || {
@ -34,6 +37,10 @@ validate_track_method() {
$LOG warn "Missing httping. Please install httping package."
return 1
}
[ -n "$2" -a "$2" != "0.0.0.0" -a "$2" != "::" ] || {
$LOG warn "Cannot determine source IP for the interface which is required by httping."
return 1
}
;;
*)
$LOG warn "Unsupported tracking method: $track_method"
@ -59,9 +66,14 @@ main() {
config_load mwan3
config_get track_method $1 track_method ping
validate_track_method $track_method || {
$LOG warn "Using ping to track interface $INTERFACE avaliability"
validate_track_method $track_method $SRC_IP || {
track_method=ping
if validate_track_method $track_method; then
$LOG warn "Using ping to track interface $INTERFACE avaliability"
else
$LOG err "No track method avaliable"
exit 1
fi
}
config_get reliability $1 reliability 1
config_get count $1 count 1


Loading…
Cancel
Save