]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
relay: On new consensus, reconfigure DNS nameservers
authorDavid Goulet <dgoulet@torproject.org>
Wed, 19 Jan 2022 19:37:26 +0000 (14:37 -0500)
committerDavid Goulet <dgoulet@torproject.org>
Tue, 15 Mar 2022 19:26:37 +0000 (15:26 -0400)
This applies only for relays. Previous commit adds two new consensus
parameters that dictate how libevent is configured with DNS resolution.
And so, with a new consensus, we now look at those values in case they
ever change.

Without this, Exit relay would have to HUP or restart to apply any new
Exit DNS consensus parameters.

Related to #40312

Signed-off-by: David Goulet <dgoulet@torproject.org>
src/feature/nodelist/networkstatus.c
src/feature/relay/dns.c
src/feature/relay/dns.h

index 666083ae50e8aa0bea0d0aecc9ee87fce272fb3e..aaddf2331dd582029b334da02ab4b886f1919d8c 100644 (file)
@@ -82,6 +82,7 @@
 #include "feature/nodelist/routerinfo.h"
 #include "feature/nodelist/routerlist.h"
 #include "feature/nodelist/torcert.h"
+#include "feature/relay/dns.h"
 #include "feature/relay/routermode.h"
 #include "lib/crypt_ops/crypto_rand.h"
 #include "lib/crypt_ops/crypto_util.h"
@@ -1706,6 +1707,7 @@ notify_after_networkstatus_changes(void)
   congestion_control_new_consensus_params(c);
   flow_control_new_consensus_params(c);
   hs_service_new_consensus_params(c);
+  dns_new_consensus_params(c);
 
   /* Maintenance of our L2 guard list */
   maintain_layer2_guards();
index 9e504a7cfa31851ad7326111973be54114674157..8467b9c0a43a9258ad622b6ee509cdde09cab549 100644 (file)
@@ -213,6 +213,19 @@ evdns_log_cb(int warn, const char *msg)
   tor_log(severity, LD_EXIT, "eventdns: %s", msg);
 }
 
+/** New consensus just appeared, take appropriate actions if need be. */
+void
+dns_new_consensus_params(const networkstatus_t *ns)
+{
+  (void) ns;
+
+  /* Consensus has parameters for the Exit relay DNS side and so we only reset
+   * the DNS nameservers if we are in server mode. */
+  if (server_mode(get_options())) {
+    dns_reset();
+  }
+}
+
 /** Initialize the DNS subsystem; called by the OR process. */
 int
 dns_init(void)
index d7a815e697051d707b5ac8c6bfdf50015e36bb6c..3f8519bd9796d3963285cfaf07cb37f0e4d7e9d8 100644 (file)
@@ -26,6 +26,7 @@ void dns_reset_correctness_checks(void);
 size_t dns_cache_total_allocation(void);
 void dump_dns_mem_usage(int severity);
 size_t dns_cache_handle_oom(time_t now, size_t min_remove_bytes);
+void dns_new_consensus_params(const networkstatus_t *ns);
 
 /* These functions are only used within the feature/relay module, and don't
  * need stubs. */
@@ -47,6 +48,8 @@ void dns_launch_correctness_checks(void);
   ((void)(severity))
 #define dns_cache_handle_oom(now, bytes) \
   ((void)(now), (void)(bytes), 0)
+#define dns_new_consensus_params(ns) \
+  ((void) ns)
 
 #define connection_dns_remove(conn) \
   STMT_BEGIN                        \