Skip to content
Snippets Groups Projects
Unverified Commit bc48e8ab authored by Andreas Ziegler's avatar Andreas Ziegler Committed by GitHub
Browse files

Merge pull request #3042 from blocktrron/fastd-cake

gluon-mesh-vpn-fastd: use CAKE as bandwidth-shaper
parents 4d4950c5 2afdfd60
No related branches found
No related tags found
No related merge requests found
...@@ -296,4 +296,14 @@ function M.subprocess.popen(path, argt, options) ...@@ -296,4 +296,14 @@ function M.subprocess.popen(path, argt, options)
return pid, parentfds return pid, parentfds
end end
function M.get_mem_total()
for line in io.lines('/proc/meminfo') do
local match = line:match('^MemTotal:%s+(%d+)')
if match then
return tonumber(match)
end
end
end
return M return M
...@@ -4,6 +4,8 @@ local site = require 'gluon.site' ...@@ -4,6 +4,8 @@ local site = require 'gluon.site'
local util = require 'gluon.util' local util = require 'gluon.util'
local vpn_core = require 'gluon.mesh-vpn' local vpn_core = require 'gluon.mesh-vpn'
local unistd = require 'posix.unistd'
local M = {} local M = {}
function M.public_key() function M.public_key()
...@@ -25,18 +27,46 @@ function M.active() ...@@ -25,18 +27,46 @@ function M.active()
return site.mesh_vpn.fastd() ~= nil return site.mesh_vpn.fastd() ~= nil
end end
local function set_limit_simple_tc(ingress_limit, egress_limit)
uci:section('simple-tc', 'interface', 'mesh_vpn', {
ifname = vpn_core.get_interface(),
enabled = true,
limit_egress = egress_limit,
limit_ingress = ingress_limit,
})
end
local function set_limit_sqm(ingress_limit, egress_limit)
uci:section('sqm', 'queue', 'mesh_vpn', {
interface = vpn_core.get_interface(),
enabled = true,
upload = egress_limit,
download = ingress_limit,
qdisc = 'cake',
script = 'piece_of_cake.qos',
debug_logging = '0',
verbosity = '5',
})
end
local function sqm_available()
return unistd.access('/lib/gluon/mesh-vpn/sqm')
end
function M.set_limit(ingress_limit, egress_limit) function M.set_limit(ingress_limit, egress_limit)
uci:delete('simple-tc', 'mesh_vpn') uci:delete('simple-tc', 'mesh_vpn')
uci:delete('sqm', 'mesh_vpn')
if ingress_limit ~= nil and egress_limit ~= nil then if ingress_limit ~= nil and egress_limit ~= nil then
uci:section('simple-tc', 'interface', 'mesh_vpn', { if sqm_available() and util.get_mem_total() > 200*1024 then
ifname = vpn_core.get_interface(), set_limit_sqm(ingress_limit, egress_limit)
enabled = true, else
limit_egress = egress_limit, set_limit_simple_tc(ingress_limit, egress_limit)
limit_ingress = ingress_limit, end
})
end end
uci:save('simple-tc') uci:save('simple-tc')
uci:save('sqm')
end end
function M.mtu() function M.mtu()
......
include $(TOPDIR)/rules.mk
PKG_NAME:=gluon-mesh-vpn-sqm
include ../gluon.mk
define Package/gluon-mesh-vpn-sqm
TITLE:=Adds support for SQM with CAKE on VPN links
DEPENDS:= +gluon-mesh-vpn-core +sqm-scripts
endef
define Package/gluon-mesh-vpn-sqm/install
$(Gluon/Build/Install)
$(INSTALL_DIR) $(1)/lib/gluon/mesh-vpn
touch $(1)/lib/gluon/mesh-vpn/sqm
endef
$(eval $(call BuildPackageGluon,gluon-mesh-vpn-sqm))
#!/usr/bin/lua #!/usr/bin/lua
local uci = require('simple-uci').cursor() local uci = require('simple-uci').cursor()
local util = require 'gluon.util'
local function get_mem_total()
for line in io.lines('/proc/meminfo') do
local match = line:match('^MemTotal:%s+(%d+)')
if match then
return tonumber(match)
end
end
end
local max_requests = 32 local max_requests = 32
if get_mem_total() < 48*1024 then if util.get_mem_total() < 48*1024 then
max_requests = 16 max_requests = 16
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment