]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
daemon/session2: rename http flag to custom_emalf_handling
authorOto Šťáva <oto.stava@nic.cz>
Tue, 21 Mar 2023 06:35:19 +0000 (07:35 +0100)
committerOto Šťáva <oto.stava@nic.cz>
Tue, 21 Mar 2023 06:35:19 +0000 (07:35 +0100)
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.

daemon/http.c
daemon/session2.h
daemon/worker.c

index 8633c664fc474f0f1d2980938da61092b1c5af7b..d028113be9393905c9fca9df99fcc81863db590e 100644 (file)
@@ -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();
 
index 4f07cb49e88a6dd465e5ec3098b6e9716e2ce75b..392e193522323e5e6ff44f6daa3c2978a7acb4ed 100644 (file)
@@ -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
index 996eb9beb4c006d1d800472ca0471e04208ee848..db63f0259f421eebb622a77b237313cdf3336bd5 100644 (file)
@@ -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;
        }