Commit 7c052747 authored by Daniel Salzman's avatar Daniel Salzman

Merge branch 'long_dname_fix' into 'master'

Long dname fix

Closes #508 and #339

See merge request !677
parents 0329eba9 2b5b4f66
......@@ -105,10 +105,11 @@ static int dname_cname_synth(const knot_rrset_t *dname_rr,
*/
static bool dname_cname_cannot_synth(const knot_rrset_t *rrset, const knot_dname_t *qname)
{
if (knot_dname_labels(qname, NULL)
- knot_dname_labels(rrset->owner, NULL)
+ knot_dname_labels(knot_dname_target(&rrset->rrs), NULL)
> KNOT_DNAME_MAXLABELS) {
if (knot_dname_labels(qname, NULL) - knot_dname_labels(rrset->owner, NULL) +
knot_dname_labels(knot_dname_target(&rrset->rrs), NULL) > KNOT_DNAME_MAXLABELS) {
return true;
} else if (knot_dname_size(qname) - knot_dname_size(rrset->owner) +
knot_dname_size(knot_dname_target(&rrset->rrs)) > KNOT_DNAME_MAXLEN) {
return true;
} else {
return false;
......@@ -309,20 +310,20 @@ static int follow_cname(knot_pkt_t *pkt, uint16_t rrtype, struct query_data *qda
if (rrtype == KNOT_RRTYPE_DNAME) {
if (dname_cname_cannot_synth(&cname_rr, qdata->name)) {
qdata->rcode = KNOT_RCODE_YXDOMAIN;
return ERROR;
}
knot_rrset_t dname_rr = cname_rr;
int ret = dname_cname_synth(&dname_rr, qdata->name, &cname_rr,
&pkt->mm);
if (ret != KNOT_EOK) {
qdata->rcode = KNOT_RCODE_SERVFAIL;
return ERROR;
}
ret = process_query_put_rr(pkt, qdata, &cname_rr, NULL, 0, KNOT_PF_FREE);
switch (ret) {
case KNOT_EOK: break;
case KNOT_ESPACE: return TRUNC;
default: return ERROR;
} else {
knot_rrset_t dname_rr = cname_rr;
int ret = dname_cname_synth(&dname_rr, qdata->name,
&cname_rr, &pkt->mm);
if (ret != KNOT_EOK) {
qdata->rcode = KNOT_RCODE_SERVFAIL;
return ERROR;
}
ret = process_query_put_rr(pkt, qdata, &cname_rr, NULL, 0, KNOT_PF_FREE);
switch (ret) {
case KNOT_EOK: break;
case KNOT_ESPACE: return TRUNC;
default: return ERROR;
}
}
}
......
......@@ -6,10 +6,14 @@ $TTL 10
A 10.0.0.1
AAAA fd00::a1
DNSKEY 256 3 13 Yg==
big DNAME uhuh
test CNAME @
uhuh AAAA fd00::a2
@ NSEC test A NS SOA AAAA RRSIG NSEC DNSKEY
test NSEC @ CNAME RRSIG NSEC
@ NSEC big A NS SOA AAAA RRSIG NSEC DNSKEY
big NSEC test DNAME RRSIG NSEC
test NSEC uhuh CNAME RRSIG NSEC
uhuh NSEC @ AAAA RRSIG NSEC
@ RRSIG SOA 13 1 10 20150810112233 20250810112233 26125 @ YQ==
RRSIG A 13 1 10 20150810112233 20250810112233 26125 @ YQ==
......@@ -17,5 +21,9 @@ test NSEC @ CNAME RRSIG NSEC
RRSIG AAAA 13 1 10 20150810112233 20250810112233 26125 @ YQ==
RRSIG DNSKEY 13 1 10 20150810112233 20250810112233 26125 @ YQ==
RRSIG NSEC 13 1 10 20150810112233 20250810112233 26125 @ YQ==
big RRSIG DNAME 13 2 10 20150810112233 20250810112233 26125 @ YQ==
RRSIG NSEC 13 2 10 20150810112233 20250810112233 26125 @ YQ==
test RRSIG CNAME 13 2 10 20150810112233 20250810112233 26125 @ YQ==
RRSIG NSEC 13 2 10 20150810112233 20250810112233 26125 @ YQ==
uhuh RRSIG AAAA 13 2 10 20150810112233 20250810112233 26125 @ YQ==
RRSIG NSEC 13 2 10 20150810112233 20250810112233 26125 @ YQ==
......@@ -6,6 +6,7 @@ Basic checks for CNAME following.
- Query for CNAME, NSEC, RRSIG is not followed.
- Query for ANY meta type is not followed.
- Query for any other type is followed.
- DNAME CNAME is too long.
"""
......@@ -69,4 +70,14 @@ resp.check_rr("answer", "test.follow", "RRSIG")
resp.check_no_rr("answer", "test")
resp.check_empty("authority")
# DNAME systhetizes too long CNAME
resp = knot.dig("63o-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx." +
"63o-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx." +
"63o-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx." +
"50o-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.big.follow.",
"CNAME", udp=True, dnssec=True)
resp.check(rcode="YXDOMAIN")
resp.check_record(section="answer", rtype="DNAME", rdata="uhuh.follow.")
resp.check_rr(section="answer", rname="big.follow.", rtype="RRSIG")
t.end()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment