-
Notifications
You must be signed in to change notification settings - Fork 229
Using IPVersion.All leads to OSError: [Errno 101] Network is unreachable logged #1357
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
Comments
The problem here really is the missing multicast support flag on the loopback interface
E.g. a Ethernet interface has the flag:
On IPv4 it is probably not a problem since the socket option I found that e.g. the Matter SDK's minimal mDNS implementation simply skips loopback (see https://github.com/project-chip/connectedhomeip/blob/v1.2.0.1/src/lib/dnssd/minimal_mdns/AddressPolicy_DefaultImpl.cpp#L41-L53). However, it seems we can learn that from the interface flags instead. But it would require a change in the ifaddr library. |
Looks like macos has MULTICAST on lo0
|
linux 4.4.x
|
|
In HA we already explicitly exclude loopback
|
There is even a docstring that loopback doesn't work. Someone might need it though so I think we can change |
There is a iflags, I think it would be the better indication. Other interfaces might have that restriction too. E.g. a manually created dummy device:
|
This would allow to filter the interfaces smarter on our end: ifaddr/ifaddr#59 |
That would be better but realistically we don't have that information unless your PR gets merged |
It seems that this is more related to the routing table, e.g. adding a route like this makes the error go away:
There is also an explicit flag which allows to turn on/off multicast on the loopback interface (by default it is off):
With ifaddr/ifaddr#59 ifaddr will return the current state of that flag per interface. However, in my testing using Arch Linux with Linux 6.14.2, even with multicast set to on, multicast is not working on the loopback interface (I don't see multicast packets from the same or other processes). It does work with a dummy interface though. |
When using
AsyncZeroconf(ip_version=IPVersion.All)
this can lead to the following warning being logged:It seems that listening to the IPv6 loopback on it's own isn't problematic, but when trying to send to that socket, it leads to the above error. The problematic socket is created via
get_all_addresses_v6()
, which returns the loopback interface with the::1
address (the full tuple being(('::1', 0, 0), 1)
).This then leads to a socket with the follow options created:
When this socket then is used, the stack trace appears:
The relevant option seem to be the IPv6 specific binding to the interface index
IPV6_MULTICAST_IF
, in this case 1 for the loopback interface.The text was updated successfully, but these errors were encountered: