Skip to content

Commit bbb4ccb

Browse files
fix: do not load all NetworkInterface objects in DHCPServer::init_interfaces
This fixes an issue that caused extra processing and memory usage when interacting with the DHCPServer Model class.
1 parent 2b6dd5e commit bbb4ccb

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/DHCPServer.inc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -252,22 +252,22 @@ class DHCPServer extends Model {
252252
}
253253

254254
/**
255-
* Initializes configurations objects for defined interface that have not yet configured the DHCP server
255+
* Initializes configuration objects for defined interface that have not yet configured the DHCP server
256256
*/
257257
private function init_interfaces(): void {
258258
# Variables
259-
$ifs_using_dhcpd = array_keys($this->get_config(path: $this->config_path, default: []));
259+
$ifs_using_dhcp_server = array_keys($this->get_config(path: $this->config_path, default: []));
260260

261261
# Loop through each defined interface
262-
foreach (NetworkInterface::read_all()->model_objects as $if) {
262+
foreach ($this->get_config("interfaces", []) as $if_id => $if) {
263263
# Skip this interface if it is not a static interface or the subnet value is greater than or equal to 31
264-
if ($if->typev4->value !== 'static' or $if->subnet->value >= 31) {
264+
if (empty($if["ipaddr"]) or $if["ipaddr"] === "dhcp" or $if->subnet->value >= 31) {
265265
continue;
266266
}
267267

268268
# Otherwise, make this interface eligible for a DHCP server
269-
if (!in_array($if->id, $ifs_using_dhcpd)) {
270-
$this->set_config(path: "$this->config_path/$if->id", value: []);
269+
if (!in_array($if_id, $ifs_using_dhcp_server)) {
270+
$this->set_config(path: "$this->config_path/$if_id", value: []);
271271
}
272272
}
273273
}

0 commit comments

Comments
 (0)