From 7852cb9270e19543f1945284d7612f8a4af505b8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C5=A0t=C4=9Bp=C3=A1n=20Bal=C3=A1=C5=BEik?= Date: Tue, 1 Aug 2017 13:57:06 +0200 Subject: [PATCH] worker: answer with NOTIMPL to all OPCODEs but QUERY bypassing resolve.c fixes #225 --- daemon/worker.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/daemon/worker.c b/daemon/worker.c index b31c7a18c..0855144e1 100644 --- a/daemon/worker.c +++ b/daemon/worker.c @@ -739,8 +739,21 @@ static int qr_task_step(struct qr_task *task, const struct sockaddr *packet_sour if (!task || task->finished) { return kr_error(ESTALE); } + + /* Answer with NOTIMPL to all OPCODEs but QUERY bypassing resolve.c */ + if(packet && knot_wire_get_opcode(packet->wire) != KNOT_OPCODE_QUERY) { + knot_wire_set_rcode(packet->wire, KNOT_RCODE_NOTIMPL); + /* We need the packet finalized so qr_task_send does not try to resolve upon it. */ + knot_wire_set_qr(packet->wire); + task->finished = true; + /* Send back answer */ + (void) qr_task_send(task, task->source.handle, (struct sockaddr *)&task->source.addr, packet); + return KR_STATE_DONE; + } + /* Close pending I/O requests */ subreq_finalize(task, packet_source, packet); + /* Consume input and produce next query */ int sock_type = -1; task->addrlist = NULL; -- 2.47.2