From 2d9dfa3b1b16ab3b4c83b24550757931656053d2 Mon Sep 17 00:00:00 2001 From: Florian Eckert Date: Fri, 4 May 2018 15:28:54 +0200 Subject: [PATCH 1/4] net/mwan3: add/remove src_ip from routing table Add or remove local_source ip also if mwan3 is stopped or started Signed-off-by: Florian Eckert --- net/mwan3/files/usr/sbin/mwan3 | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/net/mwan3/files/usr/sbin/mwan3 b/net/mwan3/files/usr/sbin/mwan3 index 5089630ed..681f82de3 100755 --- a/net/mwan3/files/usr/sbin/mwan3 +++ b/net/mwan3/files/usr/sbin/mwan3 @@ -118,7 +118,7 @@ status() start() { - local enabled + local enabled src_ip local_source config_load mwan3 config_get_bool enabled globals 'enabled' 0 @@ -127,12 +127,30 @@ start() exit 0 } + config_get local_source globals local_source 'none' + [ "${local_source}" = "none" ] || { + 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 + } + + 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 + } + config_foreach ifup interface } stop() { - local ipset route rule table IP IPT pid + local ipset route rule table IP IPT pid src_ip for pid in $(pgrep -f "mwan3track"); do kill -TERM "$pid" > /dev/null 2>&1 @@ -178,6 +196,12 @@ stop() mwan3_lock_clean rm -rf $MWAN3_STATUS_DIR $MWAN3TRACK_STATUS_DIR + + 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 + } } restart() { From 215708a415fb58acfee28278570df540603a013d Mon Sep 17 00:00:00 2001 From: Florian Eckert Date: Tue, 8 May 2018 15:42:40 +0200 Subject: [PATCH 2/4] net/mwan3: remove logging mwan3track pid is not found Remove unnecessary logging if mwan3track pid is not found Signed-off-by: Florian Eckert --- net/mwan3/files/lib/mwan3/mwan3.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/net/mwan3/files/lib/mwan3/mwan3.sh b/net/mwan3/files/lib/mwan3/mwan3.sh index 1c371ea65..74d5592eb 100644 --- a/net/mwan3/files/lib/mwan3/mwan3.sh +++ b/net/mwan3/files/lib/mwan3/mwan3.sh @@ -492,11 +492,9 @@ mwan3_track_signal() local pid pid="$(pgrep -f "mwan3track $1 $2")" - if [ "${pid}" != "" ]; then + [ "${pid}" != "" ] && { kill -USR1 "${pid}" - else - $LOG warn "Unable to send signal USR1 to mwan3track on interface $1 with pid ${pid}" - fi + } } mwan3_set_policy() From ab4e62b885488716e6ef905198ce87b2beab29e4 Mon Sep 17 00:00:00 2001 From: Florian Eckert Date: Tue, 8 May 2018 15:43:34 +0200 Subject: [PATCH 3/4] net/mwan3: execute only ifup event if l3_device is found Only execute an ifup event with the command "mwan3 ifup " if the l3_device is found in the ubus "network.interface.". Signed-off-by: Florian Eckert --- net/mwan3/files/usr/sbin/mwan3 | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/net/mwan3/files/usr/sbin/mwan3 b/net/mwan3/files/usr/sbin/mwan3 index 681f82de3..a0c296f18 100755 --- a/net/mwan3/files/usr/sbin/mwan3 +++ b/net/mwan3/files/usr/sbin/mwan3 @@ -1,6 +1,7 @@ #!/bin/sh . /lib/functions.sh +. /usr/share/libubox/jshn.sh . /lib/functions/network.sh . /lib/mwan3/mwan3.sh @@ -42,7 +43,7 @@ ifdown() ifup() { - local device enabled + local device enabled up l3_device config_load mwan3 @@ -60,12 +61,14 @@ ifup() exit 0 } + json_load $(ubus -S call network.interface.$1 status) + json_get_vars up l3_device config_get enabled "$1" enabled 0 - device=$(uci -p /var/state get network.$1.ifname) &> /dev/null - - if [ -n "$device" ] ; then - [ "$enabled" -eq 1 ] && ACTION=ifup INTERFACE=$1 DEVICE=$device /sbin/hotplug-call iface + if [ "$up" -eq 1 ] \ + && [ -n "$l3_device" ] \ + && [ "$enabled" -eq 1 ]; then + ACTION=ifup INTERFACE=$1 DEVICE=$l3_device /sbin/hotplug-call iface fi } From 18022993d9a8e6ee9d6f41193114770d20a8e117 Mon Sep 17 00:00:00 2001 From: Florian Eckert Date: Wed, 16 May 2018 11:24:37 +0200 Subject: [PATCH 4/4] net/mwan3: update version to 2.6.16 Signed-off-by: Florian Eckert --- net/mwan3/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/mwan3/Makefile b/net/mwan3/Makefile index ff082cf75..8d55479eb 100644 --- a/net/mwan3/Makefile +++ b/net/mwan3/Makefile @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=mwan3 -PKG_VERSION:=2.6.15 +PKG_VERSION:=2.6.16 PKG_RELEASE:=1 PKG_MAINTAINER:=Florian Eckert PKG_LICENSE:=GPLv2