Commit 94f8a0bb authored by Franco Fichtner's avatar Franco Fichtner

system: make sure vital kernel modules are loaded and refactor

This partially reverts commit 8ecaf5f9.

(cherry picked from commit 6b0b2569)
(cherry picked from commit 85e62204)
(cherry picked from commit fbfb0019)
(cherry picked from commit e4cd7f59)
parent c5f2a4c7
...@@ -58,7 +58,7 @@ function set_networking_interfaces_ports($probe = false) ...@@ -58,7 +58,7 @@ function set_networking_interfaces_ports($probe = false)
$key = null; $key = null;
/* kernel messages clobber stty probing on ifconfig up */ /* kernel messages clobber stty probing on ifconfig up */
mute_kernel_msgs(); system_console_mute();
$iflist = get_interface_list(false, true); $iflist = get_interface_list(false, true);
...@@ -290,7 +290,7 @@ EOD; ...@@ -290,7 +290,7 @@ EOD;
} }
if (!in_array($key, array('y', 'Y'))) { if (!in_array($key, array('y', 'Y'))) {
unmute_kernel_msgs(); system_console_unmute();
fclose($fp); fclose($fp);
return false; return false;
} }
...@@ -420,7 +420,7 @@ EOD; ...@@ -420,7 +420,7 @@ EOD;
write_config("Console assignment of interfaces"); write_config("Console assignment of interfaces");
printf(gettext("done.%s"), "\n"); printf(gettext("done.%s"), "\n");
unmute_kernel_msgs(); system_console_unmute();
fclose($fp); fclose($fp);
return true; return true;
......
...@@ -1766,7 +1766,6 @@ function interfaces_carp_setup() ...@@ -1766,7 +1766,6 @@ function interfaces_carp_setup()
if (file_exists("/var/run/booting")) { if (file_exists("/var/run/booting")) {
echo gettext("Configuring CARP settings..."); echo gettext("Configuring CARP settings...");
mute_kernel_msgs();
} }
set_single_sysctl("net.inet.carp.preempt", "1"); set_single_sysctl("net.inet.carp.preempt", "1");
...@@ -1788,7 +1787,6 @@ function interfaces_carp_setup() ...@@ -1788,7 +1787,6 @@ function interfaces_carp_setup()
} }
if (file_exists("/var/run/booting")) { if (file_exists("/var/run/booting")) {
unmute_kernel_msgs();
echo gettext("done.") . "\n"; echo gettext("done.") . "\n";
} }
} }
......
...@@ -1414,28 +1414,59 @@ function get_possible_listen_ips($include_ipv6_link_local = false, $include_loop ...@@ -1414,28 +1414,59 @@ function get_possible_listen_ips($include_ipv6_link_local = false, $include_loop
return $listenips; return $listenips;
} }
function load_crypto_module() function system_kernel_configure($verbose = false)
{ {
global $config; if ($verbose) {
echo 'Configuring kernel modules...';
flush();
}
/*
* Vital kernel modules can go missing on reboot due to
* /boot/loader.conf not materialising. This is still
* an UFS problem, despite claims otherwise. In any case,
* load all the modules again to make sure.
*
* Keep in sync with /usr/local/etc/erc.loader.d/20-modules
*/
$mods = array(
'carp',
'if_bridge',
'if_gif',
'if_gre',
'if_lagg',
'if_tap',
'if_tun',
'if_vlan',
'pf',
'pflog',
'pfsync',
);
/* we now have /dev/pf, time to fix permissions for proxies */
chgrp('/dev/pf', 'proxy');
chmod('/dev/pf', 0660);
if (!empty($config['system']['crypto_hardware'])) { if (!empty($config['system']['crypto_hardware'])) {
log_error(sprintf('Loading %s cryptographic accelerator module.', $config['system']['crypto_hardware'])); log_error(sprintf('Loading %s cryptographic accelerator module.', $config['system']['crypto_hardware']));
mwexecf('/sbin/kldload %s', $config['system']['crypto_hardware'], true); $mods[] = $config['system']['crypto_hardware'];
} }
if (isset($config['system']['cryptodev_enable'])) { if (isset($config['system']['cryptodev_enable'])) {
log_error('Loading cryptodev kernel module.'); log_error('Loading cryptodev kernel module.');
mwexecf('/sbin/kldload %s', 'cryptodev', true); $mods[] = 'cryptodev';
} }
}
function load_thermal_module()
{
global $config;
if (!empty($config['system']['thermal_hardware'])) { if (!empty($config['system']['thermal_hardware'])) {
log_error(sprintf('Loading %s thermal monitor module.', $config['system']['thermal_hardware'])); log_error(sprintf('Loading %s thermal monitor module.', $config['system']['thermal_hardware']));
mwexecf('/sbin/kldload %s', $config['system']['thermal_hardware'], true); $mods[] = $config['system']['thermal_hardware'];
}
foreach ($mods as $mod) {
mwexecf('/sbin/kldload %s', $mod, true);
}
if ($verbose) {
echo "done.\n";
} }
} }
...@@ -1540,6 +1571,31 @@ function system_cron_configure($verbose = false) ...@@ -1540,6 +1571,31 @@ function system_cron_configure($verbose = false)
} }
} }
function system_console_mutable()
{
/* this function name is a pun :) */
global $config;
return isset($config['system']['primaryconsole']) &&
($config['system']['primaryconsole'] == 'serial' ||
$config['system']['primaryconsole'] == 'null');
}
function system_console_mute()
{
if (system_console_mutable()) {
exec('/sbin/conscontrol mute on');
}
}
function system_console_unmute()
{
if (system_console_mutable()) {
exec('/sbin/conscontrol mute off');
}
}
function system_console_types() function system_console_types()
{ {
return array( return array(
......
...@@ -1363,22 +1363,6 @@ function set_single_sysctl($name, $value) ...@@ -1363,22 +1363,6 @@ function set_single_sysctl($name, $value)
return true; return true;
} }
function mute_kernel_msgs()
{
global $config;
if (isset($config['system']['enableserial'])) {
return;
}
exec('/sbin/conscontrol mute on');
}
function unmute_kernel_msgs()
{
exec('/sbin/conscontrol mute off');
}
/****f* util/msort /****f* util/msort
* NAME * NAME
* msort - sort array * msort - sort array
......
...@@ -58,11 +58,11 @@ echo " done.\n"; ...@@ -58,11 +58,11 @@ echo " done.\n";
/* start devd (dhclient now uses it) */ /* start devd (dhclient now uses it) */
echo "Starting device manager (devd)..."; echo "Starting device manager (devd)...";
mute_kernel_msgs(); system_console_mute();
exec('/sbin/devd'); exec('/sbin/devd');
sleep(1); sleep(1);
set_device_perms(); set_device_perms();
unmute_kernel_msgs(); system_console_unmute();
echo "done.\n"; echo "done.\n";
/* configure login behaviour */ /* configure login behaviour */
...@@ -105,11 +105,7 @@ if (is_interface_mismatch()) { ...@@ -105,11 +105,7 @@ if (is_interface_mismatch()) {
while (!set_networking_interfaces_ports(true)); while (!set_networking_interfaces_ports(true));
} }
/* enable optional crypto modules */ system_kernel_configure(true);
load_crypto_module();
/* enable optional thermal sensor modules */
load_thermal_module();
/* read in /etc/sysctl.conf and set values if needed */ /* read in /etc/sysctl.conf and set values if needed */
echo "Setting up extended sysctls..."; echo "Setting up extended sysctls...";
...@@ -135,10 +131,10 @@ interfaces_loopback_configure(); ...@@ -135,10 +131,10 @@ interfaces_loopback_configure();
system_syslogd_start(true); system_syslogd_start(true);
/* set up interfaces */ /* set up interfaces */
mute_kernel_msgs(); system_console_mute();
openvpn_prepare_all(); openvpn_prepare_all();
interfaces_configure(); interfaces_configure();
unmute_kernel_msgs(); system_console_unmute();
/* start OpenVPN server & clients */ /* start OpenVPN server & clients */
echo "Syncing OpenVPN settings..."; echo "Syncing OpenVPN settings...";
......
...@@ -169,8 +169,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -169,8 +169,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
system_resolvconf_generate(true); system_resolvconf_generate(true);
system_cron_configure(); system_cron_configure();
activate_powerd(); activate_powerd();
load_crypto_module(); system_kernel_configure();
load_thermal_module();
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment