Browse Source

Merge pull request #4353 from TDT-GmbH/mwan3-fixes

Mwan3 fixes
lilik-openwrt-22.03
champtar 8 years ago
committed by GitHub
parent
commit
c421c797bf
6 changed files with 26 additions and 52 deletions
  1. +1
    -1
      net/mwan3/Makefile
  2. +0
    -6
      net/mwan3/files/etc/hotplug.d/iface/15-mwan3
  3. +12
    -20
      net/mwan3/files/lib/mwan3/mwan3.sh
  4. +7
    -11
      net/mwan3/files/usr/libexec/rpcd/mwan3
  5. +1
    -9
      net/mwan3/files/usr/sbin/mwan3
  6. +5
    -5
      net/mwan3/files/usr/sbin/mwan3track

+ 1
- 1
net/mwan3/Makefile View File

@ -8,7 +8,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=mwan3
PKG_VERSION:=2.5.1
PKG_VERSION:=2.5.2
PKG_RELEASE:=5
PKG_MAINTAINER:=Florian Eckert <fe@dev.tdt.de>
PKG_LICENSE:=GPLv2


+ 0
- 6
net/mwan3/files/etc/hotplug.d/iface/15-mwan3 View File

@ -11,12 +11,6 @@ if [ "$ACTION" == "ifup" ]; then
[ -n "$DEVICE" ] || exit 3
fi
[ -x /usr/bin/ip ] || exit 4
[ -x /usr/sbin/ipset ] || exit 5
[ -x /usr/sbin/iptables ] || exit 6
[ -x /usr/sbin/ip6tables ] || exit 7
[ -x /usr/bin/logger ] || exit 8
mwan3_set_connected_iptables
config_load mwan3


+ 12
- 20
net/mwan3/files/lib/mwan3/mwan3.sh View File

@ -1,11 +1,11 @@
#!/bin/sh
IP4="/usr/bin/ip -4"
IP6="/usr/bin/ip -6"
IPS="/usr/sbin/ipset"
IPT4="/usr/sbin/iptables -t mangle -w"
IPT6="/usr/sbin/ip6tables -t mangle -w"
LOG="/usr/bin/logger -t mwan3 -p"
IP4="ip -4"
IP6="ip -6"
IPS="ipset"
IPT4="iptables -t mangle -w"
IPT6="ip6tables -t mangle -w"
LOG="logger -t mwan3 -p"
CONNTRACK_FILE="/proc/net/nf_conntrack"
mwan3_get_iface_id()
@ -390,10 +390,7 @@ mwan3_track()
}
config_list_foreach $1 track_ip mwan3_list_track_ips
if [ -e /var/run/mwan3track-$1.pid ] ; then
kill $(cat /var/run/mwan3track-$1.pid) &> /dev/null
fi
kill $(pgrep -f "mwan3track $1") &> /dev/null
if [ -n "$track_ips" ]; then
[ -x /usr/sbin/mwan3track ] && /usr/sbin/mwan3track $1 $2 $track_ips &
fi
@ -401,18 +398,13 @@ mwan3_track()
mwan3_track_signal()
{
local pid status
local pid
if [ -f "/var/run/mwan3track-${1}.pid" ]; then
pid="$(cat "/var/run/mwan3track-${1}.pid")"
status="$(pgrep -f mwan3track | grep "${pid}")"
if [ "${status}" != "" ]; then
kill -USR1 "${pid}"
else
$LOG warn "Unable to send signal USR1 to mwan3track on interface $1 with pid ${pid}"
fi
pid="$(pgrep -f "mwan3track $1")"
if [ "${pid}" != "" ]; then
kill -USR1 "${pid}"
else
$LOG warn "Unable to find \"/var/run/mwan3track-${1}.pid\" file for mwan3track on interface $1"
$LOG warn "Unable to send signal USR1 to mwan3track on interface $1 with pid ${pid}"
fi
}


+ 7
- 11
net/mwan3/files/usr/libexec/rpcd/mwan3 View File

@ -6,9 +6,9 @@
MWAN3_STATUS_DIR="/var/run/mwan3track"
MWAN3_PID_FILE="/var/run/mwan3track"
IPS="/usr/sbin/ipset"
IPT4="/usr/sbin/iptables -t mangle -w"
IPT6="/usr/sbin/ip6tables -t mangle -w"
IPS="ipset"
IPT4="iptables -t mangle -w"
IPT6="ip6tables -t mangle -w"
report_connected_v4() {
local address
@ -34,16 +34,12 @@ get_mwan3_status() {
local iface="${1}"
local iface_select="${2}"
local running="0"
local pid=""
local status=""
local pid
if [ "${iface}" = "${iface_select}" ] || [ "${iface_select}" = "" ]; then
if [ -f "${MWAN3_PID_FILE}-${iface}.pid" ]; then
pid="$(cat "${MWAN3_PID_FILE}-${iface}.pid")"
status="$(pgrep -f mwan3track | grep "${pid}")"
if [ "${status}" != "" ]; then
running="1"
fi
pid="$(pgrep -f "mwan3track $iface_selected")"
if [ "${pid}" != "" ]; then
running="1"
fi
json_add_object "${iface}"


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

@ -1,11 +1,5 @@
#!/bin/sh
[ -x /usr/bin/ip ] || exit 4
[ -x /usr/sbin/ipset ] || exit 5
[ -x /usr/sbin/iptables ] || exit 6
[ -x /usr/sbin/ip6tables ] || exit 7
[ -x /usr/bin/logger ] || exit 8
. /lib/functions.sh
. /lib/functions/network.sh
. /lib/mwan3/mwan3.sh
@ -42,9 +36,7 @@ ifdown()
ACTION=ifdown INTERFACE=$1 /sbin/hotplug-call iface
if [ -e /var/run/mwan3track-$1.pid ] ; then
kill $(cat /var/run/mwan3track-$1.pid)
fi
kill $(pgrep -f "mwan3track $1") &> /dev/null
}
ifup()


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

@ -2,7 +2,7 @@
. /lib/functions.sh
LOG="/usr/bin/logger -t $(basename "$0")[$$] -p"
LOG="logger -t $(basename "$0")[$$] -p"
INTERFACE=""
DEVICE=""
@ -10,8 +10,9 @@ IFDOWN_EVENT=0
clean_up() {
$LOG notice "Stopping mwan3track for interface \"${INTERFACE}\""
rm "/var/run/mwan3track-${INTERFACE}.pid" &> /dev/null
rm -rf "/var/run/mwan3track/${INTERFACE}" &> /dev/null
if [ "$(pgrep -f "mwan3track ${INTERFACE}")" = "" ]; then
rm -rf "/var/run/mwan3track/${INTERFACE}" &> /dev/null
fi
if [ -z "$(ls -A "/var/run/mwan3track")" ]; then
rm -rf "/var/run/mwan3track"
fi
@ -31,7 +32,6 @@ main() {
INTERFACE=$1
DEVICE=$2
echo "$$" > /var/run/mwan3track-$1.pid
mkdir -p /var/run/mwan3track/$1
trap clean_up SIGINT SIGTERM
trap if_down SIGUSR1
@ -103,13 +103,13 @@ main() {
if [ $score -eq $up ]; then
$LOG notice "Interface $1 ($2) is online"
env -i ACTION=ifup INTERFACE=$1 DEVICE=$2 /sbin/hotplug-call iface
rm /var/run/mwan3track-$1.pid
rm -rf "/var/run/mwan3track/${1}" &> /dev/null
exit 0
fi
fi
let turn++
mkdir -p "/var/run/mwan3track/${1}"
echo "${lost}" > /var/run/mwan3track/$1/LOST
echo "${score}" > /var/run/mwan3track/$1/SCORE
echo "${turn}" > /var/run/mwan3track/$1/TURN


Loading…
Cancel
Save