]> git.meshlink.io Git - catta/commitdiff
iface: check for IFA_F_DEPRECATED
authorLennart Poettering <lennart@poettering.net>
Mon, 28 Jun 2010 20:02:20 +0000 (22:02 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 28 Jun 2010 20:02:27 +0000 (22:02 +0200)
http://avahi.org/ticket/211

avahi-core/iface-linux.c
avahi-core/iface.c
avahi-core/iface.h

index 2782697a368f73a48df940945e8163172345a183..a1b7f73ec48db314de2c718e5cc4ba58cab381fd 100644 (file)
@@ -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);
index 0736df4753e343aeb9bd52207e3eaafa73202816..095580cfa9a59e990c92f381e0e7b2dfc4f2a3b5 100644 (file)
@@ -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) {
index 466c16a447ad9bfa50a1f84249ac7f23cffe5071..b38578c5761e2c45482530f8075472d92381e4c2 100644 (file)
@@ -123,6 +123,7 @@ struct AvahiInterfaceAddress {
     unsigned prefix_len;
 
     int global_scope;
+    int deprecated;
 
     AvahiSEntryGroup *entry_group;
 };