Skip to content

Commit

Permalink
unbound: speed up and safeguards for #4642
Browse files Browse the repository at this point in the history
  • Loading branch information
fichtner committed Feb 22, 2021
1 parent a3bfcc2 commit 140f4ea
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/etc/inc/plugins.inc.d/unbound.inc
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ EOF;
}

// Configure static Host entries
unbound_add_host_entries();
unbound_add_host_entries($ifconfig_details);

// Configure Domain Overrides
unbound_add_domain_overrides();
Expand Down Expand Up @@ -506,7 +506,7 @@ function unbound_add_domain_overrides($pvt = false)
}
}

function unbound_add_host_entries()
function unbound_add_host_entries($ifconfig_details = null)
{
global $config;

Expand All @@ -531,7 +531,6 @@ function unbound_add_host_entries()
} else {
$interfaces = array_keys(get_configured_interface_with_descr());
}
$ifconfig_details = legacy_interfaces_details();
foreach ($interfaces as $interface) {
if ($interface == 'lo0' || substr($interface, 0, 4) == 'ovpn') {
continue;
Expand Down Expand Up @@ -675,18 +674,17 @@ function unbound_add_host_entries()

if (isset($config['unbound']['regdhcpstatic']) && is_array($config['dhcpdv6'])) {
foreach ($config['dhcpdv6'] as $dhcpif => $dhcpifconf) {
list ($ipaddrv6) = isset($dhcpifconf['dhcpd6track6allowoverride']) ?
interfaces_primary_address6($dhcpif, null, $ifconfig_details) : [null];
if (isset($dhcpifconf['staticmap']) && isset($dhcpifconf['enable'])) {
foreach ($dhcpifconf['staticmap'] as $host) {
if (!$host['ipaddrv6'] || !$host['hostname']) {
if (empty($host['ipaddrv6']) || empty($host['hostname'])) {
continue;
}

// XXX - When using manual overide on dhcpd6 we need to get the prefix and marry it to the suffix
// Get the prefix first.
list ($ipaddrv6) = interfaces_primary_address6($dhcpif);
if (!empty($ipaddrv6)) {
$host['ipaddrv6'] = make_ipv6_64_address($ipaddrv6,$host['ipaddrv6']);
}
if (!empty($ipaddrv6)) {
$host['ipaddrv6'] = make_ipv6_64_address($ipaddrv6, $host['ipaddrv6']);
}

$domain = $config['system']['domain'];
// XXX: dhcpdv6 domain entries have been superseded by domainsearchlist,
Expand Down Expand Up @@ -796,7 +794,8 @@ function unbound_hosts_generate()
return;
}

unbound_add_host_entries();
$ifconfig_details = legacy_interfaces_details();
unbound_add_host_entries($ifconfig_details);

killbypid('/var/run/unbound.pid', 'HUP');
}
Expand Down

3 comments on commit 140f4ea

@fichtner
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marjohn56 can you give this a go? we should make sure to check dhcpd6track6allowoverride state

@marjohn56
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It writes the correct info to the host_entries.conf, v4 and v6 so looks good.

@fichtner
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Dnsmasq is also patched up now. It looks like we should really consider writing an iterator for the staticmap loops since Unbound and Dnsmasq basically use the same code and so it's harder to manage than it should. It would also push this code back to dhcpd.inc where it belongs.

Please sign in to comment.