Merge pull request #7418 from TDT-AG/pr/20181108-mwan3
mwan3: remove deprecated options
This commit is contained in:
commit
a7a8016836
7 changed files with 59 additions and 171 deletions
|
@ -8,7 +8,7 @@
|
||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=mwan3
|
PKG_NAME:=mwan3
|
||||||
PKG_VERSION:=2.7.5
|
PKG_VERSION:=2.7.6
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=1
|
||||||
PKG_MAINTAINER:=Florian Eckert <fe@dev.tdt.de>
|
PKG_MAINTAINER:=Florian Eckert <fe@dev.tdt.de>
|
||||||
PKG_LICENSE:=GPLv2
|
PKG_LICENSE:=GPLv2
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
|
|
||||||
config globals 'globals'
|
config globals 'globals'
|
||||||
option mmx_mask '0x3F00'
|
option mmx_mask '0x3F00'
|
||||||
option local_source 'none'
|
|
||||||
option rtmon_interval '5'
|
option rtmon_interval '5'
|
||||||
|
|
||||||
config interface 'wan'
|
config interface 'wan'
|
||||||
|
|
|
@ -1,98 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
. /lib/functions.sh
|
|
||||||
. /lib/functions/network.sh
|
|
||||||
. /lib/mwan3/mwan3.sh
|
|
||||||
|
|
||||||
LOG="logger -t mwan3[$$] -p"
|
|
||||||
|
|
||||||
[ "$ACTION" = "connected" -o "$ACTION" = "disconnected" ] || exit 1
|
|
||||||
[ -n "$INTERFACE" ] || exit 2
|
|
||||||
|
|
||||||
if [ "$ACTION" = "connected" ]; then
|
|
||||||
[ -n "$DEVICE" ] || exit 3
|
|
||||||
fi
|
|
||||||
|
|
||||||
config_load mwan3
|
|
||||||
config_get_bool enabled globals 'enabled' '0'
|
|
||||||
config_get local_source globals 'local_source' 'none'
|
|
||||||
[ ${enabled} = "1" ] || exit 0
|
|
||||||
[ ${local_source} = "none" ] || exit 0
|
|
||||||
|
|
||||||
config_get enabled $INTERFACE enabled 0
|
|
||||||
config_get online_metric $INTERFACE online_metric 0
|
|
||||||
[ "$enabled" == "1" ] || exit 0
|
|
||||||
|
|
||||||
if [ "$online_metric" = 0 ]; then
|
|
||||||
$LOG notice "No online metric for interface "$INTERFACE" found"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
mwan3_add_failover_metric() {
|
|
||||||
local iface="$1"
|
|
||||||
local device="$2"
|
|
||||||
local metric="$3"
|
|
||||||
|
|
||||||
local route_args
|
|
||||||
|
|
||||||
config_get family $iface family ipv4
|
|
||||||
|
|
||||||
if [ "$family" == "ipv4" ]; then
|
|
||||||
if ubus call network.interface.${iface}_4 status 1>/dev/null 2>&1; then
|
|
||||||
network_get_gateway route_args ${iface}_4
|
|
||||||
else
|
|
||||||
network_get_gateway route_args $iface
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$route_args" -a "$route_args" != "0.0.0.0" ]; then
|
|
||||||
route_args="via $route_args"
|
|
||||||
else
|
|
||||||
route_args=""
|
|
||||||
fi
|
|
||||||
|
|
||||||
$IP4 route add default $route_args dev $device proto static metric $metric 1>/dev/null 2>&1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$family" == "ipv6" ]; then
|
|
||||||
if ubus call network.interface.${iface}_6 status 1>/dev/null 2>&1; then
|
|
||||||
network_get_gateway6 route_args ${iface}_6
|
|
||||||
else
|
|
||||||
network_get_gateway6 route_args $iface
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$route_args" -a "$route_args" != "::" ]; then
|
|
||||||
route_args="via $route_args"
|
|
||||||
else
|
|
||||||
route_args=""
|
|
||||||
fi
|
|
||||||
|
|
||||||
$IP6 route add default $route_args dev $device proto static metric $metric 1>/dev/null 2>&1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
mwan3_del_failover_metric() {
|
|
||||||
local iface="$1"
|
|
||||||
local device="$2"
|
|
||||||
local metric="$3"
|
|
||||||
|
|
||||||
config_get family $iface family ipv4
|
|
||||||
|
|
||||||
if [ "$family" == "ipv4" ]; then
|
|
||||||
$IP4 route del default dev $device proto static metric $metric 1>/dev/null 2>&1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$family" == "ipv6" ]; then
|
|
||||||
$IP6 route del default dev $device proto static metric $metric 1>/dev/null 2>&1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
case "$ACTION" in
|
|
||||||
connected)
|
|
||||||
mwan3_add_failover_metric "$INTERFACE" "$DEVICE" "$online_metric"
|
|
||||||
;;
|
|
||||||
disconnected)
|
|
||||||
mwan3_del_failover_metric "$INTERFACE" "$DEVICE" "$online_metric"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
exit 0
|
|
|
@ -1,48 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
. /lib/functions.sh
|
|
||||||
. /lib/mwan3/mwan3.sh
|
|
||||||
. /lib/functions/network.sh
|
|
||||||
|
|
||||||
[ "$ACTION" = "ifup" -o "$ACTION" = "ifdown" ] || exit 1
|
|
||||||
[ -n "$INTERFACE" ] || exit 2
|
|
||||||
|
|
||||||
if [ "$ACTION" = "ifup" ]; then
|
|
||||||
[ -n "$DEVICE" ] || exit 3
|
|
||||||
fi
|
|
||||||
|
|
||||||
config_load mwan3
|
|
||||||
config_get_bool enabled globals 'enabled' '0'
|
|
||||||
[ ${enabled} -gt 0 ] || exit 0
|
|
||||||
|
|
||||||
config_get local_source globals local_source 'none'
|
|
||||||
[ "${local_source}" = "none" ] && {
|
|
||||||
exit 0
|
|
||||||
}
|
|
||||||
|
|
||||||
[ "${local_source}" = "$INTERFACE" ] || {
|
|
||||||
exit 0
|
|
||||||
}
|
|
||||||
|
|
||||||
mwan3_lock
|
|
||||||
src_ip=$(uci_get_state mwan3 globals src_ip)
|
|
||||||
[ "${src_ip}" != "" ] && {
|
|
||||||
ip route del default via "${src_ip}" dev lo 1>/dev/null 2>&1
|
|
||||||
ip addr del "${src_ip}/32" dev lo 1>/dev/null 2>&1
|
|
||||||
}
|
|
||||||
|
|
||||||
sleep 1
|
|
||||||
|
|
||||||
[ "$ACTION" = "ifup" ] && {
|
|
||||||
network_get_ipaddr src_ip "${local_source}"
|
|
||||||
if [ "${src_ip}" = "" ]; then
|
|
||||||
$LOG warn "Unable to set source ip for own initiated traffic (${local_source})"
|
|
||||||
else
|
|
||||||
ip addr add "${src_ip}/32" dev lo
|
|
||||||
ip route add default via "${src_ip}" dev lo
|
|
||||||
uci_toggle_state mwan3 globals src_ip "${src_ip}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
mwan3_unlock
|
|
||||||
|
|
||||||
exit 0
|
|
|
@ -1219,25 +1219,3 @@ mwan3_track_clean()
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mwan3_online_metric_clean() {
|
|
||||||
local iface="$1"
|
|
||||||
|
|
||||||
local online_metric ifname
|
|
||||||
|
|
||||||
config_get family $iface family ipv4
|
|
||||||
config_get online_metric $iface online_metric ""
|
|
||||||
ifname=$(uci_get_state network $iface ifname)
|
|
||||||
|
|
||||||
if [ "$family" == "ipv4" ] \
|
|
||||||
&& [ "$online_metric" != "" ] \
|
|
||||||
&& [ "$ifname" != "" ]; then
|
|
||||||
$IP4 route del default dev $ifname proto static metric $online_metric 1>/dev/null 2>&1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$family" == "ipv6" ] \
|
|
||||||
&& [ "$online_metric" != "" ] \
|
|
||||||
&& [ "$ifname" != "" ]; then
|
|
||||||
$IP6 route del default dev $ifname proto static metric $online_metric 1>/dev/null 2>&1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
|
@ -31,6 +31,44 @@ report_connected_v6() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
report_policies() {
|
||||||
|
local ipt="$1"
|
||||||
|
local policy="$2"
|
||||||
|
|
||||||
|
local percent total_weight weight iface
|
||||||
|
|
||||||
|
total_weight=$($ipt -S $policy | grep -v '.*--comment "out .*" .*$' | cut -s -d'"' -f2 | head -1 | awk '{print $3}')
|
||||||
|
|
||||||
|
for iface in $($ipt -S $policy | grep -v '.*--comment "out .*" .*$' | cut -s -d'"' -f2 | awk '{print $1}'); do
|
||||||
|
weight=$($ipt -S $policy | grep -v '.*--comment "out .*" .*$' | cut -s -d'"' -f2 | awk '$1 == "'$iface'"' | awk '{print $2}')
|
||||||
|
percent=$(($weight*100/$total_weight))
|
||||||
|
json_add_object
|
||||||
|
json_add_string interface "$iface"
|
||||||
|
json_add_int percent "$percent"
|
||||||
|
json_close_object
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
report_policies_v4() {
|
||||||
|
local policy
|
||||||
|
|
||||||
|
for policy in $($IPT4 -S | awk '{print $2}' | grep mwan3_policy_ | sort -u); do
|
||||||
|
json_add_array "${policy##*mwan3_policy_}"
|
||||||
|
report_policies "$IPT4" "$policy"
|
||||||
|
json_close_array
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
report_policies_v6() {
|
||||||
|
local policy
|
||||||
|
|
||||||
|
for policy in $($IPT6 -S | awk '{print $2}' | grep mwan3_policy_ | sort -u); do
|
||||||
|
json_add_array "${policy##*mwan3_policy_}"
|
||||||
|
report_policies "$IPT6" "$policy"
|
||||||
|
json_close_array
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
get_mwan3_status() {
|
get_mwan3_status() {
|
||||||
local iface="${1}"
|
local iface="${1}"
|
||||||
local iface_select="${2}"
|
local iface_select="${2}"
|
||||||
|
@ -100,6 +138,7 @@ main () {
|
||||||
json_add_object "status"
|
json_add_object "status"
|
||||||
json_add_string "section" "x"
|
json_add_string "section" "x"
|
||||||
json_add_string "interface" "x"
|
json_add_string "interface" "x"
|
||||||
|
json_add_string "policies" "x"
|
||||||
json_close_object
|
json_close_object
|
||||||
json_dump
|
json_dump
|
||||||
;;
|
;;
|
||||||
|
@ -130,6 +169,16 @@ main () {
|
||||||
json_close_array
|
json_close_array
|
||||||
json_close_object
|
json_close_object
|
||||||
;;
|
;;
|
||||||
|
policies)
|
||||||
|
json_add_object policies
|
||||||
|
json_add_object ipv4
|
||||||
|
report_policies_v4
|
||||||
|
json_close_object
|
||||||
|
json_add_object ipv6
|
||||||
|
report_policies_v6
|
||||||
|
json_close_object
|
||||||
|
json_close_object
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
# interfaces
|
# interfaces
|
||||||
json_add_object interfaces
|
json_add_object interfaces
|
||||||
|
@ -144,6 +193,15 @@ main () {
|
||||||
report_connected_v6
|
report_connected_v6
|
||||||
json_close_array
|
json_close_array
|
||||||
json_close_object
|
json_close_object
|
||||||
|
# policies
|
||||||
|
json_add_object policies
|
||||||
|
json_add_object ipv4
|
||||||
|
report_policies_v4
|
||||||
|
json_close_object
|
||||||
|
json_add_object ipv6
|
||||||
|
report_policies_v6
|
||||||
|
json_close_object
|
||||||
|
json_close_object
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
json_dump
|
json_dump
|
||||||
|
|
|
@ -175,7 +175,6 @@ stop()
|
||||||
|
|
||||||
config_load mwan3
|
config_load mwan3
|
||||||
config_foreach mwan3_track_clean interface
|
config_foreach mwan3_track_clean interface
|
||||||
config_foreach mwan3_online_metric_clean interface
|
|
||||||
|
|
||||||
for IP in "$IP4" "$IP6"; do
|
for IP in "$IP4" "$IP6"; do
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue