]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
daemon/worker: allow large responses for outbound over TCP
authorMarek Vavruša <mvavrusa@cloudflare.com>
Tue, 20 Mar 2018 22:41:05 +0000 (15:41 -0700)
committerGrigorii Demidov <grigorii.demidov@nic.cz>
Mon, 26 Mar 2018 13:32:18 +0000 (15:32 +0200)
This was previously fixed in e25358d4f6521a55c33ec1d3a55f2bf6e2f99607,
but broken in the rewrite. The answer buffer size must be a maximum size,
otherwise payloads larger than configured UDP buffer size can't be
transmitted over TCP.

daemon/worker.c

index eec5671397c9abf064da7c628cf24f97390af344..62b87ee26f78e6b85651853afce0966620ad9820 100644 (file)
@@ -2154,6 +2154,16 @@ int worker_process_tcp(struct worker_ctx *worker, uv_stream_t *handle,
                        /* FIXME: on high load over one connection, it's likely
                         * that we will get multiple matches sooner or later (!) */
                        if (task) {
+                               /* Make sure we can process maximum packet sizes over TCP for outbound queries.
+                                * Previous packet is allocated with mempool, so there's no need to free it manually. */
+                               if (task->pktbuf->max_size < KNOT_WIRE_MAX_PKTSIZE) {
+                                               knot_mm_t *pool = &task->pktbuf->mm;
+                                               pkt_buf = knot_pkt_new(NULL, KNOT_WIRE_MAX_PKTSIZE, pool);
+                                               if (!pkt_buf) {
+                                                               return kr_error(ENOMEM);
+                                               }
+                                               task->pktbuf = pkt_buf;
+                               }
                                knot_pkt_clear(task->pktbuf);
                                assert(task->leading == false);
                        } else  {