Commit Diff
Diff:
37b39a7388328bfbe0472083a42574c1352d59b1
5841985a5f5c9690fd0445ecbc9fadf3171fba67
Commit:
5841985a5f5c9690fd0445ecbc9fadf3171fba67
Tree:
b9159c2b7b65b723c13354fcd464fadd65ba8a96
Author:
pbug <pbug@delphinusdns.org>
Committer:
pbug <pbug@delphinusdns.org>
Date:
Thu Mar 18 08:55:09 2010 UTC
Message:
* "delegate" records, these are ns records but intended for delegation which reply a NS differently than just a zones NS records. This problem was reported by Evgeniy Bogdanov last October, and I finally got the fix/time now. * Fix a few ntohs() to htons(). The problem wasn't seen on little endian machines but may have caused problems on big endian machines. I don't know. I just noticed this per eyeball, now.
blob - 9490d34431a054fe6d4d10e48faabbc8b9d55d34
blob + 37037f1a5dfa66f49180a6ff2eb05a90aea547bb
--- db.h
+++ db.h
@@ -86,6 +86,7 @@ struct domain {
struct ns ns[10]; /* NS resource records (max 10) */
int ns_count; /* count of NS records, (max 10) */
int ns_ptr; /* pointer to last used NS address */
+ int ns_delegate; /* set if it's a delegation */
char cname[DNS_MAXNAME]; /* CNAME RR */
u_int8_t cnamelen; /* len of CNAME */
char ptr[DNS_MAXNAME]; /* PTR RR */
blob - 6fe82e4e326e321dc33d39b20118bd5211a09c64
blob + 04327d23d4d934fe12821638f795b1634347f35c
--- dns.h
+++ dns.h
@@ -124,7 +124,8 @@ struct dns_question_hdr {
/* DNS types 0xff00 -> 0xfffe (private use) RFC 5395, page 8 */
-#define DNS_TYPE_BALANCE 0xfffe
+#define DNS_TYPE_BALANCE 0xfffe /* split horizon dns */
+#define DNS_TYPE_DELEGATE 0xfffd /* ns delegations */
/* quad A - RFC 3596 */
#define DNS_TYPE_AAAA 28
blob - 75e5dc3bbf513ac6681d2501169a7108402637ff
blob + c3a23df982ded7d4b858c37c1a3c60116c97965b
--- example7.conf
+++ example7.conf
@@ -135,6 +135,9 @@ zone "centroid.eu" {
irc2.centroid.eu,a,3600,200.46.208.61
localhost.centroid.eu,a,3600,127.0.0.1
localhost.centroid.eu,aaaa,3600,::1
+ ; the below are new delegations (NS) records
+ ;delegation.centroid.eu,delegate,3600,ns1.server.com.
+ ;delegation.centroid.eu,delegate,3600,ns2.server.com.
}
zone "ipv6.centroid.eu" {
ipv6.centroid.eu,soa,3600,uranus.centroid.eu.,pjp.solarscale.de.,1244725285,3600,1800,7200,3600
blob - 1bb90761732cb08e0c26778ee7321ce008e43396
blob + 8c4e6b17db1a512465ede4ca046f5aa87df69a39
--- parse.c
+++ parse.c
@@ -46,6 +46,7 @@ struct myrr_lookup {
{ "mx", DNS_TYPE_MX },
{ "aaaa", DNS_TYPE_AAAA },
{ "ns", DNS_TYPE_NS },
+ { "delegate", DNS_TYPE_DELEGATE },
{ NULL, 0 },
};
@@ -72,7 +73,7 @@ struct cmd_lookup {
static u_int32_t config = 0;
-static const char rcsid[] = "$Id: parse.c,v 1.17 2010/03/09 15:38:22 pbug Exp $";
+static const char rcsid[] = "$Id: parse.c,v 1.18 2010/03/18 08:55:13 pbug Exp $";
/*
* PARSE_FILE - parse the configfile XXX rewrite me in yacc :(
@@ -776,6 +777,7 @@ parse_file(DB *db, char *file)
break;
case DNS_TYPE_NS:
+ case DNS_TYPE_DELEGATE:
p = endline;
save = *p;
*p = 0;
@@ -799,6 +801,12 @@ parse_file(DB *db, char *file)
*p = save;
sdomain.ns_ptr = 0;
+
+ if (type == DNS_TYPE_DELEGATE)
+ sdomain.ns_delegate = 1;
+ else
+ sdomain.ns_delegate = 0;
+
sdomain.flags |= DOMAIN_HAVE_NS;
break;
blob - 22800f6c57d4f1b9bbe66dd8f60f60967b6ee141
blob + 3d751441f69888733cf71b7379e6597ebb619770
--- reply.c
+++ reply.c
@@ -49,7 +49,7 @@ extern int additional_ptr(char *, int, struct domain *
void update_db(DB *, struct domain *);
-static const char rcsid[] = "$Id: reply.c,v 1.15 2010/03/14 08:25:29 pbug Exp $";
+static const char rcsid[] = "$Id: reply.c,v 1.16 2010/03/18 08:55:13 pbug Exp $";
/*
* REPLY_A() - replies a DNS question (*q) on socket (so)
@@ -118,8 +118,8 @@ reply_a(struct sreply *sreply, DB *db)
HTONS(odh->query);
- odh->question = ntohs(1);
- odh->answer = ntohs(sd->a_count);
+ odh->question = htons(1);
+ odh->answer = htons(sd->a_count);
odh->nsrr = 0;
odh->additional = 0;
@@ -181,7 +181,7 @@ reply_a(struct sreply *sreply, DB *db)
} while (a_count < 10 && --sd->a_count);
if (ttlhack) {
- odh->answer = ntohs(a_count);
+ odh->answer = htons(a_count);
}
if (istcp)
@@ -274,8 +274,8 @@ reply_aaaa(struct sreply *sreply, DB *db)
HTONS(odh->query);
- odh->question = ntohs(1);
- odh->answer = ntohs(sd->aaaa_count);
+ odh->question = htons(1);
+ odh->answer = htons(sd->aaaa_count);
odh->nsrr = 0;
odh->additional = 0;
@@ -399,8 +399,8 @@ reply_mx(struct sreply *sreply)
HTONS(odh->query);
- odh->question = ntohs(1);
- odh->answer = ntohs(sd->mx_count);
+ odh->question = htons(1);
+ odh->answer = htons(sd->mx_count);
odh->nsrr = 0;
odh->additional = 0;
@@ -514,13 +514,22 @@ reply_ns(struct sreply *sreply, DB *db)
outlen += (q->hdr->namelen + 4);
SET_DNS_REPLY(odh);
- SET_DNS_AUTHORITATIVE(odh);
+
+ if (sd->ns_delegate == 0)
+ SET_DNS_AUTHORITATIVE(odh);
+ else
+ SET_DNS_RECURSION(odh);
HTONS(odh->query);
- odh->question = ntohs(1);
- odh->answer = ntohs(sd->ns_count);
- odh->nsrr = 0;
+ odh->question = htons(1);
+ if (sd->ns_delegate == 0) {
+ odh->answer = htons(sd->ns_count);
+ odh->nsrr = 0;
+ } else {
+ odh->answer = 0;
+ odh->nsrr = htons(sd->ns_count);
+ }
odh->additional = 0;
/* skip dns header, question name, qtype and qclass */
@@ -654,7 +663,7 @@ reply_cname(struct sreply *sreply)
answer->name[0] = 0xc0;
answer->name[1] = 0x0c;
- answer->type = ntohs(DNS_TYPE_CNAME);
+ answer->type = htons(DNS_TYPE_CNAME);
answer->class = q->hdr->qclass;
answer->ttl = htonl(sd->ttl);
@@ -808,8 +817,8 @@ reply_ptr(struct sreply *sreply)
HTONS(odh->query);
- odh->question = ntohs(1);
- odh->answer = ntohs(1);
+ odh->question = htons(1);
+ odh->answer = htons(1);
odh->nsrr = 0;
odh->additional = 0;
@@ -955,8 +964,8 @@ reply_soa(struct sreply *sreply)
NTOHS(odh->query);
- odh->question = ntohs(1);
- odh->answer = ntohs(1);
+ odh->question = htons(1);
+ odh->answer = htons(1);
odh->nsrr = 0;
odh->additional = 0;
@@ -1262,9 +1271,9 @@ reply_nxdomain(struct sreply *sreply)
NTOHS(odh->query);
- odh->question = ntohs(1);
+ odh->question = htons(1);
odh->answer = 0;
- odh->nsrr = ntohs(1);
+ odh->nsrr = htons(1);
odh->additional = 0;
answer = (struct answer *)(&reply[0] + sizeof(struct dns_header) +
@@ -1568,9 +1577,9 @@ reply_noerror(struct sreply *sreply)
NTOHS(odh->query);
- odh->question = ntohs(1);
+ odh->question = htons(1);
odh->answer = 0;
- odh->nsrr = ntohs(1);
+ odh->nsrr = htons(1);
odh->additional = 0;
answer = (struct answer *)(&reply[0] + sizeof(struct dns_header) +
repomaster@centroid.eu