]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Vote on the StaleDesc flag from prop293
authorNick Mathewson <nickm@torproject.org>
Sun, 25 Nov 2018 15:05:13 +0000 (10:05 -0500)
committerNick Mathewson <nickm@torproject.org>
Sun, 25 Nov 2018 15:05:13 +0000 (10:05 -0500)
The StaleDesc flag tells relays that they need to upload a new
descriptor soon, or they will drop out of the consensus.

src/feature/dirauth/dirvote.c
src/feature/dirauth/voteflags.c
src/feature/dirauth/voteflags.h
src/feature/dirparse/ns_parse.c
src/feature/nodelist/fmt_routerstatus.c
src/feature/nodelist/routerstatus_st.h

index 066a9e6e8adb693a80cfbb178a97071b0734a1d4..aa4242f678b4084b1fe3b78123e4f3705851a597 100644 (file)
@@ -4620,7 +4620,8 @@ dirserv_generate_networkstatus_vote_obj(crypto_pk_t *private_key,
 
   v3_out->known_flags = smartlist_new();
   smartlist_split_string(v3_out->known_flags,
-                         "Authority Exit Fast Guard Stable V2Dir Valid HSDir",
+                         "Authority Exit Fast Guard Stable V2Dir Valid HSDir "
+                         "StaleDesc",
                          0, SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
   if (vote_on_reachability)
     smartlist_add_strdup(v3_out->known_flags, "Running");
index 4a24dcb50d28af268133c7e1df0104be6743ed98..5adf21ad11316e1a7891a85d99efdeca16069da4 100644 (file)
@@ -593,6 +593,10 @@ set_routerstatus_from_routerinfo(routerstatus_t *rs,
   rs->or_port = ri->or_port;
   rs->dir_port = ri->dir_port;
   rs->is_v2_dir = ri->supports_tunnelled_dir_requests;
+
+  rs->is_staledesc =
+    (ri->cache_info.published_on + DESC_IS_STALE_INTERVAL) < now;
+
   if (options->AuthDirHasIPv6Connectivity == 1 &&
       !tor_addr_is_null(&ri->ipv6_addr) &&
       node->last_reachable6 >= now - REACHABLE_TIMEOUT) {
index 2f0e061ea426b680e9fa907ac951e1cfb7383371..743a666cc8308155c093a590f48b4b6d2f6f4c48 100644 (file)
@@ -25,6 +25,9 @@ void set_routerstatus_from_routerinfo(routerstatus_t *rs,
 void dirserv_compute_performance_thresholds(digestmap_t *omit_as_sybil);
 
 #ifdef VOTEFLAGS_PRIVATE
+/** Any descriptor older than this age causes the authorities to set the
+ * StaleDesc flag. */
+#define DESC_IS_STALE_INTERVAL (18*60*60)
 STATIC void dirserv_set_routerstatus_testing(routerstatus_t *rs);
 #endif
 
index 3fccec15407bf39482cc9984102b49ce0bbf8f1c..e0cdb2d46d4a230f65dae906c0f93cfefc9eba77 100644 (file)
@@ -434,6 +434,8 @@ routerstatus_parse_entry_from_string(memarea_t *area,
         rs->is_hs_dir = 1;
       } else if (!strcmp(tok->args[i], "V2Dir")) {
         rs->is_v2_dir = 1;
+      } else if (!strcmp(tok->args[i], "StaleDesc")) {
+        rs->is_staledesc = 1;
       }
     }
     /* These are implied true by having been included in a consensus made
index e70aeb295031390031ba19ca533fec2b225dac06..b1d4a480388af9363b35bc2fa8eff004b13cd001 100644 (file)
@@ -135,7 +135,7 @@ routerstatus_format_entry(const routerstatus_t *rs, const char *version,
     goto done;
 
   smartlist_add_asprintf(chunks,
-                   "s%s%s%s%s%s%s%s%s%s%s\n",
+                   "s%s%s%s%s%s%s%s%s%s%s%s\n",
                   /* These must stay in alphabetical order. */
                    rs->is_authority?" Authority":"",
                    rs->is_bad_exit?" BadExit":"",
@@ -145,6 +145,7 @@ routerstatus_format_entry(const routerstatus_t *rs, const char *version,
                    rs->is_hs_dir?" HSDir":"",
                    rs->is_flagged_running?" Running":"",
                    rs->is_stable?" Stable":"",
+                   rs->is_staledesc?" StaleDesc":"",
                    rs->is_v2_dir?" V2Dir":"",
                    rs->is_valid?" Valid":"");
 
index 714aa27435b1cd6138f058d52a92a0b52739e851..ea06587799d818226242a17a7dd949c18c9971fb 100644 (file)
@@ -47,6 +47,8 @@ struct routerstatus_t {
   unsigned int is_v2_dir:1; /** True iff this router publishes an open DirPort
                              * or it claims to accept tunnelled dir requests.
                              */
+  unsigned int is_staledesc:1; /** True iff the authorities think this router
+                                * should upload a new descriptor soon. */
 
   unsigned int has_bandwidth:1; /**< The vote/consensus had bw info */
   unsigned int has_exitsummary:1; /**< The vote/consensus had exit summaries */