Revision e0bc2a6c
Added by Martin Wasley almost 9 years ago
src/etc/inc/interfaces.inc | ||
---|---|---|
1332 | 1332 |
switch ($ifcfg['ipaddrv6']) { |
1333 | 1333 |
case "slaac": |
1334 | 1334 |
case "dhcp6": |
1335 |
$pidv6 = find_dhcp6c_process($realif); |
|
1336 |
if ($pidv6) { |
|
1337 |
posix_kill($pidv6, SIGTERM); |
|
1338 |
} |
|
1339 |
sleep(3); |
|
1335 |
kill_dhcp6client_process($realif); |
|
1340 | 1336 |
unlink_if_exists("{$g['varetc_path']}/dhcp6c_{$interface}.conf"); |
1341 | 1337 |
unlink_if_exists("{$g['varetc_path']}/dhcp6c_{$interface}_script.sh"); |
1342 | 1338 |
unlink_if_exists("{$g['varetc_path']}/rtsold_{$realifv6}_script.sh"); |
... | ... | |
3062 | 3058 |
} |
3063 | 3059 |
|
3064 | 3060 |
function kill_dhcp6client_process($interface) { |
3065 |
if (empty($interface) || !does_interface_exist($interface)) {
|
|
3066 |
return;
|
|
3067 |
}
|
|
3061 |
if (empty($interface) || !does_interface_exist($interface)) { |
|
3062 |
return; |
|
3063 |
} |
|
3068 | 3064 |
|
3069 |
$i = 0; |
|
3070 |
while ((($pid = find_dhcp6c_process($interface)) != 0) && ($i < 3)) { |
|
3071 |
/* 3rd time make it die for sure */ |
|
3072 |
$sig = ($i == 2 ? SIGKILL : SIGTERM); |
|
3073 |
posix_kill($pid, $sig); |
|
3074 |
sleep(1); |
|
3075 |
$i++; |
|
3076 |
} |
|
3077 |
unset($i); |
|
3065 |
if (($pid = find_dhcp6c_process($interface)) != 0) { |
|
3066 |
mwexec("kill -9 {$pid}"); |
|
3067 |
sleep(1); |
|
3068 |
} |
|
3078 | 3069 |
} |
3079 | 3070 |
|
3080 | 3071 |
function interface_virtual_create($interface) { |
... | ... | |
4007 | 3998 |
$rtsoldscript .= "echo $2 > {$g['tmp_path']}/{$wanif}_routerv6\n"; |
4008 | 3999 |
$rtsoldscript .= "echo $2 > {$g['tmp_path']}/{$wanif}_defaultgwv6\n"; |
4009 | 4000 |
$rtsoldscript .= "/usr/bin/logger -t rtsold \"Received RA specifying route \$2 for interface {$interface}({$wanif})\"\n"; |
4010 |
$rtsoldscript .= "if [ -f {$g['varrun_path']}/dhcp6c_{$wanif}.pid ]; then\n"; |
|
4011 |
$rtsoldscript .= "\t/bin/pkill -F {$g['varrun_path']}/dhcp6c_{$wanif}.pid\n"; |
|
4012 |
$rtsoldscript .= "\t/bin/sleep 1\n"; |
|
4013 |
$rtsoldscript .= "fi\n"; |
|
4014 |
$debugOption = isset($wancfg['dhcp6debug']) ? "-D" : "-d"; |
|
4015 |
$rtsoldscript .= "/usr/local/sbin/dhcp6c {$debugOption} -c {$g['varetc_path']}/dhcp6c_{$interface}.conf -p {$g['varrun_path']}/dhcp6c_{$wanif}.pid {$wanif}\n"; |
|
4016 |
$rtsoldscript .= "/usr/bin/logger -t rtsold \"Starting dhcp6 client for interface {$interface}({$wanif})\"\n"; |
|
4001 |
|
|
4017 | 4002 |
/* non ipoe Process */ |
4018 |
if (!isset($wancfg['dhcp6withoutra'])) {
|
|
4003 |
if (!isset($wancfg['dhcp6withoutra'])) { |
|
4019 | 4004 |
$rtsoldscript .= "if [ -f {$g['varrun_path']}/dhcp6c_{$wanif}.pid ]; then\n"; |
4020 | 4005 |
$rtsoldscript .= "\t/bin/pkill -F {$g['varrun_path']}/dhcp6c_{$wanif}.pid\n"; |
4021 | 4006 |
$rtsoldscript .= "\t/bin/sleep 1\n"; |
... | ... | |
4024 | 4009 |
$rtsoldscript .= "\t/bin/sleep 1\n"; |
4025 | 4010 |
} |
4026 | 4011 |
$debugOption = isset($wancfg['dhcp6debug']) ? "-D" : "-d"; |
4012 |
|
|
4013 |
/* add the start of dhcp6c to the rtsold script if we are going to wait for ra */ |
|
4027 | 4014 |
if (!isset($wancfg['dhcp6withoutra'])) { |
4028 | 4015 |
$rtsoldscript .= "/usr/local/sbin/dhcp6c {$debugOption} -c {$g['varetc_path']}/dhcp6c_{$interface}.conf -p {$g['varrun_path']}/dhcp6c_{$wanif}.pid {$wanif}\n"; |
4029 | 4016 |
$rtsoldscript .= "/usr/bin/logger -t rtsold \"Starting dhcp6 client for interface {$interface}({$wanif})\"\n"; |
... | ... | |
4046 | 4033 |
killbypid("{$g['varrun_path']}/rtsold_{$wanif}.pid"); |
4047 | 4034 |
sleep(2); |
4048 | 4035 |
} |
4036 |
|
|
4037 |
/* start dhcp6c here if we don't want to wait for ra */ |
|
4049 | 4038 |
if (isset($wancfg['dhcp6withoutra'])) { |
4050 | 4039 |
kill_dhcp6client_process($wanif); |
4051 | 4040 |
|
4052 | 4041 |
mwexec("/usr/local/sbin/dhcp6c {$debugOption} -c {$g['varetc_path']}/dhcp6c_wan.conf -p {$g['varrun_path']}/dhcp6c_{$wanif}.pid {$wanif}"); |
4053 |
mwexec("/usr/bin/logger -t mwtag 'Starting dhcp6 client for interface wan({$wanif} in IPoE mode)'");
|
|
4042 |
mwexec("/usr/bin/logger -t info 'Starting dhcp6 client for interface wan({$wanif} in DHCP6 without RA mode)'");
|
|
4054 | 4043 |
} |
4055 | 4044 |
mwexec("/usr/sbin/rtsold -1 -p {$g['varrun_path']}/rtsold_{$wanif}.pid -O {$g['varetc_path']}/rtsold_{$wanif}_script.sh {$wanif}"); |
4056 | 4045 |
|
Also available in: Unified diff
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)