[or-cvs] be much more conservative about logging reachability compla...

arma at seul.org arma at seul.org
Wed Aug 24 14:31:34 UTC 2005


Update of /home2/or/cvsroot/tor/src/or
In directory moria:/home/arma/work/onion/cvs/tor/src/or

Modified Files:
	dirserv.c main.c or.h router.c 
Log Message:
be much more conservative about logging reachability complaints.
the ones it logs now are probably genuine problem servers.


Index: dirserv.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/dirserv.c,v
retrieving revision 1.178
retrieving revision 1.179
diff -u -d -r1.178 -r1.179
--- dirserv.c	24 Aug 2005 02:31:01 -0000	1.178
+++ dirserv.c	24 Aug 2005 14:31:32 -0000	1.179
@@ -397,7 +397,10 @@
     }
     /* We don't already have a newer one; we'll update this one. */
     log_fn(LOG_INFO,"Dirserv updating desc for server %s (nickname '%s')",hex_digest,ri->nickname);
-    ri->last_reachable = ri_old->last_reachable; /* this carries over */
+    if (ri->addr == ri_old->addr && ri->or_port == ri_old->or_port) {
+      ri->last_reachable = ri_old->last_reachable; /* these carry over */
+      ri->testing_since = ri_old->testing_since;
+    }
     *msg = verified?"Verified server updated":"Unverified server updated. (Have you sent us your key fingerprint?)";
     routerinfo_free(ri_old);
     smartlist_del_keeporder(descriptor_list, found);
@@ -581,13 +584,7 @@
       if (router_is_me(ri) && !we_are_hibernating()) {
         is_live = 1;
       } else if (conn && conn->state == OR_CONN_STATE_OPEN) {
-        if (now < ri->last_reachable + REACHABLE_TIMEOUT) {
-          is_live = 1;
-        } else {
-          log_fn(stats_n_seconds_working>REACHABLE_TIMEOUT ? LOG_NOTICE : LOG_INFO,
-                 "Router %s (%s:%d) is connected to us but not reachable by us.",
-                 ri->nickname, ri->address, ri->or_port);
-        }
+        is_live = now < ri->last_reachable + REACHABLE_TIMEOUT;
       }
     } else {
       is_live = ri->is_running;
@@ -603,6 +600,42 @@
   return 0;
 }
 
+/** Log complaints about each server that is connected to us and has
+ * been found unreachable for the past several testing periods.
+ */
+void
+dirserv_log_unreachable_servers(time_t now) {
+
+  SMARTLIST_FOREACH(descriptor_list, routerinfo_t *, ri,
+  {
+    connection_t *conn;
+    conn = connection_get_by_identity_digest(
+                    ri->identity_digest, CONN_TYPE_OR);
+    if (conn && conn->state == OR_CONN_STATE_OPEN &&
+        now >= ri->last_reachable + 2*REACHABLE_TIMEOUT &&
+        ri->testing_since &&
+        now >= ri->testing_since + 2*REACHABLE_TIMEOUT) {
+      log_fn(LOG_NOTICE,
+             "Router %s (%s:%d) is connected to us but not reachable by us.",
+             ri->nickname, ri->address, ri->or_port);
+    }
+  });
+}
+
+/** Record the fact that we've started trying to determine reachability
+ * for the router with identity <b>digest</b>.
+ * (This function can go away when we merge descriptor-list and router-list.)
+ */
+void
+dirserv_router_has_begun_reachability_testing(char *digest, time_t now) {
+  SMARTLIST_FOREACH(descriptor_list, routerinfo_t *, ri,
+  {
+    if (!memcmp(ri->identity_digest, digest, DIGEST_LEN))
+      if (!ri->testing_since)
+        ri->testing_since = now;
+  });
+}
+
 /** Remove any descriptors from the directory that are more than <b>age</b>
  * seconds old.
  */

Index: main.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/main.c,v
retrieving revision 1.541
retrieving revision 1.542
diff -u -d -r1.541 -r1.542
--- main.c	24 Aug 2005 02:31:02 -0000	1.541
+++ main.c	24 Aug 2005 14:31:32 -0000	1.542
@@ -694,6 +694,7 @@
     if (authdir_mode(options)) {
       /* Dump any old descriptors. */
       dirserv_remove_old_servers(ROUTER_MAX_AGE);
+      dirserv_log_unreachable_servers(now);
       if (!we_are_hibernating()) { /* try to determine reachability */
         router_retry_connections(1);
       }

Index: or.h
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.650
retrieving revision 1.651
diff -u -d -r1.650 -r1.651
--- or.h	24 Aug 2005 02:31:02 -0000	1.650
+++ or.h	24 Aug 2005 14:31:32 -0000	1.651
@@ -738,6 +738,7 @@
   int is_running; /**< As far as we know, is this OR currently running? */
   time_t status_set_at; /**< When did we last update is_running? */
   time_t last_reachable; /**< When was the last time we could reach this OR? */
+  time_t testing_since; /**< When did we start testing reachability for this OR? */
   int is_verified; /**< Has a trusted dirserver validated this OR? */
 
   smartlist_t *declared_family; /**< Nicknames of router which this router
@@ -1624,6 +1625,8 @@
 int dirserv_load_from_directory_string(const char *dir);
 void dirserv_free_descriptors(void);
 int list_server_status(smartlist_t *routers, char **router_status_out);
+void dirserv_log_unreachable_servers(time_t now);
+void dirserv_router_has_begun_reachability_testing(char *digest, time_t now);
 void dirserv_remove_old_servers(int age);
 int dirserv_dump_directory_to_string(char **dir_out,
                                      crypto_pk_env_t *private_key);

Index: router.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/router.c,v
retrieving revision 1.190
retrieving revision 1.191
diff -u -d -r1.190 -r1.191
--- router.c	24 Aug 2005 02:31:02 -0000	1.190
+++ router.c	24 Aug 2005 14:31:32 -0000	1.191
@@ -577,6 +577,7 @@
 router_retry_connections(int force)
 {
   int i;
+  time_t now = time(NULL);
   routerinfo_t *router;
   routerlist_t *rl;
   or_options_t *options = get_options();
@@ -597,6 +598,7 @@
       log_fn(LOG_INFO,"%sconnecting to %s at %s:%u.",
              clique_mode(options) ? "(forced) " : "",
              router->nickname, router->address, router->or_port);
+      dirserv_router_has_begun_reachability_testing(router->identity_digest, now);
       connection_or_connect(router->addr, router->or_port, router->identity_digest);
     }
   }



More information about the tor-commits mailing list