|
@@ -6,68 +6,61 @@ mwan3_get_iface_id()
|
6
|
6
|
[ "$1" == "$INTERFACE" ] && iface_id=$iface_count
|
7
|
7
|
}
|
8
|
8
|
|
9
|
|
-mwan3_get_route_args()
|
10
|
|
-{
|
11
|
|
- route_args=$(ip -4 route list dev $DEVICE default | head -1 | sed '/.*via \([^ ]*\) .*$/!d;s//\1/;q' | egrep '[0-9]{1,3}(\.[0-9]{1,3}){3}')
|
12
|
|
- [ -n "$route_args" ] && route_args="via $route_args"
|
13
|
|
- route_args="nexthop $route_args dev $DEVICE"
|
14
|
|
-}
|
15
|
|
-
|
16
|
9
|
mwan3_set_general_iptables()
|
17
|
10
|
{
|
18
|
|
- if ! iptables -S mwan3_ifaces -t mangle &> /dev/null; then
|
19
|
|
- iptables -N mwan3_ifaces -t mangle
|
|
11
|
+ if ! $IPT -S mwan3_ifaces &> /dev/null; then
|
|
12
|
+ $IPT -N mwan3_ifaces
|
20
|
13
|
fi
|
21
|
14
|
|
22
|
|
- if ! iptables -S mwan3_rules -t mangle &> /dev/null; then
|
23
|
|
- iptables -N mwan3_rules -t mangle
|
|
15
|
+ if ! $IPT -S mwan3_rules &> /dev/null; then
|
|
16
|
+ $IPT -N mwan3_rules
|
24
|
17
|
fi
|
25
|
18
|
|
26
|
|
- if ! iptables -S mwan3_connected -t mangle &> /dev/null; then
|
27
|
|
- iptables -N mwan3_connected -t mangle
|
|
19
|
+ if ! $IPT -S mwan3_connected &> /dev/null; then
|
|
20
|
+ $IPT -N mwan3_connected
|
28
|
21
|
fi
|
29
|
22
|
|
30
|
|
- if ! iptables -S mwan3_hook -t mangle &> /dev/null; then
|
31
|
|
- iptables -N mwan3_hook -t mangle
|
32
|
|
- iptables -A mwan3_hook -t mangle -j CONNMARK --restore-mark --nfmask 0xff00 --ctmask 0xff00
|
33
|
|
- iptables -A mwan3_hook -t mangle -m mark --mark 0x0/0xff00 -j mwan3_ifaces
|
34
|
|
- iptables -A mwan3_hook -t mangle -m mark --mark 0x0/0xff00 -j mwan3_connected
|
35
|
|
- iptables -A mwan3_hook -t mangle -m mark --mark 0x0/0xff00 -j mwan3_rules
|
36
|
|
- iptables -A mwan3_hook -t mangle -j CONNMARK --save-mark --nfmask 0xff00 --ctmask 0xff00
|
|
23
|
+ if ! $IPT -S mwan3_hook &> /dev/null; then
|
|
24
|
+ $IPT -N mwan3_hook
|
|
25
|
+ $IPT -A mwan3_hook -j CONNMARK --restore-mark --nfmask 0xff00 --ctmask 0xff00
|
|
26
|
+ $IPT -A mwan3_hook -m mark --mark 0x0/0xff00 -j mwan3_ifaces
|
|
27
|
+ $IPT -A mwan3_hook -m mark --mark 0x0/0xff00 -j mwan3_connected
|
|
28
|
+ $IPT -A mwan3_hook -m mark --mark 0x0/0xff00 -j mwan3_rules
|
|
29
|
+ $IPT -A mwan3_hook -j CONNMARK --save-mark --nfmask 0xff00 --ctmask 0xff00
|
37
|
30
|
fi
|
38
|
31
|
|
39
|
|
- if ! iptables -S mwan3_track_hook -t mangle &> /dev/null; then
|
40
|
|
- iptables -N mwan3_track_hook -t mangle
|
|
32
|
+ if ! $IPT -S mwan3_track_hook &> /dev/null; then
|
|
33
|
+ $IPT -N mwan3_track_hook
|
41
|
34
|
fi
|
42
|
35
|
|
43
|
|
- if ! iptables -S PREROUTING -t mangle | grep mwan3_hook &> /dev/null; then
|
44
|
|
- iptables -A PREROUTING -t mangle -j mwan3_hook
|
|
36
|
+ if ! $IPT -S PREROUTING | grep mwan3_hook &> /dev/null; then
|
|
37
|
+ $IPT -A PREROUTING -j mwan3_hook
|
45
|
38
|
fi
|
46
|
39
|
|
47
|
|
- if ! iptables -S OUTPUT -t mangle | grep mwan3_hook &> /dev/null; then
|
48
|
|
- iptables -A OUTPUT -t mangle -j mwan3_hook
|
|
40
|
+ if ! $IPT -S OUTPUT | grep mwan3_hook &> /dev/null; then
|
|
41
|
+ $IPT -A OUTPUT -j mwan3_hook
|
49
|
42
|
fi
|
50
|
43
|
|
51
|
|
- if ! iptables -S OUTPUT -t mangle | grep mwan3_track_hook &> /dev/null; then
|
52
|
|
- iptables -A OUTPUT -t mangle -j mwan3_track_hook
|
|
44
|
+ if ! $IPT -S OUTPUT | grep mwan3_track_hook &> /dev/null; then
|
|
45
|
+ $IPT -A OUTPUT -j mwan3_track_hook
|
53
|
46
|
fi
|
54
|
47
|
|
55
|
|
- iptables -F mwan3_rules -t mangle
|
|
48
|
+ $IPT -F mwan3_rules
|
56
|
49
|
}
|
57
|
50
|
|
58
|
51
|
mwan3_set_connected_iptables()
|
59
|
52
|
{
|
60
|
53
|
local connected_networks
|
61
|
54
|
|
62
|
|
- if iptables -S mwan3_connected -t mangle &> /dev/null; then
|
63
|
|
- iptables -F mwan3_connected -t mangle
|
|
55
|
+ if $IPT -S mwan3_connected &> /dev/null; then
|
|
56
|
+ $IPT -F mwan3_connected
|
64
|
57
|
|
65
|
|
- for connected_networks in $(ip -4 route | awk '{print $1}' | egrep '[0-9]{1,3}(\.[0-9]{1,3}){3}'); do
|
66
|
|
- iptables -A mwan3_connected -t mangle -d $connected_networks -m mark --mark 0x0/0xff00 -j MARK --set-xmark 0xff00/0xff00
|
|
58
|
+ for connected_networks in $($IP route | awk '{print $1}' | egrep '[0-9]{1,3}(\.[0-9]{1,3}){3}'); do
|
|
59
|
+ $IPT -A mwan3_connected -d $connected_networks -m mark --mark 0x0/0xff00 -j MARK --set-xmark 0xff00/0xff00
|
67
|
60
|
done
|
68
|
61
|
|
69
|
|
- iptables -I mwan3_connected -t mangle -d 224.0.0.0/3 -m mark --mark 0x0/0xff00 -j MARK --set-xmark 0xff00/0xff00
|
70
|
|
- iptables -I mwan3_connected -t mangle -d 127.0.0.0/8 -m mark --mark 0x0/0xff00 -j MARK --set-xmark 0xff00/0xff00
|
|
62
|
+ $IPT -I mwan3_connected -d 224.0.0.0/3 -m mark --mark 0x0/0xff00 -j MARK --set-xmark 0xff00/0xff00
|
|
63
|
+ $IPT -I mwan3_connected -d 127.0.0.0/8 -m mark --mark 0x0/0xff00 -j MARK --set-xmark 0xff00/0xff00
|
71
|
64
|
fi
|
72
|
65
|
}
|
73
|
66
|
|
|
@@ -75,56 +68,56 @@ mwan3_set_iface_iptables()
|
75
|
68
|
{
|
76
|
69
|
local local_net local_nets
|
77
|
70
|
|
78
|
|
- local_net=$(ip -4 route list dev $DEVICE scope link | awk '{print $1}' | egrep '[0-9]{1,3}(\.[0-9]{1,3}){3}')
|
|
71
|
+ local_net=$($IP route list dev $DEVICE scope link | awk '{print $1}' | egrep '[0-9]{1,3}(\.[0-9]{1,3}){3}')
|
79
|
72
|
|
80
|
|
- if ! iptables -S mwan3_iface_$INTERFACE -t mangle &> /dev/null; then
|
81
|
|
- iptables -N mwan3_iface_$INTERFACE -t mangle
|
|
73
|
+ if ! $IPT -S mwan3_iface_$INTERFACE &> /dev/null; then
|
|
74
|
+ $IPT -N mwan3_iface_$INTERFACE
|
82
|
75
|
fi
|
83
|
76
|
|
84
|
|
- iptables -F mwan3_iface_$INTERFACE -t mangle
|
85
|
|
- iptables -D mwan3_ifaces -t mangle -i $DEVICE -m mark --mark 0x0/0xff00 -j mwan3_iface_$INTERFACE &> /dev/null
|
|
77
|
+ $IPT -F mwan3_iface_$INTERFACE
|
|
78
|
+ $IPT -D mwan3_ifaces -i $DEVICE -m mark --mark 0x0/0xff00 -j mwan3_iface_$INTERFACE &> /dev/null
|
86
|
79
|
|
87
|
80
|
if [ $ACTION == "ifup" ]; then
|
88
|
81
|
if [ -n "$local_net" ]; then
|
89
|
82
|
for local_nets in $local_net ; do
|
90
|
83
|
if [ $ACTION == "ifup" ]; then
|
91
|
|
- iptables -I mwan3_iface_$INTERFACE -t mangle -s $local_net -m mark --mark 0x0/0xff00 -m comment --comment "$INTERFACE" -j MARK --set-xmark 0xff00/0xff00
|
|
84
|
+ $IPT -I mwan3_iface_$INTERFACE -s $local_net -m mark --mark 0x0/0xff00 -m comment --comment "$INTERFACE" -j MARK --set-xmark 0xff00/0xff00
|
92
|
85
|
fi
|
93
|
86
|
done
|
94
|
87
|
fi
|
95
|
88
|
|
96
|
|
- iptables -A mwan3_iface_$INTERFACE -t mangle -m mark --mark 0x0/0xff00 -m comment --comment "$INTERFACE" -j MARK --set-xmark $(($iface_id*256))/0xff00
|
97
|
|
- iptables -A mwan3_ifaces -t mangle -i $DEVICE -m mark --mark 0x0/0xff00 -j mwan3_iface_$INTERFACE
|
|
89
|
+ $IPT -A mwan3_iface_$INTERFACE -m mark --mark 0x0/0xff00 -m comment --comment "$INTERFACE" -j MARK --set-xmark $(($iface_id*256))/0xff00
|
|
90
|
+ $IPT -A mwan3_ifaces -i $DEVICE -m mark --mark 0x0/0xff00 -j mwan3_iface_$INTERFACE
|
98
|
91
|
fi
|
99
|
92
|
|
100
|
93
|
if [ $ACTION == "ifdown" ]; then
|
101
|
|
- iptables -X mwan3_iface_$INTERFACE -t mangle
|
|
94
|
+ $IPT -X mwan3_iface_$INTERFACE
|
102
|
95
|
fi
|
103
|
96
|
}
|
104
|
97
|
|
105
|
98
|
mwan3_set_iface_route()
|
106
|
99
|
{
|
107
|
|
- ip -4 route flush table $iface_id
|
108
|
|
- [ $ACTION == "ifup" ] && ip -4 route add table $iface_id default $route_args
|
|
100
|
+ $IP route flush table $iface_id
|
|
101
|
+ [ $ACTION == "ifup" ] && $IP route add table $iface_id default $route_args
|
109
|
102
|
}
|
110
|
103
|
|
111
|
104
|
mwan3_set_iface_rules()
|
112
|
105
|
{
|
113
|
|
- while [ -n "$(ip -4 rule list | awk '$1 == "'$(($iface_id+1000)):'"')" ]; do
|
114
|
|
- ip -4 rule del pref $(($iface_id+1000))
|
|
106
|
+ while [ -n "$($IP rule list | awk '$1 == "'$(($iface_id+1000)):'"')" ]; do
|
|
107
|
+ $IP rule del pref $(($iface_id+1000))
|
115
|
108
|
done
|
116
|
109
|
|
117
|
|
- while [ -n "$(ip -4 rule list | awk '$1 == "'$(($iface_id+2000)):'"')" ]; do
|
118
|
|
- ip -4 rule del pref $(($iface_id+2000))
|
|
110
|
+ while [ -n "$($IP rule list | awk '$1 == "'$(($iface_id+2000)):'"')" ]; do
|
|
111
|
+ $IP rule del pref $(($iface_id+2000))
|
119
|
112
|
done
|
120
|
113
|
|
121
|
|
- while [ -n "$(ip -4 rule list | awk '$1 == "2254:"')" ]; do
|
122
|
|
- ip -4 rule del pref 2254
|
|
114
|
+ while [ -n "$($IP rule list | awk '$1 == "2254:"')" ]; do
|
|
115
|
+ $IP rule del pref 2254
|
123
|
116
|
done
|
124
|
117
|
|
125
|
|
- [ $ACTION == "ifup" ] && ip -4 rule add pref $(($iface_id+1000)) iif $DEVICE lookup main
|
126
|
|
- [ $ACTION == "ifup" ] && ip -4 rule add pref $(($iface_id+2000)) fwmark $(($iface_id*256))/0xff00 lookup $iface_id
|
127
|
|
- ip rule add pref 2254 fwmark 0xfe00/0xff00 unreachable
|
|
118
|
+ [ $ACTION == "ifup" ] && $IP rule add pref $(($iface_id+1000)) iif $DEVICE lookup main
|
|
119
|
+ [ $ACTION == "ifup" ] && $IP rule add pref $(($iface_id+2000)) fwmark $(($iface_id*256))/0xff00 lookup $iface_id
|
|
120
|
+ $IP rule add pref 2254 fwmark 0xfe00/0xff00 unreachable
|
128
|
121
|
}
|
129
|
122
|
|
130
|
123
|
mwan3_track()
|
|
@@ -145,28 +138,28 @@ mwan3_track()
|
145
|
138
|
config_get down $INTERFACE down 5
|
146
|
139
|
config_get up $INTERFACE up 5
|
147
|
140
|
|
148
|
|
- if ! iptables -S mwan3_track_$INTERFACE -t mangle &> /dev/null; then
|
149
|
|
- iptables -N mwan3_track_$INTERFACE -t mangle
|
150
|
|
- iptables -A mwan3_track_hook -t mangle -p icmp -m icmp --icmp-type 8 -m length --length 32 -j mwan3_track_$INTERFACE
|
|
141
|
+ if ! $IPT -S mwan3_track_$INTERFACE &> /dev/null; then
|
|
142
|
+ $IPT -N mwan3_track_$INTERFACE
|
|
143
|
+ $IPT -A mwan3_track_hook -p icmp -m icmp --icmp-type 8 -m length --length 32 -j mwan3_track_$INTERFACE
|
151
|
144
|
fi
|
152
|
145
|
|
153
|
|
- iptables -F mwan3_track_$INTERFACE -t mangle
|
|
146
|
+ $IPT -F mwan3_track_$INTERFACE
|
154
|
147
|
|
155
|
148
|
for track_ip in $track_ips; do
|
156
|
|
- iptables -A mwan3_track_$INTERFACE -t mangle -d $track_ip -j MARK --set-xmark 0xff00/0xff00
|
|
149
|
+ $IPT -A mwan3_track_$INTERFACE -d $track_ip -j MARK --set-xmark 0xff00/0xff00
|
157
|
150
|
done
|
158
|
151
|
|
159
|
152
|
[ -x /usr/sbin/mwan3track ] && /usr/sbin/mwan3track $INTERFACE $DEVICE $reliability $count $timeout $interval $down $up $track_ips &
|
160
|
153
|
else
|
161
|
|
- iptables -D mwan3_track_hook -t mangle -p icmp -m icmp --icmp-type 8 -m length --length 32 -j mwan3_track_$INTERFACE &> /dev/null
|
162
|
|
- iptables -F mwan3_track_$INTERFACE -t mangle &> /dev/null
|
163
|
|
- iptables -X mwan3_track_$INTERFACE -t mangle &> /dev/null
|
|
154
|
+ $IPT -D mwan3_track_hook -p icmp -m icmp --icmp-type 8 -m length --length 32 -j mwan3_track_$INTERFACE &> /dev/null
|
|
155
|
+ $IPT -F mwan3_track_$INTERFACE &> /dev/null
|
|
156
|
+ $IPT -X mwan3_track_$INTERFACE &> /dev/null
|
164
|
157
|
fi
|
165
|
158
|
}
|
166
|
159
|
|
167
|
160
|
mwan3_set_policy()
|
168
|
161
|
{
|
169
|
|
- local iface_count iface_id metric probability weight
|
|
162
|
+ local iface_count iface_id INTERFACE metric probability weight
|
170
|
163
|
|
171
|
164
|
config_get INTERFACE $1 interface
|
172
|
165
|
config_get metric $1 metric 1
|
|
@@ -178,12 +171,12 @@ mwan3_set_policy()
|
178
|
171
|
|
179
|
172
|
[ -n "$iface_id" ] || return 0
|
180
|
173
|
|
181
|
|
- if iptables -S mwan3_iface_$INTERFACE -t mangle &> /dev/null; then
|
|
174
|
+ if $IPT -S mwan3_iface_$INTERFACE &> /dev/null; then
|
182
|
175
|
if [ "$metric" -lt "$lowest_metric" ]; then
|
183
|
176
|
|
184
|
177
|
total_weight=$weight
|
185
|
|
- iptables -F mwan3_policy_$policy -t mangle
|
186
|
|
- iptables -A mwan3_policy_$policy -t mangle -m mark --mark 0x0/0xff00 -m comment --comment "$INTERFACE $weight $weight" -j MARK --set-xmark $(($iface_id*256))/0xff00
|
|
178
|
+ $IPT -F mwan3_policy_$policy
|
|
179
|
+ $IPT -A mwan3_policy_$policy -m mark --mark 0x0/0xff00 -m comment --comment "$INTERFACE $weight $weight" -j MARK --set-xmark $(($iface_id*256))/0xff00
|
187
|
180
|
|
188
|
181
|
lowest_metric=$metric
|
189
|
182
|
|
|
@@ -204,7 +197,7 @@ mwan3_set_policy()
|
204
|
197
|
|
205
|
198
|
probability="-m statistic --mode random --probability $probability"
|
206
|
199
|
|
207
|
|
- iptables -I mwan3_policy_$policy -t mangle -m mark --mark 0x0/0xff00 $probability -m comment --comment "$INTERFACE $weight $total_weight" -j MARK --set-xmark $(($iface_id*256))/0xff00
|
|
200
|
+ $IPT -I mwan3_policy_$policy -m mark --mark 0x0/0xff00 $probability -m comment --comment "$INTERFACE $weight $total_weight" -j MARK --set-xmark $(($iface_id*256))/0xff00
|
208
|
201
|
fi
|
209
|
202
|
fi
|
210
|
203
|
}
|
|
@@ -216,22 +209,22 @@ mwan3_set_policies_iptables()
|
216
|
209
|
policy=$1
|
217
|
210
|
|
218
|
211
|
if [ "$policy" != $(echo "$policy" | cut -c1-15) ]; then
|
219
|
|
- logger -t mwan3 -p warn "Policy $policy exceeds max of 15 chars. Not setting policy" && return 0
|
|
212
|
+ $LOG warn "Policy $policy exceeds max of 15 chars. Not setting policy" && return 0
|
220
|
213
|
fi
|
221
|
214
|
|
222
|
|
- if ! iptables -S mwan3_policy_$policy -t mangle &> /dev/null; then
|
223
|
|
- iptables -N mwan3_policy_$policy -t mangle
|
|
215
|
+ if ! $IPT -S mwan3_policy_$policy &> /dev/null; then
|
|
216
|
+ $IPT -N mwan3_policy_$policy
|
224
|
217
|
fi
|
225
|
218
|
|
226
|
|
- iptables -F mwan3_policy_$policy -t mangle
|
227
|
|
- iptables -A mwan3_policy_$policy -t mangle -m mark --mark 0x0/0xff00 -m comment --comment "unreachable" -j MARK --set-xmark 0xfe00/0xff00
|
|
219
|
+ $IPT -F mwan3_policy_$policy
|
|
220
|
+ $IPT -A mwan3_policy_$policy -m mark --mark 0x0/0xff00 -m comment --comment "unreachable" -j MARK --set-xmark 0xfe00/0xff00
|
228
|
221
|
|
229
|
222
|
lowest_metric=256
|
230
|
223
|
total_weight=0
|
231
|
224
|
|
232
|
225
|
config_list_foreach $policy use_member mwan3_set_policy
|
233
|
226
|
|
234
|
|
- iptables -X $policy -t mangle &> /dev/null
|
|
227
|
+ $IPT -X $policy &> /dev/null
|
235
|
228
|
}
|
236
|
229
|
|
237
|
230
|
mwan3_set_user_rules_iptables()
|
|
@@ -256,10 +249,10 @@ mwan3_set_user_rules_iptables()
|
256
|
249
|
|
257
|
250
|
case $proto in
|
258
|
251
|
tcp|udp)
|
259
|
|
- iptables -A mwan3_rules -t mangle -p $proto -s $src_ip -d $dest_ip -m multiport --sports $src_port -m multiport --dports $dest_port -m mark --mark 0/0xff00 -m comment --comment "$1" -j $use_policy &> /dev/null
|
|
252
|
+ $IPT -A mwan3_rules -p $proto -s $src_ip -d $dest_ip -m multiport --sports $src_port -m multiport --dports $dest_port -m mark --mark 0/0xff00 -m comment --comment "$1" -j $use_policy &> /dev/null
|
260
|
253
|
;;
|
261
|
254
|
*)
|
262
|
|
- iptables -A mwan3_rules -t mangle -p $proto -s $src_ip -d $dest_ip -m mark --mark 0/0xff00 -m comment --comment "$1" -j $use_policy &> /dev/null
|
|
255
|
+ $IPT -A mwan3_rules -p $proto -s $src_ip -d $dest_ip -m mark --mark 0/0xff00 -m comment --comment "$1" -j $use_policy &> /dev/null
|
263
|
256
|
;;
|
264
|
257
|
esac
|
265
|
258
|
fi
|
|
@@ -269,45 +262,41 @@ mwan3_ifupdown()
|
269
|
262
|
{
|
270
|
263
|
local counter enabled iface_count iface_id route_args wan_metric
|
271
|
264
|
|
272
|
|
- [ -n "$DEVICE" ] || exit 0
|
273
|
|
- [ -n "$INTERFACE" ] || exit 0
|
274
|
|
- [ "$(uci get -P /var/state mwan3.$INTERFACE 2> /dev/null)" == "interface" ] || return 0
|
275
|
|
-
|
276
|
265
|
config_load mwan3
|
|
266
|
+ config_foreach mwan3_get_iface_id interface
|
|
267
|
+
|
|
268
|
+ [ -n "$iface_id" ] || return 0
|
|
269
|
+ [ "$iface_count" -le 250 ] || return 0
|
|
270
|
+ unset iface_count
|
|
271
|
+
|
277
|
272
|
config_get enabled $INTERFACE enabled 0
|
278
|
273
|
|
279
|
274
|
counter=0
|
280
|
275
|
|
281
|
276
|
if [ $ACTION == "ifup" ]; then
|
282
|
|
- [ "$enabled" -eq 1 ] || exit 0
|
|
277
|
+ [ "$enabled" -eq 1 ] || return 0
|
283
|
278
|
|
284
|
|
- while [ -z "$(ip -4 route list dev $DEVICE default | head -1)" -a "$counter" -lt 10 ]; do
|
|
279
|
+ while [ -z "$($IP route list dev $DEVICE default | head -1)" -a "$counter" -lt 10 ]; do
|
285
|
280
|
sleep 1
|
286
|
281
|
let counter++
|
287
|
282
|
if [ "$counter" -ge 10 ]; then
|
288
|
|
- logger -t mwan3 -p warn "Could not find gateway for interface $INTERFACE ($DEVICE)" && exit 0
|
|
283
|
+ $LOG warn "Could not find gateway for interface $INTERFACE ($DEVICE)" && return 0
|
289
|
284
|
fi
|
290
|
285
|
done
|
291
|
286
|
|
292
|
|
- mwan3_get_route_args
|
|
287
|
+ route_args=$($IP route list dev $DEVICE default | head -1 | sed '/.*via \([^ ]*\) .*$/!d;s//via \1/;q' | egrep '[0-9]{1,3}(\.[0-9]{1,3}){3}')
|
|
288
|
+ route_args="nexthop $route_args dev $DEVICE"
|
293
|
289
|
fi
|
294
|
290
|
|
295
|
291
|
while [ "$(pgrep -f -o hotplug-call)" -ne $$ -a "$counter" -lt 60 ]; do
|
296
|
292
|
sleep 1
|
297
|
293
|
let counter++
|
298
|
294
|
if [ "$counter" -ge 60 ]; then
|
299
|
|
- logger -t mwan3 -p warn "Timeout waiting for older hotplug processes to finish. $ACTION interface $INTERFACE ($DEVICE) aborted" && exit 0
|
|
295
|
+ $LOG warn "Timeout waiting for older hotplug processes to finish. $ACTION interface $INTERFACE ($DEVICE) aborted" && return 0
|
300
|
296
|
fi
|
301
|
297
|
done
|
302
|
298
|
|
303
|
|
- config_foreach mwan3_get_iface_id interface
|
304
|
|
-
|
305
|
|
- [ -n "$iface_id" ] || exit 0
|
306
|
|
- [ "$iface_count" -le 250 ] || exit 0
|
307
|
|
- unset iface_count
|
308
|
|
- unset counter
|
309
|
|
-
|
310
|
|
- logger -t mwan3 -p notice "$ACTION interface $INTERFACE ($DEVICE)"
|
|
299
|
+ $LOG notice "$ACTION interface $INTERFACE ($DEVICE)"
|
311
|
300
|
|
312
|
301
|
mwan3_set_general_iptables
|
313
|
302
|
mwan3_set_iface_iptables
|
|
@@ -320,9 +309,20 @@ mwan3_ifupdown()
|
320
|
309
|
config_foreach mwan3_set_user_rules_iptables rule
|
321
|
310
|
}
|
322
|
311
|
|
|
312
|
+[ -n "$DEVICE" ] || exit 0
|
|
313
|
+[ -n "$INTERFACE" ] || exit 0
|
|
314
|
+
|
|
315
|
+local IP IPT LOG
|
|
316
|
+
|
|
317
|
+IP="/usr/sbin/ip -4"
|
|
318
|
+IPT="/usr/sbin/iptables -t mangle -w"
|
|
319
|
+LOG="/usr/bin/logger -t mwan3 -p"
|
|
320
|
+
|
323
|
321
|
case "$ACTION" in
|
324
|
322
|
ifup|ifdown)
|
325
|
323
|
mwan3_ifupdown
|
326
|
324
|
mwan3_set_connected_iptables
|
327
|
325
|
;;
|
328
|
326
|
esac
|
|
327
|
+
|
|
328
|
+exit 0
|