/** see if last resort is possible - does config allow queries to parent */
static int
can_have_last_resort(struct module_env* env, uint8_t* nm, size_t nmlen,
- uint16_t qclass)
+ uint16_t qclass, struct iter_hints_stub** retstub)
{
struct delegpt* fwddp;
struct iter_hints_stub* stub;
/* has_parent side is turned off for stub_first, where we
* are allowed to go to the parent */
stub->dp->has_parent_side_NS) {
+ if(retstub) *retstub = stub;
return 0;
}
if((fwddp = forwards_find(env->fwds, nm, qclass)) &&
if(iq->depth == ie->max_dependency_depth)
return;
if(!can_have_last_resort(qstate->env, iq->dp->name, iq->dp->namelen,
- iq->qchase.qclass))
+ iq->qchase.qclass, NULL))
return;
/* is this query the same as the nscheck? */
if(qstate->qinfo.qtype == LDNS_RR_TYPE_NS &&
*/
if (iq->refetch_glue &&
iq->dp &&
- !can_have_last_resort(qstate->env,
- iq->dp->name,
- iq->dp->namelen,
- iq->qchase.qclass)) {
+ !can_have_last_resort(qstate->env, iq->dp->name,
+ iq->dp->namelen, iq->qchase.qclass, NULL)) {
iq->refetch_glue = 0;
}
}
if(iq->qchase.qtype == LDNS_RR_TYPE_DS || iq->refetch_glue ||
(iq->qchase.qtype == LDNS_RR_TYPE_NS && qstate->prefetch_leeway
- && can_have_last_resort(qstate->env, delname, delnamelen, iq->qchase.qclass))) {
+ && can_have_last_resort(qstate->env, delname, delnamelen, iq->qchase.qclass, NULL))) {
/* remove first label from delname, root goes to hints,
* but only to fetch glue, not for qtype=DS. */
/* also when prefetching an NS record, fetch it again from
*/
if(iter_dp_is_useless(&qstate->qinfo, qstate->query_flags,
iq->dp)) {
- if(!can_have_last_resort(qstate->env, iq->dp->name, iq->dp->namelen, iq->qchase.qclass)) {
+ struct iter_hints_stub* stub = NULL;
+ if(!can_have_last_resort(qstate->env, iq->dp->name, iq->dp->namelen, iq->qchase.qclass, &stub)) {
+ if(stub && !stub->noprime) {
+ verbose(VERB_QUERY, "cache has stub "
+ "but no addresses, fallback "
+ "to stub prime addresses");
+ iq->dp = delegpt_copy(stub->dp,
+ qstate->region);
+ if(!iq->dp) {
+ log_err("out of memory in "
+ "stub fallback");
+ return error_response(qstate,
+ id, LDNS_RCODE_SERVFAIL);
+ }
+ break;
+ }
verbose(VERB_ALGO, "useless dp "
"but cannot go up, servfail");
return error_response(qstate, id,
log_assert(iq->dp);
if(!can_have_last_resort(qstate->env, iq->dp->name, iq->dp->namelen,
- iq->qchase.qclass)) {
+ iq->qchase.qclass, NULL)) {
/* fail -- no more targets, no more hope of targets, no hope
* of a response. */
verbose(VERB_QUERY, "configured stub or forward servers failed -- returning SERVFAIL");
if( ((ie->supports_ipv6 && !ns->done_pside6) ||
(ie->supports_ipv4 && !ns->done_pside4)) &&
!can_have_last_resort(qstate->env, ns->name, ns->namelen,
- iq->qchase.qclass)) {
+ iq->qchase.qclass, NULL)) {
log_nametypeclass(VERB_ALGO, "cannot pside lookup ns "
"because it is also a stub/forward,",
ns->name, LDNS_RR_TYPE_NS, iq->qchase.qclass);