summaryrefslogtreecommitdiff
path: root/files/common
diff options
context:
space:
mode:
authorKatze Miau <miaukatzemiau@priveasy.de>2011-12-11 13:32:54 (GMT)
committerKatze Miau <miaukatzemiau@priveasy.de>2011-12-11 13:32:54 (GMT)
commited254615ad04befe9f847879b3d78567c51f673b (patch)
treecee5bfabbb6a9aa707acd5e575ecfd195134c258 /files/common
parent586b5073ab8b0b745e627a3e246e45e4052e6f8d (diff)
fsm inetable: sync mesh iface w/ uci, use batctl gw off, reduce redundancy
- add mesh_add/del_ipv4 to set/unset IPv4 addresses of mesh iface; the address is set using ifconfig to avoid ifudown+ifup but also updated in UCI to maintain a consistent state - use this function in queen, ghost and robinson state transitions - use `batctl gw off` in robinson state: this allows to deliever local DHCP replies while dropping the idea of announcing fake gateways - ghost.leave reuses queen.leave
Diffstat (limited to 'files/common')
-rw-r--r--files/common/etc/fsm/inetable/common.sh22
-rwxr-xr-xfiles/common/etc/fsm/inetable/trans/default.enter3
-rwxr-xr-xfiles/common/etc/fsm/inetable/trans/ghost.leave14
-rwxr-xr-xfiles/common/etc/fsm/inetable/trans/queen.enter3
-rwxr-xr-xfiles/common/etc/fsm/inetable/trans/queen.leave4
-rwxr-xr-xfiles/common/etc/fsm/inetable/trans/robinson.enter10
-rwxr-xr-xfiles/common/etc/fsm/inetable/trans/robinson.leave4
7 files changed, 38 insertions, 22 deletions
diff --git a/files/common/etc/fsm/inetable/common.sh b/files/common/etc/fsm/inetable/common.sh
index 7c73837..148c369 100644
--- a/files/common/etc/fsm/inetable/common.sh
+++ b/files/common/etc/fsm/inetable/common.sh
@@ -1,5 +1,25 @@
cloud_is_online () {
# look for mac addrs in batman gateway list
- # TODO: remove fake gws with almost zero bandwith
batctl gwl | tail -n-1 | egrep -q '([0-9a-f]{2}:){5}[0-9a-f]{2}'
}
+
+## add/remove IPv4 address from mesh iface
+# manual update to avoid full ifdown+ifup, but update uci state for
+# other users (e.g. dnsmasq)
+mesh_add_ipv4 () {
+ ifconfig br-mesh $1 netmask $2
+ echo "
+set network.mesh.ipaddr=$1
+set network.mesh.proto=static
+set network.mesh.netmask=$2
+" | uci batch
+}
+
+mesh_del_ipv4 () {
+ ifconfig br-mesh 0.0.0.0
+ echo "
+delete network.mesh.ipaddr
+delete network.mesh.proto
+delete network.mesh.netmask
+" | uci batch
+}
diff --git a/files/common/etc/fsm/inetable/trans/default.enter b/files/common/etc/fsm/inetable/trans/default.enter
new file mode 100755
index 0000000..7ca822c
--- /dev/null
+++ b/files/common/etc/fsm/inetable/trans/default.enter
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+batctl gw client \ No newline at end of file
diff --git a/files/common/etc/fsm/inetable/trans/ghost.leave b/files/common/etc/fsm/inetable/trans/ghost.leave
index 747a05d..df16d99 100755
--- a/files/common/etc/fsm/inetable/trans/ghost.leave
+++ b/files/common/etc/fsm/inetable/trans/ghost.leave
@@ -2,16 +2,4 @@
rm /tmp/ghost_since
-# free our gw ip
-ifconfig br-mesh 0.0.0.0
-
-# update status of our gateway ip
-if we_own_our_ip; then
- p2ptbl update $gwiptbl $oct3 free br-mesh
-fi
-
-# disable DHCP
-uci delete dhcp.mesh
-/etc/init.d/dnsmasq restart
-
-# TODO: remove internet redirection & splash iptable \ No newline at end of file
+./queen.leave "$1"
diff --git a/files/common/etc/fsm/inetable/trans/queen.enter b/files/common/etc/fsm/inetable/trans/queen.enter
index 6eac3a0..fe0799e 100755
--- a/files/common/etc/fsm/inetable/trans/queen.enter
+++ b/files/common/etc/fsm/inetable/trans/queen.enter
@@ -1,4 +1,5 @@
#!/bin/sh -e
+. ../common.sh
gwiptbl=/tmp/p2ptbl/gwip
NodeId="$(cat /etc/nodeid)"
@@ -30,7 +31,7 @@ p2ptbl update $gwiptbl $oct3 "queen\t$NodeId" br-mesh
batctl gw server
# set up gw IP
-ifconfig br-mesh 10.17.$oct3.1
+mesh_add_ipv4 10.17.$oct3.1 255.255.0.0
# TODO: load splash status
diff --git a/files/common/etc/fsm/inetable/trans/queen.leave b/files/common/etc/fsm/inetable/trans/queen.leave
index 660f2e2..502e972 100755
--- a/files/common/etc/fsm/inetable/trans/queen.leave
+++ b/files/common/etc/fsm/inetable/trans/queen.leave
@@ -1,9 +1,13 @@
#!/bin/sh -e
+. ../common.sh
. ../common_queen.sh
# do not announce gateway anymore
batctl gw client
+# free gw IP
+mesh_del_ipv4
+
# release IP in p2ptable (if we still own it)
if we_own_our_ip; then
p2ptbl update $gwiptbl $oct3 free br-mesh
diff --git a/files/common/etc/fsm/inetable/trans/robinson.enter b/files/common/etc/fsm/inetable/trans/robinson.enter
index 7ea0001..163f155 100755
--- a/files/common/etc/fsm/inetable/trans/robinson.enter
+++ b/files/common/etc/fsm/inetable/trans/robinson.enter
@@ -1,4 +1,5 @@
#!/bin/sh -e
+. ../common.sh
# setup random ip
gen_randnet () {
@@ -9,7 +10,8 @@ gen_randnet
while ! arping -I br-mesh -D -c 5 -q $randnet.1; do
gen_randnet
done
-ifconfig br-mesh $randnet.1
+
+mesh_add_ipv4 $randnet.1 255.0.0.0
# setup dhcp
echo "
@@ -18,13 +20,11 @@ set dhcp.mesh.start=2
set dhcp.mesh.limit=254
set dhcp.mesh.leasetime=60
set dhcp.mesh.interface=mesh
-set dhcp.mesh.start_ip=$randnet.2
-set dhcp.mesh.end_ip=$randnet.254
" | uci batch
/etc/init.d/dnsmasq restart
-# announce fake gateway; TODO: announce only tiny bandwith
-batctl gw server
+# disable batman-adv-mangling with DHCP packets
+batctl gw off
# TODO: start fake dns
diff --git a/files/common/etc/fsm/inetable/trans/robinson.leave b/files/common/etc/fsm/inetable/trans/robinson.leave
index b7f49b8..cdc5461 100755
--- a/files/common/etc/fsm/inetable/trans/robinson.leave
+++ b/files/common/etc/fsm/inetable/trans/robinson.leave
@@ -1,7 +1,7 @@
#!/bin/sh -e
+. ../common.sh
-# stop announcing fake gateway
-batctl gw client
+mesh_del_ipv4
# stop DHCP server
uci delete dhcp.mesh
contact: Jan Huwald // Impressum