Skip to content

fix: don't leave the IPv4 mDNS group by a vanished address - #543

Merged
keepsimple1 merged 3 commits into
keepsimple1:mainfrom
WillBux:fix/macos-leave-vanished-addr
Nov 22, 2026
Merged

keepsimple1 merged 3 commits into
keepsimple1:mainfrom
WillBux:fix/macos-leave-vanished-addr

Conversation

@WillBux

@WillBux WillBux commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Problem:

The daemon leaves the IPv4 mDNS group by interface address. By the time the IP check notices an interface is gone its address is often already gone from the host. macOS then drops the socket's first membership of the group instead of the intended one, so another interface silently stops receiving mDNS multicast. Other systems just fail the call.

Fix:

leave_multicast_v4() leaves the group only if the host still has the
address, and both leave paths (check_ip_changes() and
del_interface_addr()) go through it. Skipping the leave loses nothing: a
removed interface takes its membership with it, and one that only changed
its address keeps it, which the next join treats as already held.

Covered by test_leaving_a_vanished_address_keeps_other_memberships, which fails on macOS without the fix.

On macOS, leaving the group by an address the host no longer has drops
the socket's first membership instead, cutting off another interface.
Skip the leave then; the membership is gone or still valid anyway.
@keepsimple1

Copy link
Copy Markdown
Owner

Thanks for your PR! Will review it tomorrow.

Comment thread src/service_daemon.rs Resolved
Comment thread src/service_daemon.rs Resolved
Comment thread src/service_daemon.rs Resolved
Linux matches a leave by the address the membership was joined with, even
once that address is gone, and needs it: it keeps the memberships of removed
interfaces, and they count toward igmp_max_memberships. So the skip now
applies only on Apple platforms, and the leave goes ahead elsewhere.

Also skip the leave on every platform when the address is now on another
interface, as the kernel would drop that interface's membership instead.

The check uses the callers' snapshot of the host's addresses instead of
calling get_if_addrs() on every leave.
…hed-addr

Pass the address snapshot to the new del_interface_addr() call in
test_running_state_reports_join_per_ip_version, added on main by keepsimple1#524.
@keepsimple1
keepsimple1 merged commit 8af4679 into keepsimple1:main Nov 22, 2026
6 checks passed
@keepsimple1

Copy link
Copy Markdown
Owner

I've made minor edits and merged the PR. Thanks again for your initial PR!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants