Developing lightweight computation at the DSG edge

Commit 25c265fa authored by p4u's avatar p4u
Browse files

New approach for qmp gateways management:

- they are defined in /etc/config/gateways
- they are not typed section anymore but named ones
- the section name is the gw name plus qmp_
- fix some bugs found (unconfigure_bmx6_tunnels did not work)
- add a uci-defaults script to remove old gateways
TODO: a uci-defaults script which translate the old gateways into the new format
parent a34362ac
config gateway inet6
option type 'search'
option network '::/0'
option maxPrefixLen '0'
config gateway inet4
option type 'search'
option network '0.0.0.0/0'
option maxPrefixLen '0'
option ignore '1'
config gateway inet4of
option ignore '1'
option type 'offer'
option network '0.0.0.0/0'
option bandwidth '100000'
config gateway community6
option type 'search'
option network '::/0'
option minPrefixLen '32'
option maxPrefixLen '48'
config gateway cloud6
option type 'search'
option network '::/0'
option minPrefixLen '48'
config gateway community
option type 'search'
option network '10.0.0.0/8'
option maxPrefixLen '8'
option ignore '1'
config gateway communityof
option type 'offer'
option network '10.0.0.0/8'
option bandwidth '100000'
option ignore '0'
config gateway cloud
option type 'search'
option network '10.0.0.0/8'
option minPrefixLen '24'
config gateway example
option ignore '1'
option type 'search'
option gwName 'qMp-example'
option network '10.1.0.0/16'
option address '10.2.2.2/32'
option minPrefixLen '16'
option maxPrefixLen '24'
option hysteresis '20'
option bonus '10'
option minBandwidth '10000'
option exportDistance '10'
config gateway inet6of
option type 'offer'
option network '::/0'
option ignore '1'
......@@ -868,11 +868,12 @@ qmp_configure_network() {
qmp_remove_qmp_bmx6_tunnels()
{
if echo "$1" | grep -q "^qmp-[0-9]*$"
{
if echo "$1" | grep -q "^qmp_"
then
uci delete bmx6.$1
fi
uci commit bmx6
}
qmp_unconfigure_bmx6_gateways()
......@@ -905,14 +906,18 @@ qmp_translate_configuration()
qmp_add_qmp_bmx6_tunnels()
{
local section=$1
local name="$section"
local config=bmx6
local name="qmp_$gateway"
local ignore
config_get ignore "$section" ignore
if [ "$ignore" = "1" ]
then
return
fi
[ "$ignore" = "1" ] && return
[ -z "$name" ] && name="qmp_$gateway" || name="qmp_$name"
qmp_log Configuring gateway $name
local type
config_get type "$section" type
if [ "$type" = "offer" ]
......@@ -921,21 +926,21 @@ qmp_add_qmp_bmx6_tunnels()
# Future configuration
#bmx6_type=tunIn
uci set $config.$name="$bmx6_type"
uci set $config.$name.$bmx6_type="$name"
qmp_translate_configuration qmp $section network $config $name $bmx6_type
uci set $config.$name.$bmx6_type="$section"
qmp_translate_configuration gateways $section network $config $name $bmx6_type
# Future configuration
#qmp_translate_configuration qmp $section network $config $name
qmp_translate_configuration qmp $section bandwidth $config $name
#qmp_translate_configuration gateways $section network $config $name
qmp_translate_configuration gateways $section bandwidth $config $name
else
# if [ "$type" = "search" ]
bmx6_type=tunOut
uci set $config.$name="$bmx6_type"
uci set $config.$name.$bmx6_type="$name"
uci set $config.$name.$bmx6_type="$section"
local t
for t in network gwName address minPrefixLen maxPrefixLen hysteresis bonus \
tableRule minBandwidth exportDistance
do
qmp_translate_configuration qmp $section $t $config $name
qmp_translate_configuration gateways $section $t $config $name
done
fi
......@@ -945,9 +950,10 @@ qmp_add_qmp_bmx6_tunnels()
qmp_configure_bmx6_gateways()
{
qmp_unconfigure_bmx6_gateways
config_load qmp
config_load gateways
gateway=0
config_foreach qmp_add_qmp_bmx6_tunnels gateway
uci commit bmx6
}
......
......@@ -43,10 +43,7 @@ qmp_exists_gateway()
args_key_values="$(echo $@ | awk -v RS=' ' 'NR % 2 == 1 && $0 !~ "^(ignore|(minB|b)andwidth)$" {a+=1} END {print a}')"
uci_key_values=$(env | grep -v -e "^CONFIG_${config}_\(TYPE\|ignore\|\(minB\|b\)andwidth\)=" | grep -c "^CONFIG_${config}_")
if [ "$args_key_values" != "$uci_key_values" ]
then
return
fi
[ "$args_key_values" != "$uci_key_values" ] && return
while [ $# -ge 2 ]
do
......@@ -64,23 +61,23 @@ qmp_exists_gateway()
shift
done
uci_set qmp "$config" ignore "$ignore"
uci_set gateways "$config" ignore "$ignore"
uci_commit
qmp_gateway_found=true
}
qmp_set_gateway()
{
config_load qmp
config_load gateways
qmp_gateway_found=false
config_foreach qmp_exists_gateway gateway $@
if ! $qmp_gateway_found
then
local config
config="$(uci add qmp gateway)"
config="$(uci add gateways gateway)"
while [ $# -ge 2 ]
do
uci_set qmp "$config" "$1" "$2"
uci_set gateways "$config" "$1" "$2"
shift
shift
done
......
#!/bin/sh
i=0
while true; do
uci -q del qmp.@gateway[0]
[ $? -ne 0 ] && break
i=$(($i+1))
done
uci commit
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment