Commit 64b4fb0d authored by Marek Vavruša's avatar Marek Vavruša

lib: bail out on irresolvable nameservers

parent 140e028c
......@@ -309,7 +309,7 @@ static int process_answer(knot_pkt_t *pkt, struct kr_layer_param *param)
}
/* Either way it resolves current query. */
query->resolved = true;
query->flags |= QUERY_RESOLVED;
return KNOT_STATE_DONE;
}
......@@ -389,7 +389,7 @@ static int resolve(knot_layer_t *ctx, knot_pkt_t *pkt)
assert(pkt && ctx);
struct kr_layer_param *param = ctx->data;
struct kr_query *query = kr_rplan_current(param->rplan);
if (query == NULL || query->resolved) {
if (query == NULL || (query->flags & QUERY_RESOLVED)) {
return ctx->state;
}
......
......@@ -21,6 +21,7 @@
#include <libknot/rrtype/rdname.h>
#include "lib/layer/iterate.h"
#include "lib/cache.h"
#include "lib/module.h"
#define DEBUG_MSG(fmt...) QRDEBUG(kr_rplan_current(param->rplan), " cc ", fmt)
......@@ -95,7 +96,7 @@ static int read_cache(knot_layer_t *ctx, knot_pkt_t *pkt)
int state = read_cache_rr(txn, &cache_rr, timestamp, callback, param);
if (state == KNOT_STATE_DONE) {
DEBUG_MSG("=> satisfied from cache\n");
cur->resolved = true;
cur->flags |= QUERY_RESOLVED;
return state;
}
......@@ -110,7 +111,7 @@ static int read_cache(knot_layer_t *ctx, knot_pkt_t *pkt)
}
}
cur->resolved = true;
cur->flags |= QUERY_RESOLVED;
return KNOT_STATE_DONE;
}
......
......@@ -46,6 +46,7 @@ static int ns_resolve_addr(struct kr_query *cur, struct kr_layer_param *param)
{
if (kr_rplan_satisfies(cur, cur->ns.name, KNOT_CLASS_IN, KNOT_RRTYPE_A) ||
kr_rplan_satisfies(cur, cur->ns.name, KNOT_CLASS_IN, KNOT_RRTYPE_AAAA) ||
cur->flags & QUERY_AWAIT_ADDR) {
DEBUG_MSG("=> dependency loop, bailing out\n");
kr_rplan_pop(param->rplan, cur);
return KNOT_EOK;
......@@ -53,6 +54,7 @@ static int ns_resolve_addr(struct kr_query *cur, struct kr_layer_param *param)
(void) kr_rplan_push(param->rplan, cur, cur->ns.name, KNOT_CLASS_IN, KNOT_RRTYPE_AAAA);
(void) kr_rplan_push(param->rplan, cur, cur->ns.name, KNOT_CLASS_IN, KNOT_RRTYPE_A);
cur->flags |= QUERY_AWAIT_ADDR;
return KNOT_EOK;
}
......
......@@ -34,7 +34,9 @@
/** Query flags */
enum kr_query_flag {
QUERY_NO_MINIMIZE = 1 << 0, /**< Don't minimize QNAME. */
QUERY_TCP = 1 << 1 /**< Use TCP for this query. */
QUERY_TCP = 1 << 1, /**< Use TCP for this query. */
QUERY_RESOLVED = 1 << 2, /**< Query is resolved. */
QUERY_AWAIT_ADDR = 1 << 3 /**< Query is waiting for NS address. */
};
/**
......@@ -47,7 +49,6 @@ struct kr_query {
struct kr_zonecut zone_cut;
struct timeval timestamp;
knot_dname_t *sname;
bool resolved;
uint16_t stype;
uint16_t sclass;
uint16_t id;
......
......@@ -93,7 +93,7 @@ static int query(knot_layer_t *ctx, knot_pkt_t *pkt)
knot_rrset_add_rdata(&rr, raw_addr, addr_len, 0, &param->answer->mm);
callback(&rr, 0, param);
cur->resolved = true;
cur->flags |= QUERY_RESOLVED;
return KNOT_STATE_DONE;
}
}
......
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