mirror of
https://github.com/NLnetLabs/unbound.git
synced 2026-09-28 12:44:58 +02:00
Show reason when returning EDE_DNSSEC_BOGUS
This commit is contained in:
+6
-2
@@ -1278,8 +1278,12 @@ mesh_send_reply(struct mesh_state* m, int rcode, struct reply_info* rep,
|
||||
(rep->security <= sec_status_bogus ||
|
||||
rep->security == sec_status_secure_sentinel_fail)) {
|
||||
|
||||
EDNS_OPT_APPEND_EDE(&r->edns, m->s.region,
|
||||
LDNS_EDE_DNSSEC_BOGUS, "");
|
||||
char *reason = m->s.env->cfg->val_log_level >= 2
|
||||
? errinf_to_str_bogus(&m->s) : NULL;
|
||||
|
||||
edns_opt_append_ede(&r->edns, m->s.region,
|
||||
LDNS_EDE_DNSSEC_BOGUS, reason);
|
||||
free(reason);
|
||||
}
|
||||
error_encode(r_buffer, rcode, &m->s.qinfo, r->qid,
|
||||
r->qflags, &r->edns);
|
||||
|
||||
@@ -988,6 +988,35 @@ int edns_opt_append(struct edns_data* edns, struct regional* region,
|
||||
return 1;
|
||||
}
|
||||
|
||||
int edns_opt_append_ede(struct edns_data* edns, struct regional* region,
|
||||
sldns_ede_code code, const char *txt)
|
||||
{
|
||||
struct edns_option** prevp;
|
||||
struct edns_option* opt;
|
||||
size_t txt_len = txt ? strlen(txt) : 0;
|
||||
|
||||
/* allocate new element */
|
||||
opt = (struct edns_option*)regional_alloc(region, sizeof(*opt));
|
||||
if(!opt)
|
||||
return 0;
|
||||
opt->next = NULL;
|
||||
opt->opt_code = LDNS_EDNS_EDE;
|
||||
opt->opt_len = txt_len + sizeof(uint16_t);
|
||||
opt->opt_data = regional_alloc(region, txt_len + sizeof(uint16_t));
|
||||
if(!opt->opt_data)
|
||||
return 0;
|
||||
sldns_write_uint16(opt->opt_data, (uint16_t)code);
|
||||
if (txt_len)
|
||||
strncpy(opt->opt_data + 2, txt, txt_len);
|
||||
|
||||
/* append at end of list */
|
||||
prevp = &edns->opt_list;
|
||||
while(*prevp != NULL)
|
||||
prevp = &((*prevp)->next);
|
||||
*prevp = opt;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int edns_opt_list_append(struct edns_option** list, uint16_t code, size_t len,
|
||||
uint8_t* data, struct regional* region)
|
||||
{
|
||||
|
||||
+13
-1
@@ -43,6 +43,7 @@
|
||||
#define UTIL_DATA_MSGREPLY_H
|
||||
#include "util/storage/lruhash.h"
|
||||
#include "util/data/packed_rrset.h"
|
||||
#include "sldns/rrdef.h"
|
||||
struct sldns_buffer;
|
||||
struct comm_reply;
|
||||
struct alloc_cache;
|
||||
@@ -531,7 +532,18 @@ int edns_opt_append(struct edns_data* edns, struct regional* region,
|
||||
edns_opt_append((EDNS), (REGION), LDNS_EDNS_EDE, \
|
||||
sizeof(uint16_t) + sizeof(TXT) - 1, \
|
||||
(void *)&ede); \
|
||||
} while(0);
|
||||
} while(0)
|
||||
|
||||
/**
|
||||
* Append edns EDE option to edns options list
|
||||
* @param edns: the edns data structure to append the edns option to.
|
||||
* @param region: region to allocate the new edns option.
|
||||
* @param code: the EDE code.
|
||||
* @param txt: Additional text for the option
|
||||
* @return false on failure.
|
||||
*/
|
||||
int edns_opt_append_ede(struct edns_data* edns, struct regional* region,
|
||||
sldns_ede_code code, const char *txt);
|
||||
|
||||
/**
|
||||
* Append edns option to edns option list
|
||||
|
||||
Reference in New Issue
Block a user