[avahi] avahi on Linux uses incorrect address for P-t-P interface
Matt Ginzton
magi at cs.stanford.edu
Sun Jan 16 10:51:13 PST 2011
Hi,
I sent a less knowledgeable question about avahi-daemon and point-to-point links a few days ago, http://lists.freedesktop.org/archives/avahi/2011-January/001969.html. When I didn't get a response to this, I decided to build avahi from source and step through it and see how it builds its list of interfaces and their addresses.
This is in iface-linux.c, netlink_callback(). It looks for a RTM_NEWADDR message, then extracts the payload of type IFA_ADDRESS.
Short story: I think it should be using the payload of type IFA_LOCAL, not the payload of type IFA_ADDRESS.
In the VM where I was running these experiments, there are 3 interfaces -- lo, eth0 and tun0. I printed out the IFA_ADDRESS and IFA_LOCAL for all 3 of these; for lo and eth0 these are the same address; for tun0 (IFF_POINTOPOINT), IFA_ADDRESS is the remote end and IFA_LOCAL is the local end.
I'm no expert on Linux rtnetlink or these IFA fields, but quoting /usr/include/linux/if_addr.h:
/*
* Important comment:
* IFA_ADDRESS is prefix address, rather than local interface address.
* It makes no difference for normally configured broadcast interfaces,
* but for point-to-point IFA_ADDRESS is DESTINATION address,
* local address is supplied in IFA_LOCAL attribute.
*/
See also this stackoverflow question/answer: http://stackoverflow.com/questions/4678637/what-is-difference-between-ifa-local-and-ifa-address-in-rtnetlink-linux
Does anyone know why avahi is looking for IFA_ADDRESS here, and whether there's any reason not to use IFA_LOCAL instead?
Assuming there's not a specific reason to use IFA_ADDRESS here, I propose the patch attached at the end of this message, which works for me. (The bug this fixes is described in the earlier message linked above -- avahi chooses the wrong address to associate with the P-t-P interface, and if you enable avahi's reflector, avahi tries to call sendmsg() using that as the source address and the kernel always, correctly, fails the sendmsg() call with EINVAL.)
(And when/why this changed -- I was able to use avahi over P-t-P interfaces on Linux several years ago; I don't know what avahi version I was using at the time.)
thanks,
Matt
--- iface-linux.c.orig 2011-01-16 10:43:19.928941366 -0800
+++ iface-linux.c 2011-01-16 10:44:53.802731728 -0800
@@ -203,7 +203,7 @@
while (RTA_OK(a, l)) {
switch(a->rta_type) {
- case IFA_ADDRESS:
+ case IFA_LOCAL:
/* Fill in address data */
if ((raddr.proto == AVAHI_PROTO_INET6 && RTA_PAYLOAD(a) != 16) ||
More information about the avahi
mailing list