From 59b7625e542b29a477b7d789ee071ff7eed86da8 Mon Sep 17 00:00:00 2001 From: Christof Schulze Date: Sun, 8 Sep 2019 16:06:00 +0200 Subject: [PATCH] gluon-l3roamd: utilize node_client_prefix6 from site, add checks * add check_site.lua to validate required field from site * make use of node_client_prefix6 if defined in site --- package/gluon-l3roamd/check_site.lua | 3 +++ package/gluon-l3roamd/files/etc/init.d/gluon-l3roamd | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 package/gluon-l3roamd/check_site.lua diff --git a/package/gluon-l3roamd/check_site.lua b/package/gluon-l3roamd/check_site.lua new file mode 100644 index 00000000..f1e98a13 --- /dev/null +++ b/package/gluon-l3roamd/check_site.lua @@ -0,0 +1,3 @@ +need_string_match(in_domain({'prefix6'}), '^[%x:]+/64$', true) +need_string_match(in_domain({'node_client_prefix6'}), '^[%x:]+/64$', false) +need_string_match(in_domain({'prefix4'}), '^%d+.%d+.%d+.%d+/%d+$', false) diff --git a/package/gluon-l3roamd/files/etc/init.d/gluon-l3roamd b/package/gluon-l3roamd/files/etc/init.d/gluon-l3roamd index fb1ecdfc..c3ac1892 100755 --- a/package/gluon-l3roamd/files/etc/init.d/gluon-l3roamd +++ b/package/gluon-l3roamd/files/etc/init.d/gluon-l3roamd @@ -39,6 +39,12 @@ start_service () { for dev in $(gluon-list-mesh-interfaces); do echo " -m $dev"; done [ "$(ifstatus local_node | jsonfilter -e '@.up')" = 'true' ] && echo ' -i local-node' ) + + local prefix4="$(lua -e 'prefix4 = require("gluon.site").prefix4() if prefix4 then print(" -p " .. prefix4) end')" + local prefix6="$(lua -e 'print(" -p " .. require("gluon.site").prefix6())')" + local localip="$(uci get network.loopback.ip6addr | cut -d/ -f1)" + local roamingprefix="$(lua -e 'roamingprefix = require("gluon.site").node_client_prefix6() if roamingprefix then print(" -P " .. roamingprefix) end')" + /sbin/sysctl -w net.ipv6.neigh.default.gc_thresh1=2 /sbin/sysctl -w net.ipv4.neigh.default.gc_thresh1=2 @@ -46,7 +52,7 @@ start_service () { procd_set_param stdout 1 procd_set_param stderr 1 procd_set_param respawn ${respawn_threshold:-3660} ${respawn_timeout:-5} ${respawn_retry:-0} - procd_set_param command "$PROG" -s /var/run/l3roamd.sock -p $(lua -e 'print(require("gluon.site").prefix6())') $interfaces -t 254 -a $(uci get network.loopback.ip6addr | cut -d/ -f1) -4 0:0:0:0:0:ffff::/96 -b br-client + procd_set_param command "$PROG" -s /var/run/l3roamd.sock $prefix4 $prefix6 $interfaces -t 254 -a $localip -b br-client $roamingprefix procd_close_instance }