aboutsummaryrefslogtreecommitdiff
path: root/net/mwan3/files
diff options
context:
space:
mode:
authorFlorian Eckert <fe@dev.tdt.de>2020-07-14 12:02:01 +0200
committerFlorian Eckert <fe@dev.tdt.de>2020-07-15 10:23:47 +0200
commitd0c248a7dab92c81e348a31cf35c2e972f26ca39 (patch)
tree2fd724d14a57ddcc74bb017e0f65af88ec26d3fd /net/mwan3/files
parentfeae9e57423897e14dfb9f45f2defb97f480a731 (diff)
mwan3: cleanup function mwan3_create_iface_route
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
Diffstat (limited to 'net/mwan3/files')
-rw-r--r--net/mwan3/files/lib/mwan3/mwan3.sh54
1 files changed, 21 insertions, 33 deletions
diff --git a/net/mwan3/files/lib/mwan3/mwan3.sh b/net/mwan3/files/lib/mwan3/mwan3.sh
index fd9f9fc41..5ffef9405 100644
--- a/net/mwan3/files/lib/mwan3/mwan3.sh
+++ b/net/mwan3/files/lib/mwan3/mwan3.sh
@@ -483,56 +483,44 @@ mwan3_delete_iface_iptables()
mwan3_create_iface_route()
{
- local id route_args metric
+ local id via metric
- config_get family $1 family ipv4
- mwan3_get_iface_id id $1
+ config_get family "$1" family ipv4
+ mwan3_get_iface_id id "$1"
[ -n "$id" ] || return 0
if [ "$family" = "ipv4" ]; 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
-
- if [ -n "$route_args" -a "$route_args" != "0.0.0.0" ]; then
- route_args="via $route_args"
+ if ubus call "network.interface.${1}_4" status &>/dev/null; then
+ network_get_gateway via "${1}_4"
else
- route_args=""
+ network_get_gateway via "$1"
fi
- network_get_metric metric $1
- if [ -n "$metric" -a "$metric" != "0" ]; then
- route_args="$route_args metric $metric"
- fi
+ network_get_metric metric "$1"
- $IP4 route flush table $id
- $IP4 route add table $id default $route_args dev $2
+ $IP4 route flush table "$id"
+ $IP4 route add table "$id" default \
+ ${via:+via} $via \
+ ${metric:+metric} $metric \
+ dev "$2"
mwan3_rtmon_ipv4
fi
if [ "$family" = "ipv6" ]; 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
-
- if [ -n "$route_args" -a "$route_args" != "::" ]; then
- route_args="via $route_args"
+ if ubus call "network.interface.${1}_6" status &>/dev/null; then
+ network_get_gateway6 via "${1}_6"
else
- route_args=""
+ network_get_gateway6 via "$1"
fi
- network_get_metric metric $1
- if [ -n "$metric" -a "$metric" != "0" ]; then
- route_args="$route_args metric $metric"
- fi
+ network_get_metric metric "$1"
- $IP6 route flush table $id
- $IP6 route add table $id default $route_args dev $2
+ $IP6 route flush table "$id"
+ $IP6 route add table "$id" default \
+ ${via:+via} $via \
+ ${metric:+metric} $metric \
+ dev "$2"
mwan3_rtmon_ipv6
fi
}