Commit e9ffeb1a authored by Marek Vavrusa's avatar Marek Vavrusa

lib/resolve: store auth addr/rtt in consume() layer

during the consume step, the information about
upstream authoritative (address and current rtt)
is exposed in the request structure, just like
information about current query
parent ac0d8080
......@@ -213,6 +213,10 @@ struct kr_request {
const knot_rrset_t *key;
const struct sockaddr *addr;
} qsource;
struct {
unsigned rtt;
const struct sockaddr *addr;
} upstream;
uint32_t options;
int state;
rr_array_t authority;
......
......@@ -445,7 +445,19 @@ int kr_resolve_consume(struct kr_request *request, const struct sockaddr *src, k
randomized_qname_case(qname_raw, qry->secret);
}
request->state = KNOT_STATE_CONSUME;
ITERATE_LAYERS(request, qry, consume, packet);
if (qry->flags & QUERY_CACHED) {
ITERATE_LAYERS(request, qry, consume, packet);
} else {
struct timeval now;
gettimeofday(&now, NULL);
/* Fill in source and latency information. */
request->upstream.rtt = time_diff(&qry->timestamp, &now);
request->upstream.addr = src;
ITERATE_LAYERS(request, qry, consume, packet);
/* Clear temporary information */
request->upstream.addr = NULL;
request->upstream.rtt = 0;
}
}
/* Track RTT for iterative answers */
......
......@@ -113,6 +113,10 @@ struct kr_request {
const knot_rrset_t *key;
const struct sockaddr *addr;
} qsource;
struct {
unsigned rtt; /**< Current upstream RTT */
const struct sockaddr *addr; /**< Current upstream address */
} upstream; /**< Upstream information, valid only in consume() phase */
uint32_t options;
int state;
rr_array_t authority;
......
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