From 1fbf43bbd92a7ac7c07de6253f7a2efcc9a93c47 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 28 Jun 2010 22:02:20 +0200 Subject: [PATCH] iface: check for IFA_F_DEPRECATED http://avahi.org/ticket/211 --- avahi-core/iface-linux.c | 1 + avahi-core/iface.c | 26 ++++++++++++-------------- avahi-core/iface.h | 1 + 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/avahi-core/iface-linux.c b/avahi-core/iface-linux.c index 2782697..a1b7f73 100644 --- a/avahi-core/iface-linux.c +++ b/avahi-core/iface-linux.c @@ -238,6 +238,7 @@ static void netlink_callback(AvahiNetlink *nl, struct nlmsghdr *n, void* userdat /* Update the scope field for the address */ addr->global_scope = ifaddrmsg->ifa_scope == RT_SCOPE_UNIVERSE || ifaddrmsg->ifa_scope == RT_SCOPE_SITE; + addr->deprecated = !!(ifaddrmsg->ifa_flags & IFA_F_DEPRECATED); } else { AvahiInterfaceAddress *addr; assert(n->nlmsg_type == RTM_DELADDR); diff --git a/avahi-core/iface.c b/avahi-core/iface.c index 0736df4..095580c 100644 --- a/avahi-core/iface.c +++ b/avahi-core/iface.c @@ -91,7 +91,7 @@ void avahi_interface_address_update_rrs(AvahiInterfaceAddress *a, int remove_rrs avahi_address_snprint(t, sizeof(t), &a->address); if (avahi_s_entry_group_get_state(a->entry_group) == AVAHI_ENTRY_GROUP_REGISTERING && - m->server->state == AVAHI_SERVER_REGISTERING) + m->server->state == AVAHI_SERVER_REGISTERING) avahi_server_decrease_host_rr_pending(m->server); avahi_log_info("Withdrawing address record for %s on %s.", t, a->interface->hardware->name); @@ -413,6 +413,7 @@ AvahiInterfaceAddress *avahi_interface_address_new(AvahiInterfaceMonitor *m, Ava a->address = *addr; a->prefix_len = prefix_len; a->global_scope = 0; + a->deprecated = 0; a->entry_group = NULL; AVAHI_LLIST_PREPEND(AvahiInterfaceAddress, address, i->addresses, a); @@ -670,24 +671,21 @@ int avahi_interface_address_is_relevant(AvahiInterfaceAddress *a) { AvahiInterfaceAddress *b; assert(a); - /* Publish public IP addresses */ - if (a->global_scope) + /* Publish public and non-deprecated IP addresses */ + if (a->global_scope && !a->deprecated) return 1; - else { - - /* Publish link local IP addresses if they are the only ones on the link */ - for (b = a->interface->addresses; b; b = b->address_next) { - if (b == a) - continue; - if (b->global_scope) - return 0; - } + /* Publish link-local and deprecated IP addresses only if they are + * the only ones on the link */ + for (b = a->interface->addresses; b; b = b->address_next) { + if (b == a) + continue; - return 1; + if (b->global_scope && !b->deprecated) + return 0; } - return 0; + return 1; } int avahi_interface_match(AvahiInterface *i, AvahiIfIndex idx, AvahiProtocol protocol) { diff --git a/avahi-core/iface.h b/avahi-core/iface.h index 466c16a..b38578c 100644 --- a/avahi-core/iface.h +++ b/avahi-core/iface.h @@ -123,6 +123,7 @@ struct AvahiInterfaceAddress { unsigned prefix_len; int global_scope; + int deprecated; AvahiSEntryGroup *entry_group; }; -- 2.39.5