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,7 +9,7 @@ include $(TOPDIR)/rules.mk
9 9
 
10 10
 PKG_NAME:=mwan3
11 11
 PKG_VERSION:=1.5
12
-PKG_RELEASE:=6
12
+PKG_RELEASE:=7
13 13
 PKG_MAINTAINER:=Jeroen Louwes <jeroen.louwes@gmail.com>
14 14
 PKG_LICENSE:=GPLv2
15 15
 
@@ -42,9 +42,4 @@ define Package/mwan3/install
42 42
    $(CP) ./files/* $(1)
43 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 45
 $(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()
49 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 63
 mwan3_set_connected_iptables()
53 64
 {
54 65
 	local connected_networks
@@ -112,18 +123,8 @@ mwan3_set_iface_rules()
112 123
 		$IP rule del pref $(($iface_id+2000))
113 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 126
 	[ $ACTION == "ifup" ] && $IP rule add pref $(($iface_id+1000)) iif $DEVICE lookup main
124 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 130
 mwan3_track()
@@ -136,6 +137,11 @@ mwan3_track()
136 137
 	}
137 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 145
 	if [ -n "$track_ips" ]; then
140 146
 		config_get reliability $INTERFACE reliability 1
141 147
 		config_get count $INTERFACE count 1
@@ -299,7 +305,7 @@ mwan3_ifupdown()
299 305
 			sleep 1
300 306
 			let counter++
301 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 309
 			fi
304 310
 		done
305 311
 
@@ -318,6 +324,7 @@ mwan3_ifupdown()
318 324
 	$LOG notice "$ACTION interface $INTERFACE (${DEVICE:-unknown})"
319 325
 
320 326
 	mwan3_set_general_iptables
327
+	mwan3_set_general_rules
321 328
 	mwan3_set_iface_iptables
322 329
 	mwan3_set_iface_route
323 330
 	mwan3_set_iface_rules
@@ -328,14 +335,15 @@ mwan3_ifupdown()
328 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 339
 [ -n "$INTERFACE" ] || exit 0
334 340
 
335 341
 if [ $ACTION == "ifup" ]; then
336 342
 	[ -n "$DEVICE" ] || exit 0
337 343
 fi
338 344
 
345
+local IP IPT LOG
346
+
339 347
 IP="/usr/sbin/ip -4"
340 348
 IPT="/usr/sbin/iptables -t mangle -w"
341 349
 LOG="/usr/bin/logger -t mwan3 -p"

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

@@ -1,19 +0,0 @@
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,24 +1,28 @@
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 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 26
 ifdown()
23 27
 {
24 28
 	if [ -z "$1" ]; then
@@ -197,3 +201,6 @@ restart() {
197 201
 	stop
198 202
 	start
199 203
 }
204
+
205
+action=${1:-help}
206
+$action