Bug 507954 - mDNS reply is not bound to the network interface the request came from
Summary: mDNS reply is not bound to the network interface the request came from
Status: REPORTED
Alias: None
Product: kdeconnect
Classification: Applications
Component: common (other bugs)
Version First Reported In: 25.04.3
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: Albert Vaca Cintora
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-08-06 20:53 UTC by valdikss
Modified: 2025-08-06 21:45 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description valdikss 2025-08-06 20:53:57 UTC
SUMMARY

kde connect daemon sends MDNS response using incorrect interface on multi-homed network.

The response packet is not bound to the same interface from where the request came from, which forces the response to the well-known 224.0.0.251 MDNS IP address to go via the routing table and the default route (which may be another interface).


STEPS TO REPRODUCE

1.  Connect to two network interfaces, only one of which has default route (eth0), and another one is its IP range only (LAN-only, eth1)
2.  Connect another device (Android smartphone) to the second (LAN-only) network
3.  Press "refresh" on another device

OBSERVED RESULT

The mDNS request comes from Android device via LAN-only interface (eth1), but the mDNS reply goes via default route (eth0).
The device is not found upon refresh.

EXPECTED RESULT

The device is found upon refresh. mDNS reply goes via the same network interface.

SOFTWARE/OS VERSIONS
Operating System: Fedora Linux 41
KDE Plasma Version: 6.4.3
KDE Frameworks Version: 6.16.0
Qt Version: 6.8.3
Kernel Version: 6.15.8-100.fc41.x86_64 (64-bit)
Graphics Platform: Wayland
Comment 1 valdikss 2025-08-06 21:45:50 UTC
In lanlinkprovider.cpp, there's already code for Windows and FreeBSD which "sends the reply over all available interfaces", I bevieve to fix this error.
But for some reason it is put behind ifdef.

https://invent.kde.org/network/kdeconnect-kde/-/blob/release/25.04/core/backends/lan/lanlinkprovider.cpp?ref_type=heads#L194

The lazy fix is:
* To enable this code for Linux
* To use setsockopt SO_BINDTODEVICE for Linux

The proper fix is to bind to the same interface with SO_BINDTODEVICE (or at least find the interface with the same source IP from which the incoming packet was from) and send it from that interface.