From 8d4e202fa4aa7c3a549472ead942c976e218dd31 Mon Sep 17 00:00:00 2001 From: Aaron Goodman Date: Sat, 24 Oct 2020 12:53:15 -0400 Subject: mwan3: fix mwan3 route handling - support trailing route space from iproute2 - add routes even when iface is down - fix source_routing argument check - add quotes in logging to better detect issues with trailing spaces Signed-off-by: Aaron Goodman --- net/mwan3/files/usr/sbin/mwan3rtmon | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'net/mwan3') diff --git a/net/mwan3/files/usr/sbin/mwan3rtmon b/net/mwan3/files/usr/sbin/mwan3rtmon index ee470837e..569b4d172 100755 --- a/net/mwan3/files/usr/sbin/mwan3rtmon +++ b/net/mwan3/files/usr/sbin/mwan3rtmon @@ -74,7 +74,7 @@ mwan3_rtmon_route_handle() route_line=${1##"Deleted "} route_family=$2 - config_get_boolean source_routing globals source_routing 0 + config_get_bool source_routing globals source_routing 0 [ $source_routing -eq 0 ] && unset source_routing if [ "$route_line" = "$1" ]; then @@ -107,22 +107,22 @@ mwan3_rtmon_route_handle() local iface=$1 tbl=$($IP route list table $tid 2>/dev/null)$'\n' - if [ "$(cat /var/run/mwan3track/$iface/STATUS)" != "online" ]; then - LOG debug "interface $iface is offline - skipping $route_line"; + if [ -n "$iface" ] && [ "$(mwan3_get_mwan3track_status $iface)" != "active" ]; then + LOG debug "interface $iface is disabled - skipping '$route_line'"; return fi # check that action needs to be performed. May not need to take action if we # got a delete event, but table was already flushed if [ $action = "del" ] && [ -n "${tbl##*$route_line$'\n'*}" ]; then - LOG debug "skipping already deleted route table $tid - skipping $route_line" + LOG debug "skipping already deleted route table $tid - skipping '$route_line'" return fi network_get_device device "$iface" - LOG debug "adjusting route $device: $IP route $action table $tid $route_line" + LOG debug "adjusting route $device: '$IP route $action table $tid $route_line'" $IP route "$action" table $tid $route_line || - LOG warn "failed: $IP route $action table $tid $route_line" + LOG warn "failed: '$IP route $action table $tid $route_line'" } handle_route_cb(){ local iface=$1 @@ -163,9 +163,9 @@ main() sh -c "echo \$\$; exec $IP monitor route" | { read -r monitor_pid trap_with_arg func_trap "$monitor_pid" SIGINT SIGTERM SIGKILL - while read -r line; do + while IFS='' read -r line; do [ -z "${line##*table*}" ] && continue - LOG debug "handling route update $family $line" + LOG debug "handling route update $family '$line'" mwan3_lock "service" "mwan3rtmon" mwan3_rtmon_route_handle "$line" "$family" mwan3_unlock "service" "mwan3rtmon" -- cgit v1.2.3