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:
parent
f9e68be4e0
commit
cb899874dc
@ -5,8 +5,8 @@ PKG_VERSION:=1
|
|||||||
|
|
||||||
include ../gluon.mk
|
include ../gluon.mk
|
||||||
|
|
||||||
define Package/gluon-mesh-batman-adv/common
|
define Package/gluon-mesh-batman-adv-common
|
||||||
PROVIDES:=gluon-mesh-batman-adv
|
TITLE:=Gluon scripts for batman-adv and batman-adv-legacy
|
||||||
DEPENDS:= \
|
DEPENDS:= \
|
||||||
+gluon-core \
|
+gluon-core \
|
||||||
+libgluonutil \
|
+libgluonutil \
|
||||||
@ -24,31 +24,35 @@ define Package/gluon-mesh-batman-adv/common
|
|||||||
endef
|
endef
|
||||||
|
|
||||||
define Package/gluon-mesh-batman-adv-14
|
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)
|
TITLE:=Support for batman-adv meshing (compat level 14)
|
||||||
CONFLICTS:=gluon-mesh-batman-adv-15
|
DEPENDS+= \
|
||||||
DEPENDS+=+kmod-batman-adv-legacy
|
+gluon-mesh-batman-adv-common \
|
||||||
|
+kmod-batman-adv-legacy
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Package/gluon-mesh-batman-adv-15
|
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)
|
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
|
endef
|
||||||
|
|
||||||
define Package/gluon-mesh-batman-adv-14/install
|
define Package/gluon-mesh-batman-adv-14/install
|
||||||
$(Gluon/Build/Install)
|
|
||||||
|
|
||||||
$(INSTALL_DIR) $(1)/lib/gluon/mesh-batman-adv
|
$(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
|
endef
|
||||||
|
#
|
||||||
define Package/gluon-mesh-batman-adv-15/install
|
define Package/gluon-mesh-batman-adv-15/install
|
||||||
$(Gluon/Build/Install)
|
|
||||||
|
|
||||||
$(INSTALL_DIR) $(1)/lib/gluon/mesh-batman-adv
|
$(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
|
endef
|
||||||
|
|
||||||
|
$(eval $(call BuildPackageGluon,gluon-mesh-batman-adv-common))
|
||||||
$(eval $(call BuildPackageGluon,gluon-mesh-batman-adv-14))
|
$(eval $(call BuildPackageGluon,gluon-mesh-batman-adv-14))
|
||||||
$(eval $(call BuildPackageGluon,gluon-mesh-batman-adv-15))
|
$(eval $(call BuildPackageGluon,gluon-mesh-batman-adv-15))
|
||||||
|
@ -2,4 +2,18 @@
|
|||||||
need_boolean(in_domain({'mesh', 'vxlan'}), not this_domain())
|
need_boolean(in_domain({'mesh', 'vxlan'}), not this_domain())
|
||||||
|
|
||||||
need_number({'mesh', 'batman_adv', 'gw_sel_class'}, false)
|
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)
|
||||||
|
@ -42,8 +42,14 @@ proto_gluon_bat0_setup() {
|
|||||||
echo 1 > /proc/sys/net/ipv6/conf/primary0/disable_ipv6
|
echo 1 > /proc/sys/net/ipv6/conf/primary0/disable_ipv6
|
||||||
ip link set primary0 address "$primary0_mac" mtu 1532 up
|
ip link set primary0 address "$primary0_mac" mtu 1532 up
|
||||||
|
|
||||||
local routing_algo="$(uci -q get batman-adv.bat0.routing_algo || echo 'BATMAN_IV')"
|
local routing_algo="$(lua -e 'print(require("gluon.site").mesh.batman_adv.routing_algo())')"
|
||||||
(echo "$routing_algo" >/sys/module/batman_adv/parameters/routing_algo) 2>/dev/null
|
|
||||||
|
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
|
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 bat0
|
||||||
ip link del primary0
|
ip link del primary0
|
||||||
|
|
||||||
|
rmmod batman-adv
|
||||||
}
|
}
|
||||||
|
|
||||||
add_protocol gluon_bat0
|
add_protocol gluon_bat0
|
||||||
|
@ -7,20 +7,32 @@ local util = require 'gluon.util'
|
|||||||
local uci = require('simple-uci').cursor()
|
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 gw_sel_class = site.mesh.batman_adv.gw_sel_class()
|
||||||
local routing_algo = site.mesh.batman_adv.routing_algo()
|
local routing_algo = site.mesh.batman_adv.routing_algo()
|
||||||
|
|
||||||
|
uci:delete('batman-adv-legacy', 'bat0')
|
||||||
uci:delete('batman-adv', 'bat0')
|
uci:delete('batman-adv', 'bat0')
|
||||||
uci:section('batman-adv', 'mesh', 'bat0', {
|
|
||||||
orig_interval = 5000,
|
if routing_algo == 'BATMAN_IV_LEGACY' then
|
||||||
gw_mode = gw_mode,
|
uci:section('batman-adv-legacy', 'mesh', 'bat0', {
|
||||||
gw_sel_class = gw_sel_class,
|
orig_interval = 5000,
|
||||||
hop_penalty = 15,
|
gw_mode = gw_mode,
|
||||||
routing_algo = routing_algo,
|
gw_sel_class = gw_sel_class,
|
||||||
multicast_mode = true,
|
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:save('batman-adv')
|
||||||
|
|
||||||
uci:delete('network', 'gluon_bat0')
|
uci:delete('network', 'gluon_bat0')
|
||||||
|
Loading…
Reference in New Issue
Block a user