summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2014-10-21 11:05:26 -0400
committerDan Winship <danw@gnome.org>2014-10-29 09:14:43 -0400
commit3351e3a6aeb1ab1222802b8857c757e590f5a0d7 (patch)
tree2970b73466774161d685a04b69eab26ba2c1b45d
parent66a79413255f5f758921c38f6b9dc18600476db8 (diff)
rdisc: properly handle RDNSS/DNSSL forced expiration
If the router sends an RA with an RDNSS or DNSSL lifetime of "0", that means to immediately stop using the corresponding server/domain name. NMLNDPRDisc knew this, but messed up its handling of it, and so if this happened, it might end up sending out an RS to get new data every 0 seconds... (Noticed while investigating bgo 735325, though it turned out to be irrelevant there.)
-rw-r--r--src/rdisc/nm-lndp-rdisc.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/src/rdisc/nm-lndp-rdisc.c b/src/rdisc/nm-lndp-rdisc.c
index cf0267d1c..83dd58915 100644
--- a/src/rdisc/nm-lndp-rdisc.c
+++ b/src/rdisc/nm-lndp-rdisc.c
@@ -174,8 +174,15 @@ add_dns_server (NMRDisc *rdisc, const NMRDiscDNSServer *new)
NMRDiscDNSServer *item = &g_array_index (rdisc->dns_servers, NMRDiscDNSServer, i);
if (IN6_ARE_ADDR_EQUAL (&item->address, &new->address)) {
- gboolean changed = item->timestamp != new->timestamp ||
- item->lifetime != new->lifetime;
+ gboolean changed;
+
+ if (new->lifetime == 0) {
+ g_array_remove_index (rdisc->dns_servers, i);
+ return TRUE;
+ }
+
+ changed = (item->timestamp != new->timestamp ||
+ item->lifetime != new->lifetime);
if (changed) {
item->timestamp = new->timestamp;
item->lifetime = new->lifetime;
@@ -184,10 +191,6 @@ add_dns_server (NMRDisc *rdisc, const NMRDiscDNSServer *new)
}
}
- /* DNS server should no longer be used */
- if (new->lifetime == 0)
- return FALSE;
-
g_array_insert_val (rdisc->dns_servers, i, *new);
return TRUE;
}
@@ -203,8 +206,15 @@ add_dns_domain (NMRDisc *rdisc, const NMRDiscDNSDomain *new)
item = &g_array_index (rdisc->dns_domains, NMRDiscDNSDomain, i);
if (!g_strcmp0 (item->domain, new->domain)) {
- gboolean changed = item->timestamp != new->timestamp ||
- item->lifetime != new->lifetime;
+ gboolean changed;
+
+ if (new->lifetime == 0) {
+ g_array_remove_index (rdisc->dns_domains, i);
+ return TRUE;
+ }
+
+ changed = (item->timestamp != new->timestamp ||
+ item->lifetime != new->lifetime);
if (changed) {
item->timestamp = new->timestamp;
item->lifetime = new->lifetime;
@@ -213,10 +223,6 @@ add_dns_domain (NMRDisc *rdisc, const NMRDiscDNSDomain *new)
}
}
- /* Domain should no longer be used */
- if (new->lifetime == 0)
- return FALSE;
-
g_array_insert_val (rdisc->dns_domains, i, *new);
item = &g_array_index (rdisc->dns_domains, NMRDiscDNSDomain, i);
item->domain = g_strdup (new->domain);