Commit 60ba00b3 authored by Jan Kadlec's avatar Jan Kadlec

Merge branch 'tcp_payload_fix' of /git/repositories/labs/knot

parents 69bd7f32 7e3f943c
......@@ -3425,7 +3425,7 @@ int knot_ns_prep_normal_response(knot_nameserver_t *nameserver,
// set the OPT RR to the response
if (knot_query_edns_supported(query)) {
ret = knot_response_add_opt(*resp, nameserver->opt_rr, 1,
ret = knot_response_add_opt(*resp, nameserver->opt_rr,
knot_query_nsid_requested(query));
if (ret != KNOT_EOK) {
dbg_ns("Failed to set OPT RR to the response"
......@@ -3568,7 +3568,7 @@ int knot_ns_prep_update_response(knot_nameserver_t *nameserver,
// set the OPT RR to the response
if (knot_query_edns_supported(query)) {
ret = knot_response_add_opt(*resp, nameserver->opt_rr, 1,
ret = knot_response_add_opt(*resp, nameserver->opt_rr,
knot_query_nsid_requested(query));
if (ret != KNOT_EOK) {
dbg_ns("Failed to set OPT RR to the response"
......
......@@ -449,7 +449,6 @@ void knot_response_clear(knot_packet_t *resp, int clear_question)
int knot_response_add_opt(knot_packet_t *resp,
const knot_opt_rr_t *opt_rr,
int override_max_size,
int add_nsid)
{
if (resp == NULL || opt_rr == NULL) {
......@@ -498,21 +497,6 @@ int knot_response_add_opt(knot_packet_t *resp,
resp->opt_rr.size = EDNS_MIN_SIZE;
}
// if max size is set, it means there is some reason to be that way,
// so we can't just set it to higher value
if (override_max_size && resp->max_size > 0
&& resp->max_size < opt_rr->payload) {
return KNOT_EOK;
}
// set max size (less is OK)
if (override_max_size) {
dbg_response("Overriding max size to: %u\n",
resp->opt_rr.payload);
return knot_packet_set_max_size(resp, resp->opt_rr.payload);
}
return KNOT_EOK;
}
......
......@@ -130,6 +130,9 @@ void knot_response_clear(knot_packet_t *resp, int clear_question);
*
* \note The contents of the OPT RR are copied.
*
* \note It is expected that resp.max_size is already set to correct value as
* it is impossible to distinguish TCP scenario in this function.
*
* \param resp Response to set the OPT RR to.
* \param opt_rr OPT RR to set.
*
......@@ -140,9 +143,8 @@ void knot_response_clear(knot_packet_t *resp, int clear_question);
* \todo Needs test.
*/
int knot_response_add_opt(knot_packet_t *resp,
const knot_opt_rr_t *opt_rr,
int override_max_size,
int add_nsid);
const knot_opt_rr_t *opt_rr,
int add_nsid);
/*!
* \brief Adds a RRSet to the Answer section of the response.
......
......@@ -149,7 +149,7 @@ static knot_packet_t* create_query_packet(const query_t *query,
knot_edns_set_version(opt_rr, 0);
knot_edns_set_payload(opt_rr, max_size);
if (knot_response_add_opt(packet, opt_rr, 0, 0) != KNOT_EOK) {
if (knot_response_add_opt(packet, opt_rr, 0) != KNOT_EOK) {
ERR("can't set EDNS section\n");
knot_edns_free(&opt_rr);
knot_packet_free(&packet);
......
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