Skip to content

Commit

Permalink
gluon-mesh-vpn-*: make vpn MTU provider specific
Browse files Browse the repository at this point in the history
If a community uses different vpn providers, they typically
assume the same MTU for the wan device underneath the VPN. As
different VPN providers however have different overhead, the MTU
of the VPN device differs for each provider. Therefore this
commit makes the MTU of the VPN device provider specific.

This has two advantages:
1. The same site.conf can used to bake firmwares for different
   VPN providers (only by selecting a diferent vpn feature in the
   site.mk).
2. We are coming closer to the option of integrating multiple VPN
   providers into one firmware.
  • Loading branch information
lemoer committed May 21, 2022
1 parent 57c0bdb commit 7c81897
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 3 deletions.
1 change: 0 additions & 1 deletion package/gluon-mesh-vpn-core/check_site.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
need_boolean(in_site({'mesh_vpn', 'enabled'}), false)
need_number({'mesh_vpn', 'mtu'})
need_boolean(in_site({'mesh_vpn', 'pubkey_privacy'}), false)

need_boolean(in_site({'mesh_vpn', 'bandwidth_limit', 'enabled'}), false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ local util = require 'gluon.util'
local uci = require('simple-uci').cursor()

local vpn_core = require 'gluon.mesh-vpn'
local _, active_vpn = vpn_core.get_active_provider()

uci:section('network', 'interface', 'mesh_vpn', {
ifname = vpn_core.get_interface(),
proto = 'gluon_mesh',
transitive = true,
fixed_mtu = true,
macaddr = util.generate_mac(7),
mtu = site.mesh_vpn.mtu(),
mtu = active_vpn.mtu(),
})

uci:save('network')
Expand Down
1 change: 1 addition & 0 deletions package/gluon-mesh-vpn-fastd/check_site.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
local fastd_methods = {'salsa2012+umac', 'null+salsa2012+umac', 'null@l2tp', 'null'}
need_array_of({'mesh_vpn', 'fastd', 'methods'}, fastd_methods)
need_boolean(in_site({'mesh_vpn', 'fastd', 'configurable'}), false)
need_number({'mesh_vpn', 'fastd', 'mtu'})

need_one_of(in_site({'mesh_vpn', 'fastd', 'syslog_level'}),
{'error', 'warn', 'info', 'verbose', 'debug', 'debug2'}, false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
local site = require 'gluon.site'
local util = require 'gluon.util'
local vpn_core = require 'gluon.mesh-vpn'
local _, active_vpn = vpn_core.get_active_provider()

local uci = require('simple-uci').cursor()
local unistd = require 'posix.unistd'
Expand Down Expand Up @@ -49,7 +50,7 @@ uci:section('fastd', 'fastd', 'mesh_vpn', {
secret = secret,
interface = vpn_core.get_interface(),
mode = 'tap',
mtu = site.mesh_vpn.mtu(),
mtu = active_vpn.mtu(),
secure_handshakes = true,
method = methods,
packet_mark = 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,8 @@ function M.set_limit(ingress_limit, egress_limit)
uci:save('simple-tc')
end

function M.mtu()
return site.mesh_vpn.fastd.mtu()
end

return M
1 change: 1 addition & 0 deletions package/gluon-mesh-vpn-tunneldigger/check_site.lua
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
need_string_array(in_domain({'mesh_vpn', 'tunneldigger', 'brokers'}))
need_number({'mesh_vpn', 'tunneldigger', 'mtu'})
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,8 @@ function M.set_limit(ingress_limit, egress_limit)
uci:save('simple-tc')
end

function M.mtu()
return site.mesh_vpn.tunneldigger.mtu()
end

return M
1 change: 1 addition & 0 deletions package/gluon-mesh-vpn-wireguard/check_site.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ local function check_peer(k)
end

need_table({'mesh_vpn', 'wireguard', 'peers'}, check_peer)
need_number({'mesh_vpn', 'wireguard', 'mtu'})
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,8 @@ function M.set_limit(ingress_limit, egress_limit)
uci:save('simple-tc')
end

function M.mtu()
return site.mesh_vpn.wireguard.mtu()
end

return M

0 comments on commit 7c81897

Please sign in to comment.