From 822bc96b7cb972e07e92647f11dfe01579d67ed7 Mon Sep 17 00:00:00 2001 From: Florian Eckert Date: Thu, 22 Jun 2017 11:48:01 +0200 Subject: [PATCH] net/mwan3: add lock for mwan3 hotplug script If more then one interface get up/down at once mwan3 could be in a undefined state, because more then one mwan3 hotplug script are running and editing the iptables. Lock the critical section should solve this issue. Signed-off-by: Florian Eckert (cherry picked from commit b6e9debc1b97f9e4be70fb51404831ed870d844a) --- net/mwan3/files/etc/hotplug.d/iface/15-mwan3 | 3 +++ net/mwan3/files/lib/mwan3/mwan3.sh | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/net/mwan3/files/etc/hotplug.d/iface/15-mwan3 b/net/mwan3/files/etc/hotplug.d/iface/15-mwan3 index 51bba594f2..ae18f529f1 100644 --- a/net/mwan3/files/etc/hotplug.d/iface/15-mwan3 +++ b/net/mwan3/files/etc/hotplug.d/iface/15-mwan3 @@ -35,6 +35,7 @@ if [ "$ACTION" == "ifup" ]; then [ -n "$gateway" ] || exit 9 fi +mwan3_lock $LOG notice "$ACTION interface $INTERFACE (${DEVICE:-unknown})" case "$ACTION" in @@ -58,4 +59,6 @@ case "$ACTION" in ;; esac +mwan3_unlock + exit 0 diff --git a/net/mwan3/files/lib/mwan3/mwan3.sh b/net/mwan3/files/lib/mwan3/mwan3.sh index 1e1de969fa..eae69b7293 100644 --- a/net/mwan3/files/lib/mwan3/mwan3.sh +++ b/net/mwan3/files/lib/mwan3/mwan3.sh @@ -7,6 +7,14 @@ IPT4="/usr/sbin/iptables -t mangle -w" IPT6="/usr/sbin/ip6tables -t mangle -w" LOG="/usr/bin/logger -t mwan3 -p" +mwan3_lock() { + lock /var/run/mwan3.lock +} + +mwan3_unlock() { + lock -u /var/run/mwan3.lock +} + mwan3_get_iface_id() { local _tmp _iface _iface_count -- 2.30.2