[or-cvs] r12752: also clear the hsdir status flag in routerinfo_t when the re (in tor/trunk: . src/or)

arma at seul.org arma at seul.org
Mon Dec 10 16:40:14 UTC 2007


Author: arma
Date: 2007-12-10 11:40:14 -0500 (Mon, 10 Dec 2007)
New Revision: 12752

Modified:
   tor/trunk/ChangeLog
   tor/trunk/src/or/config.c
   tor/trunk/src/or/dirserv.c
   tor/trunk/src/or/networkstatus.c
   tor/trunk/src/or/or.h
Log:
also clear the hsdir status flag in routerinfo_t when the relay is no
longer listed in the relevant networkstatus document.


Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2007-12-10 14:34:26 UTC (rev 12751)
+++ tor/trunk/ChangeLog	2007-12-10 16:40:14 UTC (rev 12752)
@@ -30,7 +30,9 @@
   o Minor bugfixes:
     - The fix in 0.2.0.12-alpha cleared the "hsdir" flag in v3 network
       consensus documents when there are too many relays at a single
-      IP address. Now clear it in v2 network status documents too.
+      IP address. Now clear it in v2 network status documents too, and
+      also clear it in routerinfo_t when the relay is no longer listed
+      in the relevant networkstatus document.
     - Don't crash if we get an unexpected value for the
       PublishServerDescriptor config option. Reported by Matt Edman;
       bugfix on 0.2.0.9-alpha.

Modified: tor/trunk/src/or/config.c
===================================================================
--- tor/trunk/src/or/config.c	2007-12-10 14:34:26 UTC (rev 12751)
+++ tor/trunk/src/or/config.c	2007-12-10 16:40:14 UTC (rev 12752)
@@ -2827,7 +2827,7 @@
   if ((parse_authority_type_from_list(options->PublishServerDescriptor,
                                &options->_PublishServerDescriptor, 1) < 0)) {
     r = tor_snprintf(buf, sizeof(buf),
-        "Unrecognized value for PublishServerDescriptor");
+                     "Unrecognized value in PublishServerDescriptor");
     *msg = tor_strdup(r >= 0 ? buf : "internal error");
     return -1;
   }

Modified: tor/trunk/src/or/dirserv.c
===================================================================
--- tor/trunk/src/or/dirserv.c	2007-12-10 14:34:26 UTC (rev 12751)
+++ tor/trunk/src/or/dirserv.c	2007-12-10 16:40:14 UTC (rev 12752)
@@ -2041,15 +2041,42 @@
   rs->dir_port = ri->dir_port;
 }
 
+/** Routerstatus <b>rs</b> is part of a group of routers that are on
+ * too narrow an IP-space. Clear out its flags: we don't want people
+ * using it.
+ */
+static void
+clear_status_flags_on_sybil(routerstatus_t *rs)
+{
+  rs->is_authority = rs->is_exit = rs->is_stable = rs->is_fast =
+    rs->is_running = rs->is_named = rs->is_valid = rs->is_v2_dir =
+    rs->is_hs_dir = rs->is_possible_guard = rs->is_bad_exit = 0;
+  /* 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. */
+}
+
+/** Clear all the status flags in routerinfo <b>router</b>. We put this
+ * function here because it's eerily similar to
+ * clear_status_flags_on_sybil() above. One day we should merge them. */
+void
+router_clear_status_flags(routerinfo_t *router)
+{
+  router->is_valid = router->is_running = router->is_hs_dir =
+    router->is_fast = router->is_stable =
+    router->is_possible_guard = router->is_exit =
+    router->is_bad_exit = 0;
+}
+
 /** If we've been around for less than this amount of time, our reachability
  * information is not accurate. */
 #define DIRSERV_TIME_TO_GET_REACHABILITY_INFO (30*60)
 
 /** Return a new networkstatus_vote_t* containing our current opinion. (For v3
- * authorities */
+ * authorities) */
 networkstatus_vote_t *
 dirserv_generate_networkstatus_vote_obj(crypto_pk_env_t *private_key,
-                                       authority_cert_t *cert)
+                                        authority_cert_t *cert)
 {
   or_options_t *options = get_options();
   networkstatus_vote_t *v3_out = NULL;
@@ -2132,14 +2159,9 @@
                                        naming, exits_can_be_guards,
                                        listbadexits);
 
-      if (digestmap_get(omit_as_sybil, ri->cache_info.identity_digest)) {
-        rs->is_authority = rs->is_exit = rs->is_stable = rs->is_fast =
-          rs->is_running = rs->is_named = rs->is_valid = rs->is_v2_dir =
-          rs->is_hs_dir = rs->is_possible_guard = 0;
-        /* 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. */
-      }
+      if (digestmap_get(omit_as_sybil, ri->cache_info.identity_digest))
+        clear_status_flags_on_sybil(rs);
+
       if (!vote_on_reachability)
         rs->is_running = 0;
 
@@ -2351,11 +2373,8 @@
                                        naming, exits_can_be_guards,
                                        listbadexits);
 
-      if (digestmap_get(omit_as_sybil, ri->cache_info.identity_digest)) {
-        rs.is_authority = rs.is_exit = rs.is_stable = rs.is_fast =
-          rs.is_running = rs.is_named = rs.is_valid = rs.is_v2_dir =
-          rs.is_hs_dir = rs.is_possible_guard = 0;
-      }
+      if (digestmap_get(omit_as_sybil, ri->cache_info.identity_digest))
+        clear_status_flags_on_sybil(&rs);
 
       if (routerstatus_format_entry(outp, endp-outp, &rs, version, 0)) {
         log_warn(LD_BUG, "Unable to print router status.");

Modified: tor/trunk/src/or/networkstatus.c
===================================================================
--- tor/trunk/src/or/networkstatus.c	2007-12-10 14:34:26 UTC (rev 12751)
+++ tor/trunk/src/or/networkstatus.c	2007-12-10 16:40:14 UTC (rev 12752)
@@ -1590,12 +1590,8 @@
       if (!namingdir)
         router->is_named = 0;
       if (!authdir) {
-        if (router->purpose == ROUTER_PURPOSE_GENERAL) {
-          router->is_valid = router->is_running =
-            router->is_fast = router->is_stable =
-            router->is_possible_guard = router->is_exit =
-            router->is_bad_exit = 0;
-        }
+        if (router->purpose == ROUTER_PURPOSE_GENERAL)
+          router_clear_status_flags(router);
       }
       continue;
     }

Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h	2007-12-10 14:34:26 UTC (rev 12751)
+++ tor/trunk/src/or/or.h	2007-12-10 16:40:14 UTC (rev 12752)
@@ -3133,6 +3133,7 @@
 #define DGV_INCLUDE_PENDING 2
 #define DGV_INCLUDE_PREVIOUS 4
 const cached_dir_t *dirvote_get_vote(const char *fp, int flags);
+void router_clear_status_flags(routerinfo_t *ri);
 networkstatus_vote_t *
 dirserv_generate_networkstatus_vote_obj(crypto_pk_env_t *private_key,
                                         authority_cert_t *cert);



More information about the tor-commits mailing list