diff options
Diffstat (limited to 'avahi-core')
-rw-r--r-- | avahi-core/avahi-test.c | 1 | ||||
-rw-r--r-- | avahi-core/iface-linux.c | 39 | ||||
-rw-r--r-- | avahi-core/server.c | 8 | ||||
-rw-r--r-- | avahi-core/socket.c | 21 |
4 files changed, 50 insertions, 19 deletions
diff --git a/avahi-core/avahi-test.c b/avahi-core/avahi-test.c index 07d7a8d..8b2376f 100644 --- a/avahi-core/avahi-test.c +++ b/avahi-core/avahi-test.c @@ -381,6 +381,7 @@ int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) { avahi_s_record_browser_free(r); avahi_s_host_name_resolver_free(hnr); avahi_s_address_resolver_free(ar); + avahi_s_domain_browser_free(db); avahi_s_service_type_browser_free(stb); avahi_s_service_browser_free(sb); avahi_s_service_resolver_free(sr); diff --git a/avahi-core/iface-linux.c b/avahi-core/iface-linux.c index a1b7f73..da497bc 100644 --- a/avahi-core/iface-linux.c +++ b/avahi-core/iface-linux.c @@ -53,7 +53,7 @@ static int netlink_list_items(AvahiNetlink *nl, uint16_t type, unsigned *ret_seq n = (struct nlmsghdr*) req; n->nlmsg_len = NLMSG_LENGTH(sizeof(struct rtgenmsg)); n->nlmsg_type = type; - n->nlmsg_flags = NLM_F_ROOT|NLM_F_REQUEST; + n->nlmsg_flags = NLM_F_REQUEST|NLM_F_DUMP; n->nlmsg_pid = 0; gen = NLMSG_DATA(n); @@ -181,8 +181,8 @@ static void netlink_callback(AvahiNetlink *nl, struct nlmsghdr *n, void* userdat AvahiInterface *i; struct rtattr *a = NULL; size_t l; - AvahiAddress raddr; - int raddr_valid = 0; + AvahiAddress raddr, rlocal, *r; + int raddr_valid = 0, rlocal_valid = 0; /* We are only interested in IPv4 and IPv6 */ if (ifaddrmsg->ifa_family != AF_INET && ifaddrmsg->ifa_family != AF_INET6) @@ -195,7 +195,7 @@ static void netlink_callback(AvahiNetlink *nl, struct nlmsghdr *n, void* userdat return; /* Fill in address family for our new address */ - raddr.proto = avahi_af_to_proto(ifaddrmsg->ifa_family); + rlocal.proto = raddr.proto = avahi_af_to_proto(ifaddrmsg->ifa_family); l = NLMSG_PAYLOAD(n, sizeof(struct ifaddrmsg)); a = IFA_RTA(ifaddrmsg); @@ -203,8 +203,25 @@ static void netlink_callback(AvahiNetlink *nl, struct nlmsghdr *n, void* userdat while (RTA_OK(a, l)) { switch(a->rta_type) { + case IFA_ADDRESS: - /* Fill in address data */ + + if ((rlocal.proto == AVAHI_PROTO_INET6 && RTA_PAYLOAD(a) != 16) || + (rlocal.proto == AVAHI_PROTO_INET && RTA_PAYLOAD(a) != 4)) + return; + + memcpy(rlocal.data.data, RTA_DATA(a), RTA_PAYLOAD(a)); + rlocal_valid = 1; + + break; + + case IFA_LOCAL: + + /* Fill in local address data. Usually this is + * preferable over IFA_ADDRESS if both are set, + * since this refers to the local address of a PPP + * link while IFA_ADDRESS refers to the other + * end. */ if ((raddr.proto == AVAHI_PROTO_INET6 && RTA_PAYLOAD(a) != 16) || (raddr.proto == AVAHI_PROTO_INET && RTA_PAYLOAD(a) != 4)) @@ -223,17 +240,21 @@ static void netlink_callback(AvahiNetlink *nl, struct nlmsghdr *n, void* userdat } /* If there was no adress attached to this message, let's quit. */ - if (!raddr_valid) + if (rlocal_valid) + r = &rlocal; + else if (raddr_valid) + r = &raddr; + else return; if (n->nlmsg_type == RTM_NEWADDR) { AvahiInterfaceAddress *addr; /* This address is new or has been modified, so let's get an object for it */ - if (!(addr = avahi_interface_monitor_get_address(m, i, &raddr))) + if (!(addr = avahi_interface_monitor_get_address(m, i, r))) /* Mmm, no object existing yet, so let's create a new one */ - if (!(addr = avahi_interface_address_new(m, i, &raddr, ifaddrmsg->ifa_prefixlen))) + if (!(addr = avahi_interface_address_new(m, i, r, ifaddrmsg->ifa_prefixlen))) return; /* OOM */ /* Update the scope field for the address */ @@ -244,7 +265,7 @@ static void netlink_callback(AvahiNetlink *nl, struct nlmsghdr *n, void* userdat assert(n->nlmsg_type == RTM_DELADDR); /* Try to get a reference to our AvahiInterfaceAddress object for this address */ - if (!(addr = avahi_interface_monitor_get_address(m, i, &raddr))) + if (!(addr = avahi_interface_monitor_get_address(m, i, r))) return; /* And free it */ diff --git a/avahi-core/server.c b/avahi-core/server.c index 2b8f95f..86fd4a5 100644 --- a/avahi-core/server.c +++ b/avahi-core/server.c @@ -513,12 +513,20 @@ static void reflect_response(AvahiServer *s, AvahiInterface *i, AvahiRecord *r, static void* reflect_cache_walk_callback(AvahiCache *c, AvahiKey *pattern, AvahiCacheEntry *e, void* userdata) { AvahiServer *s = userdata; + AvahiRecord* r; assert(c); assert(pattern); assert(e); assert(s); + /* Don't reflect cache entry with ipv6 link-local addresses. */ + r = e->record; + if ((r->key->type == AVAHI_DNS_TYPE_AAAA) && + (r->data.aaaa.address.address[0] == 0xFE) && + (r->data.aaaa.address.address[1] == 0x80)) + return NULL; + avahi_record_list_push(s->record_list, e->record, e->cache_flush, 0, 0); return NULL; } diff --git a/avahi-core/socket.c b/avahi-core/socket.c index be62105..e69ec7d 100644 --- a/avahi-core/socket.c +++ b/avahi-core/socket.c @@ -653,10 +653,6 @@ AvahiDnsPacket *avahi_recv_dns_packet_ipv4( goto fail; } - /* For corrupt packets FIONREAD returns zero size (See rhbz #607297) */ - if (!ms) - goto fail; - p = avahi_dns_packet_new(ms + AVAHI_DNS_PACKET_EXTRA_SIZE); io.iov_base = AVAHI_DNS_PACKET_DATA(p); @@ -683,10 +679,14 @@ AvahiDnsPacket *avahi_recv_dns_packet_ipv4( goto fail; } - if (sa.sin_addr.s_addr == INADDR_ANY) { + /* For corrupt packets FIONREAD returns zero size (See rhbz #607297). So + * fail after having read them. */ + if (!ms) + goto fail; + + if (sa.sin_addr.s_addr == INADDR_ANY) /* Linux 2.4 behaves very strangely sometimes! */ goto fail; - } assert(!(msg.msg_flags & MSG_CTRUNC)); assert(!(msg.msg_flags & MSG_TRUNC)); @@ -810,10 +810,6 @@ AvahiDnsPacket *avahi_recv_dns_packet_ipv6( goto fail; } - /* For corrupt packets FIONREAD returns zero size (See rhbz #607297) */ - if (!ms) - goto fail; - p = avahi_dns_packet_new(ms + AVAHI_DNS_PACKET_EXTRA_SIZE); io.iov_base = AVAHI_DNS_PACKET_DATA(p); @@ -841,6 +837,11 @@ AvahiDnsPacket *avahi_recv_dns_packet_ipv6( goto fail; } + /* For corrupt packets FIONREAD returns zero size (See rhbz #607297). So + * fail after having read them. */ + if (!ms) + goto fail; + assert(!(msg.msg_flags & MSG_CTRUNC)); assert(!(msg.msg_flags & MSG_TRUNC)); |