fff-layer3-vxmesh: join multple client nets with vxlan #82

Closed
jkimmel wants to merge 3 commits from jkimmel/firmware:vxmesh into master
3 changed files with 142 additions and 2 deletions
Showing only changes of commit dd69724837 - Show all commits

View File

@ -0,0 +1,29 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=fff-layer3-vxmesh
PKG_RELEASE:=1
include $(INCLUDE_DIR)/package.mk
define Package/fff-layer3-vxmesh
SECTION:=base
CATEGORY:=Freifunk
TITLE:=Freifunk-Franken layer3 configuration for mesh via vxlan
URL:=http://www.freifunk-franken.de
DEPENDS:=+vxlan
endef
define Package/fff-layer3-vxmesh/description
Adds a simple configuration to connect multple routers into one layer 2
network via vxlan.
endef
define Build/Compile
# nothing
endef
define Package/fff-layer3-vxmesh/install
$(CP) ./files/* $(1)/
endef
$(eval $(call BuildPackage,fff-layer3-vxmesh))

View File

@ -0,0 +1,111 @@
#!/bin/sh
configure() {
local proto
local peerip
local otherpeers
local fields="
proto
port
vid
ttl
tos
mtu
macaddr
zone
rxcsum
txcsum
srcportmin
srcportmax
ageing
maxaddress
learning
rsc
proxy
l2miss
l3miss
gbp
tunlink
ipaddr
ip6addr
"
# cleanup old vxmesh and peer entries
uci -q delete network.vxmesh0
while uci -q delete network.@vxlan_peer[-1]; do :; done
# remove vxmesh0 entry from the client bridge and remove extra whitespaces
uci set network.client.ifname="$(uci -q get network.client.ifname | sed s/vxmesh0// | xargs)"
# reset dns to authorative
uci set dhcp.@dnsmasq[0].authoritative="1"
# check if a vxmesh config is available, otherwise quit
uci -q get gateway.@vxmesh[0] > /dev/null || return 0
# check if proto is set and probe for the correct peer ip
proto="$(uci -q get gateway.@vxmesh[0].proto)"
case "$proto" in
jkimmel marked this conversation as resolved Outdated

Hatte ich jetzt auch als One-liner gemacht, so lange kein output dazu muss:

uci -q get gateway.@vxmesh[0] > /dev/null || return 0

Hatte ich jetzt auch als One-liner gemacht, so lange kein output dazu muss: `uci -q get gateway.@vxmesh[0] > /dev/null || return 0`
vxlan6)
peerip="$(uci -q get gateway.@gateway[0].peer_ip6)"
;;
vxlan)
peerip="$(uci -q get gateway.@gateway[0].peer_ip)"
;;
jkimmel marked this conversation as resolved Outdated

Die ;; vielleicht in die zeile darunter schieben, wie beim default case.

Die ;; vielleicht in die zeile darunter schieben, wie beim default case.
*)
echo "FATAL: vxmesh: option proto 'vxlan|vxlan6' required!"
return 1
;;
esac
# vxmesh needs a separate peer ip as the ip on the client interface ip
# might be shared over multiple devices
[ -z "$peerip" ] && {
echo "FATAL: vxmesh: peer_ip|peer_ip6 required!"
return 1
}
uci -q get gateway.@vxmesh[0].vid > /dev/null || {
echo "FATAL: vxmesh: missing vid!"
return 1
}
# copy main options over
uci set network.vxmesh0="interface"
for option in $fields; do
uci set network.vxmesh0."$option"="$(uci -q get gateway.@vxmesh[0]."$option")"
done
# exclude peerip from the local router, so packets aren't sent to itself
jkimmel marked this conversation as resolved Outdated

Beachte hierbei, dass
uci set network.abc.def=""
dasselbe ist wie
uci del network.abc.def

Ggf. kann man also die condition entfernen:
uci set network.vxmesh0."$option"="$(uci -q get gateway.@vxmesh[0]."$option")"

das -q bei set sollte weg.

Beachte hierbei, dass uci set network.abc.def="" dasselbe ist wie uci del network.abc.def Ggf. kann man also die condition entfernen: `uci set network.vxmesh0."$option"="$(uci -q get gateway.@vxmesh[0]."$option")"` das -q bei set sollte weg.

Ah ok. Ich wollte verhindern, dass leere optionen gesetzt werden, wenn das get failed. Aber dann tut der Einzeiler ja das gleiche.

Ah ok. Ich wollte verhindern, dass leere optionen gesetzt werden, wenn das get failed. Aber dann tut der Einzeiler ja das gleiche.
otherpeers=$(uci -q get gateway.@vxmesh[0].peer | xargs -n1 | grep -v -e "$peerip")
for peer in $otherpeers; do
# create peer sections
if ! uci -q batch > /dev/null; then
echo "FATAL: vxmesh: error setting up peer!"
echo " peer: \"$peer\""
return 1
jkimmel marked this conversation as resolved Outdated

Das ist hier wohl nicht mehr noetig. Oben grep -v $peerip

Das ist hier wohl nicht mehr noetig. Oben grep -v $peerip

Danke :)

Danke :)
fi <<- EOF
add network vxlan_peer
set network.@vxlan_peer[-1].vxlan="vxmesh0"
set network.@vxlan_peer[-1].dst="$peer"
EOF
done
# with multiple routers in the network, there shouldn't be an authoritative
# dhcp server
uci set dhcp.@dnsmasq[0].authoritative="0"
# add the vxlan interface to the client bridge
uci set network.client.ifname="$(uci -q get network.client.ifname) vxmesh0"
}
apply() {
uci commit network
uci commit dhcp
}
revert() {
uci revert network
uci revert dhcp
}

View File

@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=fff-layer3
PKG_RELEASE:=8
PKG_RELEASE:=9
include $(INCLUDE_DIR)/package.mk
@ -36,7 +36,7 @@ define Package/fff-layer3
+mtr \
+tc \
+tcpdump \
+vxlan
+fff-layer3-vxmesh
endef
define Package/fff-layer3/description