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>
Adze1502 10 years ago
parent
commit
e1c07f13cc

+ 1
- 6
net/mwan3/Makefile View File

9
 
9
 
10
 PKG_NAME:=mwan3
10
 PKG_NAME:=mwan3
11
 PKG_VERSION:=1.5
11
 PKG_VERSION:=1.5
12
-PKG_RELEASE:=6
12
+PKG_RELEASE:=7
13
 PKG_MAINTAINER:=Jeroen Louwes <jeroen.louwes@gmail.com>
13
 PKG_MAINTAINER:=Jeroen Louwes <jeroen.louwes@gmail.com>
14
 PKG_LICENSE:=GPLv2
14
 PKG_LICENSE:=GPLv2
15
 
15
 
42
    $(CP) ./files/* $(1)
42
    $(CP) ./files/* $(1)
43
 endef
43
 endef
44
 
44
 
45
-define Package/mwan3/postinst
46
-   [ -n "$${IPKG_INSTROOT}" ] || /etc/init.d/mwan3 enable
47
-   exit 0
48
-endef
49
-
50
 $(eval $(call BuildPackage,mwan3))
45
 $(eval $(call BuildPackage,mwan3))

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

49
 	$IPT -F mwan3_rules
49
 	$IPT -F mwan3_rules
50
 }
50
 }
51
 
51
 
52
+mwan3_set_general_rules()
53
+{
54
+	if [ -z "$($IP rule list | awk '$1 == "2253:"')" ]; then
55
+		$IP rule add pref 2253 fwmark 0xfd00/0xff00 blackhole
56
+	fi
57
+
58
+	if [ -z "$($IP rule list | awk '$1 == "2254:"')" ]; then
59
+		$IP rule add pref 2254 fwmark 0xfe00/0xff00 unreachable
60
+	fi
61
+}
62
+
52
 mwan3_set_connected_iptables()
63
 mwan3_set_connected_iptables()
53
 {
64
 {
54
 	local connected_networks
65
 	local connected_networks
112
 		$IP rule del pref $(($iface_id+2000))
123
 		$IP rule del pref $(($iface_id+2000))
113
 	done
124
 	done
114
 
125
 
115
-	while [ -n "$($IP rule list | awk '$1 == "2253:"')" ]; do
116
-		$IP rule del pref 2253
117
-	done
118
-
119
-	while [ -n "$($IP rule list | awk '$1 == "2254:"')" ]; do
120
-		$IP rule del pref 2254
121
-	done
122
-
123
 	[ $ACTION == "ifup" ] && $IP rule add pref $(($iface_id+1000)) iif $DEVICE lookup main
126
 	[ $ACTION == "ifup" ] && $IP rule add pref $(($iface_id+1000)) iif $DEVICE lookup main
124
 	[ $ACTION == "ifup" ] && $IP rule add pref $(($iface_id+2000)) fwmark $(($iface_id*256))/0xff00 lookup $iface_id
127
 	[ $ACTION == "ifup" ] && $IP rule add pref $(($iface_id+2000)) fwmark $(($iface_id*256))/0xff00 lookup $iface_id
125
-        $IP rule add pref 2253 fwmark 0xfd00/0xff00 blackhole
126
-        $IP rule add pref 2254 fwmark 0xfe00/0xff00 unreachable
127
 }
128
 }
128
 
129
 
129
 mwan3_track()
130
 mwan3_track()
136
 	}
137
 	}
137
 	config_list_foreach $INTERFACE track_ip mwan3_list_track_ips
138
 	config_list_foreach $INTERFACE track_ip mwan3_list_track_ips
138
 
139
 
140
+	if [ -e /var/run/mwan3track-$INTERFACE.pid ] ; then
141
+		kill $(cat /var/run/mwan3track-$INTERFACE.pid) &> /dev/null
142
+		rm /var/run/mwan3track-$INTERFACE.pid &> /dev/null
143
+	fi
144
+
139
 	if [ -n "$track_ips" ]; then
145
 	if [ -n "$track_ips" ]; then
140
 		config_get reliability $INTERFACE reliability 1
146
 		config_get reliability $INTERFACE reliability 1
141
 		config_get count $INTERFACE count 1
147
 		config_get count $INTERFACE count 1
299
 			sleep 1
305
 			sleep 1
300
 			let counter++
306
 			let counter++
301
 			if [ "$counter" -ge 10 ]; then
307
 			if [ "$counter" -ge 10 ]; then
302
-				$LOG warn "Could not find gateway for interface $INTERFACE (${DEVICE:-unknown})" && return 0
308
+				$LOG warn "Could not find gateway for interface $INTERFACE ($DEVICE)" && return 0
303
 			fi
309
 			fi
304
 		done
310
 		done
305
 
311
 
318
 	$LOG notice "$ACTION interface $INTERFACE (${DEVICE:-unknown})"
324
 	$LOG notice "$ACTION interface $INTERFACE (${DEVICE:-unknown})"
319
 
325
 
320
 	mwan3_set_general_iptables
326
 	mwan3_set_general_iptables
327
+	mwan3_set_general_rules
321
 	mwan3_set_iface_iptables
328
 	mwan3_set_iface_iptables
322
 	mwan3_set_iface_route
329
 	mwan3_set_iface_route
323
 	mwan3_set_iface_rules
330
 	mwan3_set_iface_rules
328
 	config_foreach mwan3_set_user_rules_iptables rule
335
 	config_foreach mwan3_set_user_rules_iptables rule
329
 }
336
 }
330
 
337
 
331
-local IP IPT LOG
332
-
338
+[ -n "$ACTION" ] || exit 0
333
 [ -n "$INTERFACE" ] || exit 0
339
 [ -n "$INTERFACE" ] || exit 0
334
 
340
 
335
 if [ $ACTION == "ifup" ]; then
341
 if [ $ACTION == "ifup" ]; then
336
 	[ -n "$DEVICE" ] || exit 0
342
 	[ -n "$DEVICE" ] || exit 0
337
 fi
343
 fi
338
 
344
 
345
+local IP IPT LOG
346
+
339
 IP="/usr/sbin/ip -4"
347
 IP="/usr/sbin/ip -4"
340
 IPT="/usr/sbin/iptables -t mangle -w"
348
 IPT="/usr/sbin/iptables -t mangle -w"
341
 LOG="/usr/bin/logger -t mwan3 -p"
349
 LOG="/usr/bin/logger -t mwan3 -p"

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

1
-#!/bin/sh /etc/rc.common
2
-START=99
3
-
4
-start() {
5
-	/usr/sbin/mwan3 start
6
-}
7
-
8
-stop() {
9
-	/usr/sbin/mwan3 stop
10
-}
11
-
12
-restart() {
13
-	stop
14
-	start
15
-}
16
-
17
-boot() {
18
-	return 0
19
-}

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

1
-#!/bin/sh /etc/rc.common
1
+#!/bin/sh
2
+. /lib/functions.sh
2
 
3
 
3
-. /lib/network/config.sh
4
+IP="/usr/sbin/ip -4"
5
+IPT="/usr/sbin/iptables -t mangle -w"
4
 
6
 
5
-extra_help() {
6
-	cat <<EOF
7
+help()
8
+{                                                                    
9
+	cat <<EOF                                                                                      
10
+Syntax: mwan3 [command]                                                                          
11
+                                                                                                       
12
+Available commands:                                                                                    
13
+	start           Load iptables rules, ip rules and ip routes
14
+	stop            Unload iptables rules, ip rules and ip routes
15
+	restart         Reload iptables rules, ip rules and ip routes
16
+        ifup <iface>    Load rules and routes for specific interface
17
+        ifdown <iface>  Unload rules and routes for specific interface
18
+        interfaces      Show interfaces status
19
+        policies        Show policies status
20
+        rules           Show rules status
21
+        status          Show all status
7
 
22
 
8
-	ifup <iface>	Start service on interface
9
-	ifdown <iface>	Stop service on interface
10
-	interfaces	Show interfaces status
11
-	policies	Show policies status
12
-	rules		Show rules status
13
-	status		Show all status
14
 EOF
23
 EOF
15
 }
24
 }
16
 
25
 
17
-EXTRA_COMMANDS="ifdown ifup interfaces policies rules status"
18
-EXTRA_HELP="$(extra_help)"
19
-IP="/usr/sbin/ip -4"
20
-IPT="/usr/sbin/iptables -t mangle -w"
21
-
22
 ifdown()
26
 ifdown()
23
 {
27
 {
24
 	if [ -z "$1" ]; then
28
 	if [ -z "$1" ]; then
197
 	stop
201
 	stop
198
 	start
202
 	start
199
 }
203
 }
204
+
205
+action=${1:-help}
206
+$action