[PATCH 2/3] fff-hoods: Improve hoodfile gathering logic

Robert Langhammer rlanghammer at web.de
Mi Jun 17 08:50:58 CEST 2020


Hi Fabian,

soweit ich das überschauen kann, und das ist beim configurehood nicht
immer einfach, sollte es funktionieren.

Reviewed-by: Robert Langhammer <rlanghammer at web.de>

Am 06.05.20 um 16:48 schrieb Fabian Bläse:
> Instead of seperately checking for various conditions,
> which don't actually guarantee that the hoodfile can be
> fetched in a certain way (e.g. internet is available but
> keyxchange is down), the already built in return value of
> the hoodfile gathering functions is utilized.
>
> This change slightly changes the behaviour of nodes in
> certian edge cases:
> - If no hoodfile could be fetched from keyxchange, the
>   next delivery method (getGatewayHoodfile) is used
> - If the gateway is unable to deliver a hoodfile, nodes
>   now behave like the gateway is unreachable, instead of
>   continuing to use old hoodfiles
>
> These behaviour changes should be an improvement over the
> previous behaviour:isGatewayAvailable
> - VPN nodes don't disconnect and break the whole network
>   if the keyxchange is unreachable, but instead try to
>   fetch the hoodfile from the gateway
> - Instead of checking for batman gateway announcements,
>   which are completely unrelated to hoodfile delivery using
>   fe80::1, the actual status of the hoodfile download is
>   utilized. This has two effects:
>   - hoodfile delivery using fe80::1 works even if batmans
>     gateway selection isn't used at all
>   - if the batman gateway selection is active, but fe80::1
>     hoodfile delivery is broken in the hood, the nodes disconnect
>     from the hood and try to gather their hoodfile from nerby
>     nodes. Previously they continued to use the old hoodfile.
>     This should make misconfigured gateways more apparent.
>
> Signed-off-by: Fabian Bläse <fabian at blaese.de>
> ---
>  .../fff-hoods/files/usr/sbin/configurehood    | 46 +++++++++----------
>  1 file changed, 22 insertions(+), 24 deletions(-)
>
> diff --git a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
> index 3b92cbc..261b926 100755
> --- a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
> +++ b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
> @@ -69,32 +69,30 @@ if [ -s "$hoodfilelocal" ]; then
>  	cp "$hoodfilelocal" "$hoodfiletmp"
>  	echo "Use local hood file"
>  else
> -	# if we have Internet, we download the Hoodfile from the keyxchangev2
> -	if hasInternet ; then
> -		getKeyserverHoodfile "$hoodfiletmp" && cp "$hoodfiletmp" "$hoodfilewww"
> -
> -		#if no Internet, we connect to the hidden AP and download the file from another Node in range
> +	# if internet is available, the hoodfile is downloaded from our keyserver
> +	if getKeyserverHoodfile "$hoodfiletmp"; then
> +		cp "$hoodfiletmp" "$hoodfilewww"
> +
> +	# if no internet is available, but the node is already configured,
> +	# a gateway with the appropriate hoodfile should be available
> +	else if getGatewayHoodfile "$hoodfiletmp"; then
> +		cp "$hoodfiletmp" "$hoodfilewww"
> +
> +	# no internet and no gateway available. the node is either unconfigured,
> +	# has lost connectivity or the hood is broken. Try to regain connectivity by
> +	# fetching hoodfiles from nearby nodes
>  	else
> -		# connect to wireless hidden ap here and download the json File from the nearest router
> -		# Only do that, when we have no gateway in range. If the Uplinkrouter changed the hood, we lost the GW and do this automatically again, I think! Nice idea?
> -		if ! isGatewayAvailable ; then
> -			#now we haven't a gateway in Range, we search for a hidden AP to get a keyxchangev2data file!
> -			#first we delete all wifi settings
> -			rm -f "$hoodfileref" # delete this, so interfaces are recreated if reconnect with unchanged hood file takes place
> -			rm -f "$hoodfilewww" # delete this, so wrong hood file is not broadcasted anymore
> -
> -			uci -q del "system. at system[0].hood"
> -			uci -q del "system. at system[0].hoodid"
> -			uci commit system
> -			reload_config
> -		
> -			sleep 30 # Wait for the config AP, which may be created at the same time as this script has started
> +		rm -f "$hoodfileref" # delete this, so interfaces are recreated if reconnect with unchanged hood file takes place
> +		rm -f "$hoodfilewww" # delete this, so wrong hood file is not broadcasted anymore
>  
> -			getEthernetHoodfile "$hoodfiletmp" || getWirelessHoodfile "$hoodfiletmp"
> -		else
> -			echo "We have a Gateway in Range, we load the keyxchangev2data from fe80::1"
> -			getGatewayHoodfile "$hoodfiletmp" && cp "$hoodfiletmp" "$hoodfilewww"
> -		fi
> +		uci -q del "system. at system[0].hood"
> +		uci -q del "system. at system[0].hoodid"
> +		uci commit system
> +		reload_config
> +
> +		sleep 30 # Wait for the config AP, which may be created at the same time as this script has started
> +
> +		getEthernetHoodfile "$hoodfiletmp" || getWirelessHoodfile "$hoodfiletmp"
>  	fi
>  fi
>  



Mehr Informationen über die Mailingliste franken-dev