[PATCH] configurehood: Prevent connecting to hoods

mail at adrianschmutzler.de mail at adrianschmutzler.de
Di Nov 21 21:31:17 CET 2017


Hallo,

okay. Was müsste ich dann abschalten, bat0?

Oder geht das so wie ich es mir gedacht habe gar nicht?

Grüße

Adrian

> -----Original Message-----
> From: Christian Dresel [mailto:fff at chrisi01.de]
> Sent: Dienstag, 21. November 2017 21:18
> To: mail at adrianschmutzler.de; franken-dev at freifunk.net
> Subject: Re: [PATCH] configurehood: Prevent connecting to hoods
> 
> Hi
> 
> wenn ich das gerade richtig umfasse, würde das abschalten von br-mesh
> aber das Problem nicht beheben. ethX.3 hängt noch immer im Batman und
> auch Batman arbeitet noch problemlos weiter. Es gibt nur die Bridge nicht
> mehr, um als Client (mit w2ap bzw. eth0.1) mit Batman zu kommunizieren.
> Batman ansich funktioniert aber weiterhin einwandfrei und würde weiterhin
> die Hoods verbinden.
> 
> mfg
> 
> Christian
> 
> On 21.11.2017 21:15, mail at adrianschmutzler.de wrote:
> > Hallo Christian,
> >
> > ich habe das aus zwei Gründen so gewählt:
> >
> > 1. praktisch: Wenn ich eth0.3 aus batctl if herausnehme, kann ich dort den
> Namen nicht mehr nachschlagen. D.h. ich muss dann irgendwie wieder
> unterscheiden, ob ich eth0, eth1, eth0.3 oder sonstwas habe, oder ich muss
> den Namen abspeichern. Das ist in jedem Fall umständlich.
> > 2. aus Prinzip: Wenn der Router per Kabel mit zwei Hoods verbunden ist,
> dann ist er "kaputt" (fehlkonfiguriert, falsch verkabelt, wie du willst). Wenn
> der Router "kaputt" ist, sollte er sich auch kaputt anfühlen, d.h. nicht mehr
> funktionieren, sodass jemand was daran ändert. Einzelne Interfaces
> abschalten verbirgt das Problem, hier bin ich lieber konsequent.
> >
> > Grüße
> >
> > Adrian
> >
> >> -----Original Message-----
> >> From: Christian Dresel [mailto:fff at chrisi01.de]
> >> Sent: Dienstag, 21. November 2017 20:59
> >> To: Adrian Schmutzler <freifunk at adrianschmutzler.de>; franken-
> >> dev at freifunk.net
> >> Subject: Re: [PATCH] configurehood: Prevent connecting to hoods
> >>
> >> Hi
> >>
> >> auch wenn RedDog mittlerweile an einer anderen Lösung arbeitet,
> >> könnte ich auch damit leben. Aber eine Frage hab ich erstmal beim drüber
> gucken:
> >>
> >> On 20.11.2017 23:41, Adrian Schmutzler wrote:
> >>> To prevent connecting hoods, this patch loads keyxchange files from
> >>> the local network (eth0.3/eth0) before it uses the gateway.
> >>>
> >>> Thus, if other files are provided via wXconfigap, they are just
> >>> ignored. If a router is connected to two hoods by cable, it will
> >>> just disable br-mesh and wait until the next call of configurehood.
> >>> If a router is misconfigured, it is thus not working at all, which
> >>> is intended.
> >>>
> >>> Signed-off-by: Adrian Schmutzler <freifunk at adrianschmutzler.de>
> >>> ---
> >>>  .../fff/fff-hoods/files/usr/sbin/configurehood     | 28
> >> +++++++++++++++++++++-
> >>>  1 file changed, 27 insertions(+), 1 deletion(-)
> >>>
> >>> diff --git a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
> >>> b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
> >>> index 822e5fc..74a070a 100755
> >>> --- a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
> >>> +++ b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
> >>> @@ -65,6 +65,8 @@ fi
> >>>  lat=$(uci -q get fff.system.latitude)  long=$(uci -q get
> >>> fff.system.longitude)
> >>>
> >>> +(ifconfig | grep -q "br-mesh") || ifconfig br-mesh up # reenable
> >>> +br-mesh in case we disabled it earlier
> >>> +
> >>>  # if we have Internet, we download the Hoodfile from the
> >>> keyxchangev2 if hasInternet ; then
> >>>  	wget -T15 -t5 "http://keyserver.freifunk-
> >> franken.de/v2/?lat=$lat&long=$long" -O "$hoodfile"
> >>> @@ -119,7 +121,31 @@ else
> >>>  		fi
> >>>  	else
> >>>  		echo "We have a Gateway in Range, we load the
> >> keyxchangev2data from fe80::1"
> >>> -		wget -T15 -t5 "http://[fe80::1%br-
> >> mesh]:2342/keyxchangev2data" -O "$hoodfile"
> >>> +		# check eth first
> >>> +		eth="$(batctl if | grep "eth" | sed -nE
> >> 's/.*(eth[^:]+):.*/\1/p')"
> >>> +		oldhood=""
> >>> +		for mac in $(batctl n | grep "eth" | sed -nE 's/.*eth[0-
> >> 9.]+\s+([^\s]+)\s.*/\1/p'); do
> >>> +			EUI="$(echo "$mac" | awk -F: '{
> >> printf("%02x%s:%sff:fe%s:%s%s\n", xor(("0x"$1),2), $2, $3, $4, $5, $6) }')"
> >>> +			wget -T15 -t5
> >> "http://[fe80::${EUI}%${eth}]:2342/keyxchangev2data" -O "$hoodfile"
> >>> +			if [ -s "$hoodfile" ]; then
> >>> +				json_load "$(cat "$hoodfile")"
> >>> +				json_select hood
> >>> +				json_get_var newhood name
> >>> +				if [ -n "$oldhood" ] && [ -n "$newhood" ] && (
> >> ! [ "$newhood" = "$oldhood" ] ) ; then
> >>> +					# 2nd hood found, kill br-mesh and try
> >> again in 5 minutes
> >>> +					echo "Two hoods detected. Remove
> >> cables to stay in just one."
> >>> +					ifconfig br-mesh down
> >>
> >> Warum br-mesh abschalten? Dann ist ja das ganze Clientnetz weg (glaub
> >> ich)? Erschließt sich mir gerade gar nicht. Macht es nicht eher Sinn
> >> ethX.3 abzuschalten oder aus batctl if herausnehmen, damit Batman
> >> nicht mehr auf den Kabel läuft?
> >>
> >> mfg
> >>
> >> Christian
> >>
> >>> +					exit 0
> >>> +				fi
> >>> +				oldhood="$newhood"
> >>> +			fi
> >>> +		done
> >>> +		if [ ! -s "$hoodfile" ]; then
> >>> +			# Only load hoodfile from gateway if not already
> >> present from local network
> >>> +			# - This gives local network a precedence (take the
> >> hood from local network)
> >>> +			# - This prevents file insertion from a third person, as
> >> will will only connect via LAN to who I trust
> >>> +			wget -T15 -t5 "http://[fe80::1%br-
> >> mesh]:2342/keyxchangev2data" -O "$hoodfile"
> >>> +		fi
> >>>  		#UPLINK: Do nothing
> >>>  	fi
> >>>  fi
> >>>
> >
> >




Mehr Informationen über die Mailingliste franken-dev