Skip to content

Commit

Permalink
interfaces: do not use legacy_get_interface_addresses() #4749
Browse files Browse the repository at this point in the history
Speed up the callers that have $ifconfig_details ready to pass down.

(cherry picked from commit 33bc4af)
  • Loading branch information
fichtner committed Feb 24, 2022
1 parent 675a829 commit 1338883
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/etc/inc/interfaces.inc
Expand Up @@ -2382,7 +2382,7 @@ function interface_configure($verbose = false, $interface = 'wan', $reload = fal
* which triggers the interface config again, which attempts to
* spoof the MAC again which cycles the link again...
*/
if (!empty($wancfg['spoofmac']) && strcasecmp($wancfg['spoofmac'], get_interface_mac($realhwif))) {
if (!empty($wancfg['spoofmac']) && strcasecmp($wancfg['spoofmac'], get_interface_mac($realhwif, $ifconfig_details))) {
mwexecf('/sbin/ifconfig %s link %s', [$realhwif, $wancfg['spoofmac']]);
}

Expand Down Expand Up @@ -4002,9 +4002,15 @@ function is_interface_wireless($interface)

function get_interface_mac($interface, $ifconfig_details = null)
{
$macinfo = legacy_get_interface_addresses($interface, $ifconfig_details);
$intf_details = [];

return $macinfo["macaddr"];
if (empty($ifconfig_details)) {
$intf_details = legacy_interface_details($interface);
} elseif (!empty($ifconfig_details[$ifs])) {
$intf_details = $ifconfig_details[$ifs];
}

return $intf_details['macaddr'];
}

function get_vip_descr($ipaddress)
Expand Down
2 changes: 1 addition & 1 deletion src/etc/inc/plugins.inc.d/dhcpd.inc
Expand Up @@ -1641,7 +1641,7 @@ EOD;
} else {
$realif = get_real_interface($dhcpv6if, "inet6");
if (stristr("$realif", "bridge")) {
$mac = get_interface_mac($realif);
$mac = get_interface_mac($realif, $ifconfig_details);
$v6address = dhcpd_generate_ipv6_from_mac($mac);
/* create link local address for bridges */
mwexec("/sbin/ifconfig {$realif} inet6 {$v6address}");
Expand Down

0 comments on commit 1338883

Please sign in to comment.