Commit fdc754e4 authored by Ad Schellevis's avatar Ad Schellevis

(legacy) cleanup, loosly related to https://github.com/opnsense/core/issues/451

parent 288bc8cb
...@@ -39,77 +39,64 @@ require_once("unbound.inc"); ...@@ -39,77 +39,64 @@ require_once("unbound.inc");
require_once("services.inc"); require_once("services.inc");
function handle_argument_group($iface, $argument2) { function handle_argument_group($iface, $argument2) {
global $config; global $config;
if (!is_array($config['interfaces'][$iface]))
return;
if (isset($config['interfaces'][$iface]['ipaddr'])) { if (isset($config['interfaces'][$iface])) {
$ipaddr = $config['interfaces'][$iface]['ipaddr']; // set defaults
} else { $ipaddr = null ;
$ipaddr = null ; $ip6addr = null;
} if (isset($config['interfaces'][$iface]['ipaddr'])) {
if (isset($config['interfaces'][$iface]['ipaddrv6'])) { $ipaddr = $config['interfaces'][$iface]['ipaddr'];
$ip6addr = $config['interfaces'][$iface]['ipaddrv6']; }
} else { if (isset($config['interfaces'][$iface]['ipaddrv6'])) {
$ip6addr = null; $ip6addr = $config['interfaces'][$iface]['ipaddrv6'];
} }
$staticv4 = false; if (is_ipaddrv4($ipaddr) && is_ipaddrv6($ip6addr)) {
if (empty($ipaddr)) $friendly = convert_friendly_interface_to_friendly_descr($iface);
$staticv4 = true; log_error("Hotplug event detected for {$friendly}({$iface}) but ignoring since interface is configured with static IP ({$ipaddr} {$ip6addr})");
else interfaces_staticarp_configure($iface);
$staticv4 = is_ipaddrv4($ipaddr); /* NOTE: Do not generate event for OpenVPN since the daemon does that for us. */
$staticv6 = false; if (substr($iface, 0, 4) != "ovpn") {
if (empty($ip6addr)) if ($argument2 == "start" || $argument2 == "up") {
$staticv6 = true; $iface = get_real_interface($iface);
else configd_run("interface newip {$iface}");
$staticv6 = is_ipaddrv6($ip6addr); }
if ($staticv4 === true && $staticv6 === true) { }
$friendly = convert_friendly_interface_to_friendly_descr($iface); } else {
log_error("Hotplug event detected for {$friendly}({$iface}) but ignoring since interface is configured with static IP ({$ipaddr} {$ip6addr})"); switch ($argument2) {
interfaces_staticarp_configure($iface); case "stop":
$iface = get_real_interface($iface); log_error("DEVD Ethernet detached event for {$iface}");
interfaces_bring_up($iface); interface_bring_down($iface);
/* NOTE: Do not generate event for OpenVPN since the daemon does that for us. */ break;
if (($argument2 == "start" || $argument2 == "up") && substr($iface, 0, 4) != "ovpn") case "start":
configd_run("interface newip {$iface}"); log_error("DEVD Ethernet attached event for {$iface}");
} else { log_error("HOTPLUG: Configuring interface {$iface}");
switch ($argument2) { require_once("vpn.inc");
case "stop": // Do not try to readd to bridge otherwise em(4) has problems
case "down": interface_configure($iface, true, true);
log_error("DEVD Ethernet detached event for {$iface}"); break;
interface_bring_down($iface); }
break; }
case "start": }
case "up":
log_error("DEVD Ethernet attached event for {$iface}");
log_error("HOTPLUG: Configuring interface {$iface}");
require_once("vpn.inc");
// Do not try to readd to bridge otherwise em(4) has problems
interface_configure($iface, true, true);
break;
}
}
} }
if (!file_exists("/var/run/booting")) { if (!file_exists("/var/run/booting")) {
if ($argc < 3) { if ($argc < 3) {
log_error("HOTPLUG event: The number of required parameters not passed!"); log_error("HOTPLUG event: The number of required parameters not passed!");
exit; exit;
} }
$action = $argv[1]; $action = $argv[1];
switch($action) { switch($action) {
case "start": case "start":
case "stop": case "stop":
break; $interface = convert_real_interface_to_friendly_interface_name($argv[2]);
default: if (!empty($interface)) {
log_error("HOTPLUG event: The action parameter passed is wrong($action) only start/stop/up/down are allowed!"); handle_argument_group($interface, $action);
exit; }
/* NOTREACHED */ break;
break; default:
} log_error("HOTPLUG event: The action parameter passed is wrong($action) only start/stop/up/down are allowed!");
$interface = convert_real_interface_to_friendly_interface_name($argv[2]); break;
if (!empty($interface)) { }
handle_argument_group($interface, $action);
}
} }
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