From patchwork Sun Oct 8 13:28:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [v7] Configure the Node a routable IPv6 ULA From: Tim Niemeyer X-Patchwork-Id: 543 Message-Id: <20171008132831.19308-1-tim@tn-x.org> To: franken-dev@freifunk.net Cc: Adrian Schmutzler Date: Sun, 8 Oct 2017 15:28:31 +0200 From: Adrian Schmutzler Signed-off-by: Christian Dresel Signed-off-by: Adrian Schmutzler Signed-off-by: Tim Niemeyer --- Changes in v7: - Add EUI64 address - Change ifconfig to ip Changes in v6: - Typo in echo - Optimized sed Changes in v5: - Only apply if ula_prefix is not empty - Remove escape sign from ula_prefix Changes in v4: - Optimized grep and sed Changes in v3: - Added route block - Inverted condition in address block - Changed if style to "grep -q" - Added some quotes Changes in v2: - Rebased onto keyXchange v2 patchset v15 - correctly handle keyxchangev2data without reloading - added some quotes .../fff/fff-hoods/files/usr/sbin/configurehood | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood index 62b3b3b..c4815b9 100755 --- a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood +++ b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood @@ -161,6 +161,40 @@ if [ -s /tmp/keyxchangev2data ]; then fi done + # now we load the prefix from the hoodfile and set this to br-mesh + json_select network + json_get_var prefix ula_prefix + # Set $prefix::MAC as IP + if [ -n "$prefix" ] ; then + suffix="$(awk -F: '{ print $1$2":"$3$4":"$5$6 }' /sys/class/net/br-mesh/address)" + addr="$(echo "$prefix" | sed -e 's,\\,,' -e 's,/,'$suffix'/,')" + for ip in $(ip -6 addr show dev br-mesh | grep inet6 | grep -v -e "fe80::" -e "fdff::" | cut -f6 -d " "); do + ip -6 addr del "$ip" dev br-mesh + done + if ! ( ip -6 addr show dev br-mesh | grep -q "$addr" ) ; then + ip -6 addr add "$addr" dev br-mesh + echo "Set ULA address to br-mesh: $addr" + else + echo "Address already set." + fi + # Set $prefix::link-local as IP + suffix=$(awk -F: '{ printf("%02x%s:%sff:fe%s:%s%s\n", xor(("0x"$1),2), $2, $3, $4, $5, $6) }' /sys/class/net/br- mesh/address) + addr=$(echo $prefix | sed -e 's/\//'$suffix'\//') + if ! ( ip -6 addr show dev br-mesh | grep -q "$addr" ) ; then + ip -6 addr add $addr dev br-mesh + echo "Set ULA EUI-64 address to br-mesh: $addr" + else + echo "Address already set." + fi + if ! ( ip -6 route show dev br-mesh | grep -q "fc00::" ) ; then + ip -6 route add fc00::/7 via fe80::1 dev br-mesh + echo "Set ULA route to br-mesh." + else + echo "Route already set." + fi + fi + json_select ".." # back to root + echo "Loading wifi" wifi