From 963d69e8721d25492ac116132145be925ef2313a Mon Sep 17 00:00:00 2001 From: Christof Schulze Date: Wed, 23 Nov 2016 22:38:26 +0100 Subject: [PATCH 1/5] add kmod-vxlan as dependency --- package/gluon-core/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/gluon-core/Makefile b/package/gluon-core/Makefile index 2b9cfb47..70afbe11 100644 --- a/package/gluon-core/Makefile +++ b/package/gluon-core/Makefile @@ -13,7 +13,7 @@ define Package/gluon-core SECTION:=gluon CATEGORY:=Gluon TITLE:=Base files of Gluon - DEPENDS:=+gluon-site +libgluonutil +lua-platform-info +lua-hash +luci-base +luci-lib-jsonc +odhcp6c +firewall +pretty-hostname + DEPENDS:=+gluon-site +libgluonutil +lua-platform-info +lua-hash +luci-base +luci-lib-jsonc +odhcp6c +firewall +pretty-hostname +kmod_vxlan +ip-full endef define Package/gluon-core/description From a963604f56f15f429a245d5988261b701fe6371c Mon Sep 17 00:00:00 2001 From: Christof Schulze Date: Fri, 30 Dec 2016 16:19:13 +0100 Subject: [PATCH 2/5] gluon-luci-portconfig: protconfig.lua: change spaces to tabs --- .../lua/luci/model/cbi/admin/portconfig.lua | 128 +++++++++--------- 1 file changed, 66 insertions(+), 62 deletions(-) diff --git a/package/gluon-luci-portconfig/luasrc/usr/lib/lua/luci/model/cbi/admin/portconfig.lua b/package/gluon-luci-portconfig/luasrc/usr/lib/lua/luci/model/cbi/admin/portconfig.lua index 2e40577a..f3f1e5ae 100644 --- a/package/gluon-luci-portconfig/luasrc/usr/lib/lua/luci/model/cbi/admin/portconfig.lua +++ b/package/gluon-luci-portconfig/luasrc/usr/lib/lua/luci/model/cbi/admin/portconfig.lua @@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 +http://www.apache.org/licenses/LICENSE-2.0 $Id$ ]]-- @@ -75,11 +75,11 @@ o.rmempty = false if dns then - s = f:section(SimpleSection, nil, nil) + s = f:section(SimpleSection, nil, nil) - o = s:option(DynamicList, "dns", translate("Static DNS servers")) - o:write(nil, uci:get("gluon-wan-dnsmasq", dns, "server")) - o.datatype = "ipaddr" + o = s:option(DynamicList, "dns", translate("Static DNS servers")) + o:write(nil, uci:get("gluon-wan-dnsmasq", dns, "server")) + o.datatype = "ipaddr" end s = f:section(SimpleSection, nil, nil) @@ -89,80 +89,84 @@ o.default = uci:get_bool("network", "mesh_wan", "auto") and o.enabled or o.disab o.rmempty = false if sysconfig.lan_ifname then - o = s:option(Flag, "mesh_lan", translate("Enable meshing on the LAN interface")) - o.default = uci:get_bool("network", "mesh_lan", "auto") and o.enabled or o.disabled - o.rmempty = false + o = s:option(Flag, "mesh_lan", translate("Enable meshing on the LAN interface")) + o.default = uci:get_bool("network", "mesh_lan", "auto") and o.enabled or o.disabled + o.rmempty = false end + + + + if uci:get('system', 'gpio_switch_poe_passthrough') then - s = f:section(SimpleSection, nil, nil) - o = s:option(Flag, "poe_passthrough", translate("Enable PoE passthrough")) - o.default = uci:get_bool("system", "gpio_switch_poe_passthrough", "value") and o.enabled or o.disabled - o.rmempty = false + s = f:section(SimpleSection, nil, nil) + o = s:option(Flag, "poe_passthrough", translate("Enable PoE passthrough")) + o.default = uci:get_bool("system", "gpio_switch_poe_passthrough", "value") and o.enabled or o.disabled + o.rmempty = false end function f.handle(self, state, data) - if state == FORM_VALID then - uci:set("network", "wan", "proto", data.ipv4) - if data.ipv4 == "static" then - uci:set("network", "wan", "ipaddr", data.ipv4_addr:trim()) - uci:set("network", "wan", "netmask", data.ipv4_netmask:trim()) - uci:set("network", "wan", "gateway", data.ipv4_gateway:trim()) - else - uci:delete("network", "wan", "ipaddr") - uci:delete("network", "wan", "netmask") - uci:delete("network", "wan", "gateway") - end + if state == FORM_VALID then + uci:set("network", "wan", "proto", data.ipv4) + if data.ipv4 == "static" then + uci:set("network", "wan", "ipaddr", data.ipv4_addr:trim()) + uci:set("network", "wan", "netmask", data.ipv4_netmask:trim()) + uci:set("network", "wan", "gateway", data.ipv4_gateway:trim()) + else + uci:delete("network", "wan", "ipaddr") + uci:delete("network", "wan", "netmask") + uci:delete("network", "wan", "gateway") + end - uci:set("network", "wan6", "proto", data.ipv6) - if data.ipv6 == "static" then - uci:set("network", "wan6", "ip6addr", data.ipv6_addr:trim()) - uci:set("network", "wan6", "ip6gw", data.ipv6_gateway:trim()) - else - uci:delete("network", "wan6", "ip6addr") - uci:delete("network", "wan6", "ip6gw") - end + uci:set("network", "wan6", "proto", data.ipv6) + if data.ipv6 == "static" then + uci:set("network", "wan6", "ip6addr", data.ipv6_addr:trim()) + uci:set("network", "wan6", "ip6gw", data.ipv6_gateway:trim()) + else + uci:delete("network", "wan6", "ip6addr") + uci:delete("network", "wan6", "ip6gw") + end - uci:set("network", "mesh_wan", "auto", data.mesh_wan) + uci:set("network", "mesh_wan", "auto", data.mesh_wan) - if sysconfig.lan_ifname then - uci:set("network", "mesh_lan", "auto", data.mesh_lan) + if sysconfig.lan_ifname then + uci:set("network", "mesh_lan", "auto", data.mesh_lan) - local doit - if data.mesh_lan == '1' then - doit = uci.remove_from_set - else - doit = uci.add_to_set - end + local doit + if data.mesh_lan == '1' then + doit = uci.remove_from_set + else + doit = uci.add_to_set + end - for _, lanif in ipairs(lutil.split(sysconfig.lan_ifname, ' ')) do - doit(uci, "network", "client", "ifname", lanif) - end - end + for _, lanif in ipairs(lutil.split(sysconfig.lan_ifname, ' ')) do + doit(uci, "network", "client", "ifname", lanif) + end + end - uci:save("network") - uci:commit("network") + uci:save("network") + uci:commit("network") - if uci:get('system', 'gpio_switch_poe_passthrough') then - uci:set('system', 'gpio_switch_poe_passthrough', 'value', data.poe_passthrough) - uci:save('system') - uci:commit('system') - end + if uci:get('system', 'gpio_switch_poe_passthrough') then + uci:set('system', 'gpio_switch_poe_passthrough', 'value', data.poe_passthrough) + uci:save('system') + uci:commit('system') + end - if dns then - if #data.dns > 0 then - uci:set("gluon-wan-dnsmasq", dns, "server", data.dns) - else - uci:delete("gluon-wan-dnsmasq", dns, "server") - end + if dns then + if #data.dns > 0 then + uci:set("gluon-wan-dnsmasq", dns, "server", data.dns) + else + uci:delete("gluon-wan-dnsmasq", dns, "server") + end - uci:save("gluon-wan-dnsmasq") - uci:commit("gluon-wan-dnsmasq") - end - end + uci:save("gluon-wan-dnsmasq") + uci:commit("gluon-wan-dnsmasq") + end + end - return true + return true end return f From 7c496944bfeda77602bc0e3eddd31d17c704f1f1 Mon Sep 17 00:00:00 2001 From: Christof Schulze Date: Wed, 23 Nov 2016 22:38:26 +0100 Subject: [PATCH 3/5] add kmod-vxlan as dependency --- package/gluon-core/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/gluon-core/Makefile b/package/gluon-core/Makefile index 9917a5e0..7baf2255 100644 --- a/package/gluon-core/Makefile +++ b/package/gluon-core/Makefile @@ -13,7 +13,7 @@ define Package/gluon-core SECTION:=gluon CATEGORY:=Gluon TITLE:=Base files of Gluon - DEPENDS:=+gluon-site +libgluonutil +lua-platform-info +lua-hash +luci-base +luci-lib-jsonc +odhcp6c +firewall +pretty-hostname + DEPENDS:=+gluon-site +libgluonutil +lua-platform-info +lua-hash +luci-base +luci-lib-jsonc +odhcp6c +firewall +pretty-hostname +kmod_vxlan +ip-full endef define Package/gluon-core/description From a4f06228c9123608074685ac81f6ea4667fabd42 Mon Sep 17 00:00:00 2001 From: Christof Schulze Date: Fri, 30 Dec 2016 17:09:35 +0100 Subject: [PATCH 4/5] gluon-luci-portconfig: add vxlan config checkbox --- package/gluon-luci-portconfig/i18n/de.po | 3 +++ package/gluon-luci-portconfig/i18n/fr.po | 3 +++ package/gluon-luci-portconfig/i18n/gluon-luci-portconfig.pot | 3 +++ .../luasrc/usr/lib/lua/luci/model/cbi/admin/portconfig.lua | 4 ++++ 4 files changed, 13 insertions(+) diff --git a/package/gluon-luci-portconfig/i18n/de.po b/package/gluon-luci-portconfig/i18n/de.po index a94e7d41..4d365b05 100644 --- a/package/gluon-luci-portconfig/i18n/de.po +++ b/package/gluon-luci-portconfig/i18n/de.po @@ -19,6 +19,9 @@ msgstr "Automatisch (RA/DHCPv6)" msgid "Enable PoE passthrough" msgstr "PoE-Passthrough aktivieren" +msgid "Encapsulate mesh into vxlan" +msgstr "Mesh in ein vxlan einpacken" + msgid "Enable meshing on the LAN interface" msgstr "Mesh auf dem LAN-Port aktivieren" diff --git a/package/gluon-luci-portconfig/i18n/fr.po b/package/gluon-luci-portconfig/i18n/fr.po index 3ec59395..c32c410f 100644 --- a/package/gluon-luci-portconfig/i18n/fr.po +++ b/package/gluon-luci-portconfig/i18n/fr.po @@ -19,6 +19,9 @@ msgstr "Automatique (RA/DHCPv6)" msgid "Enable PoE passthrough" msgstr "" +msgid "Encapsulate mesh into vxlan" +msgstr "" + msgid "Enable meshing on the LAN interface" msgstr "Activer le réseau MESH sur le port LAN" diff --git a/package/gluon-luci-portconfig/i18n/gluon-luci-portconfig.pot b/package/gluon-luci-portconfig/i18n/gluon-luci-portconfig.pot index 5945016b..9afd6dd7 100644 --- a/package/gluon-luci-portconfig/i18n/gluon-luci-portconfig.pot +++ b/package/gluon-luci-portconfig/i18n/gluon-luci-portconfig.pot @@ -10,6 +10,9 @@ msgstr "" msgid "Enable PoE passthrough" msgstr "" +msgid "Encapsulate mesh into vxlan" +msgstr "" + msgid "Enable meshing on the LAN interface" msgstr "" diff --git a/package/gluon-luci-portconfig/luasrc/usr/lib/lua/luci/model/cbi/admin/portconfig.lua b/package/gluon-luci-portconfig/luasrc/usr/lib/lua/luci/model/cbi/admin/portconfig.lua index f3f1e5ae..9488f1f9 100644 --- a/package/gluon-luci-portconfig/luasrc/usr/lib/lua/luci/model/cbi/admin/portconfig.lua +++ b/package/gluon-luci-portconfig/luasrc/usr/lib/lua/luci/model/cbi/admin/portconfig.lua @@ -84,6 +84,10 @@ end s = f:section(SimpleSection, nil, nil) +o = s:option(Flag, "mesh_vxlan", translate("Encapsulate mesh into vxlan")) +o.default = uci:get_bool("network", uci:get_first("network","vxlan") , "active") and o.enabled or o.disabled +o.rmempty = false + o = s:option(Flag, "mesh_wan", translate("Enable meshing on the WAN interface")) o.default = uci:get_bool("network", "mesh_wan", "auto") and o.enabled or o.disabled o.rmempty = false From 842e1015e336fcebedc6d076f455f15e90e8fee2 Mon Sep 17 00:00:00 2001 From: Christof Schulze Date: Fri, 30 Dec 2016 17:22:22 +0100 Subject: [PATCH 5/5] add gluon-dns-config: a package that enables the next node to be used as dns cache --- package/gluon-dns-cache/Makefile | 36 +++++++++++++++++ package/gluon-dns-cache/README.md | 39 +++++++++++++++++++ package/gluon-dns-cache/check_site.lua | 3 ++ .../files/lib/gluon/upgrade/820-dns-config | 14 +++++++ 4 files changed, 92 insertions(+) create mode 100644 package/gluon-dns-cache/Makefile create mode 100644 package/gluon-dns-cache/README.md create mode 100644 package/gluon-dns-cache/check_site.lua create mode 100755 package/gluon-dns-cache/files/lib/gluon/upgrade/820-dns-config diff --git a/package/gluon-dns-cache/Makefile b/package/gluon-dns-cache/Makefile new file mode 100644 index 00000000..55438b97 --- /dev/null +++ b/package/gluon-dns-cache/Makefile @@ -0,0 +1,36 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=gluon-dns-config +PKG_VERSION:=1 + +PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) + +include $(GLUONDIR)/include/package.mk + +define Package/gluon-dns-config + SECTION:=gluon + CATEGORY:=Gluon + TITLE:=Use Node as DNS cache, configure using site.conf + DEPENDS:=+gluon-core +endef + +define Package/gluon-legacy/description + Use Node as DNS cache, configure using site.conf +endef + +define Build/Prepare + mkdir -p $(PKG_BUILD_DIR) +endef + +define Build/Configure +endef + +define Build/Compile +endef + +define Package/gluon-dns-config/install + $(CP) ./files/* $(1)/ +endef + +$(eval $(call BuildPackage,gluon-dns-config)) + diff --git a/package/gluon-dns-cache/README.md b/package/gluon-dns-cache/README.md new file mode 100644 index 00000000..c2a5a1bc --- /dev/null +++ b/package/gluon-dns-cache/README.md @@ -0,0 +1,39 @@ +##### Hintergrund +Es ist erstrebenswert, die Menge der kleinen Datenpakete vom Router zum +Supernode zu reduzieren. Dabei hilft es, die DNS-Anfragen der Clients zu +den Supernodes zu reduzieren. + +
+ +##### Das Packages +Durch dieses Package wird der Cache der Router-dnsmasq-Instanz, welche +auf Port 53 horcht, konfiguriert. Die Freifunk-Router halten dadurch +eine Anzahl von *dns.cacheentries* Einträgen im RAM des Routers vor. +Sollte ein DNS-Record im Cache nicht gefunden werden, wird einer der in +der Tabelle *dns.servers* angegebenen Server abgefragt. + +Dieses Paket konfiguriert neben dem Cache auch die Namensauflösung für +die Host-Namen "*nextnode*". Die IP-Adressen werden aus der *site.conf* +ausgelesen. + +#### Konfiguration +Die Konfiguration erfolgt per ***site.conf*** mit folgenden Parametern: +``` +dns = { + cacheentries = 5000, + servers = { '2a06:8187:fb00:53::53', }, +}, +``` + +* ***cacheentries*** ist die Anzahl der Einträge, die der Cache aufnehmen soll. +Je Eintrag werden ca 90 Byte RAM benötigt. Der Speicher für alle Einträge wird +als Block beim Systemstart reserviert. +* ***servers*** ist eine Namens-Liste von Servern, welche bei Cache-Misses angefragt werden. + + +--- + +Siehe auch: +https://wiki.openwrt.org/doc/uci/dhcp +http://flux242.blogspot.de/2012/06/dnsmasq-cache-size-tuning.html + diff --git a/package/gluon-dns-cache/check_site.lua b/package/gluon-dns-cache/check_site.lua new file mode 100644 index 00000000..69675e54 --- /dev/null +++ b/package/gluon-dns-cache/check_site.lua @@ -0,0 +1,3 @@ +need_string_match('dns.cacheentries', '^%d$') +need_string_array('dns.servers') +need_string_match('next_node.ip6', '^[%x:]+$') diff --git a/package/gluon-dns-cache/files/lib/gluon/upgrade/820-dns-config b/package/gluon-dns-cache/files/lib/gluon/upgrade/820-dns-config new file mode 100755 index 00000000..b4ed7b31 --- /dev/null +++ b/package/gluon-dns-cache/files/lib/gluon/upgrade/820-dns-config @@ -0,0 +1,14 @@ +#!/usr/bin/lua +local site = require 'gluon.site_config' +local uci = require('luci.model.uci').cursor() + +dnsmasq=uci:get_first("dhcp", "dnsmasq") + +uci:set('dhcp', dnsmasq, 'cachesize', site.dns.cacheentries) +uci:set('dhcp', dnsmasq, 'server', site.dns.servers) +uci:set('dhcp', dnsmasq, 'localise_queries', '1') +uci:set('dhcp', dnsmasq, 'localservice', '0') +domain = uci:add('dhcp', 'domain') +uci:set('dhcp', domain, 'name', 'nextnode') +uci:set('dhcp', domain, 'ip', site.next_node.ip6 ) +uci:save('dhcp')