Browse Source

Merge pull request #5777 from TDT-AG/pr/20181316-net-wan3-update

net/wan3: add some enhancements
lilik-openwrt-22.03
Hannu Nyman 7 years ago
committed by GitHub
parent
commit
8e7d633b73
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 5 deletions
  1. +2
    -2
      net/mwan3/Makefile
  2. +5
    -1
      net/mwan3/files/etc/mwan3.user
  3. +9
    -1
      net/mwan3/files/lib/mwan3/mwan3.sh
  4. +1
    -1
      net/mwan3/files/usr/sbin/mwan3
  5. +2
    -0
      net/mwan3/files/usr/sbin/mwan3track

+ 2
- 2
net/mwan3/Makefile View File

@ -8,8 +8,8 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=mwan3
PKG_VERSION:=2.6.10
PKG_RELEASE:=2
PKG_VERSION:=2.6.11
PKG_RELEASE:=1
PKG_MAINTAINER:=Florian Eckert <fe@dev.tdt.de>
PKG_LICENSE:=GPLv2


+ 5
- 1
net/mwan3/files/etc/mwan3.user View File

@ -7,6 +7,10 @@
#
# There are three main environment variables that are passed to this script.
#
# $ACTION Either "ifup" or "ifdown"
# $ACTION
# <ifup> Is called by netifd and mwan3track
# <ifdown> Is called by netifd and mwan3track
# <connected> Is only called by mwan3track if tracking was successful
# <disconnected> Is only called by mwan3track if tracking has failed
# $INTERFACE Name of the interface which went up or down (e.g. "wan" or "wwan")
# $DEVICE Physical device name which interface went up or down (e.g. "eth0" or "wwan0")

+ 9
- 1
net/mwan3/files/lib/mwan3/mwan3.sh View File

@ -10,6 +10,7 @@ CONNTRACK_FILE="/proc/net/nf_conntrack"
MWAN3_STATUS_DIR="/var/run/mwan3"
MWAN3TRACK_STATUS_DIR="/var/run/mwan3track"
MWAN3_INTERFACE_MAX=""
DEFAULT_LOWEST_METRIC=256
MMX_MASK=""
MMX_DEFAULT=""
@ -58,18 +59,25 @@ mwan3_id2mask()
mwan3_init()
{
local bitcnt
local mmdefault mmblackhole mmunreachable
local mmdefault
[ -d $MWAN3_STATUS_DIR ] || mkdir -p $MWAN3_STATUS_DIR/iface_state
# mwan3's MARKing mask (at least 3 bits should be set)
if [ -e "${MWAN3_STATUS_DIR}/mmx_mask" ]; then
MMX_MASK=$(cat "${MWAN3_STATUS_DIR}/mmx_mask")
MWAN3_INTERFACE_MAX=$(uci_get_state mwan3 globals iface_max)
else
config_load mwan3
config_get MMX_MASK globals mmx_mask '0xff00'
echo "$MMX_MASK" > "${MWAN3_STATUS_DIR}/mmx_mask"
$LOG notice "Using firewall mask ${MMX_MASK}"
bitcnt=$(mwan3_count_one_bits MMX_MASK)
mmdefault=$(((1<<bitcnt)-1))
MWAN3_INTERFACE_MAX=$(($mmdefault-3))
uci_toggle_state mwan3 globals iface_max "$MWAN3_INTERFACE_MAX"
$LOG notice "Max interface count is ${MWAN3_INTERFACE_MAX}"
fi
# mark mask constants


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

@ -145,7 +145,7 @@ stop()
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 $(seq 1 $MWAN3_INTERFACE_MAX); do
$IP route flush table $route &> /dev/null
done


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

@ -142,6 +142,7 @@ main() {
echo "offline" > /var/run/mwan3track/$1/STATUS
$LOG notice "Interface $1 ($2) is offline"
env -i ACTION=ifdown INTERFACE=$1 DEVICE=$2 /sbin/hotplug-call iface
env -i ACTION="disconnected" INTERFACE="$1" DEVICE="$2" /sbin/hotplug-call iface
score=0
fi
else
@ -162,6 +163,7 @@ main() {
if [ $score -eq $up ]; then
$LOG notice "Interface $1 ($2) is online"
echo "online" > /var/run/mwan3track/$1/STATUS
env -i ACTION="connected" INTERFACE="$1" DEVICE="$2" /sbin/hotplug-call iface
env -i ACTION=ifup INTERFACE=$1 DEVICE=$2 /sbin/hotplug-call iface
exit 0
fi


Loading…
Cancel
Save