Commit c14db1a3 authored by Ad Schellevis's avatar Ad Schellevis

lower call overhead in get_interface_list(), for https://github.com/opnsense/core/issues/1662

parent 9bba2092
......@@ -898,17 +898,18 @@ function get_interface_list($only_active = false, $include_dmesg = false)
$ifnames_up = legacy_interface_listget('up');
$ifnames = legacy_interface_listget();
$all_interfaces = legacy_config_get_interfaces(array('virtual' => false));
$all_interface_data = legacy_interfaces_details();
if ($only_active) {
$_ifnames = array();
$all_stats = legacy_interface_stats();
foreach ($ifnames as $ifname) {
$ifinfo = legacy_interface_stats($ifname);
if ($ifinfo['link state'] == '2') {
$ifinfo = $all_stats[$ifname];
if (!empty($ifinfo['link state']) && $ifinfo['link state'] == '2') {
$_ifnames[] = $ifname;
}
}
$ifnames = $_ifnames;
}
......@@ -918,16 +919,15 @@ function get_interface_list($only_active = false, $include_dmesg = false)
continue;
}
$ifdata = legacy_get_interface_addresses($ifname);
$ifdata = !empty($all_interface_data[$ifname]) ? $all_interface_data[$ifname] : array();
$toput = array(
'up' => in_array($ifname, $ifnames_up),
'ipaddr' => !empty($ifdata['ipaddr']) ? $ifdata['ipaddr'] : null,
'mac' => $ifdata['macaddr'],
'ipaddr' => !empty($ifdata['ipv4'][0]['ipaddr']) ? $ifdata['ipv4'][0]['ipaddr'] : null,
'mac' => !empty($ifdata['macaddr']) ? $ifdata['macaddr'] : null,
'dmesg' => '',
);
foreach (legacy_config_get_interfaces(array('virtual' => false)) as $name => $int) {
foreach ($all_interfaces as $name => $int) {
if ($int['if'] == $ifname) {
$toput['friendly'] = $name;
break;
......
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