summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2010-09-14 22:19:25 -0400
committerNick Mathewson <nickm@torproject.org>2010-09-14 22:19:25 -0400
commit60e3def3ed7428b139cfd6e36517f930a84bd085 (patch)
tree9ebca5d98cc88cb8efebf448598797ca5364b863
parente2b71d884139af902fc9b9222f5b55fe5a7a91ec (diff)
parentf5b7e039f39d881fc8f48c2e6004e605ca0e24c1 (diff)
downloadtor-60e3def3ed7428b139cfd6e36517f930a84bd085.tar.gz
tor-60e3def3ed7428b139cfd6e36517f930a84bd085.zip
Merge branch 'bug1899'
-rw-r--r--changes/bug1899_test_changed_addr4
-rw-r--r--src/or/dirserv.c4
-rw-r--r--src/or/routerlist.c10
-rw-r--r--src/or/routerlist.h1
4 files changed, 17 insertions, 2 deletions
diff --git a/changes/bug1899_test_changed_addr b/changes/bug1899_test_changed_addr
new file mode 100644
index 0000000000..2823d3c6e0
--- /dev/null
+++ b/changes/bug1899_test_changed_addr
@@ -0,0 +1,4 @@
+ o Minor features
+ - When a router changes IP or port, authorities now launch a new
+ reachability test for it. (Implements ticket 1899)
+
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 8523335ec4..3fcf1783d7 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -3136,6 +3136,10 @@ dirserv_should_launch_reachability_test(routerinfo_t *ri, routerinfo_t *ri_old)
/* It just came out of hibernation; launch a reachability test */
return 1;
}
+ if (! routers_have_same_or_addr(ri, ri_old)) {
+ /* Address or port changed; launch a reachability test */
+ return 1;
+ }
return 0;
}
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index 402e98599e..480da44ba6 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -1274,6 +1274,13 @@ mark_all_trusteddirservers_up(void)
router_dir_info_changed();
}
+/** Return true iff r1 and r2 have the same address and OR port. */
+int
+routers_have_same_or_addr(const routerinfo_t *r1, const routerinfo_t *r2)
+{
+ return r1->addr == r2->addr && r1->or_port == r2->or_port;
+}
+
/** Reset all internal variables used to count failed downloads of network
* status objects. */
void
@@ -3270,8 +3277,7 @@ router_add_to_routerlist(routerinfo_t *router, const char **msg,
log_debug(LD_DIR, "Replacing entry for router '%s/%s' [%s]",
router->nickname, old_router->nickname,
hex_str(id_digest,DIGEST_LEN));
- if (router->addr == old_router->addr &&
- router->or_port == old_router->or_port) {
+ if (routers_have_same_or_addr(router, old_router)) {
/* these carry over when the address and orport are unchanged. */
router->last_reachable = old_router->last_reachable;
router->testing_since = old_router->testing_since;
diff --git a/src/or/routerlist.h b/src/or/routerlist.h
index b53997ae8f..574bce7ffc 100644
--- a/src/or/routerlist.h
+++ b/src/or/routerlist.h
@@ -36,6 +36,7 @@ int router_get_my_share_of_directory_requests(double *v2_share_out,
void router_reset_status_download_failures(void);
void routerlist_add_family(smartlist_t *sl, routerinfo_t *router);
int routers_in_same_family(routerinfo_t *r1, routerinfo_t *r2);
+int routers_have_same_or_addr(const routerinfo_t *r1, const routerinfo_t *r2);
void add_nickname_list_to_smartlist(smartlist_t *sl, const char *list,
int must_be_running);
int router_nickname_is_in_list(routerinfo_t *router, const char *list);