Skip to content

feat(mdns): only send listening addresses that match interface #6003

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

elenaf9
Copy link
Member

@elenaf9 elenaf9 commented Apr 22, 2025

Description

The current mDNS implementation always sends all current listen addresses in a MdnsResponse, independent of whether they match the interface that we receive a MdnsQuery on.
This is causing multiple issues, e.g.:

And as noted in #5790, it also violates the mDNS specs.

This PR changes libp2p-mdns to only reply to a MdnsQuery with the listen addresses that match the IP of the interface that we received the query on.
Implementation-wise, this is solved by providing each interface-task only with the subset of listening addresses that match the interface IP.

Fixes: #5995
Related: #5790

Notes & open questions

Because each interface-task now has a different list of listening addresses that it will send out, I think it doesn't make sense anymore to have a single shared list of listening addresses. Instead, I've changed the implementation to only provide each interface-task with the listening addresses that match the interface's IP, and use a channel for informing the task about relevant listening address updates.

cc @MathJud @T-X @MatthiasvB

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • A changelog entry has been made in the appropriate crates

Comment on lines 287 to 292
if let Some(tx) = self.if_tasks.get_mut(&ip) {
if tx.unbounded_send(update).is_err() {
tracing::error!("`InterfaceState` for ip {ip} dropped");
self.if_tasks.remove(&ip);
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally this sender should be bounded. I still have to look into how to solve this best, I am currently unsure how to handle the case that a interface-task is busy and the channel full.

elenaf9 added 2 commits April 30, 2025 14:27
Requires us to handle the case that the channel is full. Solved by
adding a `pending_address_update` queue that is processed in
`Behavior::poll`.
@elenaf9 elenaf9 marked this pull request as ready for review April 30, 2025 13:54
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.

Loopback addresses published by mDNS lead to dial failures
1 participant