Commit 7d00f8c9 authored by Franco Fichtner's avatar Franco Fichtner

Revert "(legacy) remove cache stuff from find_interface_ip"

This reverts commit bc6bbc40.
parent a26d6c5b
...@@ -168,7 +168,7 @@ EOD; ...@@ -168,7 +168,7 @@ EOD;
* the if block. So using $gateway['ipprotocol'] is the better option. * the if block. So using $gateway['ipprotocol'] is the better option.
*/ */
if ($gateway['ipprotocol'] == "inet") { // This is an IPv4 gateway... if ($gateway['ipprotocol'] == "inet") { // This is an IPv4 gateway...
$gwifip = find_interface_ip($gateway['interface']); $gwifip = find_interface_ip($gateway['interface'], true);
if (!is_ipaddrv4($gwifip)) if (!is_ipaddrv4($gwifip))
continue; //Skip this target continue; //Skip this target
......
...@@ -2839,7 +2839,7 @@ function interface_vlan_adapt_mtu($vlanifs, $mtu) { ...@@ -2839,7 +2839,7 @@ function interface_vlan_adapt_mtu($vlanifs, $mtu) {
function interface_configure($interface = 'wan', $reloadall = false, $linkupevent = false) function interface_configure($interface = 'wan', $reloadall = false, $linkupevent = false)
{ {
global $config; global $config;
global $interface_sn_arr_cache; global $interface_sn_arr_cache, $interface_ip_arr_cache;
global $interface_snv6_arr_cache, $interface_ipv6_arr_cache; global $interface_snv6_arr_cache, $interface_ipv6_arr_cache;
$wancfg = $config['interfaces'][$interface]; $wancfg = $config['interfaces'][$interface];
...@@ -2956,6 +2956,7 @@ function interface_configure($interface = 'wan', $reloadall = false, $linkupeven ...@@ -2956,6 +2956,7 @@ function interface_configure($interface = 'wan', $reloadall = false, $linkupeven
} }
/* invalidate interface/ip/sn cache */ /* invalidate interface/ip/sn cache */
unset($interface_ip_arr_cache[$realif]);
unset($interface_sn_arr_cache[$realif]); unset($interface_sn_arr_cache[$realif]);
unset($interface_ipv6_arr_cache[$realif]); unset($interface_ipv6_arr_cache[$realif]);
unset($interface_snv6_arr_cache[$realif]); unset($interface_snv6_arr_cache[$realif]);
...@@ -4504,16 +4505,29 @@ function link_interface_to_gif($interface) ...@@ -4504,16 +4505,29 @@ function link_interface_to_gif($interface)
/* /*
* find_interface_ip($interface): return the interface ip (first found) * find_interface_ip($interface): return the interface ip (first found)
*/ */
function find_interface_ip($interface) { function find_interface_ip($interface, $flush = false) {
$interface = trim($interface); global $interface_ip_arr_cache;
if (does_interface_exist($interface)) {
$ifinfo = pfSense_get_interface_addresses($interface); if (!isset($interface_ip_arr_cache) || !is_array($interface_ip_arr_cache)) {
if (isset($ifinfo['ipaddr'])) { $interface_ip_arr_cache = array() ;
return $ifinfo['ipaddr']; }
}
} else { $interface = str_replace("\n", "", $interface);
return null;
if (!does_interface_exist($interface))
return;
/* Setup IP cache */
if (!isset($interface_ip_arr_cache[$interface]) or $flush) {
$ifinfo = pfSense_get_interface_addresses($interface);
if (isset($ifinfo['ipaddr'])) {
$interface_ip_arr_cache[$interface] = $ifinfo['ipaddr'];
} else {
return null;
} }
}
return $interface_ip_arr_cache[$interface];
} }
/* /*
......
...@@ -76,7 +76,7 @@ if (is_array($config['interfaces'][$interface]) && !isset($config['interfaces'][ ...@@ -76,7 +76,7 @@ if (is_array($config['interfaces'][$interface]) && !isset($config['interfaces'][
if (empty($argument)) { if (empty($argument)) {
$curwanip = get_interface_ip(); $curwanip = get_interface_ip();
} else { } else {
$curwanip = find_interface_ip($interface_real); $curwanip = find_interface_ip($interface_real, true);
if(empty($curwanip)) { if(empty($curwanip)) {
$curwanip = get_interface_ip($interface); $curwanip = get_interface_ip($interface);
} }
......
...@@ -51,7 +51,9 @@ function interfaces_carp_set_maintenancemode($carp_maintenancemode) ...@@ -51,7 +51,9 @@ function interfaces_carp_set_maintenancemode($carp_maintenancemode)
} }
unset($interface_arr_cache);
unset($carp_interface_count_cache); unset($carp_interface_count_cache);
unset($interface_ip_arr_cache);
$status = get_carp_status(); $status = get_carp_status();
if ($_POST['carp_maintenancemode'] <> "") { if ($_POST['carp_maintenancemode'] <> "") {
......
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