summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorErmal <eri@pfsense.org>2014-11-10 21:47:14 +0100
committerErmal <eri@pfsense.org>2014-11-10 21:47:14 +0100
commitd87fcac96b45958bd777c7ac38cc0665dbde6062 (patch)
tree599a680c39d7db4a859595b17fe65b948def3dc9 /etc
parent24d728bb4feb848b10d42a81df0e0a92dd599764 (diff)
downloadpfsense-d87fcac96b45958bd777c7ac38cc0665dbde6062.zip
pfsense-d87fcac96b45958bd777c7ac38cc0665dbde6062.tar.gz
Do not require the default sysctl items to be set on the config.xml but rather extract the definitions from the sysctl tree. Also to reduce config.xml size
Diffstat (limited to 'etc')
-rw-r--r--etc/inc/system.inc39
-rw-r--r--etc/inc/unbound.inc18
2 files changed, 48 insertions, 9 deletions
diff --git a/etc/inc/system.inc b/etc/inc/system.inc
index 273b5a2..87bbdb2 100644
--- a/etc/inc/system.inc
+++ b/etc/inc/system.inc
@@ -72,13 +72,50 @@ function get_default_sysctl_value($id) {
return $sysctls[$id];
}
+function get_sysctl_descr($sysctl) {
+ unset($output);
+ $_gb = exec("/sbin/sysctl -nd {$sysctl}", $output);
+
+ return $output[0];
+}
+
+function system_get_sysctls() {
+ global $config, $sysctls;
+
+ $disp_sysctl = array();
+ $disp_cache = array();
+ if (is_array($config['sysctl']) && is_array($config['sysctl']['item'])) {
+ foreach($config['sysctl']['item'] as $id => $tunable) {
+ if ($tunable['value'] == "default")
+ $value = get_default_sysctl_value($tunable['tunable']);
+ else
+ $value = $tunable['value'];
+
+ $disp_sysctl[$id] = $tunable;
+ $disp_sysctl[$id]['modified'] = true;
+ $disp_cache[$tunable['tunable']] = 'set';
+ }
+ }
+
+ foreach ($sysctls as $sysctl => $value) {
+ if (isset($disp_cache[$sysctl]))
+ continue;
+
+ $disp_sysctl[$sysctl] = array('tunable' => $sysctl, 'value' => $value, 'descr' => get_sysctl_descr($sysctl));
+
+
+ }
+ unset($disp_cache);
+ return $disp_sysctl;
+}
+
function activate_sysctls() {
global $config, $g, $sysctls;
if ($g['platform'] == 'jail')
return;
- if (is_array($config['sysctl'])) {
+ if (is_array($config['sysctl']) && is_array($config['sysctl']['item'])) {
foreach($config['sysctl']['item'] as $tunable) {
if($tunable['value'] == "default")
$value = get_default_sysctl_value($tunable['tunable']);
diff --git a/etc/inc/unbound.inc b/etc/inc/unbound.inc
index 4088035..b047346 100644
--- a/etc/inc/unbound.inc
+++ b/etc/inc/unbound.inc
@@ -79,14 +79,16 @@ function unbound_optimization() {
* Larger socket buffer for busy servers
* Check that it is set to 4MB (by default the OS has it configured to 4MB)
*/
- foreach ($config['sysctl']['item'] as $tunable) {
- if ($tunable['tunable'] == 'kern.ipc.maxsockbuf') {
- $so = floor(($tunable['value']/1024/1024)-1);
- // Check to ensure that the number is not a negative
- if ($so > 0)
- $optimization['so_rcvbuf'] = "so-rcvbuf: {$so}m";
- else
- unset($optimization['so_rcvbuf']);
+ if (is_array($config['sysctl']) && is_array($config['sysctl']['item'])) {
+ foreach ($config['sysctl']['item'] as $tunable) {
+ if ($tunable['tunable'] == 'kern.ipc.maxsockbuf') {
+ $so = floor(($tunable['value']/1024/1024)-1);
+ // Check to ensure that the number is not a negative
+ if ($so > 0)
+ $optimization['so_rcvbuf'] = "so-rcvbuf: {$so}m";
+ else
+ unset($optimization['so_rcvbuf']);
+ }
}
}
// Safety check in case kern.ipc.maxsockbuf is not available.
OpenPOWER on IntegriCloud