Skip to content

Commit

Permalink
Revert "(legacy) remove cache stuff from find_interface_ipv6_ll"
Browse files Browse the repository at this point in the history
This reverts commit 5474af2.
  • Loading branch information
fichtner committed Nov 25, 2015
1 parent 1ab17d3 commit cc145db
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/etc/inc/gwlb.inc
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ EOD;
if ($gateway['monitor'] == $gateway['gateway']) {
/* link locals really need a different src ip */
if (is_linklocal($gateway['gateway'])) {
$gwifip = find_interface_ipv6_ll($gateway['interface']);
$gwifip = find_interface_ipv6_ll($gateway['interface'], true);
} else {
$gwifip = find_interface_ipv6($gateway['interface']);
}
Expand Down
33 changes: 21 additions & 12 deletions src/etc/inc/interfaces.inc
Original file line number Diff line number Diff line change
Expand Up @@ -4528,20 +4528,29 @@ function find_interface_ipv6($interface) {
/*
* find_interface_ipv6_ll($interface): return the interface ipv6 link local (first found)
*/
function find_interface_ipv6_ll($interface) {
$interface = trim($interface);
if (does_interface_exist($interface)) {
$ifinfo = pfSense_getall_interface_addresses($interface);
foreach($ifinfo as $line) {
if (strstr($line, ":")) {
$parts = explode("/", $line);
if(is_linklocal($parts[0])) {
return $parts[0];
}
}
function find_interface_ipv6_ll($interface, $flush = false) {
global $interface_llv6_arr_cache;
global $config;

$interface = str_replace("\n", "", $interface);

if (!does_interface_exist($interface))
return;

/* Setup IP cache */
if (!isset($interface_llv6_arr_cache[$interface]) or $flush) {
$ifinfo = pfSense_getall_interface_addresses($interface);
foreach($ifinfo as $line) {
if (strstr($line, ":")) {
$parts = explode("/", $line);
if(is_linklocal($parts[0])) {
$ifinfo['linklocal'] = $parts[0];
}
}
}
return null;
$interface_llv6_arr_cache[$interface] = $ifinfo['linklocal'];
}
return $interface_llv6_arr_cache[$interface];
}

function find_interface_subnet($interface, $flush = false) {
Expand Down

0 comments on commit cc145db

Please sign in to comment.