diff mbox series

[OpenWrt-Devel,v1] 6in4: add maxtry option to make more persistent updating HE endpoint

Message ID 20180727210948.37016-1-ldir@darbyshire-bryant.me.uk
State Changes Requested
Delegated to: John Crispin
Headers show
Series [OpenWrt-Devel,v1] 6in4: add maxtry option to make more persistent updating HE endpoint | expand

Commit Message

Kevin 'ldir' Darbyshire-Bryant July 27, 2018, 9:09 p.m. UTC
Add option 'maxtry' to 6in4 interface definition.  Defaults to 3.

Defines maximum number of attempts to update Hurricane Electric
tunnel endpoint address.  Originally unconfigurable and hard coded to 3.

Each update attempt has a 5 second timeout.

Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
---
 package/network/ipv6/6in4/files/6in4.sh | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Arjen de Korte July 28, 2018, 7:29 a.m. UTC | #1
Citeren Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>:

> Add option 'maxtry' to 6in4 interface definition.  Defaults to 3.
>
> Defines maximum number of attempts to update Hurricane Electric
> tunnel endpoint address.  Originally unconfigurable and hard coded to 3.
>
> Each update attempt has a 5 second timeout.

I don't think this is a good idea. While I recognize that the update  
is accepted only on the third (and final) try, just upping the number  
of tries is not the solution.

It looks to me that the updates are failing, because the script runs  
too soon. Adding a fixed delay of 15 seconds before it runs, will  
always update on the first try.

So rather than just trying more often, it might be better to fix an  
apparent race condition here.

> Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
> ---
>  package/network/ipv6/6in4/files/6in4.sh | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/package/network/ipv6/6in4/files/6in4.sh  
> b/package/network/ipv6/6in4/files/6in4.sh
> index 941dc43d68..dce37eb3b3 100755
> --- a/package/network/ipv6/6in4/files/6in4.sh
> +++ b/package/network/ipv6/6in4/files/6in4.sh
> @@ -31,8 +31,8 @@ proto_6in4_setup() {
>  	local iface="$2"
>  	local link="6in4-$cfg"
>
> -	local mtu ttl tos ipaddr peeraddr ip6addr ip6prefix ip6prefixes  
> tunlink tunnelid username password updatekey
> -	json_get_vars mtu ttl tos ipaddr peeraddr ip6addr tunlink tunnelid  
> username password updatekey
> +	local mtu ttl tos ipaddr peeraddr ip6addr ip6prefix ip6prefixes  
> tunlink tunnelid username password updatekey maxtry
> +	json_get_vars mtu ttl tos ipaddr peeraddr ip6addr tunlink tunnelid  
> username password updatekey maxtry
>  	json_for_each_item proto_6in4_add_prefix ip6prefix ip6prefixes
>
>  	[ -z "$peeraddr" ] && {
> @@ -98,7 +98,7 @@ proto_6in4_setup() {
>
>  		local url="$http://ipv4.tunnelbroker.net/nic/update?hostname=$tunnelid"
>  		local try=0
> -		local max=3
> +		local max="${maxtry:-3}"
>
>  		(
>  			set -o pipefail
> @@ -134,6 +134,7 @@ proto_6in4_init_config() {
>  	proto_config_add_string "username"
>  	proto_config_add_string "password"
>  	proto_config_add_string "updatekey"
> +	proto_config_add_int "maxtry"
>  	proto_config_add_int "mtu"
>  	proto_config_add_int "ttl"
>  	proto_config_add_string "tos"
diff mbox series

Patch

diff --git a/package/network/ipv6/6in4/files/6in4.sh b/package/network/ipv6/6in4/files/6in4.sh
index 941dc43d68..dce37eb3b3 100755
--- a/package/network/ipv6/6in4/files/6in4.sh
+++ b/package/network/ipv6/6in4/files/6in4.sh
@@ -31,8 +31,8 @@  proto_6in4_setup() {
 	local iface="$2"
 	local link="6in4-$cfg"
 
-	local mtu ttl tos ipaddr peeraddr ip6addr ip6prefix ip6prefixes tunlink tunnelid username password updatekey
-	json_get_vars mtu ttl tos ipaddr peeraddr ip6addr tunlink tunnelid username password updatekey
+	local mtu ttl tos ipaddr peeraddr ip6addr ip6prefix ip6prefixes tunlink tunnelid username password updatekey maxtry
+	json_get_vars mtu ttl tos ipaddr peeraddr ip6addr tunlink tunnelid username password updatekey maxtry
 	json_for_each_item proto_6in4_add_prefix ip6prefix ip6prefixes
 
 	[ -z "$peeraddr" ] && {
@@ -98,7 +98,7 @@  proto_6in4_setup() {
 
 		local url="$http://ipv4.tunnelbroker.net/nic/update?hostname=$tunnelid"
 		local try=0
-		local max=3
+		local max="${maxtry:-3}"
 
 		(
 			set -o pipefail
@@ -134,6 +134,7 @@  proto_6in4_init_config() {
 	proto_config_add_string "username"
 	proto_config_add_string "password"
 	proto_config_add_string "updatekey"
+	proto_config_add_int "maxtry"
 	proto_config_add_int "mtu"
 	proto_config_add_int "ttl"
 	proto_config_add_string "tos"