Commit e22fc030 authored by Marek Vavruša's avatar Marek Vavruša

lib/nsrep: do not penalize name failures, no empty NSLIST leaders

if the NSLIST already has a candidate with addresses, never replace
current leader with an empty one. otherwise if the former leader address
was tried and failed, new empty leader would be blamed for this and
penalized
parent ecb98f14
......@@ -58,6 +58,11 @@ static void update_nsrep(struct kr_nsrep *ns, size_t pos, uint8_t *addr, size_t
static void update_nsrep_set(struct kr_nsrep *ns, const knot_dname_t *name, uint8_t *addr[], unsigned score)
{
/* NSLIST is not empty, empty NS cannot be a leader. */
if (!addr[0] && ns->addr[0].ip.sa_family != AF_UNSPEC) {
return;
}
/* Set new NS leader */
ns->name = name;
ns->score = score;
for (size_t i = 0; i < KR_NSREP_MAXADDR; ++i) {
......@@ -133,7 +138,7 @@ static int eval_nsrep(const char *k, void *v, void *baton)
score += FAVOUR_IPV6;
/* If the server is unknown but has rep record, treat it as timeouted */
if (reputation & KR_NS_NOIP4) {
score = KR_NS_TIMEOUT;
score = KR_NS_UNKNOWN;
reputation = 0; /* Start with clean slate */
}
}
......
......@@ -424,18 +424,19 @@ int kr_resolve_consume(struct kr_request *request, const struct sockaddr *src, k
ITERATE_LAYERS(request, qry, consume, packet);
}
/* Resolution failed, invalidate current NS. */
if (request->state == KNOT_STATE_FAIL) {
kr_nsrep_update_rtt(&qry->ns, src, KR_NS_TIMEOUT, ctx->cache_rtt);
invalidate_ns(rplan, qry);
qry->flags &= ~QUERY_RESOLVED;
/* Track RTT for iterative answers */
} else if (!(qry->flags & QUERY_CACHED)) {
if (!(qry->flags & QUERY_CACHED)) {
struct timeval now;
gettimeofday(&now, NULL);
kr_nsrep_update_rtt(&qry->ns, src, time_diff(&qry->timestamp, &now), ctx->cache_rtt);
/* Sucessful answer, lift any address resolution requests. */
qry->flags &= ~(QUERY_AWAIT_IPV6|QUERY_AWAIT_IPV4);
if (request->state != KNOT_STATE_FAIL)
qry->flags &= ~(QUERY_AWAIT_IPV6|QUERY_AWAIT_IPV4);
}
/* Resolution failed, invalidate current NS. */
if (request->state == KNOT_STATE_FAIL) {
invalidate_ns(rplan, qry);
qry->flags &= ~QUERY_RESOLVED;
}
/* Pop query if resolved. */
......
deckard @ 9650d081
Subproject commit 421a66cf3f1c957844b07e084af184c55a4210d2
Subproject commit 9650d08110c15a6ed80f072c877f160b12c1f351
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