Commit 989b8006 authored by Marek Vavruša's avatar Marek Vavruša Committed by Marek Vavruša

lib/iterate: fixed check for mandatory glue + test

parent de24fe5b
......@@ -203,15 +203,15 @@ static int update_cut(knot_pkt_t *pkt, const knot_rrset_t *rr, struct kr_request
}
/* Fetch glue for each NS */
kr_zonecut_add(cut, knot_ns_name(&rr->rrs, 0), NULL);
for (unsigned i = 0; i < rr->rrs.rr_count; ++i) {
const knot_dname_t *ns_name = knot_ns_name(&rr->rrs, i);
kr_zonecut_add(cut, ns_name, NULL);
int glue_records = fetch_glue(pkt, ns_name, req);
/* Glue is mandatory for NS below zone */
if (knot_dname_in(ns_name, rr->owner) ) {
if (knot_dname_in(rr->owner, ns_name) ) {
if (glue_records == 0) {
DEBUG_MSG("<= authority: missing mandatory glue, rejecting\n");
return KNOT_STATE_FAIL;
kr_zonecut_del(cut, ns_name, NULL);
}
}
}
......@@ -310,13 +310,14 @@ static int process_answer(knot_pkt_t *pkt, struct kr_request *req)
if (!knot_dname_is_equal(cname, query->sname)) {
DEBUG_MSG("<= cname chain, following\n");
struct kr_query *next = kr_rplan_push(&req->rplan, query->parent, cname, query->sclass, query->stype);
if (!next) {
return KNOT_STATE_FAIL;
}
rem_node(&query->node); /* *MUST* keep current query at tail */
insert_node(&query->node, &next->node);
kr_zonecut_set_sbelt(&next->zone_cut);
} else {
if (query->parent == NULL) {
finalize_answer(pkt, query, req);
}
next->flags |= QUERY_AWAIT_CUT;
} else if (!query->parent) {
finalize_answer(pkt, query, req);
}
return KNOT_STATE_DONE;
}
......
......@@ -62,7 +62,11 @@ static int ns_resolve_addr(struct kr_query *qry, struct kr_request *param)
return KNOT_STATE_PRODUCE;
}
/* Push new query to the resolution plan */
struct kr_query *next = kr_rplan_push(rplan, qry, qry->ns.name, KNOT_CLASS_IN, next_type);
if (!next) {
return kr_error(ENOMEM);
}
kr_zonecut_set_sbelt(&next->zone_cut);
return KNOT_STATE_PRODUCE;
}
......
......@@ -141,15 +141,17 @@ int kr_zonecut_del(struct kr_zonecut *cut, const knot_dname_t *ns, const knot_rd
}
/* Find the address list. */
int ret = kr_ok();
pack_t *pack = kr_zonecut_find(cut, ns);
if (pack == NULL) {
return kr_error(ENOENT);
}
/* Remove address from the pack. */
int ret = pack_obj_del(pack, knot_rdata_data(rdata), knot_rdata_rdlen(rdata));
if (rdata) {
ret = pack_obj_del(pack, knot_rdata_data(rdata), knot_rdata_rdlen(rdata));
}
/* No servers left, remove NS from the set. */
if (pack->len == 0) {
/* No servers left, remove NS from the set. */
free_addr_set((const char *)ns, pack, cut->pool);
return map_del(&cut->nsset, (const char *)ns);
}
......
; config options
server:
target-fetch-policy: "3 2 1 0 0"
stub-zone:
name: "."
stub-addr: 193.0.14.129 # K.ROOT-SERVERS.NET.
CONFIG_END
SCENARIO_BEGIN Test iterator with delagation with missing mandatory glue.
; K.ROOT-SERVERS.NET.
RANGE_BEGIN 0 100
ADDRESS 193.0.14.129
ENTRY_BEGIN
MATCH opcode qtype qname
ADJUST copy_id
REPLY QR NOERROR
SECTION QUESTION
. IN NS
SECTION ANSWER
. IN NS K.ROOT-SERVERS.NET.
SECTION ADDITIONAL
K.ROOT-SERVERS.NET. IN A 193.0.14.129
ENTRY_END
ENTRY_BEGIN
MATCH opcode subdomain
ADJUST copy_id copy_query
REPLY QR NOERROR
SECTION QUESTION
com. IN A
SECTION AUTHORITY
; This is the offending NS (it must be ignored)
com. IN NS a.gtld-servers.com.
com. IN NS a.gtld-servers.net.
SECTION ADDITIONAL
ENTRY_END
ENTRY_BEGIN
MATCH opcode qtype qname
ADJUST copy_id copy_query
REPLY QR NOERROR
SECTION QUESTION
a.gtld-servers.net. IN A
SECTION ANSWER
a.gtld-servers.net. IN A 192.5.6.30
ENTRY_END
ENTRY_BEGIN
MATCH opcode qtype qname
ADJUST copy_id copy_query
REPLY QR NOERROR
SECTION QUESTION
a.gtld-servers.net. IN AAAA
SECTION AUTHORITY
. SOA bla bla 1 2 3 4 5
ENTRY_END
RANGE_END
; a.gtld-servers.net.
RANGE_BEGIN 0 100
ADDRESS 192.5.6.30
ENTRY_BEGIN
MATCH opcode qtype qname
ADJUST copy_id copy_query
REPLY AA QR NOERROR
SECTION QUESTION
www.foo.com. IN A
SECTION ANSWER
www.foo.com. 10 IN A 10.20.30.40
SECTION AUTHORITY
www.foo.com. 3600 IN NS a.gtld-servers.net.
ENTRY_END
RANGE_END
STEP 1 QUERY
ENTRY_BEGIN
REPLY RD
SECTION QUESTION
www.foo.com. IN A
ENTRY_END
; recursion happens here.
STEP 10 CHECK_ANSWER
ENTRY_BEGIN
MATCH all
REPLY QR RD RA NOERROR
SECTION QUESTION
www.foo.com. IN A
SECTION ANSWER
www.foo.com. 10 IN A 10.20.30.40
ENTRY_END
SCENARIO_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