-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathadd_upload_fix
More file actions
52 lines (47 loc) · 1.86 KB
/
add_upload_fix
File metadata and controls
52 lines (47 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/sh
logmsg() {
if [ "$#" = "0" ]; then
return
fi
logger -t "${SCRIPTNAME_DISPLAY}" "$*"
}
if [ "$(nvram get qos_enable)" != "1" ] || [ "$(nvram get qos_type)" != "1" ]; then exit 0; fi # Check Adaptive QoS enabled first
readonly SCRIPTNAME_DISPLAY="AQoS_Upload_Fix"
#lock to avoid running script 3x
lockfile="/tmp/add_upload_fix.lock"
exec 100>"$lockfile"
if ! flock -n 100; then exit 0; fi
sleep 30 # Needed to avoid mismatch of flowid and mark
wan_interface=$(nvram get wan_ifnames)
lan_interface=$(nvram get lan_ifname)
temp_upload_filter=$(tc filter show dev $lan_interface | sed -n 's/.*mark\(.*\)(succ.*/\1/p')
temp_upload_flowid=$(tc filter show dev $lan_interface | sed -n 's/.*flowid//p')
temp_upload_pref=$(tc filter show dev $lan_interface | sed -n 's/.*pref\(.*\)div.*/\1/p')
temp_num_upload_filter=$(echo "$temp_upload_filter" | wc -l)
IFS=$'\n' # split on .
set -o noglob # disable glob
#set -- $temp_upload_filter # split+glob with glob disabled.
#echo "$# elements:"
#printf ' - "%s"\n' "${@}"
#set -- $temp_upload_flowid"" # split+glob with glob disabled.
#echo "$# elements:"
#printf ' - "%s"\n' "${1}"
logmsg "Starting Upload QoS Fix"
iterator=1
while [ $iterator -le $temp_num_upload_filter ]
do
set -- $temp_upload_filter""
match_id=$(eval echo \${$iterator})
set -- $temp_upload_flowid""
flow_id=$(eval echo \${$((iterator))})
set -- $temp_upload_pref""
pref=$(eval echo \${$iterator})
pref=$(echo $pref | sed -n 's/\.*u32.*/\1/p')
eval tc filter add dev $wan_interface protocol all prio $pref u32 match mark $match_id flowid $flow_id
#printf '%s\n' $preference
iterator=$(( $iterator + 1 ))
done
#Catchall
tc filter add dev $wan_interface protocol all prio 99 u32 match u32 0 0 flowid 1:14
tc filter add dev $lan_interface protocol all prio 99 u32 match u32 0 0 flowid 1:14
logmsg "Completed Upload QoS Fix"