From c72e682d213979893122525033d58e6c113330fd Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Fri, 12 Jul 2019 16:46:19 +0200 Subject: [PATCH] dhcpdv4: performance improvements, only call interfaces_staticarp_configure() when staticarp is used on this interface, prevent excessive legacy_interfaces_details() calls for https://github.com/opnsense/core/issues/3567 --- src/etc/inc/plugins.inc.d/dhcpd.inc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/etc/inc/plugins.inc.d/dhcpd.inc b/src/etc/inc/plugins.inc.d/dhcpd.inc index 1a41fb12e..f2d787d49 100644 --- a/src/etc/inc/plugins.inc.d/dhcpd.inc +++ b/src/etc/inc/plugins.inc.d/dhcpd.inc @@ -598,10 +598,12 @@ EOD; * failover peer "bleh" entries */ foreach ($config['dhcpd'] as $dhcpif => $dhcpifconf) { - interfaces_staticarp_configure($dhcpif); if (!isset($dhcpifconf['enable'])) { continue; } + if (!empty($config['dhcpd'][$dhcpif]['staticmap'])) { + interfaces_staticarp_configure($dhcpif); + } if (!empty($dhcpifconf['failover_peerip'])) { $intip = get_interface_ip($dhcpif); @@ -662,6 +664,7 @@ EOPP; } $iflist = get_configured_interface_with_descr(); + $gwObject = new \OPNsense\Routing\Gateways(legacy_interfaces_details()); foreach ($config['dhcpd'] as $dhcpif => $dhcpifconf) { if (!isset($dhcpifconf['enable']) || !isset($iflist[$dhcpif])) { @@ -895,7 +898,7 @@ EOPP; if (!empty($dhcpifconf['gateway'])) { $routers = $dhcpifconf['gateway'] != "none" ? $dhcpifconf['gateway'] : null; - } elseif ((new \OPNsense\Routing\Gateways(legacy_interfaces_details()))->hasGateways("inet")) { + } elseif ($gwObject->hasGateways("inet")) { // by default, add interface address in "option routers" $routers = $ifcfgip; } else {