Repository navigation
fix: stop the hostname rename loop caused by our own answers (#545) - #548
Merged
Merged
Conversation
After a hostname rename, the daemon answered its own probe for the new name, because the services stay announced and `name_changes` already points at the new name. When the probe held only some of the host's addresses of one family, the answer had an address the probe lacked, so `conflict_handler` saw a conflict and renamed the host again, with the same subset of addresses. This repeated without end. - Don't answer with an address record that is still being probed (RFC 6762 section 8.1). - Don't treat an answer as a conflict when one of our services publishes that address for the hostname (RFC 6762 section 9). - On a hostname conflict, move all address records of the host (A and AAAA, probing and active) to the new name, so the host isn't split between two names. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A rename in `conflict_handler` changed the records of the services but left them `Announced`. They kept answering with records that were no longer valid or not probed yet, and `probing_handler` skipped them when the new probes finished, so they were never announced under the new names. On a rename, the services waiting on the probe go back to `Probing` and wait on the new probes. For a hostname, that is every service on the host, including ones whose records were already active. Co-Authored-By: Claude Opus 5.5 <[email protected]>
RFC 6762 section 8.1: a responder must not answer with a record until its probe has finished. Address answers already follow this. Service answers now do too: - A PTR answer leaves out an instance whose SRV or TXT record is still being probed, and the additional address records still being probed. - A direct SRV or TXT answer leaves out a record still being probed, and so do its additional address records. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`add_answer_of_service` used the original hostname for the SRV target and its additional address records. After a hostname rename, a direct SRV query got a hostname the daemon no longer answers address queries for. Use the renamed hostname, as announcements and PTR answers do. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
This PR is to address #545.
The loop
An example with the addresses from the issue. The host
device-12345.local.has four addresses onwlan0:192.0.2.10fe80::a:2(link-local)2001:db8::a:1(SLAAC)2001:db8::100(DHCPv6)Setup. The IPv4 and link-local addresses come up first. They finish probing and move to
active. The two global addresses come up 5 seconds later and start a new probe for the same hostname. While that probe runs, an AAAA answer fordevice-12345.local.arrives with an address that is not one of the two being probed. That is all the oldconflict_handlerneeds to see a conflict. The answer renames the host todevice-12346.local.. Only records still inprobingmove, so the probe fordevice-12346.local.has just the two global AAAA records.name_changesmapsdevice-12345.local.todevice-12346.local., and the services stayAnnounced.Then:
device-12346.local.with2001:db8::a:1and2001:db8::100in the authority section.Announced, and their hostname now resolves todevice-12346.local., so the daemon answers with all four addresses. The oldanswer_hostname_questiontakes the addresses from each service's own address list and checks only the service's status, never whether the address records are still being probed. So the two global addresses go out too, although their probe is the one in progress.conflict_handler.device-12346.local.is being probed, so each answer record is compared with the probe:192.0.2.10: the probe has no A record, so there is nothing to compare with.2001:db8::a:1and2001:db8::100: they are in the probe, so no conflict.fe80::a:2: it is not in the probe, so this counts as a conflict, and both AAAA records in the probe move todevice-12347.local..device-12347.local.again has just the two global addresses, so it goes back to step 1.The renames never stop. In the issue #545 they ran at about 5 per second for more than 8 hours. No
NameChangeevent is sent, because no probe ever finishes.Why it needs two addresses of one family. A conflict needs an answer address that the probe lacks while the probe holds another address of the same type, like
fe80::a:2in step 3. With only one IPv6 address, the probe either has it (a match) or has no AAAA record at all (nothing to rename, like the A record). Then the loop can't start.With this PR:
active, so the probe fordevice-12346.local.has all four addresses. Both services go back toProbinguntil the new probes finish, and are then announced underdevice-12346.local..fe80::a:2is one of our own addresses, so even if such an answer arrives, it is not a conflict.Changes
answer_hostname_questionleaves out addresses that are in the probe for that hostname. When all of them are probing, it answers nothing, not even NSEC.conflict_handlerignores an A/AAAA answer when one of our services publishes that address for the hostname, original or renamed (is_own_address). An address of the interface itself is deliberately not enough, because another responder on the same host can claim the hostname with it. The integration conflict tests depend on that.probingandactive, so the host isn't split between two names and the new probe has all of its addresses.Probing. These are the services waiting on the probe, and for a hostname every service on the host. They wait on the new probes, and are announced under the new names when those finish. Before, they stayedAnnounced: they kept answering with records that were no longer valid or not probed yet, andprobing_handlerskipped them as already announced, so they were never announced under the new names.add_answer_of_serviceused the original hostname for the SRV target and its additional address records, while announcements and PTR answers used the renamed one.Tests
test_answer_hostname_question_skips_probing_addresses,test_is_own_address,test_add_answer_of_service_skips_probing_records,test_ptr_answer_skips_probing_recordsandtest_srv_answer_uses_renamed_hostname.test_own_answer_is_not_a_hostname_conflict: replays the issue on loopback. A peer causes a rename, which moves the service back toProbing. Our own answer with an address the new probe lacks doesn't cause another rename, and a real peer still does.test_hostname_conflict_reannounces_services: two services on one host. The probe of a new address hits a conflict, both services go back toProbing, and they are announced again with the new hostname in their SRV records.tests/mdns_test.rspass.Not changed
hostname_change()still reads a trailing-<digits>as a counter, sodevice-012345becomesdevice-12346, as the issue notes.