Browse Source

net/mwan3: fix mwan3track kill execution

If two interface have the same prefix "wan" for example "wan" and "wan1"
pgrep returns the PID for wan1 also "pgrep -f mwan3track wan".

Before this fix "wan1" was also killed! This is not what we want.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
lilik-openwrt-22.03
Florian Eckert 7 years ago
parent
commit
0b44ca505b
4 changed files with 10 additions and 7 deletions
  1. +3
    -3
      net/mwan3/files/lib/mwan3/mwan3.sh
  2. +5
    -2
      net/mwan3/files/usr/libexec/rpcd/mwan3
  3. +1
    -1
      net/mwan3/files/usr/sbin/mwan3
  4. +1
    -1
      net/mwan3/files/usr/sbin/mwan3track

+ 3
- 3
net/mwan3/files/lib/mwan3/mwan3.sh View File

@ -449,7 +449,7 @@ mwan3_track()
}
config_list_foreach $1 track_ip mwan3_list_track_ips
kill $(pgrep -f "mwan3track $1") &> /dev/null
kill $(pgrep -f "mwan3track $1 $2") &> /dev/null
if [ -n "$track_ips" ]; then
[ -x /usr/sbin/mwan3track ] && /usr/sbin/mwan3track "$1" "$2" "$3" $track_ips &
fi
@ -459,7 +459,7 @@ mwan3_track_signal()
{
local pid
pid="$(pgrep -f "mwan3track $1")"
pid="$(pgrep -f "mwan3track $1 $2")"
if [ "${pid}" != "" ]; then
kill -USR1 "${pid}"
else
@ -789,7 +789,7 @@ mwan3_report_iface_status()
config_list_foreach $1 track_ip mwan3_list_track_ips
if [ -n "$track_ips" ]; then
if [ -n "$(pgrep -f "mwan3track $1")" ]; then
if [ -n "$(pgrep -f "mwan3track $1 $device")" ]; then
tracking="active"
else
tracking="down"


+ 5
- 2
net/mwan3/files/usr/libexec/rpcd/mwan3 View File

@ -1,6 +1,7 @@
#!/bin/sh
. /lib/functions.sh
. /lib/functions/network.sh
. /usr/share/libubox/jshn.sh
MWAN3_STATUS_DIR="/var/run/mwan3track"
@ -34,10 +35,12 @@ get_mwan3_status() {
local iface="${1}"
local iface_select="${2}"
local running="0"
local pid
local pid device
network_get_device device $1
if [ "${iface}" = "${iface_select}" ] || [ "${iface_select}" = "" ]; then
pid="$(pgrep -f "mwan3track $iface")"
pid="$(pgrep -f "mwan3track $iface $device")"
if [ "${pid}" != "" ]; then
running="1"
fi


+ 1
- 1
net/mwan3/files/usr/sbin/mwan3 View File

@ -36,7 +36,7 @@ ifdown()
ACTION=ifdown INTERFACE=$1 /sbin/hotplug-call iface
kill $(pgrep -f "mwan3track $1") &> /dev/null
kill $(pgrep -f "mwan3track $1 $2") &> /dev/null
}
ifup()


+ 1
- 1
net/mwan3/files/usr/sbin/mwan3track View File

@ -10,7 +10,7 @@ IFDOWN_EVENT=0
clean_up() {
$LOG notice "Stopping mwan3track for interface \"${INTERFACE}\""
if [ "$(pgrep -f "mwan3track ${INTERFACE}")" = "" ]; then
if [ "$(pgrep -f "mwan3track ${INTERFACE} ${DEVICE}")" = "" ]; then
rm -rf "/var/run/mwan3track/${INTERFACE}" &> /dev/null
fi
if [ -z "$(ls -A "/var/run/mwan3track")" ]; then


Loading…
Cancel
Save