From: Oto Šťáva Date: Tue, 21 Mar 2023 06:35:19 +0000 (+0100) Subject: daemon/session2: rename http flag to custom_emalf_handling X-Git-Tag: v6.0.2~42^2~6 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=c3d535da0c3010101efe42a8b5cea9f33521731c;p=thirdparty%2Fknot-resolver.git daemon/session2: rename http flag to custom_emalf_handling The session2 API as well as everything that uses it should be as independent of the underlying protocols as possible, providing functionality through firing different events. There was a left-over `struct session2::http` flag, which allowed the DoH layer to return a Bad Request reply. This has been renamed so that it does not mention HTTP apart from the example in the doc comments, in case another protocol needs to use this functionality at some point. --- diff --git a/daemon/http.c b/daemon/http.c index 8633c664f..d028113be 100644 --- a/daemon/http.c +++ b/daemon/http.c @@ -877,7 +877,7 @@ static int pl_http_sess_init(struct protolayer_manager *manager, struct sockaddr *peer = session2_get_peer(manager->session); kr_log_debug(DOH, "[%p] h2 session created for %s\n", (void *)http->h2, kr_straddr(peer)); - manager->session->http = true; + manager->session->custom_emalf_handling = true; ret = kr_ok(); diff --git a/daemon/session2.h b/daemon/session2.h index 4f07cb49e..392e19352 100644 --- a/daemon/session2.h +++ b/daemon/session2.h @@ -842,9 +842,10 @@ struct session2 { * Set during protocol layer initialization by the stream-based layer. */ bool stream : 1; - /** If true, the session contains a HTTP protocol layer. - * Set during protocol layer initialization by the HTTP layer. */ - bool http : 1; + /** If true, the session contains a protocol layer with custom handling + * of malformed queries. This is used e.g. by the HTTP layer, which will + * return a Bad Request status on a malformed query. */ + bool custom_emalf_handling : 1; /** If true, a connection is established. Only applicable to sessions * using connection-based protocols. One of the stream-based protocol diff --git a/daemon/worker.c b/daemon/worker.c index 996eb9beb..db63f0259 100644 --- a/daemon/worker.c +++ b/daemon/worker.c @@ -1351,9 +1351,7 @@ static int worker_submit(struct session2 *session, struct comm_info *comm, knot_ } /* Badly formed query when using DoH leads to a Bad Request */ - /* TODO: Do not necessarily tie it to HTTP - it should probably be a - * more generic flag */ - if (session->http && !is_outgoing && ret) { + if (session->custom_emalf_handling && !is_outgoing && ret) { session2_event(session, PROTOLAYER_EVENT_MALFORMED, NULL); return ret; }