[tor-commits] [tor/master] Move TestingDirAuthTimeToLearnReachability into dirauth module.

nickm at torproject.org nickm at torproject.org
Fri Jan 17 13:37:45 UTC 2020


commit cde5abfdc6381e618f9649dd00f74d91d65848d7
Author: Nick Mathewson <nickm at torproject.org>
Date:   Thu Dec 19 10:00:25 2019 -0500

    Move TestingDirAuthTimeToLearnReachability into dirauth module.
---
 src/app/config/config.c                 |  1 -
 src/app/config/or_options_st.h          |  5 -----
 src/feature/dirauth/dirauth_config.c    | 12 ++++++------
 src/feature/dirauth/dirauth_options.inc |  5 +++++
 src/feature/dirauth/voteflags.c         |  5 +++--
 src/test/test_options.c                 | 31 +++++++++++++++++--------------
 6 files changed, 31 insertions(+), 28 deletions(-)

diff --git a/src/app/config/config.c b/src/app/config/config.c
index 262013de4..3e1549b70 100644
--- a/src/app/config/config.c
+++ b/src/app/config/config.c
@@ -392,7 +392,6 @@ static const config_var_t option_vars_[] = {
   V(DisableOOSCheck,             BOOL,     "1"),
   V(DisableNetwork,              BOOL,     "0"),
   V(DirAllowPrivateAddresses,    BOOL,     "0"),
-  V(TestingAuthDirTimeToLearnReachability, INTERVAL, "30 minutes"),
   OBSOLETE("DirListenAddress"),
   V(DirPolicy,                   LINELIST, NULL),
   VPORT(DirPort),
diff --git a/src/app/config/or_options_st.h b/src/app/config/or_options_st.h
index 2796aaba7..a38eae40f 100644
--- a/src/app/config/or_options_st.h
+++ b/src/app/config/or_options_st.h
@@ -686,11 +686,6 @@ struct or_options_t {
       voting. Only altered on testing networks. */
   int TestingV3AuthVotingStartOffset;
 
-  /** If an authority has been around for less than this amount of time, it
-   * does not believe its reachability information is accurate.  Only
-   * altered on testing networks. */
-  int TestingAuthDirTimeToLearnReachability;
-
   /** Clients don't download any descriptor this recent, since it will
    * probably not have propagated to enough caches.  Only altered on testing
    * networks. */
diff --git a/src/feature/dirauth/dirauth_config.c b/src/feature/dirauth/dirauth_config.c
index e3f06e9e8..4a3f56996 100644
--- a/src/feature/dirauth/dirauth_config.c
+++ b/src/feature/dirauth/dirauth_config.c
@@ -213,12 +213,6 @@ options_validate_dirauth_testing(const or_options_t *old_options,
   if (!authdir_mode(options))
     return 0;
 
-  if (options->TestingAuthDirTimeToLearnReachability < 0) {
-    REJECT("TestingAuthDirTimeToLearnReachability must be non-negative.");
-  } else if (options->TestingAuthDirTimeToLearnReachability > 2*60*60) {
-    COMPLAIN("TestingAuthDirTimeToLearnReachability is insanely high.");
-  }
-
   if (!authdir_mode_v3(options))
     return 0;
 
@@ -443,6 +437,12 @@ dirauth_options_validate(const void *arg, char **msg)
   t = format_recommended_version_list(options->RecommendedServerVersions, 1);
   tor_free(t);
 
+  if (options->TestingAuthDirTimeToLearnReachability < 0) {
+    REJECT("TestingAuthDirTimeToLearnReachability must be non-negative.");
+  } else if (options->TestingAuthDirTimeToLearnReachability > 2*60*60) {
+    COMPLAIN("TestingAuthDirTimeToLearnReachability is insanely high.");
+  }
+
   return 0;
 }
 
diff --git a/src/feature/dirauth/dirauth_options.inc b/src/feature/dirauth/dirauth_options.inc
index d5ae09cf2..e1550a6e9 100644
--- a/src/feature/dirauth/dirauth_options.inc
+++ b/src/feature/dirauth/dirauth_options.inc
@@ -65,6 +65,11 @@ CONF_VAR(RecommendedClientVersions, LINELIST, 0, NULL)
 /** Which versions of tor should we tell users to run on relays? */
 CONF_VAR(RecommendedServerVersions, LINELIST, 0, NULL)
 
+/** If an authority has been around for less than this amount of time, it
+ * does not believe its reachability information is accurate.  Only
+ * altered on testing networks. */
+CONF_VAR(TestingAuthDirTimeToLearnReachability, INTERVAL, 0, "30 minutes")
+
 /** Boolean: is this an authoritative directory that's willing to recommend
  * versions? */
 CONF_VAR(VersioningAuthoritativeDirectory, BOOL, 0, "0")
diff --git a/src/feature/dirauth/voteflags.c b/src/feature/dirauth/voteflags.c
index 97cb2eb72..757bc3594 100644
--- a/src/feature/dirauth/voteflags.c
+++ b/src/feature/dirauth/voteflags.c
@@ -460,8 +460,9 @@ dirserv_get_flag_thresholds_line(void)
 int
 running_long_enough_to_decide_unreachable(void)
 {
-  return time_of_process_start
-    + get_options()->TestingAuthDirTimeToLearnReachability < approx_time();
+  const dirauth_options_t *opts = dirauth_get_options();
+  return time_of_process_start +
+    opts->TestingAuthDirTimeToLearnReachability < approx_time();
 }
 
 /** Each server needs to have passed a reachability test no more
diff --git a/src/test/test_options.c b/src/test/test_options.c
index 346520716..10e79c48d 100644
--- a/src/test/test_options.c
+++ b/src/test/test_options.c
@@ -3851,14 +3851,15 @@ test_options_validate__testing_options(void *ignored)
   options_test_data_t *tdata = NULL;
   setup_capture_of_logs(LOG_WARN);
 
-#define TEST_TESTING_OPTION(name, low_val, high_val, err_low, EXTRA_OPT_STR) \
+#define TEST_TESTING_OPTION(name, accessor, \
+                            low_val, high_val, err_low, EXTRA_OPT_STR)  \
   STMT_BEGIN                                                            \
     free_options_test_data(tdata);                                      \
   tdata = get_options_test_data(EXTRA_OPT_STR                           \
                                 VALID_DIR_AUTH                          \
                                 "TestingTorNetwork 1\n"                 \
                                 );                                      \
-  tdata->opt-> name = low_val;                                       \
+  accessor(tdata->opt)->name = low_val;                                 \
   ret = options_validate(NULL, tdata->opt,  &msg);            \
   tt_int_op(ret, OP_EQ, -1);                                            \
   tt_str_op(msg, OP_EQ, #name " " err_low);                \
@@ -3869,7 +3870,7 @@ test_options_validate__testing_options(void *ignored)
                                 VALID_DIR_AUTH                          \
                                 "TestingTorNetwork 1\n"                 \
                                 );                                      \
-  tdata->opt->  name = high_val;                                      \
+  accessor(tdata->opt)->name = high_val;                                \
   mock_clean_saved_logs();                                              \
   ret = options_validate(NULL, tdata->opt,  &msg);            \
   tt_int_op(ret, OP_EQ, 0);                                             \
@@ -3878,30 +3879,32 @@ test_options_validate__testing_options(void *ignored)
   tor_free(msg); \
   STMT_END
 
-  TEST_TESTING_OPTION(TestingAuthDirTimeToLearnReachability, -1, 8000,
+  TEST_TESTING_OPTION(TestingAuthDirTimeToLearnReachability,
+                      get_dirauth_options, -1, 8000,
                       "must be non-negative.", ENABLE_AUTHORITY_V3);
-  TEST_TESTING_OPTION(TestingAuthDirTimeToLearnReachability, -1, 8000,
+  TEST_TESTING_OPTION(TestingAuthDirTimeToLearnReachability,
+                      get_dirauth_options, -1, 8000,
                       "must be non-negative.", ENABLE_AUTHORITY_BRIDGE);
 
-  TEST_TESTING_OPTION(TestingEstimatedDescriptorPropagationTime, -1, 3601,
+  TEST_TESTING_OPTION(TestingEstimatedDescriptorPropagationTime, , -1, 3601,
                       "must be non-negative.", "");
-  TEST_TESTING_OPTION(TestingClientMaxIntervalWithoutRequest, -1, 3601,
+  TEST_TESTING_OPTION(TestingClientMaxIntervalWithoutRequest, , -1, 3601,
                       "is way too low.", "");
-  TEST_TESTING_OPTION(TestingDirConnectionMaxStall, 1, 3601,
+  TEST_TESTING_OPTION(TestingDirConnectionMaxStall, , 1, 3601,
                       "is way too low.", "");
 
-  TEST_TESTING_OPTION(TestingEstimatedDescriptorPropagationTime, -1, 3601,
+  TEST_TESTING_OPTION(TestingEstimatedDescriptorPropagationTime, , -1, 3601,
                       "must be non-negative.", ENABLE_AUTHORITY_V3);
-  TEST_TESTING_OPTION(TestingClientMaxIntervalWithoutRequest, -1, 3601,
+  TEST_TESTING_OPTION(TestingClientMaxIntervalWithoutRequest, , -1, 3601,
                       "is way too low.", ENABLE_AUTHORITY_V3);
-  TEST_TESTING_OPTION(TestingDirConnectionMaxStall, 1, 3601,
+  TEST_TESTING_OPTION(TestingDirConnectionMaxStall, , 1, 3601,
                       "is way too low.", ENABLE_AUTHORITY_V3);
 
-  TEST_TESTING_OPTION(TestingEstimatedDescriptorPropagationTime, -1, 3601,
+  TEST_TESTING_OPTION(TestingEstimatedDescriptorPropagationTime, , -1, 3601,
                       "must be non-negative.", ENABLE_AUTHORITY_BRIDGE);
-  TEST_TESTING_OPTION(TestingClientMaxIntervalWithoutRequest, -1, 3601,
+  TEST_TESTING_OPTION(TestingClientMaxIntervalWithoutRequest, , -1, 3601,
                       "is way too low.", ENABLE_AUTHORITY_BRIDGE);
-  TEST_TESTING_OPTION(TestingDirConnectionMaxStall, 1, 3601,
+  TEST_TESTING_OPTION(TestingDirConnectionMaxStall, , 1, 3601,
                       "is way too low.", ENABLE_AUTHORITY_BRIDGE);
 
   free_options_test_data(tdata);





More information about the tor-commits mailing list