Browse Source

mwan3: update to version 1.5-7

Fixed issue where an manual ifup-ed interface would immediatly go down again
Remove from init as mwan3 is not a service

Signed-off-by: Jeroen Louwes <jeroen.louwes@gmail.com>
lilik-openwrt-22.03
Adze1502 10 years ago
parent
commit
e1c07f13cc
4 changed files with 44 additions and 53 deletions
  1. +1
    -6
      net/mwan3/Makefile
  2. +21
    -13
      net/mwan3/files/etc/hotplug.d/iface/15-mwan3
  3. +0
    -19
      net/mwan3/files/etc/init.d/mwan3
  4. +22
    -15
      net/mwan3/files/usr/sbin/mwan3

+ 1
- 6
net/mwan3/Makefile View File

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=mwan3
PKG_VERSION:=1.5
PKG_RELEASE:=6
PKG_RELEASE:=7
PKG_MAINTAINER:=Jeroen Louwes <jeroen.louwes@gmail.com>
PKG_LICENSE:=GPLv2
@ -42,9 +42,4 @@ define Package/mwan3/install
$(CP) ./files/* $(1)
endef
define Package/mwan3/postinst
[ -n "$${IPKG_INSTROOT}" ] || /etc/init.d/mwan3 enable
exit 0
endef
$(eval $(call BuildPackage,mwan3))

+ 21
- 13
net/mwan3/files/etc/hotplug.d/iface/15-mwan3 View File

@ -49,6 +49,17 @@ mwan3_set_general_iptables()
$IPT -F mwan3_rules
}
mwan3_set_general_rules()
{
if [ -z "$($IP rule list | awk '$1 == "2253:"')" ]; then
$IP rule add pref 2253 fwmark 0xfd00/0xff00 blackhole
fi
if [ -z "$($IP rule list | awk '$1 == "2254:"')" ]; then
$IP rule add pref 2254 fwmark 0xfe00/0xff00 unreachable
fi
}
mwan3_set_connected_iptables()
{
local connected_networks
@ -112,18 +123,8 @@ mwan3_set_iface_rules()
$IP rule del pref $(($iface_id+2000))
done
while [ -n "$($IP rule list | awk '$1 == "2253:"')" ]; do
$IP rule del pref 2253
done
while [ -n "$($IP rule list | awk '$1 == "2254:"')" ]; do
$IP rule del pref 2254
done
[ $ACTION == "ifup" ] && $IP rule add pref $(($iface_id+1000)) iif $DEVICE lookup main
[ $ACTION == "ifup" ] && $IP rule add pref $(($iface_id+2000)) fwmark $(($iface_id*256))/0xff00 lookup $iface_id
$IP rule add pref 2253 fwmark 0xfd00/0xff00 blackhole
$IP rule add pref 2254 fwmark 0xfe00/0xff00 unreachable
}
mwan3_track()
@ -136,6 +137,11 @@ mwan3_track()
}
config_list_foreach $INTERFACE track_ip mwan3_list_track_ips
if [ -e /var/run/mwan3track-$INTERFACE.pid ] ; then
kill $(cat /var/run/mwan3track-$INTERFACE.pid) &> /dev/null
rm /var/run/mwan3track-$INTERFACE.pid &> /dev/null
fi
if [ -n "$track_ips" ]; then
config_get reliability $INTERFACE reliability 1
config_get count $INTERFACE count 1
@ -299,7 +305,7 @@ mwan3_ifupdown()
sleep 1
let counter++
if [ "$counter" -ge 10 ]; then
$LOG warn "Could not find gateway for interface $INTERFACE (${DEVICE:-unknown})" && return 0
$LOG warn "Could not find gateway for interface $INTERFACE ($DEVICE)" && return 0
fi
done
@ -318,6 +324,7 @@ mwan3_ifupdown()
$LOG notice "$ACTION interface $INTERFACE (${DEVICE:-unknown})"
mwan3_set_general_iptables
mwan3_set_general_rules
mwan3_set_iface_iptables
mwan3_set_iface_route
mwan3_set_iface_rules
@ -328,14 +335,15 @@ mwan3_ifupdown()
config_foreach mwan3_set_user_rules_iptables rule
}
local IP IPT LOG
[ -n "$ACTION" ] || exit 0
[ -n "$INTERFACE" ] || exit 0
if [ $ACTION == "ifup" ]; then
[ -n "$DEVICE" ] || exit 0
fi
local IP IPT LOG
IP="/usr/sbin/ip -4"
IPT="/usr/sbin/iptables -t mangle -w"
LOG="/usr/bin/logger -t mwan3 -p"


+ 0
- 19
net/mwan3/files/etc/init.d/mwan3 View File

@ -1,19 +0,0 @@
#!/bin/sh /etc/rc.common
START=99
start() {
/usr/sbin/mwan3 start
}
stop() {
/usr/sbin/mwan3 stop
}
restart() {
stop
start
}
boot() {
return 0
}

+ 22
- 15
net/mwan3/files/usr/sbin/mwan3 View File

@ -1,24 +1,28 @@
#!/bin/sh /etc/rc.common
#!/bin/sh
. /lib/functions.sh
. /lib/network/config.sh
IP="/usr/sbin/ip -4"
IPT="/usr/sbin/iptables -t mangle -w"
extra_help() {
cat <<EOF
help()
{
cat <<EOF
Syntax: mwan3 [command]
Available commands:
start Load iptables rules, ip rules and ip routes
stop Unload iptables rules, ip rules and ip routes
restart Reload iptables rules, ip rules and ip routes
ifup <iface> Load rules and routes for specific interface
ifdown <iface> Unload rules and routes for specific interface
interfaces Show interfaces status
policies Show policies status
rules Show rules status
status Show all status
ifup <iface> Start service on interface
ifdown <iface> Stop service on interface
interfaces Show interfaces status
policies Show policies status
rules Show rules status
status Show all status
EOF
}
EXTRA_COMMANDS="ifdown ifup interfaces policies rules status"
EXTRA_HELP="$(extra_help)"
IP="/usr/sbin/ip -4"
IPT="/usr/sbin/iptables -t mangle -w"
ifdown()
{
if [ -z "$1" ]; then
@ -197,3 +201,6 @@ restart() {
stop
start
}
action=${1:-help}
$action

Loading…
Cancel
Save