mirror of
https://github.com/NLnetLabs/unbound.git
synced 2025-12-23 16:20:26 -05:00
- Fix to use the now cached EDE, if any, for CD_bit queries.
This commit is contained in:
parent
8aec671860
commit
2cc9563cf8
3 changed files with 41 additions and 4 deletions
|
|
@ -475,7 +475,8 @@ answer_norec_from_cache(struct worker* worker, struct query_info* qinfo,
|
||||||
uint16_t udpsize = edns->udp_size;
|
uint16_t udpsize = edns->udp_size;
|
||||||
int secure = 0;
|
int secure = 0;
|
||||||
time_t timenow = *worker->env.now;
|
time_t timenow = *worker->env.now;
|
||||||
int must_validate = (!(flags&BIT_CD) || worker->env.cfg->ignore_cd)
|
int has_cd_bit = (flags&BIT_CD);
|
||||||
|
int must_validate = (!has_cd_bit || worker->env.cfg->ignore_cd)
|
||||||
&& worker->env.need_to_validate;
|
&& worker->env.need_to_validate;
|
||||||
struct dns_msg *msg = NULL;
|
struct dns_msg *msg = NULL;
|
||||||
struct delegpt *dp;
|
struct delegpt *dp;
|
||||||
|
|
@ -546,6 +547,16 @@ answer_norec_from_cache(struct worker* worker, struct query_info* qinfo,
|
||||||
worker->env.now_tv))
|
worker->env.now_tv))
|
||||||
return 0;
|
return 0;
|
||||||
msg->rep->flags |= BIT_QR|BIT_RA;
|
msg->rep->flags |= BIT_QR|BIT_RA;
|
||||||
|
/* Attach the cached EDE (RFC8914) if CD bit is set and the answer is
|
||||||
|
* bogus. */
|
||||||
|
if(worker->env.cfg->ede && has_cd_bit &&
|
||||||
|
(check_delegation_secure(msg->rep) == sec_status_bogus ||
|
||||||
|
check_delegation_secure(msg->rep) == sec_status_secure_sentinel_fail) &&
|
||||||
|
msg->rep->reason_bogus != LDNS_EDE_NONE) {
|
||||||
|
edns_opt_list_append_ede(&edns->opt_list_out,
|
||||||
|
worker->scratchpad, msg->rep->reason_bogus,
|
||||||
|
msg->rep->reason_bogus_str);
|
||||||
|
}
|
||||||
if(!reply_info_answer_encode(&msg->qinfo, msg->rep, id, flags,
|
if(!reply_info_answer_encode(&msg->qinfo, msg->rep, id, flags,
|
||||||
repinfo->c->buffer, 0, 1, worker->scratchpad,
|
repinfo->c->buffer, 0, 1, worker->scratchpad,
|
||||||
udpsize, edns, (int)(edns->bits & EDNS_DO), secure)) {
|
udpsize, edns, (int)(edns->bits & EDNS_DO), secure)) {
|
||||||
|
|
@ -636,7 +647,8 @@ answer_from_cache(struct worker* worker, struct query_info* qinfo,
|
||||||
uint16_t udpsize = edns->udp_size;
|
uint16_t udpsize = edns->udp_size;
|
||||||
struct reply_info* encode_rep = rep;
|
struct reply_info* encode_rep = rep;
|
||||||
struct reply_info* partial_rep = *partial_repp;
|
struct reply_info* partial_rep = *partial_repp;
|
||||||
int must_validate = (!(flags&BIT_CD) || worker->env.cfg->ignore_cd)
|
int has_cd_bit = (flags&BIT_CD);
|
||||||
|
int must_validate = (!has_cd_bit || worker->env.cfg->ignore_cd)
|
||||||
&& worker->env.need_to_validate;
|
&& worker->env.need_to_validate;
|
||||||
*partial_repp = NULL; /* avoid accidental further pass */
|
*partial_repp = NULL; /* avoid accidental further pass */
|
||||||
|
|
||||||
|
|
@ -768,6 +780,15 @@ answer_from_cache(struct worker* worker, struct query_info* qinfo,
|
||||||
EDNS_OPT_LIST_APPEND_EDE(&edns->opt_list_out,
|
EDNS_OPT_LIST_APPEND_EDE(&edns->opt_list_out,
|
||||||
worker->scratchpad, LDNS_EDE_STALE_ANSWER, "");
|
worker->scratchpad, LDNS_EDE_STALE_ANSWER, "");
|
||||||
}
|
}
|
||||||
|
/* Attach the cached EDE (RFC8914) if CD bit is set and the
|
||||||
|
* answer is bogus. */
|
||||||
|
if(*is_secure_answer == 0 &&
|
||||||
|
worker->env.cfg->ede && has_cd_bit &&
|
||||||
|
encode_rep->reason_bogus != LDNS_EDE_NONE) {
|
||||||
|
edns_opt_list_append_ede(&edns->opt_list_out,
|
||||||
|
worker->scratchpad, encode_rep->reason_bogus,
|
||||||
|
encode_rep->reason_bogus_str);
|
||||||
|
}
|
||||||
if(!reply_info_answer_encode(qinfo, encode_rep, id, flags,
|
if(!reply_info_answer_encode(qinfo, encode_rep, id, flags,
|
||||||
repinfo->c->buffer, timenow, 1, worker->scratchpad,
|
repinfo->c->buffer, timenow, 1, worker->scratchpad,
|
||||||
udpsize, edns, (int)(edns->bits & EDNS_DO),
|
udpsize, edns, (int)(edns->bits & EDNS_DO),
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
altogether) before giving up on attaching EDE options.
|
altogether) before giving up on attaching EDE options.
|
||||||
- More braces and formatting for Fix for EDNS EDE size calculation to
|
- More braces and formatting for Fix for EDNS EDE size calculation to
|
||||||
avoid future bugs.
|
avoid future bugs.
|
||||||
|
- Fix to use the now cached EDE, if any, for CD_bit queries.
|
||||||
|
|
||||||
1 August 2023: Wouter
|
1 August 2023: Wouter
|
||||||
- Fix for EDNS EDE size calculation.
|
- Fix for EDNS EDE size calculation.
|
||||||
|
|
|
||||||
17
testdata/ede.tdir/ede.test
vendored
17
testdata/ede.tdir/ede.test
vendored
|
|
@ -84,5 +84,20 @@ then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# TODO EDE with CD bit set (EDE but no SERVFAIL) for a cached answer
|
# EDE with CD bit set (EDE but no SERVFAIL) for a cached answer
|
||||||
|
# Same test as above
|
||||||
|
dig @127.0.0.1 -p $UNBOUND_PORT cd.dnskey-failures.test +cd > cd_bit_ede.txt
|
||||||
|
|
||||||
|
if ! grep -q -e "NXDOMAIN" cd_bit_ede.txt
|
||||||
|
then
|
||||||
|
echo "No NXDOMAIN reply with CD bit set for cached answer"
|
||||||
|
cat cd_bit_ede.txt
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if ! grep -q -e "OPT=15: 00 09" -e "EDE: 9" cd_bit_ede.txt
|
||||||
|
then
|
||||||
|
echo "No EDE attached with CD bit set for cached answer"
|
||||||
|
cat cd_bit_ede.txt
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
# TODO DNSSEC indeterminate when implemented
|
# TODO DNSSEC indeterminate when implemented
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue