]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Explicitly set the RD bit for the mesh query flags when prefetching.
authorYorgos Thessalonikefs <yorgos@nlnetlabs.nl>
Wed, 26 Jun 2024 13:51:58 +0000 (15:51 +0200)
committerYorgos Thessalonikefs <yorgos@nlnetlabs.nl>
Wed, 26 Jun 2024 13:51:58 +0000 (15:51 +0200)
  These queries have no waiting client but they need to be treated as
  recursive.

doc/Changelog
services/mesh.c

index 41fa34523317323867259fb2f954e0557587e004..37d2f8d9903546db1c3c32d8974e4b07d2762ea6 100644 (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
        - Fix pkg-config availability check in dnstap/dnstap.m4 and
          systemd.m4.
index e886c4b92c846ce4f686b99c5a3a8d1319e9993e..9797c75262237978522bcab16a21f1b84be07669 100644 (file)
@@ -413,6 +413,7 @@ void mesh_new_client(struct mesh_area* mesh, struct query_info* qinfo,
        int timeout = mesh->env->cfg->serve_expired?
                mesh->env->cfg->serve_expired_client_timeout:0;
        struct sldns_buffer* r_buffer = rep->c->buffer;
+       uint16_t mesh_flags = qflags&(BIT_RD|BIT_CD);
        if(rep->c->tcp_req_info) {
                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;
        }
        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? */
        if(!s || s->list_select == mesh_no_list) {
                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;
 #endif
                s = mesh_state_create(mesh->env, qinfo, cinfo,
-                       qflags&(BIT_RD|BIT_CD), 0, 0);
+                       mesh_flags, 0, 0);
                if(!s) {
                        log_err("mesh_state_create: out of memory; SERVFAIL");
                        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_noreply = 0;
        int added = 0;
+       uint16_t mesh_flags = qflags&(BIT_RD|BIT_CD);
        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 */
 
@@ -594,7 +596,7 @@ mesh_new_callback(struct mesh_area* mesh, struct query_info* qinfo,
                struct rbnode_type* n;
 #endif
                s = mesh_state_create(mesh->env, qinfo, NULL,
-                       qflags&(BIT_RD|BIT_CD), 0, 0);
+                       mesh_flags, 0, 0);
                if(!s) {
                        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,
        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,
-               qflags&(BIT_RD|BIT_CD), 0, 0);
+               mesh_flags, 0, 0);
 #ifdef UNBOUND_DEBUG
        struct rbnode_type* n;
 #endif
@@ -694,8 +700,7 @@ static void mesh_schedule_prefetch(struct mesh_area* mesh,
                return;
        }
 
-       s = mesh_state_create(mesh->env, qinfo, NULL,
-               qflags&(BIT_RD|BIT_CD), 0, 0);
+       s = mesh_state_create(mesh->env, qinfo, NULL, mesh_flags, 0, 0);
        if(!s) {
                log_err("prefetch mesh_state_create: out of memory");
                return;
@@ -756,14 +761,17 @@ static void mesh_schedule_prefetch_subnet(struct mesh_area* mesh,
 #ifdef UNBOUND_DEBUG
        struct rbnode_type* n;
 #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)) {
                verbose(VERB_ALGO, "Too many queries. dropped prefetch.");
                mesh->stats_dropped ++;
                return;
        }
 
-       s = mesh_state_create(mesh->env, qinfo, NULL,
-               qflags&(BIT_RD|BIT_CD), 0, 0);
+       s = mesh_state_create(mesh->env, qinfo, NULL, mesh_flags, 0, 0);
        if(!s) {
                log_err("prefetch_subnet mesh_state_create: out of memory");
                return;