Skip to content

Commit 80ba5e4

Browse files
rany2hauke
authored andcommitted
6in4: improve HE tunnel update procedure
- uclient-fetch timeout bumped from 5s to 15s. If we do not do this we get flagged by HE as the update request is expensive and takes more than 5s to execute. Currently 5s timeout causes uclient-fetch to be killed prematurely as can be seen by the following log: 10:34:57 user.notice 6in4-henet: update 1/3: timeout 10:35:07 user.notice 6in4-henet: update 2/3: timeout 10:35:17 user.notice 6in4-henet: update 3/3: timeout 10:35:22 user.notice 6in4-henet: update failed The above is the worst case, what usually happens is: 10:53:59 user.notice 6in4-henet: update 1/3: timeout 10:54:06 user.notice 6in4-henet: update 2/3: abuse 10:54:06 user.notice 6in4-henet: updated - We now use an exponential backoff starting from 5 seconds. - Detect ca-bundle so we don't use --no-check-certificates unnecessarily. - The while loop was changed so we don't retry unnecessarily after the final failure. - Worst-case total time the update operation might take before bailing out is: (sum(15 + (5 × (2^(x − 1))), 1, 2) + 15) seconds = 1 min Signed-off-by: Rany Hany <rany_hany@riseup.net> Link: openwrt/openwrt#22016 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> (cherry picked from commit 862b46d)
1 parent b8fe7b5 commit 80ba5e4

File tree

1 file changed

+10
-4
lines changed
  • package/network/ipv6/6in4/files

1 file changed

+10
-4
lines changed

package/network/ipv6/6in4/files/6in4.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ test_6in4_rfc1918()
2525

2626
proto_6in4_update() {
2727
sh -c '
28-
timeout=5
28+
timeout=15
2929
3030
(while [ $((timeout--)) -gt 0 ]; do
3131
sleep 1
@@ -123,7 +123,7 @@ proto_6in4_setup() {
123123
local ca_path="${SSL_CERT_DIR:-/etc/ssl/certs}"
124124

125125
[ -f /lib/libustream-ssl.so ] && http=https
126-
[ "$http" = "https" -a -z "$(find $ca_path -name "*.0" 2>/dev/null)" ] && {
126+
[ "$http" = "https" -a -z "$(find "$ca_path" \( -name "*.0" -o -name "*.crt" \) 2>/dev/null)" ] && {
127127
urlget_opts="$urlget_opts --no-check-certificate"
128128
}
129129

@@ -135,18 +135,24 @@ proto_6in4_setup() {
135135

136136
local try=0
137137
local max=3
138+
local retry_delay=5
138139

139140
(
140141
set -o pipefail
141-
while [ $((++try)) -le $max ]; do
142+
while true; do
143+
try=$((try + 1))
142144
if proto_6in4_update $urlget $urlget_opts --user="$username" --password="$password" "$url" 2>&1 | \
143145
sed -e 's,^Killed$,timeout,' -e "s,^,update $try/$max: ," | \
144146
logger -t "$link";
145147
then
146148
logger -t "$link" "updated"
147149
return 0
148150
fi
149-
sleep 5
151+
152+
[ "$try" -ge "$max" ] && break
153+
154+
sleep "$retry_delay"
155+
retry_delay=$((retry_delay * 2))
150156
done
151157
logger -t "$link" "update failed"
152158
)

0 commit comments

Comments
 (0)