From 0822b3dd3c276e25388e56074c417c32aaa716f2 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Sat, 19 Mar 2016 11:34:44 +0100 Subject: [PATCH] inc: minor tweaks and simplifications --- src/etc/inc/interfaces.inc | 8 ++++---- src/etc/inc/interfaces.lib.inc | 2 +- src/etc/inc/util.inc | 21 ++++----------------- 3 files changed, 9 insertions(+), 22 deletions(-) diff --git a/src/etc/inc/interfaces.inc b/src/etc/inc/interfaces.inc index f93dda251..22c5ef3d5 100644 --- a/src/etc/inc/interfaces.inc +++ b/src/etc/inc/interfaces.inc @@ -3346,8 +3346,8 @@ function interface_6rd_configure($interface = "wan", $wancfg) return; } - if (!is_module_loaded('if_stf.ko')) { - mwexec('/sbin/kldload if_stf.ko'); + if (!is_module_loaded('if_stf')) { + mwexec('/sbin/kldload if_stf'); } $wanif = get_real_interface($interface); @@ -3384,7 +3384,7 @@ function interface_6rd_configure($interface = "wan", $wancfg) /* XXX: need to extend to support variable prefix size for v4 */ if (!is_module_loaded('if_stf')) { - mwexec('/sbin/kldload if_stf.ko'); + mwexec('/sbin/kldload if_stf'); } $stfiface = "{$interface}_stf"; if (does_interface_exist($stfiface)) { @@ -3497,7 +3497,7 @@ function interface_6to4_configure($interface = 'wan', $wancfg) /* setup the stf interface */ if (!is_module_loaded("if_stf")) { - mwexec("/sbin/kldload if_stf.ko"); + mwexec("/sbin/kldload if_stf"); } $stfiface = "{$interface}_stf"; if (does_interface_exist($stfiface)) { diff --git a/src/etc/inc/interfaces.lib.inc b/src/etc/inc/interfaces.lib.inc index ecd0d94dc..b3605fa86 100644 --- a/src/etc/inc/interfaces.lib.inc +++ b/src/etc/inc/interfaces.lib.inc @@ -215,7 +215,7 @@ function legacy_netgraph_attach($ifs) function legacy_netgraph_detach($ifs) { - mwexecf('/usr/sbin/ngctl msg %s: detach', array($ifs)); + mwexecf('/usr/sbin/ngctl msg %s: detach', array($ifs), true); } function legacy_netgraph_rename($tmpifs, $ifs) diff --git a/src/etc/inc/util.inc b/src/etc/inc/util.inc index ed2790b8e..65d3c8712 100644 --- a/src/etc/inc/util.inc +++ b/src/etc/inc/util.inc @@ -72,15 +72,7 @@ function is_process_running($process) function is_subsystem_dirty($subsystem = '') { - if ($subsystem == '') { - return false; - } - - if (file_exists("/tmp/{$subsystem}.dirty")) { - return true; - } - - return false; + return file_exists("/tmp/{$subsystem}.dirty"); } function mark_subsystem_dirty($subsystem = '') @@ -124,14 +116,9 @@ function unlock($cfglckkey = null) } } -function is_module_loaded($module_name) { - $module_name = str_replace(".ko", "", $module_name); - $running = 0; - $_gb = exec("/sbin/kldstat -qn {$module_name} 2>&1", $_gb, $running); - if (intval($running) == 0) - return true; - else - return false; +function is_module_loaded($module_name) +{ + return !mwexecf('/sbin/kldstat -qn %s', $module_name, true); } /* validate non-negative numeric string, or equivalent numeric variable */