]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix edns client subnet to add the option based on the option list,
authorW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Mon, 28 Feb 2022 13:39:48 +0000 (14:39 +0100)
committerW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Mon, 28 Feb 2022 13:39:48 +0000 (14:39 +0100)
  so that it is not state dependent, after the state fix of #605 for
  double EDNS options.

doc/Changelog
edns-subnet/subnetmod.c

index f3d92592729fc038d7d405b88d8a5c35b6cac1f4..fe8ef0d838c547c3c47917a0a00d840376a54a77 100644 (file)
@@ -5,6 +5,9 @@
 28 February 2022: Wouter
        - Fix #633: Document unix domain socket support for unbound-control.
        - Fix for #633: updated fix with new text.
+       - Fix edns client subnet to add the option based on the option list,
+         so that it is not state dependent, after the state fix of #605 for
+         double EDNS options.
 
 25 February 2022: Wouter
        - Fix to detect that no IPv6 support means that IPv6 addresses are
index 81f0bf3ade55a6b31c5b19f7b2744f97a95b065a..3c723bcc3d18c7197555517dac6ae9b54ce63f73 100644 (file)
@@ -162,17 +162,21 @@ int ecs_whitelist_check(struct query_info* qinfo,
                /* Address on whitelist or client query contains ECS option, we
                 * want to sent out ECS. Only add option if it is not already
                 * set. */
-               if(!(sq->subnet_sent)) {
+               if(!edns_opt_list_find(qstate->edns_opts_back_out,
+                       qstate->env->cfg->client_subnet_opcode)) {
                        ecs_opt_list_append(&sq->ecs_server_out,
                                &qstate->edns_opts_back_out, qstate);
-                       sq->subnet_sent = 1;
                }
+               sq->subnet_sent = 1;
        }
-       else if(sq->subnet_sent) {
+       else {
                /* Outgoing ECS option is set, but we don't want to sent it to
                 * this address, remove option. */
-               edns_opt_list_remove(&qstate->edns_opts_back_out,
-                       qstate->env->cfg->client_subnet_opcode);
+               if(!edns_opt_list_find(qstate->edns_opts_back_out,
+                       qstate->env->cfg->client_subnet_opcode)) {
+                       edns_opt_list_remove(&qstate->edns_opts_back_out,
+                               qstate->env->cfg->client_subnet_opcode);
+               }
                sq->subnet_sent = 0;
        }
        return 1;