Commit Diff
Diff:
41606258fa13cc0a5621e2e929631480b84fc787
382c1ee399ef503bcf9e2af747718d39a64b4d88
Commit:
382c1ee399ef503bcf9e2af747718d39a64b4d88
Tree:
1121a4aafee8fba8d58a038e85a9164776968bf8
Author:
pjp <pjp@delphinusdns.org>
Committer:
pjp <pjp@delphinusdns.org>
Date:
Tue Sep 5 18:27:43 2017 UTC
Message:
Copy Recursion Desired bit on authoritative answers like most other authoritative servers do out there. Found by Habbie of PowerDNS. Thanks! Tested on OpenBSD.
blob - 8c9ce6466f8963d15fe3c9d94572830fedc766a1
blob + 88c656bf2235e84ba58c12d48d2faf7e65ad52cb
--- ddd-dns.h
+++ ddd-dns.h
@@ -220,6 +220,7 @@ struct question {
char *converted_name;
u_int16_t edns0len;
u_int8_t ednsversion;
+ int rd;
int dnssecok;
int badvers;
};
blob - 763a7403828f83f6531995a2bb364e8d84f0e7c8
blob + ac7d6f0bef9c2984277722fe16ec6d63c7e98bec
--- delphinusdnsd.c
+++ delphinusdnsd.c
@@ -151,7 +151,7 @@ uint8_t vslen = DD_VERSION_LEN;
#endif
int *ptr = NULL;
-static const char rcsid[] = "$Id: delphinusdnsd.c,v 1.21 2017/09/05 17:56:55 pjp Exp $";
+static const char rcsid[] = "$Id: delphinusdnsd.c,v 1.22 2017/09/05 18:27:43 pjp Exp $";
/*
* MAIN - set up arguments, set up database, set up sockets, call mainloop
@@ -943,6 +943,7 @@ build_question(char *buf, int len, int additional)
struct dns_optrr *opt = NULL;
struct question *q = NULL;
+ struct dns_header *hdr = (struct dns_header *)buf;
/* find the end of name */
for (i = sizeof(struct dns_header); i < len; i++) {
@@ -1135,6 +1136,8 @@ build_question(char *buf, int len, int additional)
memcpy((char *)&q->hdr->qtype, (char *)qtype, sizeof(u_int16_t));
memcpy((char *)&q->hdr->qclass, (char *)qclass, sizeof(u_int16_t));
+ /* make note of whether recursion is desired */
+ q->rd = ((ntohs(hdr->query) & DNS_RECURSE) == DNS_RECURSE);
return (q);
}
blob - 34150ae72bea84e18eed7413a533a8e221e4ccaa
blob + d23ad96019e08968feeeed941f2b60d0140e2db1
--- reply.c
+++ reply.c
@@ -109,7 +109,7 @@ extern uint8_t vslen;
outlen = tmplen; \
} while (0);
-static const char rcsid[] = "$Id: reply.c,v 1.54 2017/06/26 20:28:50 pjp Exp $";
+static const char rcsid[] = "$Id: reply.c,v 1.55 2017/09/05 18:27:43 pjp Exp $";
/*
* REPLY_A() - replies a DNS question (*q) on socket (so)
@@ -178,6 +178,10 @@ reply_a(struct sreply *sreply, ddDB *db)
else
SET_DNS_RECURSION_AVAIL(odh);
+ if (q->rd) {
+ SET_DNS_RECURSION(odh);
+ }
+
HTONS(odh->query);
odh->question = htons(1);
@@ -360,6 +364,10 @@ reply_nsec3param(struct sreply *sreply)
else
SET_DNS_RECURSION_AVAIL(odh);
+ if (q->rd) {
+ SET_DNS_RECURSION(odh);
+ }
+
HTONS(odh->query);
odh->question = htons(1);
@@ -550,6 +558,10 @@ reply_nsec3(struct sreply *sreply, ddDB *db)
else
SET_DNS_RECURSION_AVAIL(odh);
+ if (q->rd) {
+ SET_DNS_RECURSION(odh);
+ }
+
HTONS(odh->query);
odh->question = htons(1);
@@ -740,6 +752,10 @@ reply_nsec(struct sreply *sreply)
else
SET_DNS_RECURSION_AVAIL(odh);
+ if (q->rd) {
+ SET_DNS_RECURSION(odh);
+ }
+
HTONS(odh->query);
odh->question = htons(1);
@@ -920,6 +936,10 @@ reply_ds(struct sreply *sreply)
else
SET_DNS_RECURSION_AVAIL(odh);
+ if (q->rd) {
+ SET_DNS_RECURSION(odh);
+ }
+
HTONS(odh->query);
odh->question = htons(1);
@@ -1101,6 +1121,10 @@ reply_dnskey(struct sreply *sreply)
else
SET_DNS_RECURSION_AVAIL(odh);
+ if (q->rd) {
+ SET_DNS_RECURSION(odh);
+ }
+
HTONS(odh->query);
odh->question = htons(1);
@@ -1279,6 +1303,10 @@ reply_rrsig(struct sreply *sreply, ddDB *db)
else
SET_DNS_RECURSION_AVAIL(odh);
+ if (q->rd) {
+ SET_DNS_RECURSION(odh);
+ }
+
HTONS(odh->query);
odh->question = htons(1);
@@ -1445,6 +1473,10 @@ reply_aaaa(struct sreply *sreply, ddDB *db)
else
SET_DNS_RECURSION_AVAIL(odh);
+ if (q->rd) {
+ SET_DNS_RECURSION(odh);
+ }
+
HTONS(odh->query);
odh->question = htons(1);
@@ -1622,6 +1654,10 @@ reply_mx(struct sreply *sreply, ddDB *db)
} else
SET_DNS_RECURSION_AVAIL(odh);
+ if (q->rd) {
+ SET_DNS_RECURSION(odh);
+ }
+
HTONS(odh->query);
odh->question = htons(1);
@@ -1800,6 +1836,9 @@ reply_ns(struct sreply *sreply, ddDB *db)
} else
SET_DNS_RECURSION_AVAIL(odh);
+ if (q->rd) {
+ SET_DNS_RECURSION(odh);
+ }
HTONS(odh->query);
@@ -2002,6 +2041,10 @@ reply_cname(struct sreply *sreply)
else
SET_DNS_RECURSION_AVAIL(odh);
+ if (q->rd) {
+ SET_DNS_RECURSION(odh);
+ }
+
HTONS(odh->query);
odh->question = htons(1);
@@ -2194,6 +2237,10 @@ reply_ptr(struct sreply *sreply)
else
SET_DNS_RECURSION_AVAIL(odh);
+ if (q->rd) {
+ SET_DNS_RECURSION(odh);
+ }
+
HTONS(odh->query);
odh->question = htons(1);
@@ -2362,6 +2409,10 @@ reply_soa(struct sreply *sreply)
else
SET_DNS_RECURSION_AVAIL(odh);
+ if (q->rd) {
+ SET_DNS_RECURSION(odh);
+ }
+
NTOHS(odh->query);
odh->question = htons(1);
@@ -2603,6 +2654,10 @@ reply_txt(struct sreply *sreply)
else
SET_DNS_RECURSION_AVAIL(odh);
+ if (q->rd) {
+ SET_DNS_RECURSION(odh);
+ }
+
HTONS(odh->query);
odh->question = htons(1);
@@ -2755,6 +2810,10 @@ reply_version(struct sreply *sreply)
else
SET_DNS_RECURSION_AVAIL(odh);
+ if (q->rd) {
+ SET_DNS_RECURSION(odh);
+ }
+
HTONS(odh->query);
odh->question = htons(1);
@@ -2889,6 +2948,10 @@ reply_tlsa(struct sreply *sreply)
} else
SET_DNS_RECURSION_AVAIL(odh);
+ if (q->rd) {
+ SET_DNS_RECURSION(odh);
+ }
+
HTONS(odh->query);
odh->question = htons(1);
@@ -3071,6 +3134,10 @@ reply_sshfp(struct sreply *sreply)
} else
SET_DNS_RECURSION_AVAIL(odh);
+ if (q->rd) {
+ SET_DNS_RECURSION(odh);
+ }
+
HTONS(odh->query);
odh->question = htons(1);
@@ -3254,6 +3321,10 @@ reply_naptr(struct sreply *sreply, ddDB *db)
} else
SET_DNS_RECURSION_AVAIL(odh);
+ if (q->rd) {
+ SET_DNS_RECURSION(odh);
+ }
+
HTONS(odh->query);
odh->question = htons(1);
@@ -3457,6 +3528,10 @@ reply_srv(struct sreply *sreply, ddDB *db)
} else
SET_DNS_RECURSION_AVAIL(odh);
+ if (q->rd) {
+ SET_DNS_RECURSION(odh);
+ }
+
HTONS(odh->query);
odh->question = htons(1);
@@ -3717,7 +3792,9 @@ reply_nxdomain(struct sreply *sreply, ddDB *db)
}
SET_DNS_RCODE_NAMEERR(odh);
-
+ if (q->rd) {
+ SET_DNS_RECURSION(odh);
+ }
HTONS(odh->query);
if (istcp) {
@@ -3763,6 +3840,10 @@ reply_nxdomain(struct sreply *sreply, ddDB *db)
SET_DNS_AUTHORITATIVE(odh);
SET_DNS_RCODE_NAMEERR(odh);
+
+ if (q->rd) {
+ SET_DNS_RECURSION(odh);
+ }
NTOHS(odh->query);
@@ -4242,10 +4323,11 @@ reply_noerror(struct sreply *sreply, ddDB *db)
memset((char *)&odh->query, 0, sizeof(u_int16_t));
SET_DNS_REPLY(odh);
-#if 0
- SET_DNS_RCODE_NAMEERR(odh);
-#endif
+ if (q->rd) {
+ SET_DNS_RECURSION(odh);
+ }
+
HTONS(odh->query);
if (istcp) {
@@ -4290,6 +4372,10 @@ reply_noerror(struct sreply *sreply, ddDB *db)
else
SET_DNS_AUTHORITATIVE(odh);
+ if (q->rd) {
+ SET_DNS_RECURSION(odh);
+ }
+
NTOHS(odh->query);
odh->question = htons(1);
@@ -4602,6 +4688,10 @@ reply_any(struct sreply *sreply)
else
SET_DNS_RECURSION_AVAIL(odh);
+ if (q->rd) {
+ SET_DNS_RECURSION(odh);
+ }
+
NTOHS(odh->query);
odh->question = htons(1);
repomaster@centroid.eu