LOG debug "Max interface count is ${MWAN3_INTERFACE_MAX}"
fi
+ # remove "linkdown", expiry and source based routing modifiers from route lines
+ MWAN3_ROUTE_LINE_EXP="s/linkdown //; s/expires [0-9]\+sec//;s/error [0-9]\+//; ${source_routing:+s/default\(.*\) from [^ ]*/default\1/;} p"
+
# mark mask constants
bitcnt=$(mwan3_count_one_bits MMX_MASK)
mmdefault=$(((1<<bitcnt)-1))
local source_routing
config_get_bool source_routing globals source_routing 0
[ $source_routing -eq 0 ] && unset source_routing
- $IP route list table main | sed -ne "/^linkdown/T; s/expires \([0-9]\+\)sec//;s/error [0-9]\+//; ${source_routing:+s/default\(.*\) from [^ ]*/default\1/;} p" | uniq
+ $IP route list table main | sed -ne "$MWAN3_ROUTE_LINE_EXP" | uniq
}
mwan3_create_iface_route()
mwan3_rtmon_route_handle()
{
- local action route_line family tbl device line route_line_exp tid source_routing
+ local action route_line family tbl device line tid source_routing
route_line=${1##"Deleted "}
route_family=$2
if [ "$route_line" = "$1" ]; then
action="replace"
- route_line_exp="s/expires \([0-9]\+\)sec//;s/error [0-9]\+//; ${source_routing:+s/default\(.*\) from [^ ]*/default\1/}"
$IPS -! add mwan3_connected_${route_family##ip} ${route_line%% *}
else
action="del"
- route_line_exp="s/expires [0-9]\+sec//;s/error [0-9]\+//; ${source_routing:+s/default\(.*\) from [^ ]*/default\1/}"
mwan3_set_connected_${route_family}
fi
+ if [ -z "${route_line##*linkdown*}" ]; then
+ LOG debug "attempting to add link on down interface - $route_line"
+ fi
+
if [ "$route_family" = "ipv4" ]; then
IP="$IP4"
elif [ "$route_family" = "ipv6" ] && [ $NO_IPV6 -eq 0 ]; then
IP="$IP6"
- route_line=$(echo "$route_line" | sed "$route_line_exp")
else
LOG warn "route update called with invalid family - $route_family"
return
fi
-
- # don't try to add routes when link has gone down
- if [ -z "${route_line##linkdown*}" ]; then
- LOG debug "not adding route due to linkdown - skipping $route_line"
- return
- fi
+ route_line=$(echo "$route_line" | sed -ne "$MWAN3_ROUTE_LINE_EXP")
handle_route() {
local iface=$1