- Explicitly set the RD bit for the mesh query flags when prefetching.

These queries have no waiting client but they need to be treated as
  recursive.
This commit is contained in:
Yorgos Thessalonikefs 2024-06-26 15:51:58 +02:00
parent b67fbb69e7
commit 70f73a33b3
2 changed files with 22 additions and 9 deletions

View file

@ -1,3 +1,8 @@
26 June 2024: Yorgos
- Explicitly set the RD bit for the mesh query flags when prefetching.
These queries have no waiting client but they need to be treated as
recursive.
21 June 2024: Yorgos 21 June 2024: Yorgos
- Fix pkg-config availability check in dnstap/dnstap.m4 and - Fix pkg-config availability check in dnstap/dnstap.m4 and
systemd.m4. systemd.m4.

View file

@ -413,6 +413,7 @@ void mesh_new_client(struct mesh_area* mesh, struct query_info* qinfo,
int timeout = mesh->env->cfg->serve_expired? int timeout = mesh->env->cfg->serve_expired?
mesh->env->cfg->serve_expired_client_timeout:0; mesh->env->cfg->serve_expired_client_timeout:0;
struct sldns_buffer* r_buffer = rep->c->buffer; struct sldns_buffer* r_buffer = rep->c->buffer;
uint16_t mesh_flags = qflags&(BIT_RD|BIT_CD);
if(rep->c->tcp_req_info) { if(rep->c->tcp_req_info) {
r_buffer = rep->c->tcp_req_info->spool_buffer; r_buffer = rep->c->tcp_req_info->spool_buffer;
} }
@ -425,7 +426,7 @@ void mesh_new_client(struct mesh_area* mesh, struct query_info* qinfo,
return; return;
} }
if(!unique) if(!unique)
s = mesh_area_find(mesh, cinfo, qinfo, qflags&(BIT_RD|BIT_CD), 0, 0); s = mesh_area_find(mesh, cinfo, qinfo, mesh_flags, 0, 0);
/* does this create a new reply state? */ /* does this create a new reply state? */
if(!s || s->list_select == mesh_no_list) { if(!s || s->list_select == mesh_no_list) {
if(!mesh_make_new_space(mesh, rep->c->buffer)) { if(!mesh_make_new_space(mesh, rep->c->buffer)) {
@ -453,7 +454,7 @@ void mesh_new_client(struct mesh_area* mesh, struct query_info* qinfo,
struct rbnode_type* n; struct rbnode_type* n;
#endif #endif
s = mesh_state_create(mesh->env, qinfo, cinfo, s = mesh_state_create(mesh->env, qinfo, cinfo,
qflags&(BIT_RD|BIT_CD), 0, 0); mesh_flags, 0, 0);
if(!s) { if(!s) {
log_err("mesh_state_create: out of memory; SERVFAIL"); log_err("mesh_state_create: out of memory; SERVFAIL");
if(!inplace_cb_reply_servfail_call(mesh->env, qinfo, NULL, NULL, if(!inplace_cb_reply_servfail_call(mesh->env, qinfo, NULL, NULL,
@ -583,8 +584,9 @@ mesh_new_callback(struct mesh_area* mesh, struct query_info* qinfo,
int was_detached = 0; int was_detached = 0;
int was_noreply = 0; int was_noreply = 0;
int added = 0; int added = 0;
uint16_t mesh_flags = qflags&(BIT_RD|BIT_CD);
if(!unique) if(!unique)
s = mesh_area_find(mesh, NULL, qinfo, qflags&(BIT_RD|BIT_CD), 0, 0); s = mesh_area_find(mesh, NULL, qinfo, mesh_flags, 0, 0);
/* there are no limits on the number of callbacks */ /* there are no limits on the number of callbacks */
@ -594,7 +596,7 @@ mesh_new_callback(struct mesh_area* mesh, struct query_info* qinfo,
struct rbnode_type* n; struct rbnode_type* n;
#endif #endif
s = mesh_state_create(mesh->env, qinfo, NULL, s = mesh_state_create(mesh->env, qinfo, NULL,
qflags&(BIT_RD|BIT_CD), 0, 0); mesh_flags, 0, 0);
if(!s) { if(!s) {
return 0; return 0;
} }
@ -673,8 +675,12 @@ static void mesh_schedule_prefetch(struct mesh_area* mesh,
struct query_info* qinfo, uint16_t qflags, time_t leeway, int run, struct query_info* qinfo, uint16_t qflags, time_t leeway, int run,
int rpz_passthru) int rpz_passthru)
{ {
/* Explicitly set the BIT_RD regardless of the client's flags. This is
* for a prefetch query (no client attached) but it needs to be treated
* as a recursion query. */
uint16_t mesh_flags = BIT_RD|(qflags&BIT_CD);
struct mesh_state* s = mesh_area_find(mesh, NULL, qinfo, struct mesh_state* s = mesh_area_find(mesh, NULL, qinfo,
qflags&(BIT_RD|BIT_CD), 0, 0); mesh_flags, 0, 0);
#ifdef UNBOUND_DEBUG #ifdef UNBOUND_DEBUG
struct rbnode_type* n; struct rbnode_type* n;
#endif #endif
@ -694,8 +700,7 @@ static void mesh_schedule_prefetch(struct mesh_area* mesh,
return; return;
} }
s = mesh_state_create(mesh->env, qinfo, NULL, s = mesh_state_create(mesh->env, qinfo, NULL, mesh_flags, 0, 0);
qflags&(BIT_RD|BIT_CD), 0, 0);
if(!s) { if(!s) {
log_err("prefetch mesh_state_create: out of memory"); log_err("prefetch mesh_state_create: out of memory");
return; return;
@ -756,14 +761,17 @@ static void mesh_schedule_prefetch_subnet(struct mesh_area* mesh,
#ifdef UNBOUND_DEBUG #ifdef UNBOUND_DEBUG
struct rbnode_type* n; struct rbnode_type* n;
#endif #endif
/* Explicitly set the BIT_RD regardless of the client's flags. This is
* for a prefetch query (no client attached) but it needs to be treated
* as a recursion query. */
uint16_t mesh_flags = BIT_RD|(qflags&BIT_CD);
if(!mesh_make_new_space(mesh, NULL)) { if(!mesh_make_new_space(mesh, NULL)) {
verbose(VERB_ALGO, "Too many queries. dropped prefetch."); verbose(VERB_ALGO, "Too many queries. dropped prefetch.");
mesh->stats_dropped ++; mesh->stats_dropped ++;
return; return;
} }
s = mesh_state_create(mesh->env, qinfo, NULL, s = mesh_state_create(mesh->env, qinfo, NULL, mesh_flags, 0, 0);
qflags&(BIT_RD|BIT_CD), 0, 0);
if(!s) { if(!s) {
log_err("prefetch_subnet mesh_state_create: out of memory"); log_err("prefetch_subnet mesh_state_create: out of memory");
return; return;