[tor-commits] [tor/master] Make dirauths vote the Sybil flag when other flags are zeroed out

asn at torproject.org asn at torproject.org
Wed Feb 24 10:44:41 UTC 2021


commit 88559aca2d9487a9b101bb563b1ddf857a013962
Author: Neel Chauhan <neel at neelc.org>
Date:   Fri Feb 12 15:43:48 2021 -0800

    Make dirauths vote the Sybil flag when other flags are zeroed out
---
 changes/ticket40255                     |  5 +++++
 src/feature/dirauth/dirvote.c           | 10 +++++++---
 src/feature/dirparse/ns_parse.c         |  2 ++
 src/feature/nodelist/fmt_routerstatus.c |  3 ++-
 src/feature/nodelist/routerstatus_st.h  |  1 +
 5 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/changes/ticket40255 b/changes/ticket40255
new file mode 100644
index 0000000000..026c64f697
--- /dev/null
+++ b/changes/ticket40255
@@ -0,0 +1,5 @@
+  o Major features (directory authority, sybil):
+    - When voting for a relay with a Sybil-like appearance, add the Sybil
+      flag when clearing out the other flags. This lets a relay operator
+      know why their relay hasn't been voted on. Closes ticket 40255.
+      Patch by Neel Chauhan.
diff --git a/src/feature/dirauth/dirvote.c b/src/feature/dirauth/dirvote.c
index 0f62a8bbf5..430589b2ae 100644
--- a/src/feature/dirauth/dirvote.c
+++ b/src/feature/dirauth/dirvote.c
@@ -4542,13 +4542,16 @@ routers_make_ed_keys_unique(smartlist_t *routers)
   } SMARTLIST_FOREACH_END(ri);
 }
 
-/** Routerstatus <b>rs</b> is part of a group of routers that are on
- * too narrow an IP-space. Clear out its flags since we don't want it be used
+/** Routerstatus <b>rs</b> is part of a group of routers that are on too
+ * narrow an IP-space. Clear out its flags since we don't want it be used
  * because of its Sybil-like appearance.
  *
  * Leave its BadExit flag alone though, since if we think it's a bad exit,
  * we want to vote that way in case all the other authorities are voting
  * Running and Exit.
+ *
+ * Also set the Sybil flag in order to let a relay operator know that's
+ * why their relay hasn't been voted on.
  */
 static void
 clear_status_flags_on_sybil(routerstatus_t *rs)
@@ -4556,6 +4559,7 @@ clear_status_flags_on_sybil(routerstatus_t *rs)
   rs->is_authority = rs->is_exit = rs->is_stable = rs->is_fast =
     rs->is_flagged_running = rs->is_named = rs->is_valid =
     rs->is_hs_dir = rs->is_v2_dir = rs->is_possible_guard = 0;
+  rs->is_sybil = 1;
   /* FFFF we might want some mechanism to check later on if we
    * missed zeroing any flags: it's easy to add a new flag but
    * forget to add it to this clause. */
@@ -4570,6 +4574,7 @@ const char DIRVOTE_UNIVERSAL_FLAGS[] =
   "HSDir "
   "Stable "
   "StaleDesc "
+  "Sybil "
   "V2Dir "
   "Valid";
 /** Space-separated list of all flags that we may or may not vote on,
@@ -4749,7 +4754,6 @@ dirserv_generate_networkstatus_vote_obj(crypto_pk_t *private_key,
     dirserv_read_measured_bandwidths(options->V3BandwidthsFile,
                                      routerstatuses, bw_file_headers,
                                      bw_file_digest256);
-
   } else {
     /*
      * No bandwidths file; clear the measured bandwidth cache in case we had
diff --git a/src/feature/dirparse/ns_parse.c b/src/feature/dirparse/ns_parse.c
index 138d248b08..8c5f449b89 100644
--- a/src/feature/dirparse/ns_parse.c
+++ b/src/feature/dirparse/ns_parse.c
@@ -446,6 +446,8 @@ routerstatus_parse_entry_from_string(memarea_t *area,
         rs->is_v2_dir = 1;
       } else if (!strcmp(tok->args[i], "StaleDesc")) {
         rs->is_staledesc = 1;
+      } else if (!strcmp(tok->args[i], "Sybil")) {
+        rs->is_sybil = 1;
       }
     }
     /* These are implied true by having been included in a consensus made
diff --git a/src/feature/nodelist/fmt_routerstatus.c b/src/feature/nodelist/fmt_routerstatus.c
index 252b2e61fe..5c1e9309b9 100644
--- a/src/feature/nodelist/fmt_routerstatus.c
+++ b/src/feature/nodelist/fmt_routerstatus.c
@@ -87,7 +87,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%s\n",
+                   "s%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":"",
@@ -98,6 +98,7 @@ routerstatus_format_entry(const routerstatus_t *rs, const char *version,
                    rs->is_flagged_running?" Running":"",
                    rs->is_stable?" Stable":"",
                    rs->is_staledesc?" StaleDesc":"",
+                   rs->is_sybil?" Sybil":"",
                    rs->is_v2_dir?" V2Dir":"",
                    rs->is_valid?" Valid":"");
 
diff --git a/src/feature/nodelist/routerstatus_st.h b/src/feature/nodelist/routerstatus_st.h
index 254ba73f7f..ef8687db76 100644
--- a/src/feature/nodelist/routerstatus_st.h
+++ b/src/feature/nodelist/routerstatus_st.h
@@ -58,6 +58,7 @@ struct routerstatus_t {
                              */
   unsigned int is_staledesc:1; /** True iff the authorities think this router
                                 * should upload a new descriptor soon. */
+  unsigned int is_sybil:1; /** True iff this router is a sybil. */
 
   unsigned int has_bandwidth:1; /**< The vote/consensus had bw info */
   unsigned int has_exitsummary:1; /**< The vote/consensus had exit summaries */





More information about the tor-commits mailing list