mwan3: fix empty gateway when creating routing table

Interfaces of some PtP protocols do not have a real gateway. In that
case ubus may fill them with '0.0.0.0' or even leave it blank. This
will cause error when adding new routing rule.

Signed-off-by: David Yang <mmyangfl@gmail.com>
This commit is contained in:
David Yang
2017-10-28 22:48:38 +08:00
parent 5688f3e65a
commit 6f38affd0c
2 changed files with 13 additions and 9 deletions
+12 -4
View File
@@ -324,10 +324,14 @@ mwan3_create_iface_route()
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
@@ -337,10 +341,14 @@ mwan3_create_iface_route()
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
}