Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support static DNS mappings using Kea DHCP. #7362

Merged
merged 11 commits into from May 17, 2024

Conversation

reitermarkus
Copy link
Contributor

Closes #7307.

@AdSchellevis AdSchellevis self-assigned this Apr 5, 2024
@fichtner
Copy link
Member

fichtner commented Apr 5, 2024

I've added 14cc9a1c2f and b53fe7c1d9 to avoid tainting private static_mapping consumers after discussion with @AdSchellevis.

I'm not against this, but this needs careful crafting because the current PR is (in light of the impending breakage it would have created above) not complete. Here are a few thoughts:

  • For one the action is not required and shouldn't be added until its needed.
  • You should check if the static mapping's server is actually enabled.
  • Given the lack of an IPv6 kea implementation we shouldn't mess with looping over IPv6 entries that don't exist.

Cheers,
Franco

@reitermarkus
Copy link
Contributor Author

reitermarkus commented Apr 5, 2024

For one the action is not required and shouldn't be added until its needed.

So the action is not needed for the plugin function to work? Where is the list.static action for dhcpd needed, as I based this off of this and this doesn't seem to be used anywhere?

You should check if the static mapping's server is actually enabled.

This is now checked.

Given the lack of an IPv6 kea implementation we shouldn't mess with looping over IPv6 entries that don't exist.

I have removed the useless loop.

@reitermarkus
Copy link
Contributor Author

@fichtner, can you have another look here?


$subnet_node = $keav4->getNodeByReference("subnets.subnet4.{$reservation->subnet}");

$domain = $domain_fallback;
Copy link
Member

Choose a reason for hiding this comment

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

we should maybe considering removing domain_fallback or at least not implementing it for kea.. it was only a workaround for unbound when it wasn't capable of setting the right domain

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So it should not use the system domain as fallback?

https://github.com/opnsense/core/blob/24.7.a/src/etc/inc/plugins.inc.d/unbound.inc#L586

Or is this set automatically?

Comment on lines 96 to 101
$entry = [
'descr' => $description,
'domain' => $domain,
'hostname' => $hostname,
'ipaddr' => $ip_address,
];
Copy link
Member

Choose a reason for hiding this comment

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

interface key is missing here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Where to get the interface from? Or just set it to null?

Comment on lines 75 to 82
$hostname = (string)$reservation->hostname;
if (empty($hostname)) {
$hostname = null;
}
$description = (string)$reservation->description;
if (empty($description)) {
$description = null;
}
Copy link
Member

Choose a reason for hiding this comment

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

this feels a bit overcomplicated, empty strings should be fine. you end up thowing a PHP warning now or later because empty() should be the first sanity check then which can mute the warning. Here it does nothing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you end up thowing a PHP warning now or later because empty() should be the first sanity check then which can mute the warning

I'm not quite following, should the empty check be removed completely or moved somewhere else?

@dMopp
Copy link

dMopp commented May 5, 2024

I would love to see it in the next release :)

@AdSchellevis AdSchellevis force-pushed the master branch 2 times, most recently from be6c1bb to 030ed19 Compare May 15, 2024 16:21
@fichtner fichtner assigned fichtner and unassigned AdSchellevis May 17, 2024
Copy link
Member

@fichtner fichtner left a comment

Choose a reason for hiding this comment

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

good for merge! all relevant parts to make this happen are in 24.1.7 now

@fichtner fichtner merged commit 139a3ad into opnsense:master May 17, 2024
@fichtner
Copy link
Member

Merged, thanks!

@dMopp
Copy link

dMopp commented May 18, 2024

Just for myself: that means it will be part of the NEXT release, right?

@fichtner
Copy link
Member

Next development version. Final release in 24.1.9 most likely.

@reitermarkus reitermarkus deleted the kea-static-mapping branch May 19, 2024 22:27
@dMopp
Copy link

dMopp commented May 21, 2024

opnsense-patch 139a3ad Works well :). Thanks. Next stop: dynamic leases into unbound 👯‍♂️

@fichtner
Copy link
Member

It's not the full patching. I'd say it works but I'd rather have confirmation on latest development state because there it works without the obvious issues it introduces into the wider system.

@dMopp
Copy link

dMopp commented May 21, 2024

Yeah, all fine, for "me" it seems to work fine. And i can always revert if in case of any issues

@fichtner
Copy link
Member

Well, the point was that if the actual development state is tested it helps us more to ship the feature than cherry-picking the PR commit because mistakes can happen. I know it works as a concept because it was reviewed and merged, but it doesn't reflect the full state of changes necessary. That's all.

@dMopp
Copy link

dMopp commented May 22, 2024

Ah, okay I understood. Might consider it, but it might affect the woman acceptance factor 😅

@fichtner
Copy link
Member

We all have our reasons, no problem. I just wanted to get that point across. In any case kudos for using opnsense-patch to subvert the WAF. ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Register KEA DHCP Mappings with Unbound
4 participants