net/mwan3: send SIGKILL to mwan3track

In some situation it is not enough to send a SIGTERM to mwan3track to
ask service to stop accurate. If this does not work send him a SIGKILL
to prevent mwan3track running more then once per interface.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
This commit is contained in:
Florian Eckert 2018-01-31 11:58:38 +01:00
parent f9a787e8df
commit 7cf9d9ec20
3 changed files with 14 additions and 6 deletions

View file

@ -446,7 +446,7 @@ mwan3_delete_iface_ipset_entries()
mwan3_track() mwan3_track()
{ {
local track_ip track_ips local track_ip track_ips pid
mwan3_list_track_ips() mwan3_list_track_ips()
{ {
@ -454,7 +454,11 @@ mwan3_track()
} }
config_list_foreach $1 track_ip mwan3_list_track_ips config_list_foreach $1 track_ip mwan3_list_track_ips
kill $(pgrep -f "mwan3track $1 $2") &> /dev/null for pid in $(pgrep -f "mwan3track $1 $2"); do
kill -TERM "$pid" > /dev/null 2>&1
sleep 1
kill -KILL "$pid" > /dev/null 2>&1
done
if [ -n "$track_ips" ]; then if [ -n "$track_ips" ]; then
[ -x /usr/sbin/mwan3track ] && /usr/sbin/mwan3track "$1" "$2" "$3" "$4" $track_ips & [ -x /usr/sbin/mwan3track ] && /usr/sbin/mwan3track "$1" "$2" "$3" "$4" $track_ips &
fi fi

View file

@ -132,9 +132,13 @@ start()
stop() stop()
{ {
local ipset route rule table IP IPT local ipset route rule table IP IPT pid
killall mwan3track &> /dev/null for pid in $(pgrep -f "mwan3track"); do
kill -TERM "$pid" > /dev/null 2>&1
sleep 1
kill -KILL "$pid" > /dev/null 2>&1
done
config_load mwan3 config_load mwan3
config_foreach mwan3_track_clean interface config_foreach mwan3_track_clean interface

View file

@ -62,8 +62,8 @@ main() {
STATUS=$3 STATUS=$3
SRC_IP=$4 SRC_IP=$4
mkdir -p /var/run/mwan3track/$1 mkdir -p /var/run/mwan3track/$1
trap clean_up SIGINT SIGTERM trap clean_up TERM
trap if_down SIGUSR1 trap if_down USR1
config_load mwan3 config_load mwan3
config_get track_method $1 track_method ping config_get track_method $1 track_method ping