Skip to content

Socket setup failures can leave Running / false IpAdd; request daemon-owned publication readiness #514

Closed

Description

@SoulessRaven

In mdns-sd 0.21.4 on Linux, ServiceDaemon::new starts socket construction asynchronously.
Zeroconf::new can fail both wildcard UDP5353 binds with EADDRINUSE, retain neither
publication socket, and still initialize DaemonStatus::Running. register() Ok and a
later status() reply therefore do not establish local publication prerequisites.
Initial bind failures are debug messages before a monitor can be installed; monitor
queues can also drop events. We do not require remote packet delivery confirmation.
A bounded reproduction uses a disposable network namespace, one up private IPv4
interface and exclusive UDP5353 occupants (no SO_REUSEADDR/SO_REUSEPORT). Leave the
interface intact, construct ServiceDaemon, register a service, then query status.
Actual binds fail while status remains Running. Separating families with the namespace's
bindv6only setting demonstrates IPv4-only and IPv6-only failures independently.
Related source findings:

  • IPv4 set_multicast_ttl_v4(255) errors are discarded before retaining the socket.
  • Constructor join failures are logged as skipped but still insert the address.
  • An occupied add_interface entry inserts a new address and emits IpAdd after a failed join.
  • The vacant branch already returns without insertion on join failure.
    A consumer needs a bounded daemon-thread operation, ordered after registration, which
    checks actual socket/clone/poller prerequisites, successful membership bookkeeping,
    the registered service and its interface restrictions, and current selected interface
    identity. A capacity-one nonblocking reply avoids dependence on monitor delivery.
    Its result should explicitly mean point-in-time LOCAL prerequisites, not completed
    probing, remote receipt or continuing multicast health.
    For a single-address IPv4 consumer, we have tested a small carry patch that rejects
    TTL/join failures, verifies the exact registered service/name/index/address, rejects
    ambiguous address ownership across all OS interfaces (including down/loopback), and
    sets the source on the actual daemon socket. It requires IPv4; IPv6 failure may be
    optional for that consumer. This is application policy, not a proposal to impose IPv4
    requirements on all mdns-sd users.
    Important upstream distinction: Linux multicast membership is per interface. A second
    address on an already joined interface may return EADDRINUSE despite valid membership.
    Our single-address consumer deliberately fails closed on this condition. A general
    upstream solution should track successful membership per ifindex/family and distinguish
    already-held membership from a genuine failure; blindly copying that conservative
    occupied-branch return would regress multi-address use cases.
    No continuous polling, preflight port-free probe, custom DNS or packet-delivery heuristic
    is necessary. Are you open to a truthful daemon-owned prerequisite API and the setup/
    bookkeeping fixes, with proper upstream per-interface membership semantics?

Activity

  1. keepsimple1 commented on Oct 1, 2026

    @keepsimple1
    Owner

    Thank you for opening this issue. There are multiple sub-issues here, I will address them in a number of PRs. The first one is in #515 .

  2. keepsimple1 commented on Oct 17, 2026

    @keepsimple1
    Owner

    The 2nd and 3rd, 4th items are fixed by #523.

  3. keepsimple1 commented on Oct 17, 2026

    @keepsimple1
    Owner

    Are you open to a truthful daemon-owned prerequisite API

    @SoulessRaven for the rest of this issue, I've opened a PR #524 with the following solution:

    1. ServiceDaemon::new() will return Err if both IPv4 and IPv6 failed to bind.
    2. Via the existing status() API (not a new API) DaemonStatus::Running will include a RunningState that contains detailed states, namely Ipv4State and Ipv6State.

    Will this approach work for you? RunningState can be enhanced to include more info if you need.

  4. keepsimple1 commented on Nov 14, 2026

    @keepsimple1
    Owner

    I've merged PR #524 into main. I believe this solved the last open item of this issue. Please give it a try. If any problems, please open a new issue (or follow up there). Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions