Browse Source

net/mwan3: move mwan3track clean up to mwan3 cmd

This is usefull to see the last state of the interface with ubus.

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

+ 16
- 0
net/mwan3/files/lib/mwan3/mwan3.sh View File

@ -8,6 +8,8 @@ IPT6="ip6tables -t mangle -w"
LOG="logger -t mwan3[$$] -p" LOG="logger -t mwan3[$$] -p"
CONNTRACK_FILE="/proc/net/nf_conntrack" CONNTRACK_FILE="/proc/net/nf_conntrack"
MWAN3_STATUS_DIR="/var/run/mwan3track"
# mwan3's MARKing mask (at least 3 bits should be set) # mwan3's MARKing mask (at least 3 bits should be set)
MMX_MASK=0xff00 MMX_MASK=0xff00
@ -65,6 +67,10 @@ mwan3_unlock() {
lock -u /var/run/mwan3.lock lock -u /var/run/mwan3.lock
} }
mwan3_lock_clean() {
rm -rf /var/run/mwan3.lock
}
mwan3_get_iface_id() mwan3_get_iface_id()
{ {
local _tmp _iface _iface_count local _tmp _iface _iface_count
@ -919,3 +925,13 @@ mwan3_flush_conntrack()
$LOG warning "connection tracking not enabled" $LOG warning "connection tracking not enabled"
fi fi
} }
mwan3_track_clean()
{
rm -rf "$MWAN3_STATUS_DIR/${1}" &> /dev/null
[ -d "$MWAN3_STATUS_DIR" ] && {
if [ -z "$(ls -A "$MWAN3_STATUS_DIR")" ]; then
rm -rf "$MWAN3_STATUS_DIR"
fi
}
}

+ 6
- 0
net/mwan3/files/usr/sbin/mwan3 View File

@ -37,6 +37,7 @@ ifdown()
ACTION=ifdown INTERFACE=$1 /sbin/hotplug-call iface ACTION=ifdown INTERFACE=$1 /sbin/hotplug-call iface
kill $(pgrep -f "mwan3track $1 $2") &> /dev/null kill $(pgrep -f "mwan3track $1 $2") &> /dev/null
mwan3_track_clean $1
} }
ifup() ifup()
@ -121,6 +122,9 @@ stop()
killall mwan3track &> /dev/null killall mwan3track &> /dev/null
config_load mwan3
config_foreach mwan3_track_clean interface
for IP in "$IP4" "$IP6"; do for IP in "$IP4" "$IP6"; do
for route in $($IP route list table all | sed 's/.*table \([^ ]*\) .*/\1/' | awk '{print $1}' | awk '{for(i=1;i<=NF;i++) if($i+0>0) if($i+0<255) {print;break}}'); do for route in $($IP route list table all | sed 's/.*table \([^ ]*\) .*/\1/' | awk '{print $1}' | awk '{for(i=1;i<=NF;i++) if($i+0>0) if($i+0<255) {print;break}}'); do
@ -153,6 +157,8 @@ stop()
for ipset in $($IPS -n list | grep mwan3 | grep -E '_v4|_v6'); do for ipset in $($IPS -n list | grep mwan3 | grep -E '_v4|_v6'); do
$IPS -q destroy $ipset $IPS -q destroy $ipset
done done
mwan3_lock_clean
} }
restart() { restart() {


+ 0
- 7
net/mwan3/files/usr/sbin/mwan3track View File

@ -10,12 +10,6 @@ IFDOWN_EVENT=0
clean_up() { clean_up() {
$LOG notice "Stopping mwan3track for interface \"${INTERFACE}\"" $LOG notice "Stopping mwan3track for interface \"${INTERFACE}\""
if [ "$(pgrep -f "mwan3track ${INTERFACE} ${DEVICE}")" = "" ]; then
rm -rf "/var/run/mwan3track/${INTERFACE}" &> /dev/null
fi
if [ -z "$(ls -A "/var/run/mwan3track")" ]; then
rm -rf "/var/run/mwan3track"
fi
exit 0 exit 0
} }
@ -144,7 +138,6 @@ main() {
if [ $score -eq $up ]; then if [ $score -eq $up ]; then
$LOG notice "Interface $1 ($2) is online" $LOG notice "Interface $1 ($2) is online"
env -i ACTION=ifup INTERFACE=$1 DEVICE=$2 /sbin/hotplug-call iface env -i ACTION=ifup INTERFACE=$1 DEVICE=$2 /sbin/hotplug-call iface
rm -rf "/var/run/mwan3track/${1}" &> /dev/null
exit 0 exit 0
fi fi
fi fi


Loading…
Cancel
Save