[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor] 02/03: relay: On new consensus, reconfigure DNS nameservers



This is an automated email from the git hooks/post-receive script.

dgoulet pushed a commit to branch main
in repository tor.

commit 2cdb5ceb1dfdeead331f6f65b8aa67791d91f94d
Author: David Goulet <dgoulet@xxxxxxxxxxxxxx>
AuthorDate: Wed Jan 19 14:37:26 2022 -0500

    relay: On new consensus, reconfigure DNS nameservers
    
    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@xxxxxxxxxxxxxx>
---
 src/feature/nodelist/networkstatus.c |  2 ++
 src/feature/relay/dns.c              | 13 +++++++++++++
 src/feature/relay/dns.h              |  3 +++
 3 files changed, 18 insertions(+)

diff --git a/src/feature/nodelist/networkstatus.c b/src/feature/nodelist/networkstatus.c
index 666083ae50..aaddf2331d 100644
--- a/src/feature/nodelist/networkstatus.c
+++ b/src/feature/nodelist/networkstatus.c
@@ -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();
diff --git a/src/feature/relay/dns.c b/src/feature/relay/dns.c
index 9e504a7cfa..8467b9c0a4 100644
--- a/src/feature/relay/dns.c
+++ b/src/feature/relay/dns.c
@@ -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)
diff --git a/src/feature/relay/dns.h b/src/feature/relay/dns.h
index d7a815e697..3f8519bd97 100644
--- a/src/feature/relay/dns.h
+++ b/src/feature/relay/dns.h
@@ -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                        \

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits