]> git.ipfire.org Git - thirdparty/knot-dns.git/commitdiff
ddns: fix assert if TLS communication and no QUIC available
authorDaniel Salzman <daniel.salzman@nic.cz>
Tue, 7 Oct 2025 17:43:21 +0000 (19:43 +0200)
committerDaniel Salzman <daniel.salzman@nic.cz>
Wed, 8 Oct 2025 08:58:43 +0000 (10:58 +0200)
src/knot/events/handlers/update.c

index e824307868cb5df6b79ad89c470fbfc13baee5af..c41debc4470da36dd60bed5b3d63637c437c6917 100644 (file)
@@ -373,22 +373,30 @@ static void forward_requests(conf_t *conf, zone_t *zone, list_t *requests)
 
 static void send_update_response(conf_t *conf, zone_t *zone, knot_request_t *req)
 {
-       if (req->resp) {
-               // Sign the response if the secret is known.
-               if (req->sign.tsig_key.secret.size > 0) {
-                       knotd_qdata_t qdata;
-                       knotd_qdata_extra_t extra;
-                       init_qdata_from_request(&qdata, zone, req, NULL, &extra);
-                       (void)process_query_sign_response(req->resp, &qdata);
-               }
+       if (req->resp == NULL) {
+               return;
+       }
+
+       // Sign the response if the secret is known.
+       if (req->sign.tsig_key.secret.size > 0) {
+               knotd_qdata_t qdata;
+               knotd_qdata_extra_t extra;
+               init_qdata_from_request(&qdata, zone, req, NULL, &extra);
+               (void)process_query_sign_response(req->resp, &qdata);
+       }
 
-               if (net_is_stream(req->fd) && req->tls_req_ctx.conn != NULL) {
-                       (void)knot_tls_send(req->tls_req_ctx.conn,
-                                           req->resp->wire, req->resp->size);
+       if (net_is_stream(req->fd)) {
+               if (req->tls_req_ctx.conn != NULL) {
+                       (void)knot_tls_send(req->tls_req_ctx.conn, req->resp->wire,
+                                           req->resp->size);
                        knot_tls_conn_block(req->tls_req_ctx.conn, false);
+               } else {
+                       (void)net_dns_tcp_send(req->fd, req->resp->wire, req->resp->size,
+                                              conf->cache.srv_tcp_remote_io_timeout, NULL);
                }
+       } else {
+               if (req->quic_conn != NULL) {
 #ifdef ENABLE_QUIC
-               else if (req->quic_conn != NULL) {
                        assert(!net_is_stream(req->fd));
                        uint8_t op_buf[KNOT_WIRE_MAX_PKTSIZE];
                        struct iovec out_payload = { .iov_base = op_buf, .iov_len = sizeof(op_buf) };
@@ -410,17 +418,12 @@ static void send_update_response(conf_t *conf, zone_t *zone, knot_request_t *req
                                                     &rpl, 4, KNOT_QUIC_SEND_IGNORE_BLOCKED);
                        }
                        knot_quic_conn_block(req->quic_conn, false);
-               } else // NOTE ties to 'if' below
 #else
-               assert(req->quic_conn == NULL);
+                       assert(0);
 #endif // ENABLE_QUIC
-
-               if (net_is_stream(req->fd)) {
-                       net_dns_tcp_send(req->fd, req->resp->wire, req->resp->size,
-                                        conf->cache.srv_tcp_remote_io_timeout, NULL);
                } else {
-                       net_dgram_send(req->fd, req->resp->wire, req->resp->size,
-                                      &req->remote);
+                       (void)net_dgram_send(req->fd, req->resp->wire, req->resp->size,
+                                            &req->remote);
                }
        }
 }