summaryrefslogtreecommitdiffstats
path: root/etc/rc.linkup
diff options
context:
space:
mode:
authorErmal Luçi <eri@pfsense.org>2008-10-19 14:05:41 +0000
committerErmal Luçi <eri@pfsense.org>2008-10-19 14:05:41 +0000
commit4367b5f627439192c9e1a7d4fe608eb4ada14590 (patch)
tree0d5ac64a8f5266e2332a6850f5e0de665e605430 /etc/rc.linkup
parentadec6851084a557c2133f90d5bcb15e92fdb83c5 (diff)
downloadpfsense-4367b5f627439192c9e1a7d4fe608eb4ada14590.zip
pfsense-4367b5f627439192c9e1a7d4fe608eb4ada14590.tar.gz
Bring order and simplify logic.
Diffstat (limited to 'etc/rc.linkup')
-rwxr-xr-xetc/rc.linkup106
1 files changed, 50 insertions, 56 deletions
diff --git a/etc/rc.linkup b/etc/rc.linkup
index 69a0753..e3dfe04 100755
--- a/etc/rc.linkup
+++ b/etc/rc.linkup
@@ -29,64 +29,58 @@
POSSIBILITY OF SUCH DAMAGE.
*/
- /* parse the configuration and include all functions used below */
- require_once("globals.inc");
- require_once("config.inc");
- require_once("functions.inc");
+/* parse the configuration and include all functions used below */
+require_once("globals.inc");
+require_once("config.inc");
+require_once("functions.inc");
- if($g['booting'] == true) {
- /* ignore all linkup events */
- } else {
- for ($i = 1; $i <= $_SERVER['argc']; $i++) {
- $argspassed .= $_SERVER['argv'][$i] . " ";
- $argument1 = $_SERVER['argv'][$i];
- $argument2 = $_SERVER['argv'][$i+1];
- handle_argument_group($argument1, $argument2);
- }
- }
-
- function handle_argument_group($argument1, $argument2) {
- global $config;
- log_error("Processing {$argument1} - {$argument2}");
- $iface = convert_real_interface_to_friendly_interface_name($argument1);
- if($iface == "") {
- log_error("Not a valid interface \"$iface\"");
- return;
- }
- if($argument2 == "") {
- log_error("Not a valid interface action \"$argument2\"");
- return;
- }
- if($config['interfaces'][$iface]['ipaddr'] <> "dhcp" and
- $config['interfaces'][$iface]['ipaddr'] <> "pppoe" and
- $config['interfaces'][$iface]['ipaddr'] <> "pptp") {
- log_error("Hotplug event detected for {$argument1} but ignoring since interface is not set for DHCP");
- exec("/usr/sbin/arp -d -i {$argument1} -a");
- } else {
- switch ($argument2) {
- case "stop":
- case "down":
- log_error("DEVD Ethernet detached event for {$argument1}");
- exec("/sbin/ifconfig {$argument1} delete");
- exec("/usr/sbin/arp -d -i {$argument1} -a");
- exit;
- break; /* LINT - NOT REACHED */
- case "start":
- case "up":
- log_error("DEVD Ethernet attached event for {$argument1}");
- exec("/sbin/ifconfig {$argument1} up");
- exec("/usr/sbin/arp -d -i {$argument1} -a");
- break;
- }
+function handle_argument_group($argument1, $argument2) {
+ global $config;
- if($config['interfaces'][$iface]['ipaddr'] <> "pppoe" and
- $config['interfaces'][$iface]['ipaddr'] <> "pptp") {
- /* do not reconfigure on hotplug events when using pppoe or pptp */
- /* XXX: Why not?! */
- log_error("HOTPLUG: Configuring wan interface {$argument1}");
- interface_configure($iface);
- }
- }
+ log_error("Processing {$argument1} - {$argument2}");
+ $iface = convert_real_interface_to_friendly_interface_name($argument1);
+ if ($iface == "") {
+ log_error("Not a valid interface {$argument1} -> \"$iface\"");
+ return;
+ }
+ if($argument2 == "") {
+ log_error("Not a valid interface action \"$argument2\"");
+ return;
+ }
+
+ $ipaddr = $config['interfaces'][$iface]['ipaddr'];
+ if (is_ipaddr($ipaddr)) {
+ log_error("Hotplug event detected for {$argument1} but ignoring since interface is configured with static ip({$ipaddr})");
+ exec("/usr/sbin/arp -d -i {$argument1} -a");
+ } else {
+ switch ($argument2) {
+ case "stop":
+ case "down":
+ log_error("DEVD Ethernet detached event for {$argument1}");
+ if ($ipaddr <> "pppoe" || $ipaddr <> "pptp")
+ interface_bring_down($iface);
+ exit;
+ break; /* LINT - NOTREACHED */
+ case "start":
+ case "up":
+ log_error("DEVD Ethernet attached event for {$argument1}");
+ exec("/usr/sbin/arp -d -i {$argument1} -a");
+ log_error("HOTPLUG: Configuring interface {$argument1}");
+ if ($ipaddr <> "pppoe" || $ipaddr <> "pptp")
+ interface_configure($iface);
+ break;
}
+ }
+}
+if ($g['booting'] == true) {
+ /* ignore all linkup events */
+} else {
+ for ($i = 1; $i <= $_SERVER['argc']; $i++) {
+ $argspassed .= $_SERVER['argv'][$i] . " ";
+ $argument1 = $_SERVER['argv'][$i];
+ $argument2 = $_SERVER['argv'][$i+1];
+ handle_argument_group($argument1, $argument2);
+ }
+}
?>
OpenPOWER on IntegriCloud