Fixes #2627. When an interface goes down try to shut the RAs and dhcpd6 service on that interface

This commit is contained in:
Ermal 2014-02-21 13:28:53 +00:00
parent 9510780ffa
commit 080fd00bac
2 changed files with 27 additions and 5 deletions

View File

@ -1252,6 +1252,7 @@ function interface_bring_down($interface = "wan", $destroy = false, $ifacecfg =
break;
}
$track6 = array();
switch ($ifcfg['ipaddrv6']) {
case "slaac":
case "dhcp6":
@ -1268,6 +1269,7 @@ function interface_bring_down($interface = "wan", $destroy = false, $ifacecfg =
pfSense_interface_flags($realif, -IFF_UP);
mwexec("/usr/sbin/arp -d -i " . escapeshellarg($realif) . " -a");
}
$track6 = link_interface_to_track6($interface);
break;
case "6rd":
case "6to4":
@ -1279,6 +1281,7 @@ function interface_bring_down($interface = "wan", $destroy = false, $ifacecfg =
if ($destroy == true)
pfSense_interface_flags($realif, -IFF_UP);
}
$track6 = link_interface_to_track6($interface);
break;
default:
if(does_interface_exist("$realif")) {
@ -1291,9 +1294,19 @@ function interface_bring_down($interface = "wan", $destroy = false, $ifacecfg =
pfSense_interface_flags($realif, -IFF_UP);
mwexec("/usr/sbin/arp -d -i " . escapeshellarg($realif) . " -a");
}
$track6 = link_interface_to_track6($interface);
break;
}
if (!empty($track6) && is_array($track6)) {
foreach ($track6 as $trackif) {
if (!function_exists('services_dhcp_configure'))
require_once('services.inc');
/* Bring down radvd and dhcp6 on these interfaces */
services_dhcpd_configure('inet6', $track6);
}
}
if (file_exists("{$g['tmp_path']}/{$realif}_router"))
$old_router = trim(file_get_contents("{$g['tmp_path']}/{$realif}_router"));
// log_error("Checking for old router states: {$g['tmp_path']}/{$realif}_router = {$old_router}");

View File

@ -42,7 +42,7 @@ define('DYNDNS_PROVIDER_VALUES', 'dnsomatic dyndns dyndns-static dyndns-custom d
define('DYNDNS_PROVIDER_DESCRIPTIONS', 'DNS-O-Matic,DynDNS (dynamic),DynDNS (static),DynDNS (custom),DHS,DyNS,easyDNS,No-IP,No-IP (free),ODS.org,ZoneEdit,Loopia,freeDNS,DNSexit,OpenDNS,Namecheap,HE.net,HE.net (v6),HE.net Tunnelbroker,SelfHost,Route 53,Custom,Custom (v6)');
/* implement ipv6 route advertising deamon */
function services_radvd_configure() {
function services_radvd_configure($blacklist = array()) {
global $config, $g;
if ($g['platform'] == 'jail')
@ -72,6 +72,9 @@ function services_radvd_configure() {
if (!isset($config['interfaces'][$dhcpv6if]['enable']))
continue;
/* Do not put in the config an interface which is down */
if (isset($blacklist[$dhcpv6if]))
continue;
if (!isset($dhcpv6ifconf['ramode']))
$dhcpv6ifconf['ramode'] = $dhcpv6ifconf['mode'];
@ -210,6 +213,9 @@ function services_radvd_configure() {
continue;
if(!isset($config['interfaces'][$if]['enable']))
continue;
/* Do not put in the config an interface which is down */
if (isset($blacklist[$if]))
continue;
$trackif = $config['interfaces'][$if]['track6-interface'];
if (empty($config['interfaces'][$trackif]))
continue;
@ -297,7 +303,7 @@ function services_radvd_configure() {
return 0;
}
function services_dhcpd_configure($family = "all") {
function services_dhcpd_configure($family = "all", $blacklist = array()) {
global $config, $g;
/* configure DHCPD chroot once */
@ -325,8 +331,8 @@ function services_dhcpd_configure($family = "all") {
if ($family == "all" || $family == "inet")
services_dhcpdv4_configure();
if ($family == "all" || $family == "inet6") {
services_dhcpdv6_configure();
services_radvd_configure();
services_dhcpdv6_configure($blacklist);
services_radvd_configure($blacklist);
}
}
@ -895,7 +901,7 @@ EOD;
return 0;
}
function services_dhcpdv6_configure() {
function services_dhcpdv6_configure($blacklist = array()) {
global $config, $g;
if($g['services_dhcp_server_enable'] == false)
@ -946,6 +952,9 @@ function services_dhcpdv6_configure() {
/* we add a fake entry for interfaces that are set to track6 another WAN */
foreach ($Iflist as $ifname) {
/* Do not put in the config an interface which is down */
if (isset($blacklist[$ifname]))
continue;
if (!empty($config['interfaces'][$ifname]['track6-interface'])) {
$realif = get_real_interface($ifname, "inet6");
$ifcfgipv6 = get_interface_ipv6($ifname);