aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2005-10-12 18:25:25 +0000
committerNick Mathewson <nickm@torproject.org>2005-10-12 18:25:25 +0000
commit972b7512c7e90aca3ba73333c8fa32cfb9974571 (patch)
tree54b3e8b4bf57801c8f14c49fdab13b4b3b43e1e8
parentfd9bfef13bb68c38adb9bb7017c8bbf73d3bfb2c (diff)
downloadtor-972b7512c7e90aca3ba73333c8fa32cfb9974571.tar
tor-972b7512c7e90aca3ba73333c8fa32cfb9974571.tar.gz
authorities do not replace server descriptors where nothing semantically relevant has changed since the last upload.
svn:r5240
-rw-r--r--src/or/directory.c2
-rw-r--r--src/or/dirserv.c15
-rw-r--r--src/or/routerlist.c18
3 files changed, 29 insertions, 6 deletions
diff --git a/src/or/directory.c b/src/or/directory.c
index ba6e5234b..f7dd7a807 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -1441,7 +1441,7 @@ directory_handle_command_post(connection_t *conn, char *headers,
if (!authdir_mode(get_options())) {
/* we just provide cached directories; we don't want to
* receive anything. */
- write_http_status_line(conn, 400, "Nonauthoritative directory does not not store server descriptors.");
+ write_http_status_line(conn, 400, "Nonauthoritative directory does not accept posted server descriptors.");
return 0;
}
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 44ed8c31e..23f4d952c 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -439,7 +439,7 @@ int
dirserv_add_descriptor(const char *desc, const char **msg)
{
int r;
- routerinfo_t *ri = NULL;
+ routerinfo_t *ri = NULL, *ri_old = NULL;
tor_assert(msg);
*msg = NULL;
@@ -450,6 +450,19 @@ dirserv_add_descriptor(const char *desc, const char **msg)
*msg = "Rejected: Couldn't parse server descriptor.";
return -2;
}
+ /* Check whether this descriptor is semantically identical to the last one
+ * from this server. (We do this here and not in router_add_to_routerlist
+ * because we want to be able to accept the newest router descriptor that
+ * another authority has, so we all converge on the same one.) */
+ ri_old = router_get_by_digest(ri->identity_digest);
+ if (ri_old && ri_old->published_on < ri->published_on &&
+ router_differences_are_cosmetic(ri_old, ri)) {
+ log_fn(LOG_INFO,
+ "Not replacing descriptor from '%s'; differences are cosmetic.",
+ ri->nickname);
+ *msg = "Not replacing router descriptor; no information has changed since the last one with this identity.";
+ return 0;
+ }
if ((r = router_add_to_routerlist(ri, msg, 0))<0) {
return r == -1 ? 0 : -1;
} else {
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index ce5730053..bf20f5598 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -2533,8 +2533,6 @@ routers_update_status_from_networkstatus(smartlist_t *routers, int reset_failure
if (!routerstatus_list)
return;
- log_fn(LOG_NOTICE, "Here, %d %d", reset_failures, assume_recognized);
-
SMARTLIST_FOREACH(routers, routerinfo_t *, router,
{
rs = router_get_combined_status_by_digest(router->identity_digest);
@@ -2864,11 +2862,19 @@ router_reset_descriptor_download_failures(void)
int
router_differences_are_cosmetic(routerinfo_t *r1, routerinfo_t *r2)
{
+ tor_assert(r1 && r2);
+
/* post-0.1.1.6 servers know what they're doing. */
if (tor_version_as_new_as(r1->platform, "0.1.1.6-alpha") ||
tor_version_as_new_as(r1->platform, "0.1.1.6-alpha"))
return 0;
+ if (r1->published_on > r2->published_on) {
+ routerinfo_t *ri_tmp = r2;
+ r2 = r1;
+ r1 = ri_tmp;
+ }
+
/* If any key fields differ, they're different. */
if (strcasecmp(r1->address, r2->address) ||
strcasecmp(r1->nickname, r2->nickname) ||
@@ -2901,8 +2907,12 @@ router_differences_are_cosmetic(routerinfo_t *r1, routerinfo_t *r2)
return 0;
/* Did more than 6 hours pass? */
- if (r1->published_on + 6*60*60 < r2->published_on ||
- r2->published_on + 6*60*60 < r1->published_on)
+ if (r1->published_on + 6*60*60 < r2->published_on)
+ return 0;
+
+ /* Did uptime fail to increase by approximately the amount we would think,
+ * give or take 30 minutes? */
+ if (abs(r2->uptime - (r1->uptime + (r2->published_on-r1->published_on)))>30*60)
return 0;
/* Otherwise, the difference is cosmetic. */