summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2005-11-27 20:41:10 +0000
committerScott Ullrich <sullrich@pfsense.org>2005-11-27 20:41:10 +0000
commitd7a6517a4bf23188d37dfa60d9314437275d6343 (patch)
tree74b2c5926940b32e0da46b470129aa4b1da357a0
parent528df9a78e17a9c7acfddff1e3c50696e3a24228 (diff)
downloadpfsense-d7a6517a4bf23188d37dfa60d9314437275d6343.zip
pfsense-d7a6517a4bf23188d37dfa60d9314437275d6343.tar.gz
MFC 8080
* Do not process hotplug events from pppoe * Cleanup kill by pid function, accept a real pid (dhclient depends on this)
-rw-r--r--etc/inc/interfaces.inc28
-rw-r--r--etc/inc/util.inc7
-rwxr-xr-xetc/rc.linkup88
3 files changed, 69 insertions, 54 deletions
diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc
index 1e53eaf..b6ad801 100644
--- a/etc/inc/interfaces.inc
+++ b/etc/inc/interfaces.inc
@@ -690,11 +690,14 @@ function interfaces_wan_configure() {
/* find dhclient process for wan and kill it */
killbypid(find_dhclient_process("wan"));
+ /* remove wanup file if it exists */
+ unlink_if_exists("{$g['tmp_path']}/wanup");
+
/* kill PPPoE client (mpd) */
killbypid("{$g['varrun_path']}/mpd.pid");
/* wait for processes to die */
- sleep(1);
+ sleep(3);
unlink_if_exists("{$g['varetc_path']}/dhclient_wan.conf");
unlink_if_exists("{$g['varetc_path']}/mpd.conf");
@@ -1073,24 +1076,27 @@ EOD;
fwrite($fd, $mpdconf);
fclose($fd);
-
- /* if mpd is active, lets take it down */
- if(file_exists("{$g['varrun_path']}/mpd.pid")) {
- killbypid(file_get_contents("{$g['varrun_path']}/mpd.pid"));
- sleep(1);
+
+ if(file_exists("{$g['varrun_path']}/mpd.pid") and $g['booting']) {
+ /* if we are booting and mpd has already been started then don't start again. */
+ } else {
+ /* if mpd is active, lets take it down */
+ if(file_exists("{$g['varrun_path']}/mpd.pid")) {
+ killbypid("{$g['varrun_path']}/mpd.pid");
+ sleep(3);
+ }
+ /* fire up mpd */
+ mwexec("/usr/local/sbin/mpd -b -d {$g['varetc_path']} -p {$g['varrun_path']}/mpd.pid pppoe");
}
- /* fire up mpd */
- mwexec("/usr/local/sbin/mpd -b -d {$g['varetc_path']} -p {$g['varrun_path']}/mpd.pid pppoe");
-
/* sleep until wan is up - or 30 seconds, whichever comes first */
for ($count = 0; $count < 30; $count++) {
if(file_exists("{$g['tmp_path']}/wanup")) {
break;
}
-
sleep(1);
}
+
unlink_if_exists("{$g['tmp_path']}/wanup");
return 0;
@@ -1420,4 +1426,4 @@ function discover_bridge($interface1, $interface2) {
return "-1";
}
-?>
+?> \ No newline at end of file
diff --git a/etc/inc/util.inc b/etc/inc/util.inc
index cea6998..2502c56 100644
--- a/etc/inc/util.inc
+++ b/etc/inc/util.inc
@@ -37,7 +37,10 @@ function killbypid($pidfile) {
/* sigkill a process by pid file */
function sigkillbypid($pidfile, $sig) {
if (file_exists($pidfile)) {
- mwexec("/bin/kill -s $sig `/bin/cat " . $pidfile . "`");
+ $pid = file_get_contents($pidfile);
+ mwexec("/bin/kill -s $sig {$pid}");
+ } else {
+ mwexec("/bin/kill -s $sig {$pidfile}");
}
}
@@ -487,4 +490,4 @@ function xml_safe_fieldname($fieldname) {
return strtolower(str_replace($replace, "", $fieldname));
}
-?>
+?> \ No newline at end of file
diff --git a/etc/rc.linkup b/etc/rc.linkup
index 8a19d2a..480881c 100755
--- a/etc/rc.linkup
+++ b/etc/rc.linkup
@@ -34,47 +34,53 @@
require_once("config.inc");
require_once("functions.inc");
- if($g['booting'] == true)
- exit;
-
- $friendly_interface = convert_real_interface_to_friendly_interface_name($argv[1]);
- 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[1]} but ignoring since interface is not set for DHCP");
- exit;
- }
-
- if($argv[2] == "stop" or $argv[2] == "down") {
- log_error("DEVD Ethernet detached event for {$argv[1]}");
- exec("/sbin/ifconfig {$argv[1]} delete");
- exec("/usr/sbin/arp -da");
- exit;
- }
-
- if($argv[2] == "start" or $argv[2] == "up") {
- log_error("DEVD Ethernet attached event for {$argv[1]}");
- exec("/sbin/ifconfig {$argv[1]} up");
- exec("/usr/sbin/arp -da");
- }
-
- if($argv[1] <> "") {
- $interface = convert_real_interface_to_friendly_interface_name($argv[1]);
- } else {
- log_error("WARNING: No interface passed to rc.linkup");
- $interface = "wan";
- }
-
- if($interface == "wan") {
- log_error("HOTPLUG: Configuring wan interface {$interface}");
- interfaces_wan_configure();
- } else if($interface == "lan") {
- log_error("HOTPLUG: Configuring lan interface {$interface}");
- interfaces_lan_configure();
+ if($g['booting'] == true) {
+ /* ignore all linkup events */
} else {
- log_error("HOTPLUG: Configuring optional interface {$interface}");
- interfaces_optional_configure_if($interface);
+
+ $friendly_interface = convert_real_interface_to_friendly_interface_name($argv[1]);
+ 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[1]} but ignoring since interface is not set for DHCP");
+ exit;
+ }
+
+ if($argv[2] == "stop" or $argv[2] == "down") {
+ log_error("DEVD Ethernet detached event for {$argv[1]}");
+ exec("/sbin/ifconfig {$argv[1]} delete");
+ exec("/usr/sbin/arp -da");
+ exit;
+ }
+
+ if($argv[2] == "start" or $argv[2] == "up") {
+ log_error("DEVD Ethernet attached event for {$argv[1]}");
+ exec("/sbin/ifconfig {$argv[1]} up");
+ exec("/usr/sbin/arp -da");
+ }
+
+ if($argv[1] <> "") {
+ $interface = convert_real_interface_to_friendly_interface_name($argv[1]);
+ } else {
+ log_error("WARNING: No interface passed to rc.linkup");
+ $interface = "wan";
+ }
+
+ 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 {
+ log_error("HOTPLUG: Configuring optional interface {$interface}");
+ interfaces_optional_configure_if($interface);
+ }
+
}
-?> \ No newline at end of file
+?>
OpenPOWER on IntegriCloud