summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-07-30 19:34:50 +0200
committerLennart Poettering <lennart@poettering.net>2014-07-30 19:34:50 +0200
commit57f5ad3149b604d07816da61e6aa7dcf1cc56b64 (patch)
tree5fbc41a68e175c84569203ef64fdcb1b730d6710 /src
parentfcf57f9cf706ff5be2b5e6d41b2ac48e3e98467b (diff)
resolved: properly set TTL in SOA records
Diffstat (limited to 'src')
-rw-r--r--src/resolve/resolved-dns-answer.c6
-rw-r--r--src/resolve/resolved-dns-answer.h2
-rw-r--r--src/resolve/resolved-dns-zone.c4
-rw-r--r--src/resolve/resolved-dns-zone.h3
-rw-r--r--src/resolve/resolved-link.c3
5 files changed, 10 insertions, 8 deletions
diff --git a/src/resolve/resolved-dns-answer.c b/src/resolve/resolved-dns-answer.c
index b6883a3aba..7c4ab18b58 100644
--- a/src/resolve/resolved-dns-answer.c
+++ b/src/resolve/resolved-dns-answer.c
@@ -97,13 +97,15 @@ int dns_answer_add(DnsAnswer *a, DnsResourceRecord *rr) {
return 1;
}
-int dns_answer_add_soa(DnsAnswer *a, const char *name) {
+int dns_answer_add_soa(DnsAnswer *a, const char *name, uint32_t ttl) {
_cleanup_(dns_resource_record_unrefp) DnsResourceRecord *soa = NULL;
soa = dns_resource_record_new_full(DNS_CLASS_IN, DNS_TYPE_SOA, name);
if (!soa)
return -ENOMEM;
+ soa->ttl = ttl;
+
soa->soa.mname = strdup(name);
if (!soa->soa.mname)
return -ENOMEM;
@@ -116,7 +118,7 @@ int dns_answer_add_soa(DnsAnswer *a, const char *name) {
soa->soa.refresh = 1;
soa->soa.retry = 1;
soa->soa.expire = 1;
- soa->soa.minimum = 1;
+ soa->soa.minimum = ttl;
return dns_answer_add(a, soa);
}
diff --git a/src/resolve/resolved-dns-answer.h b/src/resolve/resolved-dns-answer.h
index 917bfced5f..af3e462ed5 100644
--- a/src/resolve/resolved-dns-answer.h
+++ b/src/resolve/resolved-dns-answer.h
@@ -38,7 +38,7 @@ DnsAnswer *dns_answer_ref(DnsAnswer *a);
DnsAnswer *dns_answer_unref(DnsAnswer *a);
int dns_answer_add(DnsAnswer *a, DnsResourceRecord *rr);
-int dns_answer_add_soa(DnsAnswer *a, const char *name);
+int dns_answer_add_soa(DnsAnswer *a, const char *name, uint32_t ttl);
int dns_answer_contains(DnsAnswer *a, DnsResourceKey *key);
int dns_answer_find_soa(DnsAnswer *a, DnsResourceKey *key, DnsResourceRecord **ret);
diff --git a/src/resolve/resolved-dns-zone.c b/src/resolve/resolved-dns-zone.c
index b51f503df8..99ea420ff4 100644
--- a/src/resolve/resolved-dns-zone.c
+++ b/src/resolve/resolved-dns-zone.c
@@ -275,7 +275,7 @@ int dns_zone_lookup(DnsZone *z, DnsQuestion *q, DnsAnswer **ret_answer, DnsAnswe
if (k < 0)
return k;
if (k == 0)
- r = dns_answer_add_soa(soa, DNS_RESOURCE_KEY_NAME(q->keys[i]));
+ r = dns_answer_add_soa(soa, DNS_RESOURCE_KEY_NAME(q->keys[i]), LLMNR_DEFAULT_TTL);
else
r = dns_answer_add(answer, j->rr);
if (r < 0)
@@ -292,7 +292,7 @@ int dns_zone_lookup(DnsZone *z, DnsQuestion *q, DnsAnswer **ret_answer, DnsAnswe
}
} else {
if (hashmap_get(z->by_name, DNS_RESOURCE_KEY_NAME(q->keys[i]))) {
- r = dns_answer_add_soa(soa, DNS_RESOURCE_KEY_NAME(q->keys[i]));
+ r = dns_answer_add_soa(soa, DNS_RESOURCE_KEY_NAME(q->keys[i]), LLMNR_DEFAULT_TTL);
if (r < 0)
return r;
}
diff --git a/src/resolve/resolved-dns-zone.h b/src/resolve/resolved-dns-zone.h
index 5e7a1f72d0..b2af028cfc 100644
--- a/src/resolve/resolved-dns-zone.h
+++ b/src/resolve/resolved-dns-zone.h
@@ -38,3 +38,6 @@ int dns_zone_put(DnsZone *z, DnsResourceRecord *rr);
void dns_zone_remove_rr(DnsZone *z, DnsResourceRecord *rr);
int dns_zone_lookup(DnsZone *z, DnsQuestion *q, DnsAnswer **answer, DnsAnswer **soa);
+
+/* RFC 4795 Section 2.8. suggests a TTL of 30s by default */
+#define LLMNR_DEFAULT_TTL (30)
diff --git a/src/resolve/resolved-link.c b/src/resolve/resolved-link.c
index cd6e4ba8e6..a4c23bab06 100644
--- a/src/resolve/resolved-link.c
+++ b/src/resolve/resolved-link.c
@@ -25,9 +25,6 @@
#include "strv.h"
#include "resolved-link.h"
-/* RFC 4795 Section 2.8. suggests a TTL of 30s by default */
-#define LLMNR_DEFAULT_TTL (30)
-
static void link_address_add_rrs(LinkAddress *a);
int link_new(Manager *m, Link **ret, int ifindex) {