]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
Fix issue #825: interaction between ECS and serve-expired.
authorPhilip Homburg <philip@nlnetlabs.nl>
Tue, 31 Jan 2023 14:16:38 +0000 (15:16 +0100)
committerPhilip Homburg <philip@nlnetlabs.nl>
Tue, 21 Feb 2023 08:20:28 +0000 (09:20 +0100)
edns-subnet/subnetmod.c
services/mesh.c
util/module.h

index 458a89702269593cf57ae4ec475e4600062518d5..5e6d9efd372db7f788e80147710ab79d6b94661a 100644 (file)
@@ -779,6 +779,11 @@ subnetmod_operate(struct module_qstate *qstate, enum module_ev event,
                                &qstate->mesh_info->reply_list->query_reply.client_addr,
                                &sq->ecs_client_in, qstate->env->cfg);
                }
+               else if(qstate->client_addr.ss_family != AF_UNSPEC) {
+                       subnet_option_from_ss(
+                               &qstate->client_addr,
+                               &sq->ecs_client_in, qstate->env->cfg);
+               }
                
                if(sq->ecs_client_in.subnet_validdata == 0) {
                        /* No clients are interested in result or we could not
index 9007b6e08c32fb605f7ce883aca42938797a2c3a..8321a48b20b72b328740090ae1907b416bbea80f 100644 (file)
@@ -803,20 +803,10 @@ static void mesh_schedule_prefetch_subnet(struct mesh_area* mesh,
                        return;
                }
        } else {
-               /* Fake the ECS data from the client's IP */
-               struct ecs_data ecs;
-               memset(&ecs, 0, sizeof(ecs));
-               subnet_option_from_ss(&rep->client_addr, &ecs, mesh->env->cfg);
-               if(ecs.subnet_validdata == 0) {
-                       log_err("prefetch_subnet subnet_option_from_ss: invalid data");
-                       return;
-               }
-               subnet_ecs_opt_list_append(&ecs, &s->s.edns_opts_front_in,
-                       &s->s, s->s.region);
-               if(!s->s.edns_opts_front_in) {
-                       log_err("prefetch_subnet subnet_ecs_opt_list_append: out of memory");
-                       return;
-               }
+               /* Store the client's address. Later in the subnet module,
+                * it is decided whether to include an ECS option or not.
+                */
+               s->s.client_addr =  rep->client_addr;
        }
 #ifdef UNBOUND_DEBUG
        n =
index 013c65b02dcffa593a1b0eb8c781ef16f54d8b8f..3752c8c335b3a46583fd3e7f9a6656915472f84e 100644 (file)
@@ -619,6 +619,10 @@ struct module_qstate {
        /** if this is a validation recursion query that does not get
         * validation itself */
        int is_valrec;
+       /** client network address is needed for the client-subnet option
+        *  when probing, but we want use reply_list in mesh_info, because
+        * we don't want to send a reply. */
+        struct sockaddr_storage client_addr;
 
        /** comm_reply contains server replies */
        struct comm_reply* reply;