Skip to content
Snippets Groups Projects
Commit b262b725 authored by Matthias Schiffer's avatar Matthias Schiffer Committed by Martin Weinelt
Browse files

gluon-mesh-batman-adv: adjust to removal of batman-adv UCI config

parent 75fa7e73
No related branches found
No related tags found
No related merge requests found
...@@ -8,6 +8,13 @@ proto_gluon_bat0_init_config() { ...@@ -8,6 +8,13 @@ proto_gluon_bat0_init_config() {
no_device=1 no_device=1
available=1 available=1
renew_handler=1 renew_handler=1
proto_config_add_string 'gw_mode'
}
lookup_site() {
local path="$1" default="$2"
lua -e "print(require('gluon.site').$path('$default'))"
} }
proto_gluon_bat0_renew() { proto_gluon_bat0_renew() {
...@@ -36,16 +43,43 @@ proto_gluon_bat0_renew() { ...@@ -36,16 +43,43 @@ proto_gluon_bat0_renew() {
proto_gluon_bat0_setup() { proto_gluon_bat0_setup() {
local config="$1" local config="$1"
local routing_algo=$(lookup_site 'mesh.batman_adv.routing_algo' 'BATMAN_IV')
local gw_mode
json_get_vars gw_mode
batctl routing_algo "$routing_algo"
batctl interface create
batctl orig_interval 5000
batctl hop_penalty 15
batctl multicast_mode 0
case "$gw_mode" in
server)
batctl gw_mode "server"
;;
client)
local gw_sel_class="$(lookup_site 'mesh.batman_adv.gw_sel_class')"
if [ -n "$gw_sel_class" ]; then
batctl gw_mode "client" "$gw_sel_class"
else
batctl gw_mode "client"
fi
;;
*)
batctl gw_mode "off"
;;
esac
local primary0_mac="$(lua -e 'print(require("gluon.util").generate_mac(3))')" local primary0_mac="$(lua -e 'print(require("gluon.util").generate_mac(3))')"
ip link add primary0 type dummy ip link add primary0 type dummy
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="$(lua -e 'print(require("gluon.site").mesh.batman_adv.routing_algo())')" batctl interface add primary0
(echo "$routing_algo" >/sys/module/batman_adv/parameters/routing_algo) 2>/dev/null
echo bat0 > /sys/class/net/primary0/batman_adv/mesh_iface
proto_init_update primary0 1 proto_init_update primary0 1
proto_send_update "$config" proto_send_update "$config"
...@@ -56,7 +90,7 @@ proto_gluon_bat0_setup() { ...@@ -56,7 +90,7 @@ proto_gluon_bat0_setup() {
proto_gluon_bat0_teardown() { proto_gluon_bat0_teardown() {
local config="$1" local config="$1"
ip link del bat0 batctl interface destroy
ip link del primary0 ip link del primary0
} }
......
#!/usr/bin/lua #!/usr/bin/lua
local sysconfig = require 'gluon.sysconfig' local sysconfig = require 'gluon.sysconfig'
local site = require 'gluon.site'
local util = require 'gluon.util' 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('network', 'gluon_bat0', 'gw_mode') or uci:get('network', '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-legacy', 'bat0')
uci:save('batman-adv-legacy') uci:save('batman-adv-legacy')
uci:delete('batman-adv', '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 = false,
})
uci:save('batman-adv') uci:save('batman-adv')
uci:delete('network', 'gluon_bat0') uci:delete('network', 'gluon_bat0')
uci:section('network', 'interface', 'gluon_bat0', { uci:section('network', 'interface', 'gluon_bat0', {
proto = 'gluon_bat0', proto = 'gluon_bat0',
gw_mode = gw_mode,
}) })
uci:delete('network', 'bat0') uci:delete('network', 'bat0')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment