gluon-mesh-batman-adv: allow installing mesh-batman-adv-14 and -15 at the same time

The new routing_algo site.conf value BATMAN_IV_LEGACY is introduced. With
these changes, the routing_algo setting becomes mandatory.

Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
This commit is contained in:
Linus Lüssing 2019-07-27 07:40:26 +02:00 committed by Matthias Schiffer
parent f9e68be4e0
commit cb899874dc
No known key found for this signature in database
GPG Key ID: 16EF3F64CB201D9C
4 changed files with 65 additions and 27 deletions

View File

@ -5,8 +5,8 @@ PKG_VERSION:=1
include ../gluon.mk
define Package/gluon-mesh-batman-adv/common
PROVIDES:=gluon-mesh-batman-adv
define Package/gluon-mesh-batman-adv-common
TITLE:=Gluon scripts for batman-adv and batman-adv-legacy
DEPENDS:= \
+gluon-core \
+libgluonutil \
@ -24,31 +24,35 @@ define Package/gluon-mesh-batman-adv/common
endef
define Package/gluon-mesh-batman-adv-14
$(Package/gluon-mesh-batman-adv/common)
PROVIDES:=gluon-mesh-batman-adv
TITLE:=Support for batman-adv meshing (compat level 14)
CONFLICTS:=gluon-mesh-batman-adv-15
DEPENDS+=+kmod-batman-adv-legacy
DEPENDS+= \
+gluon-mesh-batman-adv-common \
+kmod-batman-adv-legacy
endef
define Package/gluon-mesh-batman-adv-15
$(Package/gluon-mesh-batman-adv/common)
PROVIDES:=gluon-mesh-batman-adv
TITLE:=Support for batman-adv meshing (compat level 15)
DEPENDS+=+kmod-batman-adv
DEPENDS+= \
+gluon-mesh-batman-adv-common \
+kmod-batman-adv
endef
define Package/gluon-mesh-batman-adv-common/install
$(Gluon/Build/Install)
endef
define Package/gluon-mesh-batman-adv-14/install
$(Gluon/Build/Install)
$(INSTALL_DIR) $(1)/lib/gluon/mesh-batman-adv
echo 14 > $(1)/lib/gluon/mesh-batman-adv/compat
touch $(1)/lib/gluon/mesh-batman-adv/compat-14
endef
#
define Package/gluon-mesh-batman-adv-15/install
$(Gluon/Build/Install)
$(INSTALL_DIR) $(1)/lib/gluon/mesh-batman-adv
echo 15 > $(1)/lib/gluon/mesh-batman-adv/compat
touch $(1)/lib/gluon/mesh-batman-adv/compat-15
endef
$(eval $(call BuildPackageGluon,gluon-mesh-batman-adv-common))
$(eval $(call BuildPackageGluon,gluon-mesh-batman-adv-14))
$(eval $(call BuildPackageGluon,gluon-mesh-batman-adv-15))

View File

@ -2,4 +2,18 @@
need_boolean(in_domain({'mesh', 'vxlan'}), not this_domain())
need_number({'mesh', 'batman_adv', 'gw_sel_class'}, false)
need_one_of({'mesh', 'batman_adv', 'routing_algo'}, {'BATMAN_IV', 'BATMAN_V'}, false)
local allowed_algos = {}
local has_compat_14 = (os.execute('exec ls "$IPKG_INSTROOT"/lib/gluon/mesh-batman-adv/compat-14 >/dev/null 2>&1') == 0)
local has_compat_15 = (os.execute('exec ls "$IPKG_INSTROOT"/lib/gluon/mesh-batman-adv/compat-15 >/dev/null 2>&1') == 0)
if has_compat_14 then
table.insert(allowed_algos, 'BATMAN_IV_LEGACY')
end
if has_compat_15 then
table.insert(allowed_algos, 'BATMAN_IV')
table.insert(allowed_algos, 'BATMAN_V')
end
need_one_of({'mesh', 'batman_adv', 'routing_algo'}, allowed_algos)

View File

@ -42,8 +42,14 @@ proto_gluon_bat0_setup() {
echo 1 > /proc/sys/net/ipv6/conf/primary0/disable_ipv6
ip link set primary0 address "$primary0_mac" mtu 1532 up
local routing_algo="$(uci -q get batman-adv.bat0.routing_algo || echo 'BATMAN_IV')"
(echo "$routing_algo" >/sys/module/batman_adv/parameters/routing_algo) 2>/dev/null
local routing_algo="$(lua -e 'print(require("gluon.site").mesh.batman_adv.routing_algo())')"
if [ "$routing_algo" = 'BATMAN_IV_LEGACY' ]; then
modprobe batman-adv-legacy
else
modprobe batman-adv
(echo "$routing_algo" >/sys/module/batman_adv/parameters/routing_algo) 2>/dev/null
fi
echo bat0 > /sys/class/net/primary0/batman_adv/mesh_iface
@ -58,6 +64,8 @@ proto_gluon_bat0_teardown() {
ip link del bat0
ip link del primary0
rmmod batman-adv
}
add_protocol gluon_bat0

View File

@ -7,20 +7,32 @@ local util = require 'gluon.util'
local uci = require('simple-uci').cursor()
local gw_mode = uci:get('batman-adv', 'bat0', 'gw_mode') or 'client'
local gw_mode = uci:get('batman-adv', 'bat0', 'gw_mode') or uci:get('batman-adv-legacy', 'bat0', 'gw_mode') or 'client'
local gw_sel_class = site.mesh.batman_adv.gw_sel_class()
local routing_algo = site.mesh.batman_adv.routing_algo()
uci:delete('batman-adv-legacy', 'bat0')
uci:delete('batman-adv', 'bat0')
uci:section('batman-adv', 'mesh', 'bat0', {
orig_interval = 5000,
gw_mode = gw_mode,
gw_sel_class = gw_sel_class,
hop_penalty = 15,
routing_algo = routing_algo,
multicast_mode = true,
})
if routing_algo == 'BATMAN_IV_LEGACY' then
uci:section('batman-adv-legacy', 'mesh', 'bat0', {
orig_interval = 5000,
gw_mode = gw_mode,
gw_sel_class = gw_sel_class,
hop_penalty = 15,
})
else
uci:section('batman-adv', 'mesh', 'bat0', {
orig_interval = 5000,
gw_mode = gw_mode,
gw_sel_class = gw_sel_class,
hop_penalty = 15,
routing_algo = routing_algo,
multicast_mode = true,
})
end
uci:save('batman-adv-legacy')
uci:save('batman-adv')
uci:delete('network', 'gluon_bat0')