From dd206b7d0bc4a7de739b6dbccbac5b5ffcae9024 Mon Sep 17 00:00:00 2001 From: Florian Eckert Date: Tue, 15 Jan 2019 10:20:02 +0100 Subject: [PATCH 1/4] mwan3: lock critical mwan3rtmon section Signed-off-by: Florian Eckert --- net/mwan3/files/usr/sbin/mwan3rtmon | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/net/mwan3/files/usr/sbin/mwan3rtmon b/net/mwan3/files/usr/sbin/mwan3rtmon index afdc96d1a..f8e6ec081 100755 --- a/net/mwan3/files/usr/sbin/mwan3rtmon +++ b/net/mwan3/files/usr/sbin/mwan3rtmon @@ -23,11 +23,16 @@ main() { config_get rtmon_interval globals rtmon_interval '5' sleep 3 - while mwan3_rtmon_ipv4 || mwan3_rtmon_ipv6; do + while true; do + mwan3_lock + [ mwan3_remon_ipv4 = "1" ] || \ + [ mwan3_rtmon_ipv6 = "1" ] && break + mwan3_unlock [ "$rtmon_interval" = "0" ] && break sleep "$rtmon_interval" & wait done + mwan3_unlock } main "$@" From d167e3718d147a1b4036c5e7c423c932705935e3 Mon Sep 17 00:00:00 2001 From: Florian Eckert Date: Tue, 15 Jan 2019 10:22:21 +0100 Subject: [PATCH 2/4] mwan3: lock critical section on mwan3 down Signed-off-by: Florian Eckert --- net/mwan3/files/usr/sbin/mwan3 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/mwan3/files/usr/sbin/mwan3 b/net/mwan3/files/usr/sbin/mwan3 index 6aee3db0c..fa8f0a4d5 100755 --- a/net/mwan3/files/usr/sbin/mwan3 +++ b/net/mwan3/files/usr/sbin/mwan3 @@ -136,6 +136,8 @@ stop() { local ipset route rule table IP IPT pid + mwan3_lock + for pid in $(pgrep -f "mwan3rtmon"); do kill -TERM "$pid" > /dev/null 2>&1 sleep 1 @@ -184,6 +186,8 @@ stop() $IPS -q destroy $ipset done + mwan3_unlock + mwan3_lock_clean rm -rf $MWAN3_STATUS_DIR $MWAN3TRACK_STATUS_DIR From 2ff9c8ecb7a9745444d0502472c6fc2282d89de2 Mon Sep 17 00:00:00 2001 From: Florian Eckert Date: Tue, 15 Jan 2019 10:24:54 +0100 Subject: [PATCH 3/4] mwan3: add locking debug possibility Signed-off-by: Florian Eckert --- net/mwan3/files/etc/hotplug.d/iface/15-mwan3 | 8 ++++---- net/mwan3/files/etc/hotplug.d/iface/16-mwan3 | 4 ++-- net/mwan3/files/lib/mwan3/mwan3.sh | 2 ++ net/mwan3/files/usr/sbin/mwan3 | 4 ++-- net/mwan3/files/usr/sbin/mwan3rtmon | 6 +++--- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/net/mwan3/files/etc/hotplug.d/iface/15-mwan3 b/net/mwan3/files/etc/hotplug.d/iface/15-mwan3 index 55d0aa20d..65b99c1bd 100644 --- a/net/mwan3/files/etc/hotplug.d/iface/15-mwan3 +++ b/net/mwan3/files/etc/hotplug.d/iface/15-mwan3 @@ -16,11 +16,11 @@ config_load mwan3 config_get_bool enabled globals 'enabled' '0' [ ${enabled} -gt 0 ] || exit 0 -mwan3_lock +mwan3_lock "$ACTION" "$INTERFACE" mwan3_init mwan3_set_connected_iptables mwan3_set_custom_ipset -mwan3_unlock +mwan3_unlock "$ACTION" "$INTERFACE" config_get enabled $INTERFACE enabled 0 config_get initial_state $INTERFACE initial_state "online" @@ -58,7 +58,7 @@ else running=1 fi -mwan3_lock +mwan3_lock "$ACTION" "$INTERFACE" $LOG notice "Execute "$ACTION" event on interface $INTERFACE (${DEVICE:-unknown})" case "$ACTION" in @@ -91,6 +91,6 @@ case "$ACTION" in ;; esac -mwan3_unlock +mwan3_unlock "$ACTION" "$INTERFACE" exit 0 diff --git a/net/mwan3/files/etc/hotplug.d/iface/16-mwan3 b/net/mwan3/files/etc/hotplug.d/iface/16-mwan3 index d2d148baf..15a8ae5f1 100644 --- a/net/mwan3/files/etc/hotplug.d/iface/16-mwan3 +++ b/net/mwan3/files/etc/hotplug.d/iface/16-mwan3 @@ -9,9 +9,9 @@ config_get_bool enabled globals 'enabled' '0' [ ${enabled} -gt 0 ] || exit 0 if [ "$ACTION" == "ifup" ]; then - mwan3_lock + mwan3_lock "$ACTION" "mwan3rtmon" mwan3_rtmon - mwan3_unlock + mwan3_unlock "$ACTION" "mwan3rtmon" fi exit 0 diff --git a/net/mwan3/files/lib/mwan3/mwan3.sh b/net/mwan3/files/lib/mwan3/mwan3.sh index d28ab28e2..a3343739b 100644 --- a/net/mwan3/files/lib/mwan3/mwan3.sh +++ b/net/mwan3/files/lib/mwan3/mwan3.sh @@ -163,9 +163,11 @@ mwan3_init() mwan3_lock() { lock /var/run/mwan3.lock +# $LOG debug "$1 $2 (lock)" } mwan3_unlock() { +# $LOG debug "$1 $2 (unlock)" lock -u /var/run/mwan3.lock } diff --git a/net/mwan3/files/usr/sbin/mwan3 b/net/mwan3/files/usr/sbin/mwan3 index fa8f0a4d5..ef8b851f2 100755 --- a/net/mwan3/files/usr/sbin/mwan3 +++ b/net/mwan3/files/usr/sbin/mwan3 @@ -136,7 +136,7 @@ stop() { local ipset route rule table IP IPT pid - mwan3_lock + mwan3_lock "command" "mwan3" for pid in $(pgrep -f "mwan3rtmon"); do kill -TERM "$pid" > /dev/null 2>&1 @@ -186,7 +186,7 @@ stop() $IPS -q destroy $ipset done - mwan3_unlock + mwan3_unlock "command" "mwan3" mwan3_lock_clean rm -rf $MWAN3_STATUS_DIR $MWAN3TRACK_STATUS_DIR diff --git a/net/mwan3/files/usr/sbin/mwan3rtmon b/net/mwan3/files/usr/sbin/mwan3rtmon index f8e6ec081..f68c298cd 100755 --- a/net/mwan3/files/usr/sbin/mwan3rtmon +++ b/net/mwan3/files/usr/sbin/mwan3rtmon @@ -24,15 +24,15 @@ main() { sleep 3 while true; do - mwan3_lock + mwan3_lock "service" "mwan3rtmon" [ mwan3_remon_ipv4 = "1" ] || \ [ mwan3_rtmon_ipv6 = "1" ] && break - mwan3_unlock + mwan3_unlock "service" "mwan3rtmon" [ "$rtmon_interval" = "0" ] && break sleep "$rtmon_interval" & wait done - mwan3_unlock + mwan3_unlock "service" "mwan3rtmon" } main "$@" From 7b4c075cc2079ca289e4104d5c351bb043e0cb1e Mon Sep 17 00:00:00 2001 From: Florian Eckert Date: Tue, 22 Jan 2019 14:29:34 +0100 Subject: [PATCH 4/4] mwan3: update version to 2.7.10 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 ee1565e9a..5ad3e7e3f 100644 --- a/net/mwan3/Makefile +++ b/net/mwan3/Makefile @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=mwan3 -PKG_VERSION:=2.7.9 +PKG_VERSION:=2.7.10 PKG_RELEASE:=1 PKG_MAINTAINER:=Florian Eckert PKG_LICENSE:=GPLv2