summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarjohn56 <martin@queens-park.com>2016-08-07 21:06:25 +0100
committerRenato Botelho <renato@netgate.com>2016-09-02 16:18:31 -0300
commite0bc2a6c159213279fd7b34b00fddff4c63f5aa1 (patch)
tree1e4530baa8f42bf1f4ff42ae66198d252ba6b534
parent1e0d9c89f702c495d829f226374b73c38a8a7925 (diff)
downloadpfsense-e0bc2a6c159213279fd7b34b00fddff4c63f5aa1.zip
pfsense-e0bc2a6c159213279fd7b34b00fddff4c63f5aa1.tar.gz
DHCP6 Before RA. Additions and ammendments
Replaced posix_kill() in kill_dhcp6client_process() with mwexec("kill -9 $pid"), this is because the posix_kill call was not reliably killing the dhcp6c process, kill -9 works every time. Changes to the rtsold script creation. The script lines starting dhcp6c should not have be written to the script when dhcpwithoutra is true. Style corrections, I spend more time doing these than changing code! (cherry picked from commit c4ddb03acbbb4ff2a88162a9afc9e589a6f4d053)
-rw-r--r--src/etc/inc/interfaces.inc41
1 files changed, 15 insertions, 26 deletions
diff --git a/src/etc/inc/interfaces.inc b/src/etc/inc/interfaces.inc
index 177661d..90b5ecf 100644
--- a/src/etc/inc/interfaces.inc
+++ b/src/etc/inc/interfaces.inc
@@ -1332,11 +1332,7 @@ function interface_bring_down($interface = "wan", $destroy = false, $ifacecfg =
switch ($ifcfg['ipaddrv6']) {
case "slaac":
case "dhcp6":
- $pidv6 = find_dhcp6c_process($realif);
- if ($pidv6) {
- posix_kill($pidv6, SIGTERM);
- }
- sleep(3);
+ kill_dhcp6client_process($realif);
unlink_if_exists("{$g['varetc_path']}/dhcp6c_{$interface}.conf");
unlink_if_exists("{$g['varetc_path']}/dhcp6c_{$interface}_script.sh");
unlink_if_exists("{$g['varetc_path']}/rtsold_{$realifv6}_script.sh");
@@ -3062,19 +3058,14 @@ function find_dhcp6c_process($interface) {
}
function kill_dhcp6client_process($interface) {
- if (empty($interface) || !does_interface_exist($interface)) {
- return;
- }
+ if (empty($interface) || !does_interface_exist($interface)) {
+ return;
+ }
- $i = 0;
- while ((($pid = find_dhcp6c_process($interface)) != 0) && ($i < 3)) {
- /* 3rd time make it die for sure */
- $sig = ($i == 2 ? SIGKILL : SIGTERM);
- posix_kill($pid, $sig);
- sleep(1);
- $i++;
- }
- unset($i);
+ if (($pid = find_dhcp6c_process($interface)) != 0) {
+ mwexec("kill -9 {$pid}");
+ sleep(1);
+ }
}
function interface_virtual_create($interface) {
@@ -4007,15 +3998,9 @@ function interface_dhcpv6_configure($interface = "wan", $wancfg) {
$rtsoldscript .= "echo $2 > {$g['tmp_path']}/{$wanif}_routerv6\n";
$rtsoldscript .= "echo $2 > {$g['tmp_path']}/{$wanif}_defaultgwv6\n";
$rtsoldscript .= "/usr/bin/logger -t rtsold \"Received RA specifying route \$2 for interface {$interface}({$wanif})\"\n";
- $rtsoldscript .= "if [ -f {$g['varrun_path']}/dhcp6c_{$wanif}.pid ]; then\n";
- $rtsoldscript .= "\t/bin/pkill -F {$g['varrun_path']}/dhcp6c_{$wanif}.pid\n";
- $rtsoldscript .= "\t/bin/sleep 1\n";
- $rtsoldscript .= "fi\n";
- $debugOption = isset($wancfg['dhcp6debug']) ? "-D" : "-d";
- $rtsoldscript .= "/usr/local/sbin/dhcp6c {$debugOption} -c {$g['varetc_path']}/dhcp6c_{$interface}.conf -p {$g['varrun_path']}/dhcp6c_{$wanif}.pid {$wanif}\n";
- $rtsoldscript .= "/usr/bin/logger -t rtsold \"Starting dhcp6 client for interface {$interface}({$wanif})\"\n";
+
/* non ipoe Process */
- if (!isset($wancfg['dhcp6withoutra'])) {
+ if (!isset($wancfg['dhcp6withoutra'])) {
$rtsoldscript .= "if [ -f {$g['varrun_path']}/dhcp6c_{$wanif}.pid ]; then\n";
$rtsoldscript .= "\t/bin/pkill -F {$g['varrun_path']}/dhcp6c_{$wanif}.pid\n";
$rtsoldscript .= "\t/bin/sleep 1\n";
@@ -4024,6 +4009,8 @@ function interface_dhcpv6_configure($interface = "wan", $wancfg) {
$rtsoldscript .= "\t/bin/sleep 1\n";
}
$debugOption = isset($wancfg['dhcp6debug']) ? "-D" : "-d";
+
+ /* add the start of dhcp6c to the rtsold script if we are going to wait for ra */
if (!isset($wancfg['dhcp6withoutra'])) {
$rtsoldscript .= "/usr/local/sbin/dhcp6c {$debugOption} -c {$g['varetc_path']}/dhcp6c_{$interface}.conf -p {$g['varrun_path']}/dhcp6c_{$wanif}.pid {$wanif}\n";
$rtsoldscript .= "/usr/bin/logger -t rtsold \"Starting dhcp6 client for interface {$interface}({$wanif})\"\n";
@@ -4046,11 +4033,13 @@ function interface_dhcpv6_configure($interface = "wan", $wancfg) {
killbypid("{$g['varrun_path']}/rtsold_{$wanif}.pid");
sleep(2);
}
+
+ /* start dhcp6c here if we don't want to wait for ra */
if (isset($wancfg['dhcp6withoutra'])) {
kill_dhcp6client_process($wanif);
mwexec("/usr/local/sbin/dhcp6c {$debugOption} -c {$g['varetc_path']}/dhcp6c_wan.conf -p {$g['varrun_path']}/dhcp6c_{$wanif}.pid {$wanif}");
- mwexec("/usr/bin/logger -t mwtag 'Starting dhcp6 client for interface wan({$wanif} in IPoE mode)'");
+ mwexec("/usr/bin/logger -t info 'Starting dhcp6 client for interface wan({$wanif} in DHCP6 without RA mode)'");
}
mwexec("/usr/sbin/rtsold -1 -p {$g['varrun_path']}/rtsold_{$wanif}.pid -O {$g['varetc_path']}/rtsold_{$wanif}_script.sh {$wanif}");
OpenPOWER on IntegriCloud