summaryrefslogtreecommitdiffstats
path: root/etc/rc.linkup
diff options
context:
space:
mode:
Diffstat (limited to 'etc/rc.linkup')
-rwxr-xr-xetc/rc.linkup114
1 files changed, 55 insertions, 59 deletions
diff --git a/etc/rc.linkup b/etc/rc.linkup
index 2ef5fe7..0f1b25e 100755
--- a/etc/rc.linkup
+++ b/etc/rc.linkup
@@ -34,72 +34,68 @@
require_once("config.inc");
require_once("functions.inc");
- $processed_nics = array();
-
if($g['booting'] == true) {
/* ignore all linkup events */
} else {
- $processing = true;
- $counter = 1;
- $argspassed = file_get_contents("/tmp/rc.linkup");
- log_error("Arguments passed rc.linkup. '{$argspassed}'");
- while($processing == true) {
- /* do not process nics twice */
- if (in_array($argv[$counter] . $argv[$counter+1], $processed_nics))
- continue;
- if($argv[$counter] == "")
- exit;
- $processed_nics[] = $argv[$counter] . $argv[$counter+1];
- log_error("Processing {$argv[$counter]} - {$argv[$counter+1]}");
- $friendly_interface = convert_real_interface_to_friendly_interface_name($argv[$counter]);
- if($config['interfaces'][$friendly_interface]['ipaddr'] <> "dhcp" and
- $config['interfaces'][$friendly_interface]['ipaddr'] <> "pppoe" and
- $config['interfaces'][$friendly_interface]['ipaddr'] <> "bigpond" and
- $config['interfaces'][$friendly_interface]['ipaddr'] <> "pptp") {
- log_error("Hotplug event detected for {$argv[$counter]} but ignoring since interface is not set for DHCP");
- $counter++;
- $counter++;
- } else {
-
- if($argv[$counter+1] == "stop" or $argv[$counter+1] == "down") {
- log_error("DEVD Ethernet detached event for {$argv[$counter]}");
- exec("/sbin/ifconfig {$argv[$counter]} delete");
- exec("/usr/sbin/arp -da");
- }
-
- if($argv[$counter+1] == "start" or $argv[$counter+1] == "up") {
- log_error("DEVD Ethernet attached event for {$argv[$counter]}");
- exec("/sbin/ifconfig {$argv[$counter]} up");
- exec("/usr/sbin/arp -da");
- }
-
- if($argv[$counter] <> "") {
- $interface = convert_real_interface_to_friendly_interface_name($argv[$counter]);
- } else {
- log_error("WARNING: No interface passed to rc.linkup");
- $interface = "wan";
- }
+ for ($i = 1; $i <= $ARGC; $i++)
+ $argspassed .= $ARGV[$i] . " ";
+ log_error("Arguments passed rc.linkup. '{$argspassed}'");
+
+ if ( $ARGC != 2 ) {
+ log_error("Incorrect number of arguments passed rc.linkup...exiting.");
+ exit;
+ }
- if($interface == "wan") {
- if($config['interfaces'][$friendly_interface]['ipaddr'] <> "pppoe") {
- /* do not reconfigure on hotplug events when using pppoe */
- log_error("HOTPLUG: Configuring wan interface {$interface}");
- interfaces_wan_configure();
- }
- } else if($interface == "lan") {
- log_error("HOTPLUG: Configuring lan interface {$interface}");
- interfaces_lan_configure();
- } else {
- $int = str_replace("opt", "", $interface);
- interfaces_optional_configure_if($int);
- echo "interfaces_optional_configure_if($int);\n";
- log_error("HOTPLUG: Configuring optional interface {$interface} - opt{$int}");
+ log_error("Processing {$ARGV[1]} - {$ARGV[2]}");
+ $iface = convert_real_interface_to_friendly_interface_name($ARGV[1]);
+ /* XXX: billm - is this correct? we claim DHCP, but we're checking other types too */
+ if($config['interfaces'][$friendly_interface]['ipaddr'] <> "dhcp" and
+ $config['interfaces'][$iface]['ipaddr'] <> "pppoe" and
+ $config['interfaces'][$iface]['ipaddr'] <> "bigpond" and
+ $config['interfaces'][$iface]['ipaddr'] <> "pptp") {
+ log_error("Hotplug event detected for {$ARGV[1]} but ignoring since interface is not set for DHCP");
+ } else {
+ switch ($ARGV[1]) {
+ case "stop":
+ case "down":
+ {
+ log_error("DEVD Ethernet detached event for {$ARGV[1]}");
+ exec("/sbin/ifconfig {$ARGV[1]} delete");
+ exec("/usr/sbin/arp -da");
+ /* XXX: billm - this feels right, but is new and may be wrong */
+ exit;
+ break; /* LINT - NOT REACHED */
+ }
+ case "start":
+ case "up":
+ {
+ log_error("DEVD Ethernet attached event for {$ARGV[1]}");
+ exec("/sbin/ifconfig {$ARGV[1]} up");
+ exec("/usr/sbin/arp -da");
+ break;
}
+ }
- $counter++;
- $counter++;
+ switch ($iface) {
+ case "wan":
+ if($config['interfaces'][$iface]['ipaddr'] <> "pppoe") {
+ /* do not reconfigure on hotplug events when using pppoe */
+ log_error("HOTPLUG: Configuring wan interface {$ARGV[1]}");
+ interfaces_wan_configure();
+ }
+ break;
+ case "lan":
+ log_error("HOTPLUG: Configuring lan interface {$ARGV[1]}");
+ interfaces_lan_configure();
+ break;
+ default:
+ $int = str_replace("opt", "", $interface);
+ interfaces_optional_configure_if($int);
+ echo "interfaces_optional_configure_if($int);\n";
+ log_error("HOTPLUG: Configuring optional interface {$interface} - opt{$int}");
+ break;
}
}
}
-?> \ No newline at end of file
+?>
OpenPOWER on IntegriCloud