Commit 633c207e authored by Daniel Salzman's avatar Daniel Salzman

process_query: add EDNS also to EMALF response if in query

parent 4cb8f251
/* Copyright (C) 2017 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 2018 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -332,24 +332,6 @@ static int prepare_answer(const knot_pkt_t *query, knot_pkt_t *resp, knot_layer_
}
knot_wire_clear_cd(resp->wire);
/* Query MUST carry a question. */
const knot_dname_t *qname = knot_pkt_qname(query);
if (qname == NULL) {
qdata->rcode = KNOT_RCODE_FORMERR;
return KNOT_EMALF;
}
/* Convert query QNAME to lowercase, but keep original QNAME case.
* Already checked for absence of compression and length.
*/
memcpy(qdata->extra->orig_qname, qname, query->qname_size);
ret = process_query_qname_case_lower((knot_pkt_t *)query);
if (ret != KNOT_EOK) {
return ret;
}
/* Find zone for QNAME. */
qdata->extra->zone = answer_zone_find(query, server->zone_db);
/* Setup EDNS. */
ret = answer_edns_init(query, resp, qdata);
if (ret != KNOT_EOK || qdata->rcode != 0) {
......@@ -380,7 +362,25 @@ static int prepare_answer(const knot_pkt_t *query, knot_pkt_t *resp, knot_layer_
resp->max_size = KNOT_WIRE_MAX_PKTSIZE;
}
return ret;
/* Query MUST carry a question. */
const knot_dname_t *qname = knot_pkt_qname(query);
if (qname == NULL) {
qdata->rcode = KNOT_RCODE_FORMERR;
return KNOT_EMALF;
}
/* Convert query QNAME to lowercase, but keep original QNAME case.
* Already checked for absence of compression and length.
*/
memcpy(qdata->extra->orig_qname, qname, query->qname_size);
ret = process_query_qname_case_lower((knot_pkt_t *)query);
if (ret != KNOT_EOK) {
return ret;
}
/* Find zone for QNAME. */
qdata->extra->zone = answer_zone_find(query, server->zone_db);
return KNOT_EOK;
}
static void set_rcode_to_packet(knot_pkt_t *pkt, knotd_qdata_t *qdata)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment