Skip to content

Commit

Permalink
Revert "(legacy) remove cache stuff from find_interface_subnet"
Browse files Browse the repository at this point in the history
This reverts commit d4f27bc.
  • Loading branch information
fichtner committed Nov 25, 2015
1 parent 84854b1 commit 1ab17d3
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions src/etc/inc/interfaces.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2839,6 +2839,7 @@ function interface_vlan_adapt_mtu($vlanifs, $mtu) {
function interface_configure($interface = 'wan', $reloadall = false, $linkupevent = false)
{
global $config;
global $interface_sn_arr_cache;
global $interface_snv6_arr_cache;

$wancfg = $config['interfaces'][$interface];
Expand Down Expand Up @@ -2955,6 +2956,7 @@ function interface_configure($interface = 'wan', $reloadall = false, $linkupeven
}

/* invalidate interface/ip/sn cache */
unset($interface_sn_arr_cache[$realif]);
unset($interface_snv6_arr_cache[$realif]);

$tunnelif = substr($realif, 0, 3);
Expand Down Expand Up @@ -4542,15 +4544,27 @@ function find_interface_ipv6_ll($interface) {
return null;
}

function find_interface_subnet($interface) {
$interface = trim($interface);
if (does_interface_exist($interface)) {
$ifinfo = pfSense_get_interface_addresses($interface);
if (isset($ifinfo['subnetbits'])) {
return $ifinfo['subnetbits'];
}
function find_interface_subnet($interface, $flush = false) {
global $interface_sn_arr_cache;

if (!isset($interface_sn_arr_cache) || !is_array($interface_sn_arr_cache)){
$interface_sn_arr_cache = array();
}

$interface = str_replace("\n", "", $interface);
if (does_interface_exist($interface) == false)
return;

if (!isset($interface_sn_arr_cache[$interface]['subnetbits']) || $flush) {
$ifinfo = pfSense_get_interface_addresses($interface);
if (isset($ifinfo['subnetbits'])) {
$interface_sn_arr_cache[$interface] = $ifinfo['subnetbits'];
} else {
return null;
}
return null;
}

return $interface_sn_arr_cache[$interface];
}

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

0 comments on commit 1ab17d3

Please sign in to comment.