|
@@ -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')
|