Commit a26d6c5b authored by Franco Fichtner's avatar Franco Fichtner

Revert "(legacy) remove cache stuff from find_interface_ipv6"

This reverts commit 47aaef9d.
parent cc145db9
...@@ -190,7 +190,7 @@ EOD; ...@@ -190,7 +190,7 @@ EOD;
if (is_linklocal($gateway['gateway'])) { if (is_linklocal($gateway['gateway'])) {
$gwifip = find_interface_ipv6_ll($gateway['interface'], true); $gwifip = find_interface_ipv6_ll($gateway['interface'], true);
} else { } else {
$gwifip = find_interface_ipv6($gateway['interface']); $gwifip = find_interface_ipv6($gateway['interface'], true);
} }
} else { } else {
/* 'monitor' has been set, so makes sure it has precedence over /* 'monitor' has been set, so makes sure it has precedence over
...@@ -198,14 +198,14 @@ EOD; ...@@ -198,14 +198,14 @@ EOD;
* is a local link and 'monitor' is global routable then the * is a local link and 'monitor' is global routable then the
* ICMP6 response would not find its way back home... * ICMP6 response would not find its way back home...
*/ */
$gwifip = find_interface_ipv6($gateway['interface']); $gwifip = find_interface_ipv6($gateway['interface'], true);
if (is_linklocal($gateway['monitor'])) { if (is_linklocal($gateway['monitor'])) {
if (!strstr($gateway['monitor'], '%')) { if (!strstr($gateway['monitor'], '%')) {
$gateway['monitor'] .= "%{$gateway['interface']}"; $gateway['monitor'] .= "%{$gateway['interface']}";
} }
} else { } else {
// Monitor is a routable address, so use a routable address for the "src" part // Monitor is a routable address, so use a routable address for the "src" part
$gwifip = find_interface_ipv6($gateway['interface']); $gwifip = find_interface_ipv6($gateway['interface'], true);
} }
} }
......
...@@ -2840,7 +2840,7 @@ function interface_configure($interface = 'wan', $reloadall = false, $linkupeven ...@@ -2840,7 +2840,7 @@ function interface_configure($interface = 'wan', $reloadall = false, $linkupeven
{ {
global $config; global $config;
global $interface_sn_arr_cache; global $interface_sn_arr_cache;
global $interface_snv6_arr_cache; global $interface_snv6_arr_cache, $interface_ipv6_arr_cache;
$wancfg = $config['interfaces'][$interface]; $wancfg = $config['interfaces'][$interface];
...@@ -2957,6 +2957,7 @@ function interface_configure($interface = 'wan', $reloadall = false, $linkupeven ...@@ -2957,6 +2957,7 @@ function interface_configure($interface = 'wan', $reloadall = false, $linkupeven
/* invalidate interface/ip/sn cache */ /* invalidate interface/ip/sn cache */
unset($interface_sn_arr_cache[$realif]); unset($interface_sn_arr_cache[$realif]);
unset($interface_ipv6_arr_cache[$realif]);
unset($interface_snv6_arr_cache[$realif]); unset($interface_snv6_arr_cache[$realif]);
$tunnelif = substr($realif, 0, 3); $tunnelif = substr($realif, 0, 3);
...@@ -3157,6 +3158,7 @@ function interface_track6_configure($interface = 'lan', $wancfg, $linkupevent = ...@@ -3157,6 +3158,7 @@ function interface_track6_configure($interface = 'lan', $wancfg, $linkupevent =
function interface_track6_6rd_configure($interface = 'lan', $lancfg) function interface_track6_6rd_configure($interface = 'lan', $lancfg)
{ {
global $config; global $config;
global $interface_ipv6_arr_cache;
global $interface_snv6_arr_cache; global $interface_snv6_arr_cache;
if (!is_array($lancfg)) if (!is_array($lancfg))
...@@ -3207,6 +3209,7 @@ function interface_track6_6rd_configure($interface = 'lan', $lancfg) ...@@ -3207,6 +3209,7 @@ function interface_track6_6rd_configure($interface = 'lan', $lancfg)
$oip = find_interface_ipv6($lanif); $oip = find_interface_ipv6($lanif);
if (is_ipaddrv6($oip)) if (is_ipaddrv6($oip))
mwexec("/sbin/ifconfig {$lanif} inet6 {$oip} delete"); mwexec("/sbin/ifconfig {$lanif} inet6 {$oip} delete");
unset($interface_ipv6_arr_cache[$lanif]);
unset($interface_snv6_arr_cache[$lanif]); unset($interface_snv6_arr_cache[$lanif]);
log_error("rd6 {$interface} with ipv6 address {$rd6lan} based on {$lancfg['track6-interface']} ipv4 {$ip4address}"); log_error("rd6 {$interface} with ipv6 address {$rd6lan} based on {$lancfg['track6-interface']} ipv4 {$ip4address}");
mwexec("/sbin/ifconfig {$lanif} inet6 {$rd6lan} prefixlen 64"); mwexec("/sbin/ifconfig {$lanif} inet6 {$rd6lan} prefixlen 64");
...@@ -3217,6 +3220,7 @@ function interface_track6_6rd_configure($interface = 'lan', $lancfg) ...@@ -3217,6 +3220,7 @@ function interface_track6_6rd_configure($interface = 'lan', $lancfg)
function interface_track6_6to4_configure($interface = 'lan', $lancfg) function interface_track6_6to4_configure($interface = 'lan', $lancfg)
{ {
global $config; global $config;
global $interface_ipv6_arr_cache;
global $interface_snv6_arr_cache; global $interface_snv6_arr_cache;
if (!is_array($lancfg)) if (!is_array($lancfg))
...@@ -3263,6 +3267,7 @@ function interface_track6_6to4_configure($interface = 'lan', $lancfg) ...@@ -3263,6 +3267,7 @@ function interface_track6_6to4_configure($interface = 'lan', $lancfg)
$oip = find_interface_ipv6($lanif); $oip = find_interface_ipv6($lanif);
if (is_ipaddrv6($oip)) if (is_ipaddrv6($oip))
mwexec("/sbin/ifconfig {$lanif} inet6 {$oip} delete"); mwexec("/sbin/ifconfig {$lanif} inet6 {$oip} delete");
unset($interface_ipv6_arr_cache[$lanif]);
unset($interface_snv6_arr_cache[$lanif]); unset($interface_snv6_arr_cache[$lanif]);
log_error("sixto4 {$interface} with ipv6 address {$sixto4lan} based on {$lancfg['track6-interface']} ipv4 {$ip4address}"); log_error("sixto4 {$interface} with ipv6 address {$sixto4lan} based on {$lancfg['track6-interface']} ipv4 {$ip4address}");
mwexec("/sbin/ifconfig {$lanif} inet6 {$sixto4lan} prefixlen 64"); mwexec("/sbin/ifconfig {$lanif} inet6 {$sixto4lan} prefixlen 64");
...@@ -4506,23 +4511,39 @@ function find_interface_ip($interface) { ...@@ -4506,23 +4511,39 @@ function find_interface_ip($interface) {
if (isset($ifinfo['ipaddr'])) { if (isset($ifinfo['ipaddr'])) {
return $ifinfo['ipaddr']; return $ifinfo['ipaddr'];
} }
} else {
return null;
} }
return null;
} }
/* /*
* find_interface_ipv6($interface): return the interface ip (first found) * find_interface_ipv6($interface): return the interface ip (first found)
*/ */
function find_interface_ipv6($interface) { function find_interface_ipv6($interface, $flush = false) {
// a bit obscure, why should this be different then find_interface_ip? global $interface_ipv6_arr_cache;
$interface = get_real_interface(trim($interface)); global $config;
if (does_interface_exist($interface)) {
$ifinfo = pfSense_get_interface_addresses($interface); if (!isset($interface_ipv6_arr_cache) || !is_array($interface_ipv6_arr_cache)) {
if (isset($ifinfo['ipaddr6'])) { $interface_ipv6_arr_cache = array();
return $ifinfo['ipaddr6']; }
}
$interface = trim($interface);
$interface = get_real_interface($interface);
if (!does_interface_exist($interface))
return;
/* Setup IP cache */
if (!isset($interface_ipv6_arr_cache[$interface]) or $flush) {
$ifinfo = pfSense_get_interface_addresses($interface);
if (isset($ifinfo['ipaddr6'])) {
$interface_ipv6_arr_cache[$interface] = $ifinfo['ipaddr6'];
} else {
return null;
} }
return null; }
return $interface_ipv6_arr_cache[$interface];
} }
/* /*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment