testframe_init(struct module_env* env, struct cachedb_env* cachedb_env)
{
struct testframe_moddata* d;
- (void)env;
verbose(VERB_ALGO, "testframe_init");
d = (struct testframe_moddata*)calloc(1,
sizeof(struct testframe_moddata));
log_err("out of memory");
return 0;
}
+ cachedb_env->no_internal_lookup = 1;
+
+ if(!edns_register_option(49152,
+ 1 /* bypass cache */,
+ 0 /* no aggregation */, env)) {
+ log_err("cachedb: could not register test opcode");
+ free(d);
+ return 0;
+ }
+
lock_basic_init(&d->lock);
lock_protect(&d->lock, d, sizeof(*d));
return 1;
if(qstate->return_msg->rep->ttl == 0 &&
!qstate->env->cfg->serve_expired)
return 0;
+
+ /* The EDE is added to the out-list so it is encoded in the cached message */
+ if (qstate->env->cfg->ede && qstate->return_msg->rep->reason_bogus != LDNS_EDE_NONE) {
+ edns_opt_list_append_ede(&edns.opt_list_out, qstate->env->scratch,
+ qstate->return_msg->rep->reason_bogus,
+ qstate->return_msg->rep->reason_bogus_str);
+ }
+
if(verbosity >= VERB_ALGO)
log_dns_msg("cachedb encoding", &qstate->return_msg->qinfo,
qstate->return_msg->rep);
{
struct msg_parse* prs;
struct edns_data edns;
+ struct edns_option* ede;
uint64_t timestamp, expiry;
time_t adjust;
size_t lim = sldns_buffer_limit(buf);
if(!qstate->return_msg)
return 0;
+ /* We find the EDE in the in-list after parsing */
+ if (qstate->env->cfg->ede && (ede = edns_opt_list_find(edns.opt_list_in, LDNS_EDNS_EDE))) {
+ if (ede->opt_len >= 2) {
+ qstate->return_msg->rep->reason_bogus =
+ sldns_read_uint16(ede->opt_data);
+ }
+
+ /* allocate space and store the error string and it's size */
+ if (ede->opt_len > 2) {
+ size_t ede_len = ede->opt_len - 2;
+
+ qstate->return_msg->rep->reason_bogus_str = regional_alloc(
+ qstate->region, sizeof(char) * (ede_len));
+
+ memcpy(qstate->return_msg->rep->reason_bogus_str,
+ ede->opt_data+2, ede_len);
+
+ qstate->return_msg->rep->reason_bogus_str_size = ede_len;
+ }
+ }
+
qstate->return_rcode = LDNS_RCODE_NOERROR;
/* see how much of the TTL expired, and remove it */
/* lookup inside unbound's internal cache.
* This does not look for expired entries. */
- if(cachedb_intcache_lookup(qstate)) {
+ if(!ie->no_internal_lookup && cachedb_intcache_lookup(qstate)) {
if(verbosity >= VERB_ALGO) {
if(qstate->return_msg->rep)
log_dns_msg("cachedb internal cache lookup",
m->s.env->cfg->ignore_cd) && rep &&
(rep->security <= sec_status_bogus ||
rep->security == sec_status_secure_sentinel_fail)) {
- char *reason = m->s.env->cfg->val_log_level >= 2
- ? errinf_to_str_bogus(&m->s) : NULL;
-
+ char *reason = NULL;
/* During validation the EDE code can be received via two
* code paths. One code path fills the reply_info EDE, and
* the other fills it in the errinf_strlist. These paths
* the complexity of the validator. At the time of writing
* we make the choice to prefer the EDE from errinf_strlist
* but a compelling reason to do otherwise is just as valid
+ *
+ * Not that we try to tie EDE text (reason_bogus_str) to
+ * the location where we found the reason_bogus.
*/
sldns_ede_code reason_bogus = errinf_to_reason_bogus(&m->s);
if ((reason_bogus == LDNS_EDE_DNSSEC_BOGUS &&
rep->reason_bogus != LDNS_EDE_NONE) ||
reason_bogus == LDNS_EDE_NONE) {
- reason_bogus = rep->reason_bogus;
+
+ reason_bogus = rep->reason_bogus;
+ if (rep->reason_bogus_str_size) {
+ reason = strdup(rep->reason_bogus_str);
+ }
+ }
+
+ if (!reason) {
+ reason = m->s.env->cfg->val_log_level >= 2
+ ? errinf_to_str_bogus(&m->s) : NULL;
}
if(reason_bogus != LDNS_EDE_NONE) {