From: Marek VavruĊĦa Date: Tue, 20 Mar 2018 22:41:05 +0000 (-0700) Subject: daemon/worker: allow large responses for outbound over TCP X-Git-Tag: v2.2.0~3^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=78c1d32ddc4796d1331c7e02763debce7e829e33;p=thirdparty%2Fknot-resolver.git daemon/worker: allow large responses for outbound over TCP 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. --- diff --git a/daemon/worker.c b/daemon/worker.c index eec567139..62b87ee26 100644 --- a/daemon/worker.c +++ b/daemon/worker.c @@ -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 {