diff --git a/docs/site-example/site.conf b/docs/site-example/site.conf index 39263529..698ab8de 100644 --- a/docs/site-example/site.conf +++ b/docs/site-example/site.conf @@ -80,9 +80,6 @@ -- anycast IPs of all nodes ip4 = '10.xxx.0.xxx', ip6 = 'fdxx:xxxx:xxxx::xxxx', - - -- anycast MAC of all nodes - mac = 'xe:xx:xx:xx:xx:xx', }, -- Options specific to routing protocols (optional) diff --git a/docs/user/site.rst b/docs/user/site.rst index 099af5fe..51b9e78a 100644 --- a/docs/user/site.rst +++ b/docs/user/site.rst @@ -114,7 +114,7 @@ wifi24 \: optional interface's ESSID. This is the WiFi the clients connect to. ``mesh`` requires a single parameter, a string, named ``id`` which sets the - mesh id, also visible as an open WiFi in some network managers. Usually you + mesh id, also visible as an open WiFi in some network managers. Usually you don't want users to connect to this mesh-SSID, so use a cryptic id that no one will accidentally mistake for the client WiFi. @@ -154,10 +154,14 @@ next_node \: package next_node = { ip4 = '10.23.42.1', ip6 = 'fdca:ffee:babe:1::1', - mac = 'ca:ff:ee:ba:be:00' + mac = '16:41:95:40:f7:dc' } - The IPv4 next-node address is optional. + All values of this section are optional. If the IPv4 or IPv6 address is + omitted, there will be no IPv4 or IPv6 anycast address. The MAC address + defaults to ``16:41:95:40:f7:dc``; this value usually doesn't need to be + changed, but it can be adjusted to match existing deployments that use a + different value. mesh \: optional Options specific to routing protocols. @@ -284,7 +288,7 @@ mesh_on_wan \: optional mesh_on_lan \: optional Enables the mesh on the LAN port (``true`` or ``false``). :: - + mesh_on_lan = true, poe_passthrough \: optional diff --git a/package/gluon-client-bridge/check_site.lua b/package/gluon-client-bridge/check_site.lua index c71f11c0..34060f16 100644 --- a/package/gluon-client-bridge/check_site.lua +++ b/package/gluon-client-bridge/check_site.lua @@ -1,15 +1,15 @@ -need_string_match('next_node.mac', '^%x[02468aAcCeE]:%x%x:%x%x:%x%x:%x%x:%x%x$') +need_string_match('next_node.mac', '^%x[02468aAcCeE]:%x%x:%x%x:%x%x:%x%x:%x%x$', false) if need_string_match('next_node.ip4', '^%d+.%d+.%d+.%d+$', false) then - need_string_match('prefix4', '^%d+.%d+.%d+.%d+/%d+$') + need_string_match('prefix4', '^%d+.%d+.%d+.%d+/%d+$') end need_string_match('next_node.ip6', '^[%x:]+$', false) for _, config in ipairs({'wifi24', 'wifi5'}) do - if need_table(config .. '.ap', nil, false) then - need_string(config .. '.ap.ssid') - need_boolean(config .. '.ap.disabled', false) - end + if need_table(config .. '.ap', nil, false) then + need_string(config .. '.ap.ssid') + need_boolean(config .. '.ap.disabled', false) + end end diff --git a/package/gluon-client-bridge/luasrc/lib/gluon/upgrade/310-gluon-client-bridge-local-node b/package/gluon-client-bridge/luasrc/lib/gluon/upgrade/310-gluon-client-bridge-local-node index 43e54145..47b86481 100755 --- a/package/gluon-client-bridge/luasrc/lib/gluon/upgrade/310-gluon-client-bridge-local-node +++ b/package/gluon-client-bridge/luasrc/lib/gluon/upgrade/310-gluon-client-bridge-local-node @@ -1,16 +1,20 @@ #!/usr/bin/lua +local client_bridge = require 'gluon.client_bridge' local site = require 'gluon.site_config' local sysconfig = require 'gluon.sysconfig' local uci = require('simple-uci').cursor() +local next_node = site.next_node or {} + + uci:delete('network', 'local_node_dev') uci:section('network', 'device', 'local_node_dev', { type = 'veth', name = 'local-node', - macaddr = site.next_node.mac, + macaddr = client_bridge.next_node_macaddr(), peer_name = 'local-port', peer_macaddr = sysconfig.primary_mac, }) @@ -18,13 +22,13 @@ uci:section('network', 'device', 'local_node_dev', { local ip4, ip6 -if site.next_node.ip4 then +if next_node.ip4 then local plen = site.prefix4:match('/%d+$') - ip4 = site.next_node.ip4 .. plen + ip4 = next_node.ip4 .. plen end -if site.next_node.ip6 then - ip6 = site.next_node.ip6 .. '/128' +if next_node.ip6 then + ip6 = next_node.ip6 .. '/128' end uci:delete('network', 'local_node') diff --git a/package/gluon-client-bridge/luasrc/usr/lib/lua/gluon/client_bridge.lua b/package/gluon-client-bridge/luasrc/usr/lib/lua/gluon/client_bridge.lua new file mode 100644 index 00000000..e1ad2737 --- /dev/null +++ b/package/gluon-client-bridge/luasrc/usr/lib/lua/gluon/client_bridge.lua @@ -0,0 +1,8 @@ +local site = require 'gluon.site_config' + + +module 'gluon.client_bridge' + +function next_node_macaddr() + return (site.next_node or {}).mac or '16:41:95:40:f7:dc' +end diff --git a/package/gluon-mesh-batman-adv/files/lib/gluon/ebtables/250-next-node b/package/gluon-mesh-batman-adv/files/lib/gluon/ebtables/250-next-node index 54dd7e32..54c95736 100644 --- a/package/gluon-mesh-batman-adv/files/lib/gluon/ebtables/250-next-node +++ b/package/gluon-mesh-batman-adv/files/lib/gluon/ebtables/250-next-node @@ -1,10 +1,13 @@ +local client_bridge = require 'gluon.client_bridge' local site = require 'gluon.site_config' -local next_node = site.next_node +local next_node = site.next_node or {} -rule('FORWARD --logical-out br-client -o bat0 -d ' .. next_node.mac .. ' -j DROP') -rule('OUTPUT --logical-out br-client -o bat0 -d ' .. next_node.mac .. ' -j DROP') -rule('FORWARD --logical-out br-client -o bat0 -s ' .. next_node.mac .. ' -j DROP') -rule('OUTPUT --logical-out br-client -o bat0 -s ' .. next_node.mac .. ' -j DROP') +local macaddr = client_bridge.next_node_macaddr() + +rule('FORWARD --logical-out br-client -o bat0 -d ' .. macaddr .. ' -j DROP') +rule('OUTPUT --logical-out br-client -o bat0 -d ' .. macaddr .. ' -j DROP') +rule('FORWARD --logical-out br-client -o bat0 -s ' .. macaddr .. ' -j DROP') +rule('OUTPUT --logical-out br-client -o bat0 -s ' .. macaddr .. ' -j DROP') if next_node.ip4 then rule('FORWARD --logical-out br-client -o bat0 -p ARP --arp-ip-src ' .. next_node.ip4 .. ' -j DROP')