Skip to content

Commit

Permalink
gluon-mesh-olsrd: support clientap
Browse files Browse the repository at this point in the history
  • Loading branch information
mkg20001 committed Jun 13, 2023
1 parent 2c2e57e commit 018bc97
Show file tree
Hide file tree
Showing 8 changed files with 420 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package/features
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ when(_'status-page' and _'mesh-batman-adv-15', {
})


when(_'mesh-babel', {
when(_'mesh-babel' or _'mesh-olsrd', {
'gluon-radvd',
})

Expand Down
3 changes: 2 additions & 1 deletion package/gluon-mesh-olsrd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ define Package/gluon-mesh-olsrd
@IPV6 \
+oonf-olsrd2 \
+firewall \
+gluon-mesh-layer3-common
+gluon-mesh-layer3-common \
+gluon-l3roamd
PROVIDES:=gluon-mesh-provider
endef

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ local uci = require('simple-uci').cursor()
local site = require 'gluon.site'
local util = require 'gluon.util'
local wireless = require 'gluon.wireless'
local l3 = require 'gluon.l3'

local mesh_interfaces = util.get_role_interfaces(uci, 'mesh')
local uplink_interfaces = util.get_role_interfaces(uci, 'uplink')
local client_interfaces = util.get_role_interfaces(uci, 'client')
Expand Down Expand Up @@ -51,7 +53,6 @@ if pcall(function() require 'gluon.mesh-vpn' end) then
end
end

table.insert(intf.wired_mesh, 'loopback')

local has_uplink_mesh = false
local has_other_mesh = false
Expand All @@ -73,14 +74,15 @@ if has_other_mesh then
end

uci:delete_all('olsrd2', 'interface')
uci:delete_all('olsrd2', 'lan_import')

if site.mesh.olsrd.v2.enable(true) then
os.execute('/etc/init.d/olsrd2 enable')

local addrs = { }
local lan = { }
local lan = nil
local orig = { }
local cfg = site.mesh.olsrd.v2
local config = uci:get_first("olsrd2", "olsrv2")

-- set global config
local olsr2Config = {
Expand Down Expand Up @@ -115,11 +117,26 @@ if site.mesh.olsrd.v2.enable(true) then

table.insert(addrs, '-127.0.0.1/8')
table.insert(addrs, '-::1/128')
local addr = uci:get('network', 'loopback', 'ip6addr')
table.insert(orig, addr)

table.insert(addrs, 'default_accept')
table.insert(orig, 'default_reject')

local client_ranges_v6 = {}
local l3roamd_ranges = {}

table.insert(client_ranges_v6, site.prefix6())
table.insert(client_ranges_v6, 'default_reject')

uci:set("olsrd2", config, "originator", addrs)
uci:set("olsrd2", config, "lan", lan)
table.insert(l3roamd_ranges, l3.node_client_prefix6())
table.insert(l3roamd_ranges, 'default_reject')

uci:delete_all('olsrd2', 'olsrv2')
uci:section('olsrd2', 'olsrv2', nil, {
originator = orig,
lan = lan,
})

if #intf.wired_mesh then
uci:section('olsrd2', 'interface', 'wired_mesh', {
Expand All @@ -142,11 +159,33 @@ if site.mesh.olsrd.v2.enable(true) then
})
end

local loopback_addrs = {
uci:get('network', 'loopback', 'ip6addr'),
'default_reject',
}

uci:section('olsrd2', 'interface', 'loopback', {
ifname = { 'loopback' },
bindto = addrs,
routeable = loopback_addrs,
bindto = loopback_addrs,
})

uci:section('olsrd2', 'lan_import', 'l3roamd_clients_v6', {
name = 'l3roamd_clients_v6',
matches = client_ranges_v6,
prefix_length = 128,
protocol = 158, -- l3roamd
})

-- This does not work as olsrv2 rejects any addresses from loopback
-- as that is already a mesh interface
-- l3roamd works fine without, as wifi disassociation events still notify
-- the daemon and remove the routes
--uci:section('olsrd2', 'lan_import', 'l3roamd_prefix', {
-- name = 'l3roamd_ranges',
-- matches = l3roamd_ranges,
--})

uci:section('firewall', 'rule', 'allow_olsr2_mesh', {
src = 'mesh',
dest_port = '269',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
From: Maciej Krüger <[email protected]>
Date: Mon, 2 Jan 2023 01:45:37 +0100
Subject: oonf-olsrd2: fix building with multiple plugins

Code to replace colons wasn't working (debian stable)
Took it from stackoverflow, works now

diff --git a/oonf-olsrd2/Makefile b/oonf-olsrd2/Makefile
index 40190edb72547587bc53bb3bee150398b7413aa2..6067003a846340fb0e6221c2473959480b12fb4b 100644
--- a/oonf-olsrd2/Makefile
+++ b/oonf-olsrd2/Makefile
@@ -17,8 +17,8 @@ CMAKE_INSTALL:=1
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/cmake.mk

-SPACE:=
-SPACE+=
+# ref https://stackoverflow.com/a/10571900/3990041
+SPACE:= $(subst ,, )
CMAKE_OPTIONAL_PLUGINS:= $(subst $(SPACE),;,$(strip \
$(if $(filter y,$(CONFIG_OONF_NHDP_AUTOLL4)),auto_ll4,) \
$(if $(filter y,$(CONFIG_OONF_OLSRV2_LAN_IMPORT)),lan_import,) \
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
From: Patrick Grimm <[email protected]>
Date: Sun, 8 Jan 2023 18:14:36 +0100
Subject: oonf-olsrd2: add missing static plugin olsrv2_lan

Signed-off-by: Patrick Grimm <[email protected]>

diff --git a/oonf-olsrd2/Config.in b/oonf-olsrd2/Config.in
index 1cc037aff3ebc9a2a1ea2d2c94857d62b8b28006..b0d7d7cb2767f7b12d089ccd44042e6788dcf9de 100644
--- a/oonf-olsrd2/Config.in
+++ b/oonf-olsrd2/Config.in
@@ -44,4 +44,16 @@
The MPR plugin reduce the routing graph to limit the overhead of the OLSRv2 protocol
default n

+ config OONF_OLSRV2_LAN
+ bool "New config option for Locally attached entries"
+ help
+ Adds the 'lan' section to the config to configure LANs without setting multiple settings in a single key/value pair
+ default y
+
+ config OONF_OLSRV2_OLD_LAN
+ bool "Legacy option for Locally attached entries"
+ help
+ Adds the olsr 'lan' config key in the olsrv2 section
+ default n
+
endmenu
diff --git a/oonf-olsrd2/Makefile b/oonf-olsrd2/Makefile
index 6067003a846340fb0e6221c2473959480b12fb4b..f3d81fcfe61936635280afd997ec487ed0ffa2fc 100644
--- a/oonf-olsrd2/Makefile
+++ b/oonf-olsrd2/Makefile
@@ -27,6 +27,8 @@ CMAKE_OPTIONAL_PLUGINS:= $(subst $(SPACE),;,$(strip \
$(if $(filter y,$(CONFIG_OONF_GENERIC_REMOTECONTROL)),remotecontrol,) \
$(if $(filter y,$(CONFIG_OONF_OLSRV2_MPR)),mpr,) \
$(if $(filter y,$(CONFIG_OONF_GENERIC_HTTP)),http,) \
+ $(if $(filter y,$(CONFIG_OONF_OLSRV2_LAN)),olsrv2_lan,) \
+ $(if $(filter y,$(CONFIG_OONF_OLSRV2_OLD_LAN)),olsrv2_old_lan,) \
))

BUILD_TYPE:= $(if $(filter y,$(CONFIG_DEBUG)),Debug,Release)
Loading

0 comments on commit 018bc97

Please sign in to comment.