Repository navigation
fix: do not record an interface address whose multicast join failed - #523
Merged
Merged
Conversation
Addresses items 2 and 3 of #514: - `Zeroconf::new` logged a failed join as "Skipped" but still recorded the address, so the IP check never retried the join. - `add_interface` recorded a new address on a known interface, and emitted `IpAdd`, even if its join failed. Both now go through `add_intf_addr`, which joins only when the interface holds no membership for that IP version yet. Membership is per interface and per IP version, so another address of the same version reuses it instead of joining again, which would fail with `AddrInUse` (`WSAEINVAL` on Windows), e.g. the link-local and global IPv6 addresses of one interface. A genuine join failure records nothing, and the next IP check retries it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 17, 2026
keepsimple1
added a commit
that referenced
this pull request
Nov 14, 2026
Problem: The multicast sockets are set up only once, when the daemon starts, and failures were only logged at debug!. A daemon that couldn't bind sockets (neither IPv4 or IPv6) still started, register() returned Ok, and status() said Running. Such failures can't be reported as a DaemonEvent either, since no monitor exists that early. Failed multicast joins on an interface were likewise only logged. Changes: - new() fails when nothing can work. ServiceDaemon::new() / new_with_port() now create both sockets and register them with the poller before spawning the daemon thread. They return an error if neither the IPv4 nor the IPv6 socket can be bound, or if registering with the poller fails (previously the daemon thread just exited with a debug log). If only one socket fails (e.g. a host without IPv6), the daemon still runs. - DaemonStatus::Running(RunningState). RunningState is a snapshot of the daemon's local setup, as of when it handled the status() request. It does not say whether packets get delivered or whether services can be found. ipv4_socket() / ipv6_socket() return a SocketState, with: is_bound(): whether that multicast socket was bound; bind_error(): why it failed, if it did, so callers can tell "no IPv6 here" from "port in use". enabled_intfs() returns the enabled interfaces the daemon uses, ordered by index, as EnabledIntf: name(), index(), and ipv4() / ipv6(), each an Option<Membership> (None if the daemon has no address of that version there). Membership has: addrs(): the addresses of that version on the interface; is_joined() / join_error(): whether the multicast join worked, or the error from the last failed attempt, which is retried at the next IP check. All four public types are #[non_exhaustive] with private fields, so more state can be added later without breaking anyone. Join failures are tracked. A failed join records nothing in my_intfs (since fix: do not record an interface address whose multicast join failed #523), so failures are kept in a separate map. An entry is cleared when a later join on that interface and IP version succeeds, when the address is disabled or invalid, or when the IP check no longer finds it. The status is now built on request, so the stored status field is gone. Docs. new() / new_with_port() said an unusable port is reported through monitor(), which was never the case. They now describe the new behavior, and status() says its result is a snapshot. Breaking change DaemonStatus::Running is now DaemonStatus::Running(RunningState). Code matching or comparing it needs DaemonStatus::Running(_). That's a compile error rather than a silent behavior change, but it needs a minor version bump (0.22). Part of #514. Also address issue #544.
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.
Addresses the next items in #514:
In both cases the address was treated as live even though the socket could not receive mDNS on it. And because it was recorded, the periodic IP check never retried the join.
Change
Zeroconf::newandadd_interfacenow share one helper,add_intf_addr:AddrInUse(WSAEINVALon Windows). This mirrors the leave side, which leaves only when the last address of a version is gone.IpAdd. The next IP check sees the address as new and retries the join.AddrInUsehandling from fix: record an interface whose multicast join failed, ending an endless retry #513, for different interfaces sharing one address, is unchanged.Tests
test_second_address_reuses_interface_membership: a second IPv4 and IPv6 address on an interface that already holds both memberships is recorded without a join.test_failed_join_does_not_record_address: a failed join on a new interface, or on a known interface without that version's membership, records nothing and emits noIpAdd.🤖 Generated with Claude Code