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>
This commit is contained in:
Adze1502 2014-10-02 09:57:50 +02:00
parent 26b38b7dda
commit e1c07f13cc
4 changed files with 46 additions and 55 deletions

View file

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

View file

@ -49,6 +49,17 @@ mwan3_set_general_iptables()
$IPT -F mwan3_rules $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() mwan3_set_connected_iptables()
{ {
local connected_networks local connected_networks
@ -112,18 +123,8 @@ mwan3_set_iface_rules()
$IP rule del pref $(($iface_id+2000)) $IP rule del pref $(($iface_id+2000))
done 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+1000)) iif $DEVICE lookup main
[ $ACTION == "ifup" ] && $IP rule add pref $(($iface_id+2000)) fwmark $(($iface_id*256))/0xff00 lookup $iface_id [ $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() mwan3_track()
@ -136,6 +137,11 @@ mwan3_track()
} }
config_list_foreach $INTERFACE track_ip mwan3_list_track_ips 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 if [ -n "$track_ips" ]; then
config_get reliability $INTERFACE reliability 1 config_get reliability $INTERFACE reliability 1
config_get count $INTERFACE count 1 config_get count $INTERFACE count 1
@ -299,7 +305,7 @@ mwan3_ifupdown()
sleep 1 sleep 1
let counter++ let counter++
if [ "$counter" -ge 10 ]; then 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 fi
done done
@ -318,6 +324,7 @@ mwan3_ifupdown()
$LOG notice "$ACTION interface $INTERFACE (${DEVICE:-unknown})" $LOG notice "$ACTION interface $INTERFACE (${DEVICE:-unknown})"
mwan3_set_general_iptables mwan3_set_general_iptables
mwan3_set_general_rules
mwan3_set_iface_iptables mwan3_set_iface_iptables
mwan3_set_iface_route mwan3_set_iface_route
mwan3_set_iface_rules mwan3_set_iface_rules
@ -328,14 +335,15 @@ mwan3_ifupdown()
config_foreach mwan3_set_user_rules_iptables rule config_foreach mwan3_set_user_rules_iptables rule
} }
local IP IPT LOG [ -n "$ACTION" ] || exit 0
[ -n "$INTERFACE" ] || exit 0 [ -n "$INTERFACE" ] || exit 0
if [ $ACTION == "ifup" ]; then if [ $ACTION == "ifup" ]; then
[ -n "$DEVICE" ] || exit 0 [ -n "$DEVICE" ] || exit 0
fi fi
local IP IPT LOG
IP="/usr/sbin/ip -4" IP="/usr/sbin/ip -4"
IPT="/usr/sbin/iptables -t mangle -w" IPT="/usr/sbin/iptables -t mangle -w"
LOG="/usr/bin/logger -t mwan3 -p" LOG="/usr/bin/logger -t mwan3 -p"

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
}

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() { help()
{
cat <<EOF cat <<EOF
Syntax: mwan3 [command]
ifup <iface> Start service on interface Available commands:
ifdown <iface> Stop service on interface 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 interfaces Show interfaces status
policies Show policies status policies Show policies status
rules Show rules status rules Show rules status
status Show all status status Show all status
EOF 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() ifdown()
{ {
if [ -z "$1" ]; then if [ -z "$1" ]; then
@ -197,3 +201,6 @@ restart() {
stop stop
start start
} }
action=${1:-help}
$action