From 7d2fedc976cb23901ee3f88d6d322bf1fb21ae0e Mon Sep 17 00:00:00 2001 From: Ermal Date: Tue, 18 Dec 2012 15:31:10 +0000 Subject: Make the script rc.linkuip compatible with ipv6 as well. --- etc/rc.linkup | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) (limited to 'etc') diff --git a/etc/rc.linkup b/etc/rc.linkup index 23d7c9b..217fe65 100755 --- a/etc/rc.linkup +++ b/etc/rc.linkup @@ -39,9 +39,14 @@ require_once("interfaces.inc"); function handle_argument_group($iface, $argument2) { global $config; + if (!is_array($config['interfaces'][$iface])) + return; + $ipaddr = $config['interfaces'][$iface]['ipaddr']; - if (is_ipaddr($ipaddr) || empty($ipaddr)) { - log_error("Hotplug event detected for {$iface} but ignoring since interface is configured with static IP ({$ipaddr})"); + $ip6addr = $config['interfaces'][$iface]['ipaddrv6']; + if ((!empty($ipaddr) && is_ipaddrv4($ipaddr)) || (empty($ipaddr) && empty($ip6addr)) || (!empty($ip6addr) && is_ipaddrv6($ip6addr))) { + $friendly = convert_friendly_interface_to_friendly_descr($iface); + log_error("Hotplug event detected for {$friendly}({$iface}) but ignoring since interface is configured with static IP ({$ipaddr} {$ip6addr})"); interfaces_staticarp_configure($iface); $iface = get_real_interface($iface); interfaces_bring_up($iface); @@ -75,28 +80,24 @@ global $g; if (file_exists("{$g['varrun_path']}/booting")) { /* ignore all linkup events */ } else { - foreach($_SERVER['argv'] as $argv) { - switch($argv) { - case "start": - $action = "start"; - break; - case "stop": - $action = "stop"; - break; - case "/etc/rc.linkup": - break; - default: - $interface = convert_real_interface_to_friendly_interface_name($argv); - if($interface == "") { - unset($interface); - } - break; - } - if(($action) && ($interface)) { - handle_argument_group($interface, $action); - unset ($action, $interface); - } + if ($argc < 3) { + log_error("HOTPLUG event: The number of required parameters not passed!"); + exit; + } + $action = $argv[1]; + switch($action) { + case "start": + case "stop": + break; + default: + log_error("HOTPLUG event: The action parameter passed is wrong($action) only start/stop/up/down are allowed!"); + exit; + /* NOTREACHED */ + break; } + $interface = convert_real_interface_to_friendly_interface_name($argv[2]); + if (!empty($interface)) + handle_argument_group($interface, $action); } ?> -- cgit v1.1