Commit 8a458582 authored by Franco Fichtner's avatar Franco Fichtner

Revert "(legacy) kill "interface cache", let's not try to cache things that...

Revert "(legacy) kill "interface cache", let's not try to cache things that may change during the session... all for saving a ifconfig call."

This reverts commit 4c48ab5d.
parent 7d00f8c9
......@@ -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")) {
......
......@@ -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();
......
......@@ -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;
......@@ -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;
}
......@@ -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);
......@@ -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");
......@@ -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;
}
......@@ -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]);
......
......@@ -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
......
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