aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changes/immediate_reachability_check7
-rw-r--r--src/or/dirserv.c26
-rw-r--r--src/or/dirvote.c3
-rw-r--r--src/or/or.h1
-rw-r--r--src/or/routerlist.c10
5 files changed, 36 insertions, 11 deletions
diff --git a/changes/immediate_reachability_check b/changes/immediate_reachability_check
new file mode 100644
index 000000000..0352356ef
--- /dev/null
+++ b/changes/immediate_reachability_check
@@ -0,0 +1,7 @@
+ o Minor features:
+ - Directory authorities now do an immediate reachability check as soon
+ as they hear about a new relay. This change should slightly reduce
+ the time between setting up a relay and getting listed as running
+ in the consensus. It should also improve the time between setting
+ up a bridge and seeing use by bridge users.
+
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index b5c4c7b50..ad96e7670 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -3091,6 +3091,23 @@ dirserv_orconn_tls_done(const char *address,
* skip testing. */
}
+/** Helper function for dirserv_test_reachability(). Start a TLS
+ * connection to <b>router</b>, and annotate it with when we started
+ * the test. */
+void
+dirserv_single_reachability_test(time_t now, routerinfo_t *router)
+{
+ tor_addr_t router_addr;
+ log_debug(LD_OR,"Testing reachability of %s at %s:%u.",
+ router->nickname, router->address, router->or_port);
+ /* Remember when we started trying to determine reachability */
+ if (!router->testing_since)
+ router->testing_since = now;
+ tor_addr_from_ipv4h(&router_addr, router->addr);
+ connection_or_connect(&router_addr, router->or_port,
+ router->cache_info.identity_digest);
+}
+
/** Auth dir server only: if <b>try_all</b> is 1, launch connections to
* all known routers; else we want to load balance such that we only
* try a few connections per call.
@@ -3117,7 +3134,6 @@ dirserv_test_reachability(time_t now, int try_all)
SMARTLIST_FOREACH_BEGIN(rl->routers, routerinfo_t *, router) {
const char *id_digest = router->cache_info.identity_digest;
- tor_addr_t router_addr;
if (router_is_me(router))
continue;
if (bridge_auth && router->purpose != ROUTER_PURPOSE_BRIDGE)
@@ -3125,13 +3141,7 @@ dirserv_test_reachability(time_t now, int try_all)
// if (router->cache_info.published_on > cutoff)
// continue;
if (try_all || (((uint8_t)id_digest[0]) % 128) == ctr) {
- log_debug(LD_OR,"Testing reachability of %s at %s:%u.",
- router->nickname, router->address, router->or_port);
- /* Remember when we started trying to determine reachability */
- if (!router->testing_since)
- router->testing_since = now;
- tor_addr_from_ipv4h(&router_addr, router->addr);
- connection_or_connect(&router_addr, router->or_port, id_digest);
+ dirserv_single_reachability_test(now, router);
}
} SMARTLIST_FOREACH_END(router);
if (!try_all) /* increment ctr */
diff --git a/src/or/dirvote.c b/src/or/dirvote.c
index 6053e5090..d5610131a 100644
--- a/src/or/dirvote.c
+++ b/src/or/dirvote.c
@@ -2696,7 +2696,8 @@ dirvote_add_vote(const char *vote_body, const char **msg_out, int *status_out)
networkstatus_voter_info_t *vi_old = get_voter(v->vote);
if (!memcmp(vi_old->vote_digest, vi->vote_digest, DIGEST_LEN)) {
/* Ah, it's the same vote. Not a problem. */
- log_info(LD_DIR, "Discarding a vote we already have.");
+ log_info(LD_DIR, "Discarding a vote we already have (from %s).",
+ vi->address);
if (*status_out < 200)
*status_out = 200;
goto discard;
diff --git a/src/or/or.h b/src/or/or.h
index e365f6949..71a9ff73d 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -3913,6 +3913,7 @@ void dirserv_orconn_tls_done(const char *address,
uint16_t or_port,
const char *digest_rcvd,
int as_advertised);
+void dirserv_single_reachability_test(time_t now, routerinfo_t *router);
void dirserv_test_reachability(time_t now, int try_all);
int authdir_wants_to_reject_router(routerinfo_t *ri, const char **msg,
int complain);
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index 637163a75..f4db40d25 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -3204,7 +3204,7 @@ router_add_to_routerlist(routerinfo_t *router, const char **msg,
if (!in_consensus && (router->cache_info.published_on <=
old_router->cache_info.published_on)) {
/* Same key, but old. This one is not listed in the consensus. */
- log_debug(LD_DIR, "Skipping not-new descriptor for router '%s'",
+ log_debug(LD_DIR, "Not-new descriptor for router '%s'",
router->nickname);
/* Only journal this desc if we'll be serving it. */
if (!from_cache && should_cache_old_descriptors())
@@ -3247,9 +3247,15 @@ router_add_to_routerlist(routerinfo_t *router, const char **msg,
/* We haven't seen a router with this identity before. Add it to the end of
* the list. */
routerlist_insert(routerlist, router);
- if (!from_cache)
+ if (!from_cache) {
+ if (authdir) {
+ /* launch an immediate reachability test, so we will have an opinion
+ * soon in case we're generating a consensus soon */
+ dirserv_single_reachability_test(time(NULL), router);
+ }
signed_desc_append_to_journal(&router->cache_info,
&routerlist->desc_store);
+ }
directory_set_dirty();
return ROUTER_ADDED_SUCCESSFULLY;
}