Skip to content
Snippets Groups Projects
Commit 76ac60d0 authored by Michael Schwarz's avatar Michael Schwarz
Browse files

Implemented new function sysctl_set_if_lower

In 180-increase-arp-caches the same logic was called again
and again. This could be done by a function!

See https://git.c3pb.de/freifunk-pb/ffpb-packages/issues/2
parent 23fff48d
No related branches found
No related tags found
No related merge requests found
......@@ -3,23 +3,18 @@
require 'luci.sys'
local sysctl = require 'gluon.sysctl'
if (tonumber(luci.sys.exec('sysctl net.ipv4.neigh.default.gc_thresh1'):match('%d+', 34)) or 128) < 192 then
sysctl.set('net.ipv4.neigh.default.gc_thresh1', 192)
end
if (tonumber(luci.sys.exec('sysctl net.ipv4.neigh.default.gc_thresh2'):match('%d+', 34)) or 512) < 640 then
sysctl.set('net.ipv4.neigh.default.gc_thresh2', 640)
end
if (tonumber(luci.sys.exec('sysctl net.ipv4.neigh.default.gc_thresh3'):match('%d+', 34)) or 1024) < 1280 then
sysctl.set('net.ipv4.neigh.default.gc_thresh3', 1280)
end
if (tonumber(luci.sys.exec('sysctl net.ipv6.neigh.default.gc_thresh1'):match('%d+', 34)) or 128) < 512 then
sysctl.set('net.ipv6.neigh.default.gc_thresh1', 512)
end
if (tonumber(luci.sys.exec('sysctl net.ipv6.neigh.default.gc_thresh2'):match('%d+', 34)) or 512) < 1024 then
sysctl.set('net.ipv6.neigh.default.gc_thresh2', 1024)
end
if (tonumber(luci.sys.exec('sysctl net.ipv6.neigh.default.gc_thresh3'):match('%d+', 34)) or 1024) < 1536 then
sysctl.set('net.ipv6.neigh.default.gc_thresh3', 1536)
function sysctl_set_if_lower(_key, _value)
local command = "sysctl " .. _key
if (tonumber(luci.sys.exec(command):match('%d+', 34)) or 128) < _value then
sysctl.set(_key, _value)
end
end
sysctl_set_if_lower('net.ipv4.neigh.default.gc_thresh1', 192)
sysctl_set_if_lower('net.ipv4.neigh.default.gc_thresh2', 640)
sysctl_set_if_lower('net.ipv4.neigh.default.gc_thresh3', 1280)
sysctl_set_if_lower('net.ipv6.neigh.default.gc_thresh1', 512)
sysctl_set_if_lower('net.ipv6.neigh.default.gc_thresh2', 1024)
sysctl_set_if_lower('net.ipv6.neigh.default.gc_thresh3', 1536)
os.execute('sync; sysctl -qp')
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