Skip to content
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

Send multicast packets on all multicast-capable interfaces #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cgutman
Copy link
Contributor

@cgutman cgutman commented Aug 1, 2019

On multi-homed hosts, the interface that will be used for outgoing multicast traffic is implementation-defined. As a result, the mDNS queries don't always go out on the interfaces where the discoverable hosts are.

We want to ensure that Server::sendMessageToAll() sends queries to all multicast-capable interfaces, so we should use QUdpSocket::setMulticastInterface() to do that.

@cgutman cgutman mentioned this pull request Mar 3, 2020
@yuriy-mochurad
Copy link

It would be great to have this feature in anytime soon

@beeka
Copy link

beeka commented Sep 24, 2020

I've just tried this but it isn't quite enough as Server::sendMessage() can be called to send to a multicast address (e.g. in HostnamePrivate::onMessageReceived()). My hack was to call sendMessageToAll() if message.address().isMulticast()... this was introduced in Qt 5.6 but is generic and less error-prone than checking for the MdnsIpv?Address matches. It is possible that the real bug is with Hostname calling sendMessage() rather than sendMessageToAll.

The other related change I made was to replicate the protocol check that sendMessage() does, so that the ipv4Socket is only used to send to IpV4 addresses.

If I was braver / it was my baby, I would consider having just the sendMessage() function and have it cope with multicast addresses on multi-homed systems and noting the protocol version.

NB: I had this issue due to using Hyper-V on Windows, which creates a virtual network interface that becomes an unintended sink for multicast messages that are not properly directed. I can tidy and share my code if @nitroshare says this is wanted and would merge it (this pull request was raised over a year ago, which indicates there is no interest in this issue).

@mckaymatthew
Copy link

Hey I'd just like to say that this does interest me and this PR fixed my issues. It was also attributable to Hyper-V on Windows causing default routing of multicast packets getting lost on other interfaces.

@asashnov
Copy link

asashnov commented Mar 23, 2022

Another common configuration where this fix helps:

Standard home router, laptop connected by ethernet. And a device with mDNS service which have mDNS service inside it, working as Wi-Fi client or Wi-Fi Access point.

When the device is Wi-Fi client, qmdnsengine works. When the device in AP mode, qmdgsengine can't see it because sending mDNS packets only to ethernet.

@mckaymatthew
Copy link

mckaymatthew commented Feb 7, 2023

@cgutman

I found another instance where this is occurring, the library isn't tracking which interface a service query came in on, and is sending to a interface, which is not the correct one. I just updated the call to be sendMessageToAll, which isn't very conservative, but works.
I don't want to duplicate your PR without talking to you, do you want to pull my change into your PR? mckaymatthew@f7a1e88

monsieurgustav pushed a commit to monsieurgustav/qmdnsengine that referenced this pull request Oct 8, 2024
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.

5 participants