diff --git a/daemon/engine.c b/daemon/engine.c index d0d6d87cee8b53306cdfc66b33de77d83f836461..749308a542100804fcbf8bd4f2e8a1905f00b5f1 100644 --- a/daemon/engine.c +++ b/daemon/engine.c @@ -377,26 +377,27 @@ static int l_fromjson(lua_State *L) static int init_resolver(struct engine *engine) { - /* Note: it had been zored by engine_init(). */ + /* Note: whole *engine had been zeroed by engine_init(). */ + struct kr_context * const ctx = &engine->resolver; /* Open resolution context */ - engine->resolver.trust_anchors = map_make(NULL); - engine->resolver.negative_anchors = map_make(NULL); - engine->resolver.pool = engine->pool; - engine->resolver.modules = &engine->modules; - engine->resolver.cache_rtt_tout_retry_interval = KR_NS_TIMEOUT_RETRY_INTERVAL; + ctx->trust_anchors = map_make(NULL); + ctx->negative_anchors = map_make(NULL); + ctx->pool = engine->pool; + ctx->modules = &engine->modules; + ctx->cache_rtt_tout_retry_interval = KR_NS_TIMEOUT_RETRY_INTERVAL; /* Create OPT RR */ - engine->resolver.downstream_opt_rr = mm_alloc(engine->pool, sizeof(knot_rrset_t)); - engine->resolver.upstream_opt_rr = mm_alloc(engine->pool, sizeof(knot_rrset_t)); - if (!engine->resolver.downstream_opt_rr || !engine->resolver.upstream_opt_rr) { + ctx->downstream_opt_rr = mm_alloc(engine->pool, sizeof(knot_rrset_t)); + ctx->upstream_opt_rr = mm_alloc(engine->pool, sizeof(knot_rrset_t)); + if (!ctx->downstream_opt_rr || !ctx->upstream_opt_rr) { return kr_error(ENOMEM); } - knot_edns_init(engine->resolver.downstream_opt_rr, KR_EDNS_PAYLOAD, 0, KR_EDNS_VERSION, engine->pool); - knot_edns_init(engine->resolver.upstream_opt_rr, KR_EDNS_PAYLOAD, 0, KR_EDNS_VERSION, engine->pool); + knot_edns_init(ctx->downstream_opt_rr, KR_EDNS_PAYLOAD, 0, KR_EDNS_VERSION, engine->pool); + knot_edns_init(ctx->upstream_opt_rr, KR_EDNS_PAYLOAD, 0, KR_EDNS_VERSION, engine->pool); /* Use default TLS padding */ - engine->resolver.tls_padding = -1; + ctx->tls_padding = -1; /* Empty init; filled via ./lua/postconfig.lua */ - kr_zonecut_init(&engine->resolver.root_hints, (const uint8_t *)"", engine->pool); - lru_create(&engine->resolver.cache_cookie, LRU_COOKIES_SIZE, NULL, NULL); + kr_zonecut_init(&ctx->root_hints, (const uint8_t *)"", engine->pool); + lru_create(&ctx->cache_cookie, LRU_COOKIES_SIZE, NULL, NULL); /* Load basic modules */ engine_register(engine, "iterate", NULL, NULL); diff --git a/lib/resolve.h b/lib/resolve.h index e5855cc3eafb23e6b64dc6771f079ad6128ec7b4..8f2a3383a7f53b41da5b5200b7cdc3658cbf9cbf 100644 --- a/lib/resolve.h +++ b/lib/resolve.h @@ -149,6 +149,7 @@ typedef array_t(struct kr_module *) module_array_t; */ struct kr_context { + /** Default kr_request flags. For startup defaults see init_resolver() */ struct kr_qflags options; /** Default EDNS towards *both* clients and upstream.