Discussion:
[avahi] getaddrinfo (Avahi) returning unreachable IP address for .local hostname
Jared Albers
2015-12-31 18:29:25 UTC
Permalink
Hi Guys,

I'm using 'getaddrinfo' to resolve .local hostnames in an application.
However I've encountered a scenario in which the address being returned for
a device is a self-assigned IPv4 address (169.254.X.X) that can't be
reached on any interface by the host machine. I'm assuming this because the
host machine has received an IPv4 address via the DHCP server and therefore
there is no reason to also have a self-assigned address?

It is my understanding that 'getaddrinfo' will ultimately use Avahi to
resolve .local hostnames as defined in the 'hosts:' line of the
'nsswitch.conf' file. It is also my understanding according to this old
thread (http://lists.freedesktop.org/archives/avahi/2009-May/001644.html),
that by design Avahi returns only one IP address when resolving.

As such, I'd like to better understand why 'getaddrinfo' is returning an
unreachable address for a host. Is this a bug in Avahi?

The device in question has three addresses (1 self-assigned IPv4, 1
DHCP-assigned IPv4, and 1 IPv6). If by design Avahi will only return a
single address to 'getaddrinfo', why isn't it returning a reachable address?

If I force binding a self-assigned address via 'avahi-autoipd --force-bind
eth0', then I'm able to communicate with the device. Alternatively, if I
force communication over IPv6, I'm also able to communicate with the device.

However, both of the above mentioned techniques aren't really suitable
solutions. It seems inappropriate and potentially problematic for an
application to bind a self-assigned IP address to an interface, and relying
solely on IPv6 to communicate won't work if the user has disabled IPv6
addressing (perhaps for compatibility reasons).

How do I go about fixing this issue?

-Jared
Martin Nyolt
2016-01-01 22:29:52 UTC
Permalink
Hi Jared.

(First, please note that I'm also quite new to avahi and this mailing list. I might not have all necessary information.)

As far as I understand from that old thread, avahi publishes only one address per interface - i.e. the machine decides which of its addresses it will publish.
If the machine has two addresses in two networks (say 169.254.0.0/16 and 192.16.0.0/24), it wouldn't know which to prefer:
* there may be machines which are *only* in the 169.254.0.0/16 net (because no DHCP was available) and
*there may also be machines which are *only* in the 192.16.0.0/24 net (because DHCP was available when setting up the interface).
For this reason, mixing self-configured IPv4 169.254.0.0/16 addresses with addresses in other networks is not recommended [1]. Therefore, you should probably fix the multiple addresses.

Yet, in contrast to that old post from 2009, RFC 6762 says that a response MUST include all addresses for the interface [2]. Section 6.4 also recommends response aggregation, which aleviates the problem of waiting for multiple responses to "guarantee" an exhaustive answer.
So maybe avahi needs some re-design with regard to that RFC?

Of course, it might be possible to determine which address to return based on the source address of the querying machine. But this is not how avahi publishing and mDNS works, I think.


Best regards,
Martin


[1]: RFC 3972, Section 1.9: https://tools.ietf.org/html/rfc3927#section-1.9
[2]: RFC 6762, Section 6.2: https://tools.ietf.org/html/rfc6762#section-6.2
Post by Jared Albers
Hi Guys,
I'm using 'getaddrinfo' to resolve .local hostnames in an application.
However I've encountered a scenario in which the address being returned for
a device is a self-assigned IPv4 address (169.254.X.X) that can't be
reached on any interface by the host machine. I'm assuming this because the
host machine has received an IPv4 address via the DHCP server and therefore
there is no reason to also have a self-assigned address?
It is my understanding that 'getaddrinfo' will ultimately use Avahi to
resolve .local hostnames as defined in the 'hosts:' line of the
'nsswitch.conf' file. It is also my understanding according to this old
thread (http://lists.freedesktop.org/archives/avahi/2009-May/001644.html),
that by design Avahi returns only one IP address when resolving.
As such, I'd like to better understand why 'getaddrinfo' is returning an
unreachable address for a host. Is this a bug in Avahi?
The device in question has three addresses (1 self-assigned IPv4, 1
DHCP-assigned IPv4, and 1 IPv6). If by design Avahi will only return a
single address to 'getaddrinfo', why isn't it returning a reachable address?
If I force binding a self-assigned address via 'avahi-autoipd --force-bind
eth0', then I'm able to communicate with the device. Alternatively, if I
force communication over IPv6, I'm also able to communicate with the device.
However, both of the above mentioned techniques aren't really suitable
solutions. It seems inappropriate and potentially problematic for an
application to bind a self-assigned IP address to an interface, and relying
solely on IPv6 to communicate won't work if the user has disabled IPv6
addressing (perhaps for compatibility reasons).
How do I go about fixing this issue?
-Jared
_______________________________________________
avahi mailing list
http://lists.freedesktop.org/mailman/listinfo/avahi
Jared Albers
2016-01-02 22:50:00 UTC
Permalink
Hi Martin,

Unfortunately the device in question is a 3rd-party embedded device, more
specifically the Apple AirPort Express. I have no control over its
self-assigned addresses.

I see that several years ago someone posted a similar issue as described in
this thread:
http://lists.freedesktop.org/archives/avahi/2012-September/002183.html

He then provided a patch in this thread:
http://lists.freedesktop.org/archives/avahi/2012-September/002187.html

I do not see if/when the patch was acknowledged and committed. I've also
downloaded the latest 0.6.31 source tarball and I do not see any reference
to the proposed changes.

Why was this patch never acknowledged or pulled?

-Jared
Date: Fri, 1 Jan 2016 23:29:52 +0100
Subject: Re: [avahi] getaddrinfo (Avahi) returning unreachable IP
address for .local hostname
Content-Type: text/plain; charset=utf-8; format=flowed
Hi Jared.
(First, please note that I'm also quite new to avahi and this mailing
list. I might not have all necessary information.)
As far as I understand from that old thread, avahi publishes only one
address per interface - i.e. the machine decides which of its addresses it
will publish.
If the machine has two addresses in two networks (say 169.254.0.0/16 and
* there may be machines which are *only* in the 169.254.0.0/16 net
(because no DHCP was available) and
*there may also be machines which are *only* in the 192.16.0.0/24 net
(because DHCP was available when setting up the interface).
For this reason, mixing self-configured IPv4 169.254.0.0/16 addresses
with addresses in other networks is not recommended [1]. Therefore, you
should probably fix the multiple addresses.
Yet, in contrast to that old post from 2009, RFC 6762 says that a response
MUST include all addresses for the interface [2]. Section 6.4 also
recommends response aggregation, which aleviates the problem of waiting for
multiple responses to "guarantee" an exhaustive answer.
So maybe avahi needs some re-design with regard to that RFC?
Of course, it might be possible to determine which address to return based
on the source address of the querying machine. But this is not how avahi
publishing and mDNS works, I think.
Best regards,
Martin
https://tools.ietf.org/html/rfc3927#section-1.9
https://tools.ietf.org/html/rfc6762#section-6.2
Post by Jared Albers
Hi Guys,
I'm using 'getaddrinfo' to resolve .local hostnames in an application.
However I've encountered a scenario in which the address being returned
for
Post by Jared Albers
a device is a self-assigned IPv4 address (169.254.X.X) that can't be
reached on any interface by the host machine. I'm assuming this because
the
Post by Jared Albers
host machine has received an IPv4 address via the DHCP server and
therefore
Post by Jared Albers
there is no reason to also have a self-assigned address?
It is my understanding that 'getaddrinfo' will ultimately use Avahi to
resolve .local hostnames as defined in the 'hosts:' line of the
'nsswitch.conf' file. It is also my understanding according to this old
thread (http://lists.freedesktop.org/archives/avahi/2009-May/001644.html
),
Post by Jared Albers
that by design Avahi returns only one IP address when resolving.
As such, I'd like to better understand why 'getaddrinfo' is returning an
unreachable address for a host. Is this a bug in Avahi?
The device in question has three addresses (1 self-assigned IPv4, 1
DHCP-assigned IPv4, and 1 IPv6). If by design Avahi will only return a
single address to 'getaddrinfo', why isn't it returning a reachable
address?
Post by Jared Albers
If I force binding a self-assigned address via 'avahi-autoipd
--force-bind
Post by Jared Albers
eth0', then I'm able to communicate with the device. Alternatively, if I
force communication over IPv6, I'm also able to communicate with the
device.
Post by Jared Albers
However, both of the above mentioned techniques aren't really suitable
solutions. It seems inappropriate and potentially problematic for an
application to bind a self-assigned IP address to an interface, and
relying
Post by Jared Albers
solely on IPv6 to communicate won't work if the user has disabled IPv6
addressing (perhaps for compatibility reasons).
How do I go about fixing this issue?
-Jared
Loading...