From 89b7612fdbabd92ccfd0496fce568187d4e11081 Mon Sep 17 00:00:00 2001 From: Christof Schulze Date: Mon, 19 Nov 2018 07:21:02 +0100 Subject: [PATCH] gluon-l3roamd: init: dynamically configure mesh interfaces gracefully during reload This patch makes use of the new feature in l3roamd to gracefully add, remove and list the mesh interfaces that are currently in use. This helps when changing mesh interfaces often - a characteristic of the wireguard protocol implementation as in the previous behavior all local clients are dropped when adjusting mesh interfaces. --- .../files/etc/init.d/gluon-l3roamd | 33 +++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/package/gluon-l3roamd/files/etc/init.d/gluon-l3roamd b/package/gluon-l3roamd/files/etc/init.d/gluon-l3roamd index c64f3b1d..fb1ecdfc 100755 --- a/package/gluon-l3roamd/files/etc/init.d/gluon-l3roamd +++ b/package/gluon-l3roamd/files/etc/init.d/gluon-l3roamd @@ -5,10 +5,39 @@ START=55 USE_PROCD=1 PROG=/usr/sbin/l3roamd +echotol3roamd() { + local count=0 + local line="$1" + while ! (echo -e "$line" | uc /var/run/l3roamd.sock >/dev/null 2>&1) + do + sleep 1 + echo retrying to connect to l3roamd in PID $$, waited ${count}s >&2 + count=$((count+1)) + done + return 0 +} + + + +reload_service() { + for i in $(ubus call network.interface dump | jsonfilter -e "@.interface[@.proto='gluon_mesh' && @.up=true].device") + do + echotol3roamd "add_meshif $i" + done + + for i in $(echotol3roamd "get_meshifs"| jsonfilter -e "@.mesh_interfaces[@]") + do + if ! ubus call network.interface dump | jsonfilter -e "@.interface[@.proto='gluon_mesh' && @.up=true].device"|grep -q $i + then + echotol3roamd "del_meshif $i" + fi + done +} + start_service () { local interfaces=$( - for dev in $(gluon-list-mesh-interfaces); do echo " -m $dev"; done - [ "$(ifstatus local_node | jsonfilter -e '@.up')" = 'true' ] && echo ' -i local-node' + for dev in $(gluon-list-mesh-interfaces); do echo " -m $dev"; done + [ "$(ifstatus local_node | jsonfilter -e '@.up')" = 'true' ] && echo ' -i local-node' ) /sbin/sysctl -w net.ipv6.neigh.default.gc_thresh1=2 /sbin/sysctl -w net.ipv4.neigh.default.gc_thresh1=2