fix: refuse a dhcp/hosts reservation IP another host already holds - #186
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #185. Also changes the code-of-conduct contact to
openwrt-iac@gugod.fr, which is unrelated but a one-line docs edit and not worth its own cycle.The defect
Two
dhcp/hostsreservations on one IP were accepted, and dnsmasq treats that as fatal rather than ignoring the second entry: it logsduplicate dhcp-host IP addressand refuses to start. The box loses DNS and DHCP until someone removes one by hand, from a write that answered 200.On a device, before:
after:
The caveat in the issue, resolved by measurement
I filed #185 warning that
unique_fieldis a single-field mechanism while dnsmasq's rule might be subtler, and that two reservations could legitimately share an address for a host with several NICs. That turns out not to apply, because uapi already models that case as one reservation carrying severalmacs. Measured both shapes on a device:So nothing legitimate needs two reservations on one address, and a plain uniqueness check matches what dnsmasq actually rejects. dnsmasq's own source is not in the SDK feeds, so this is empirical rather than read off the implementation, which is worth knowing if its behaviour ever changes.
Reservations with no
ipare untouched:check_unique_fieldskips a value that is not a non-empty string, and several address-less reservations are normal. Covered by a test.One correction to the issue text
I wrote there that
unique_field"produces a 409 conflict before anything is written". It produces 422 with field codeconflict, consistent with every other validation failure. My unit test asserted 409 and failed, which is how I found out. The write is still refused before the commit, so the "before anything is written" half was right.Does this change the wire surface? Yes, and it is the breaking direction: a payload that was accepted is now refused. It is a
fixrather than afeat!because the accepted payload never worked, it took the DNS server down. Anyone relying on it had a broken box. Worth a note in the next release's changelog rather than a major.Was it verified against a real device, or only by CI? On a device, with the tables above, including that dnsmasq survives the refused write and that a different address still succeeds. Four unit tests cover the refusal, the field and code, a different address, several macs on one reservation, and address-less reservations. Mutation-checked: removing
unique_fieldfails the refusal test with 200.Was LuCI checked? Yes.
luci-mod-network's dhcp view has no duplicate-IP guard, so this is a deliberate improvement on the baseline rather than a correction of an accidental divergence, as #185 records.