diff options
authorMatt Ginzton <>2011-03-08 23:55:56 +0100
committerLennart Poettering <>2011-03-08 23:55:56 +0100
commit28948f72a2689afe0ba8a31fd396a0c7faf7c213 (patch)
parentb0f64b072a583f20efa97955f8900ec6d971210d (diff)
core: avahi on Linux uses incorrect address for P-t-P interface
Hi, I sent a less knowledgeable question about avahi-daemon and point-to-point links a few days ago, 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: 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
1 files changed, 1 insertions, 1 deletions
diff --git a/avahi-core/iface-linux.c b/avahi-core/iface-linux.c
index 4d12f73..c1843dd 100644
--- a/avahi-core/iface-linux.c
+++ b/avahi-core/iface-linux.c
@@ -203,7 +203,7 @@ static void netlink_callback(AvahiNetlink *nl, struct nlmsghdr *n, void* userdat
while (RTA_OK(a, l)) {
switch(a->rta_type) {
+ case IFA_LOCAL:
/* Fill in address data */
if ((raddr.proto == AVAHI_PROTO_INET6 && RTA_PAYLOAD(a) != 16) ||