kr_request: move ::has_tls to ::qsource.flags.tls

We were quite inconsistent here.
parent 20c59bba
......@@ -165,6 +165,7 @@ struct kr_rplan {
};
struct kr_request_qsource_flags {
_Bool tcp : 1;
_Bool tls : 1;
};
struct kr_request {
struct kr_context *ctx;
......@@ -191,7 +192,6 @@ struct kr_request {
_Bool auth_validated;
uint8_t rank;
struct kr_rplan rplan;
int has_tls;
trace_log_f trace_log;
trace_callback_f trace_finish;
int vars_ref;
......
......@@ -322,11 +322,13 @@ static struct request_ctx *request_create(struct worker_ctx *worker,
req->qsource.dst_addr = dst_addr;
}
req->qsource.flags.tcp = false;
req->qsource.flags.tls = false;
} else if (handle->type == UV_TCP) {
if (uv_tcp_getsockname((uv_tcp_t *)handle, dst_addr, &addr_len) == 0) {
req->qsource.dst_addr = dst_addr;
}
req->qsource.flags.tcp = true;
req->qsource.flags.tls = s && session_flags(s)->has_tls;
}
return ctx;
......@@ -1354,7 +1356,6 @@ static int qr_task_step(struct qr_task *task,
task->addrlist = NULL;
task->addrlist_count = 0;
task->addrlist_turn = 0;
req->has_tls = (ctx->source.session && session_flags(ctx->source.session)->has_tls);
if (worker->too_many_open) {
/* */
......
......@@ -441,7 +441,7 @@ static int edns_create(knot_pkt_t *pkt, knot_pkt_t *template, struct kr_request
wire_size += KR_COOKIE_OPT_MAX_LEN;
}
#endif /* defined(ENABLE_COOKIES) */
if (req->has_tls) {
if (req->qsource.flags.tls) {
if (req->ctx->tls_padding == -1)
/* FIXME: we do not know how to reserve space for the
* default padding policy, since we can't predict what
......@@ -642,7 +642,7 @@ static int answer_finalize(struct kr_request *request, int state)
}
/* Write EDNS information */
if (answer->opt_rr) {
if (request->has_tls) {
if (request->qsource.flags.tls) {
if (answer_padding(request) != kr_ok()) {
return answer_fail(request);
}
......
......@@ -177,7 +177,8 @@ struct kr_context
/* Kept outside, because kres-gen.lua can't handle this depth
* (and lines here were too long anyway). */
struct kr_request_qsource_flags {
bool tcp:1; /**< true if the request is on tcp; only meaningful if (dst_addr). */
bool tcp:1; /**< true if the request is on TCP (or TLS); only meaningful if (dst_addr). */
bool tls:1; /**< true if the request is on TLS; only meaningful if (dst_addr). */
};
/**
......@@ -226,7 +227,6 @@ struct kr_request {
uint8_t rank;
struct kr_rplan rplan;
int has_tls;
trace_log_f trace_log; /**< Logging tracepoint */
trace_callback_f trace_finish; /**< Request finish tracepoint */
int vars_ref; /**< Reference to per-request variable table. LUA_NOREF if not set. */
......
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