Skip to content

Commit

Permalink
Revert "(legacy) kill "interface cache", let's not try to cache thing…
Browse files Browse the repository at this point in the history
…s that may change during the session... all for saving a ifconfig call."

This reverts commit 4c48ab5.
  • Loading branch information
fichtner committed Nov 25, 2015
1 parent 7d00f8c commit 8a45858
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 9 deletions.
3 changes: 3 additions & 0 deletions src/etc/inc/filter.inc
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ function filter_configure_sync($delete_states_if_needed = true)
filter_pflog_start();
update_filter_reload_status(gettext("Initializing"), true);

/* invalidate interface cache */
get_interface_arr(true);

/* Get interface list to work with. */
filter_generate_optcfg_array();
if(file_exists("/var/run/booting")) {
Expand Down
3 changes: 2 additions & 1 deletion src/etc/inc/gwlb.inc
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,8 @@ function return_gateways_array($disabled = false, $localhost = false, $inactive
$found_defaultv4 = 0;
$found_defaultv6 = 0;

$interfaces = legacy_interface_listget();
// Ensure the interface cache is up to date first
$interfaces = get_interface_arr(true);
$interfaces_v4 = array();
$interfaces_v6 = array();

Expand Down
45 changes: 40 additions & 5 deletions src/etc/inc/interfaces.inc
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,21 @@ function interfaces_bring_up($interface)
legacy_interface_flags($interface, 'up');
}

/*
* Return the interface array
*/
function get_interface_arr($flush = false)
{
global $interface_arr_cache;

/* If the cache doesn't exist, build it */
if (!isset($interface_arr_cache) or $flush) {
$interface_arr_cache = legacy_interface_listget();
}

return $interface_arr_cache;
}

function interface_override_flags()
{
global $config;
Expand All @@ -111,14 +126,24 @@ function interface_override_flags()
);
}

function does_interface_exist($interface)
function does_interface_exist($interface, $flush = true)
{
$ints = legacy_interface_listget();
if (empty($interface) || $ints == null || !in_array($interface, $ints)) {
global $config;

if(!$interface) {
return false;
} else {
return true;
}

$ints = get_interface_arr($flush);
if ($ints == null) {
return false;
}

if (!in_array($interface, $ints)) {
return false;
}

return true;
}


Expand Down Expand Up @@ -285,6 +310,9 @@ function interface_vlan_configure(&$vlan)

interfaces_bring_up($vlanif);

/* invalidate interface cache */
get_interface_arr(true);

/* XXX: ermal -- for now leave it here at the moment it does not hurt. */
interfaces_bring_up($if);

Expand Down Expand Up @@ -338,6 +366,9 @@ function interface_qinq_configure(&$vlan, $fd = NULL) {
fwrite($fd, "connect {$qinqif}: {$vlanif}qinq: upper nomatch\n");
}

/* invalidate interface cache */
get_interface_arr(true);

if (!stristr($qinqif, "_vlan"))
mwexec("/sbin/ifconfig {$qinqif} promisc\n");

Expand Down Expand Up @@ -403,6 +434,9 @@ function interface_qinq2_configure(&$qinq, $fd, $macaddr) {
fwrite($fd, "msg {$if}h{$tag}: setifname \"{$vlanif}\"\n");
fwrite($fd, "msg {$if}h{$tag}: set {$macaddr}\n");

/* invalidate interface cache */
get_interface_arr(true);

return $vlanif;
}

Expand Down Expand Up @@ -2956,6 +2990,7 @@ function interface_configure($interface = 'wan', $reloadall = false, $linkupeven
}

/* invalidate interface/ip/sn cache */
get_interface_arr(true);
unset($interface_ip_arr_cache[$realif]);
unset($interface_sn_arr_cache[$realif]);
unset($interface_ipv6_arr_cache[$realif]);
Expand Down
5 changes: 2 additions & 3 deletions src/etc/inc/pfsense-utils.inc
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,10 @@ function setup_polling()
function setup_microcode() {

/* if list */
$ifs = legacy_interface_listget();
$ifs = get_interface_arr();

foreach($ifs as $if) {
foreach($ifs as $if)
enable_hardware_offloading($if);
}
}

/****f* legacy/get_carp_status
Expand Down

0 comments on commit 8a45858

Please sign in to comment.