Verified Commit 06bf7a39 authored by Grigorii Demidov's avatar Grigorii Demidov Committed by Vladimír Čunát

force kresd to follow net.ip(4,6) settings when forwarding

parent 41cf07be
......@@ -280,23 +280,24 @@ int kr_nsrep_set(struct kr_query *qry, size_t index, const struct sockaddr *sock
if (index >= KR_NSREP_MAXADDR) {
return kr_error(ENOSPC);
}
qry->ns.name = (const uint8_t *)"";
/* Reset score on first entry */
if (index == 0) {
qry->ns.score = KR_NS_UNKNOWN;
qry->ns.reputation = 0;
}
if (!sock) {
qry->ns.name = (const uint8_t *)"";
qry->ns.addr[index].ip.sa_family = AF_UNSPEC;
return kr_ok();
}
switch (sock->sa_family) {
case AF_INET:
if (qry->flags.NO_IPV4) {
return kr_error(ENOENT);
}
qry->ns.addr[index].ip4 = *(const struct sockaddr_in *)sock;
break;
case AF_INET6:
if (qry->flags.NO_IPV6) {
return kr_error(ENOENT);
}
qry->ns.addr[index].ip6 = *(const struct sockaddr_in6 *)sock;
break;
default:
......@@ -304,6 +305,13 @@ int kr_nsrep_set(struct kr_query *qry, size_t index, const struct sockaddr *sock
return kr_error(EINVAL);
}
qry->ns.name = (const uint8_t *)"";
/* Reset score on first entry */
if (index == 0) {
qry->ns.score = KR_NS_UNKNOWN;
qry->ns.reputation = 0;
}
/* Retrieve RTT from cache */
struct kr_context *ctx = qry->ns.ctx;
kr_nsrep_rtt_lru_entry_t *rtt_cache_entry = ctx
......
......@@ -82,7 +82,8 @@ end
-- Override the list of nameservers (forwarders)
local function set_nslist(qry, list)
for i, ns in ipairs(list) do
assert(ffi.C.kr_nsrep_set(qry, i - 1, ns) == 0);
-- kr_nsrep_set() can return kr_error(ENOENT), it's OK
ffi.C.kr_nsrep_set(qry, i - 1, ns)
end
-- If less than maximum NSs, insert guard to terminate the list
if #list < 4 then
......
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