Repository navigation
Description
I stumbled across this issue while troubleshooting an unrelated network issue in an application using this library. I don't know much about mDNS, so if this is deemed to be Claude gibberish, feel free to close it.
The network change that triggered it went from one WLAN to another, which also are in different VLANs (however not firewalled off from each other). The hostname of the device is also in a format device-1234 where the numeric part is a serial number.
Summary
After one hostname rename while services are announced, the daemon answers its own probes for the new hostname. conflict_handler() then sees that answer as a conflict and renames the hostname again. The loop never stops by itself. On our device it ran for more than 8 hours, about 5 renames per second, until we restarted the process.
The loop continues only when the interface has more than one address of the same family, for example a link-local IPv6 address and global IPv6 addresses.
Environment
- mdns-sd 0.21.6.
conflict_handler()is the same in 0.21.7. - Linux arm64 (Debian bookworm), one Wi-Fi interface
wlan0. - Addresses on
wlan0: one IPv4 address, one link-local IPv6 address, two global IPv6 addresses (SLAAC and DHCPv6). - Two services with the same hostname,
<name>._http._tcp.local.and<name>._example._tcp.local..ServiceDaemon::new()with default options (multicast loopback on,requires_probetrue).
What we see
- About 28 mDNS packets per second from the device, all to itself, and
DaemonEvent::Respondabout 8 times per second. - The hostname increments without a stop:
device-12346.local.,device-12347.local.,device-12348.local., … - Both instance names stay at
<name> (2)and get a probe again after each hostname rename (about 4 probes per second for each). - No
DaemonEvent::NameChange, because no probe finishes.
A packet capture on the device (addresses replaced with documentation addresses) shows that the probe and the answer have different address sets:
| Record | In the probe for device-N.local. (authority section) |
In the answer from the same device |
|---|---|---|
A 192.0.2.10 |
no | yes |
AAAA 2001:db8::a:1 (SLAAC) |
yes | yes |
AAAA fe80::a:2 (link-local) |
no | yes |
AAAA 2001:db8::100 (DHCPv6) |
yes | yes |
Every probe and every answer in the capture comes from the device's own address.
How the loop works (from the 0.21.6 source)
- The daemon probes
device-N.local.The probe has only the AAAA records that were moved there by the previous rename: the two global addresses. - Multicast loopback gives the probe back to the daemon.
handle_query()→answer_hostname_question()answers it, because the services areAnnouncedanddns_registry.resolve_name(service.get_hostname())already returnsdevice-N.local..conflict_handler()writes the new name intoname_changesat the time of the rename, before the probe for the new name is finished. The answer has all addresses of the services, including the link-local one. - Loopback gives the answer back to the daemon.
handle_response()→conflict_handler().device-N.local.is inprobing, so the answer is checked. - For the answer AAAA
fe80::…, no record in the probe matches (any_matchis false). Theretainthen marks every probe AAAA record with different rdata as a conflict, which is both global addresses. - The records move to a new probe for
hostname_change("device-N")=device-N+1, and the loop starts again at step 1.
The A record causes no conflict, because the probe has no A record. With only one IPv6 address on the interface, the answer would match the probe and the loop would stop after one rename.
The first rename
We do not know exactly which packet caused the first rename. It happened during a network change. In 15 seconds our code did three restarts of the announcement (unregister() of both services, then register() of both at once), while the interface got its addresses in two steps (IPv4 and link-local first, the global IPv6 addresses 5 seconds later). After the third restart the loop started. Both the hostname and the instance names were renamed, so the first conflict was possibly also an answer from the daemon itself, from the registration that was still in the middle of its unregister. We have no packet capture of that moment.
Possible fixes
- In
conflict_handler(), compare an answer with all of the daemon's own records for that name (all addresses of the services that use the hostname), not only with the records in the probe. An address that belongs to the daemon is not a conflict. We think this is closest to RFC 6762 section 9. - Do not answer for a name while it is in
probing. For example, updatename_changesonly when the probe for the new name finishes. Then step 2 cannot happen. - In the
retainof step 4, mark as a conflict only the probe records that the answer actually contradicts, not every record of the same type.
Workaround
ServiceInfo::set_requires_probe(false) stops the loop for us. Our hostnames are unique by design.
A related note
hostname_change() reads a -<digits> suffix as a counter. Our hostnames end with a serial number (device-012345), so the first rename publishes the device under a different serial (device-12346), without the leading zero. A note in the documentation about this would help other users with such names.
We do not have a minimal reproduction yet. We can test a branch on the device.
Activity
keepsimple1 commentedon Nov 10, 2026
Thanks for opening this. Looks like a valid issue. Will work on a fix and get back to you.
keepsimple1 commentedon Nov 13, 2026
Could you help test the branch
fix/issue-545-hostname-rename-loopfrom PR #548?keepsimple1 commentedon Nov 15, 2026
I've updated the PR and merged it into
main. I believe it fixed the issue. Please test it out with the latestmainif you have chance. If any problems, please open a new issue or follow up at here. Cheers!OlivierLDff commentedon Nov 30, 2026
Thanks I ran in the same issue, this is now fixed!