This is usefull to see the last state of the interface with ubus.
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
LOG="logger -t mwan3[$$] -p"
CONNTRACK_FILE="/proc/net/nf_conntrack"
+MWAN3_STATUS_DIR="/var/run/mwan3track"
+
# mwan3's MARKing mask (at least 3 bits should be set)
MMX_MASK=0xff00
lock -u /var/run/mwan3.lock
}
+mwan3_lock_clean() {
+ rm -rf /var/run/mwan3.lock
+}
+
mwan3_get_iface_id()
{
local _tmp _iface _iface_count
$LOG warning "connection tracking not enabled"
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
+ }
+}
ACTION=ifdown INTERFACE=$1 /sbin/hotplug-call iface
kill $(pgrep -f "mwan3track $1 $2") &> /dev/null
+ mwan3_track_clean $1
}
ifup()
killall mwan3track &> /dev/null
+ config_load mwan3
+ config_foreach mwan3_track_clean interface
+
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 ipset in $($IPS -n list | grep mwan3 | grep -E '_v4|_v6'); do
$IPS -q destroy $ipset
done
+
+ mwan3_lock_clean
}
restart() {
clean_up() {
$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
}
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 -rf "/var/run/mwan3track/${1}" &> /dev/null
exit 0
fi
fi