announce: rename the host on a probe conflict instead of giving up - #33
Open
LorbusChris wants to merge 1 commit into
Open
announce: rename the host on a probe conflict instead of giving up#33LorbusChris wants to merge 1 commit into
LorbusChris wants to merge 1 commit into
Conversation
When probing finds another responder already using our host name, umdns
prints a message on stderr and returns from the announce state machine
without ever reaching STATE_ANNOUNCE. It then never announces its host
records or its services, never retries, and stays that way until it is
restarted. The init script does not capture stderr, so nothing reaches
the log either: the daemon is running, the services are still listed by
`ubus call umdns announcements`, port 5353 is still bound, and there is
simply nothing on the wire.
RFC 6762 section 9 asks a responder to pick a new name and probe again.
Do that: append a -N suffix to the host name and restart probing, up to
HOSTNAME_MAX_SUFFIX attempts, keeping the old behaviour of giving up
once those are exhausted. The suffix is derived from the unsuffixed
system host name, so repeated conflicts produce host-2, host-3 and not
host-2-2. Services that did not carry an explicit hostname or instance
follow the rename automatically, as they point at the globals.
Since the host name is global while the announce state machine is per
interface, all interfaces probe again for the new name rather than
announce the old one.
get_hostname() is called again on every service reload, so it now only
resets the suffix when the system host name itself changed, letting a
name picked to resolve a conflict survive an unrelated reload.
Tested against avahi-daemon holding testrouter.local: umdns logs
the host testrouter.local already exists, renaming to testrouter-2.local
and goes on to announce testrouter-2.local, where before it announced
nothing.
Note this only changes what happens once a conflict is detected. The
detection itself is unchanged and remains cache based, so a responder
that answers the probe but never announces unsolicited can still be
missed.
Assisted-By: Claude Opus 4.8
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.
When probing finds another responder already using our host name, umdns prints a
message on stderr and returns from the announce state machine without ever
reaching
STATE_ANNOUNCE. It then never announces its host records or itsservices, never retries, and stays that way until restarted.
The init script does not capture stderr, so nothing reaches the log either: the
daemon is running, the services are still listed by
ubus call umdns announcements, port 5353 is still bound, and there is simply nothing on the wire.RFC 6762 section 9 asks a responder to pick a new name and probe again. Do that:
append a
-Nsuffix and restart probing, up toHOSTNAME_MAX_SUFFIXattempts,keeping the old behaviour of giving up once those are exhausted. The suffix is
derived from the unsuffixed system host name, so repeated conflicts give
host-2,host-3and nothost-2-2. Services that carry no explicithostnameorinstancefollow the rename automatically, as they point at the globals.Since the host name is global while the announce state machine is per interface,
all interfaces probe again for the new name rather than announce the old one.
get_hostname()is called again on every service reload, so it now only resetsthe suffix when the system host name itself changed, letting a name picked to
resolve a conflict survive an unrelated reload.
Tested against
avahi-daemonholdingtestrouter.local:and umdns goes on to announce
testrouter-2.local, where before it announcednothing. Builds clean under the project's
-Werror.Note this only changes what happens once a conflict is detected. Detection
itself is unchanged and remains cache based, so a responder that answers the probe
but never announces unsolicited can still be missed.