From da416d98844391af1263a7af44a7276de1564049 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Sat, 20 Jun 2009 21:54:56 -0400 Subject: [PATCH 01/21] Bump version to 0.2.1.16-rc.dev --- configure.in | 2 +- contrib/tor-mingw.nsi.in | 2 +- src/win32/orconfig.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.in b/configure.in index 37bccce965..8d97c8e80a 100644 --- a/configure.in +++ b/configure.in @@ -5,7 +5,7 @@ dnl Copyright (c) 2007-2008, The Tor Project, Inc. dnl See LICENSE for licensing information AC_INIT -AM_INIT_AUTOMAKE(tor, 0.2.1.16-rc) +AM_INIT_AUTOMAKE(tor, 0.2.1.16-rc-dev) AM_CONFIG_HEADER(orconfig.h) AC_CANONICAL_HOST diff --git a/contrib/tor-mingw.nsi.in b/contrib/tor-mingw.nsi.in index d65347ebe7..4e1df5e63a 100644 --- a/contrib/tor-mingw.nsi.in +++ b/contrib/tor-mingw.nsi.in @@ -9,7 +9,7 @@ !include "FileFunc.nsh" !insertmacro GetParameters -!define VERSION "0.2.1.16-rc" +!define VERSION "0.2.1.16-rc-dev" !define INSTALLER "tor-${VERSION}-win32.exe" !define WEBSITE "https://www.torproject.org/" !define LICENSE "LICENSE" diff --git a/src/win32/orconfig.h b/src/win32/orconfig.h index 037e869029..eede82385f 100644 --- a/src/win32/orconfig.h +++ b/src/win32/orconfig.h @@ -226,6 +226,6 @@ #define USING_TWOS_COMPLEMENT /* Version number of package */ -#define VERSION "0.2.1.16-rc" +#define VERSION "0.2.1.16-rc-dev" From e6a1e7001b6546832661ff3608ea3358f7615bd7 Mon Sep 17 00:00:00 2001 From: Karsten Loesing Date: Mon, 22 Jun 2009 15:00:04 +0200 Subject: [PATCH 02/21] Add warning that the results of --enable-geoip-stats are different from those in master. --- src/or/config.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/or/config.c b/src/or/config.c index 81999516dd..b744f8faf4 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -1381,6 +1381,13 @@ options_act(or_options_t *old_options) geoip_load_file(actual_fname, options); tor_free(actual_fname); } +#ifdef ENABLE_GEOIP_STATS + log_warn(LD_CONFIG, "We are configured to measure GeoIP statistics, but " + "the way these statistics are measured has changed " + "significantly in later versions of Tor. The results may not be " + "as expected if you are used to later versions. Be sure you " + "know what you are doing."); +#endif /* Check if we need to parse and add the EntryNodes config option. */ if (options->EntryNodes && (!old_options || From 262455527a82d1a9d482e3df32651700b2ba8c6e Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Mon, 22 Jun 2009 12:34:32 -0400 Subject: [PATCH 03/21] Serve DirPortFrontPage even if the write bucket is low. arma's rationale: "I think this is a bug, since people intentionally set DirPortFrontPage, so they really do want their relay to serve that page when it's asked for. Having it appear only sometimes (or roughly never in Sebastian's case) makes it way less useful." Fixes bug 1013; bugfix on 0.2.1.8-alpha. --- ChangeLog | 6 ++++++ src/or/directory.c | 10 +++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 436116bd7f..f7da7c4cba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Changes in version 0.2.1.17-?? - 2009-??-?? + o Minor bugfixes: + - Serve the DirPortFrontPage page even when we have been approaching + our quotas recently. Fixes bug 1013; bugfix on 0.2.1.8-alpha. + + Changes in version 0.2.1.16-rc - 2009-06-20 o Security fixes: - Fix an edge case where a malicious exit relay could convince a diff --git a/src/or/directory.c b/src/or/directory.c index d783772eac..4ab2633022 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -2428,13 +2428,9 @@ directory_handle_command_get(dir_connection_t *conn, const char *headers, dlen = strlen(frontpage); /* Let's return a disclaimer page (users shouldn't use V1 anymore, and caches don't fetch '/', so this is safe). */ - if (global_write_bucket_low(TO_CONN(conn), dlen, 1)) { - log_info(LD_DIRSERV, - "Client asked for DirPortFrontPage content, but we've been " - "writing too many bytes lately. Sending 503 Dir busy."); - write_http_status_line(conn, 503, "Directory busy, try again later"); - goto done; - } + + /* [We don't check for write_bucket_low here, since we want to serve + * this page no matter what.] */ note_request(url, dlen); write_http_response_header_impl(conn, dlen, "text/html", "identity", NULL, DIRPORTFRONTPAGE_CACHE_LIFETIME); From 1aaab8288d4b5afdff56c17a01c82a2a89e4ef01 Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Sun, 21 Jun 2009 08:54:35 -0400 Subject: [PATCH 04/21] Clients now use bandwidth values in the consensus rather than the bandwidth values in each relay descriptor. This approach opens the door to more accurate bandwidth estimates once the directory authorities start doing active measurements. Implements more of proposal 141. --- src/or/routerlist.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/or/routerlist.c b/src/or/routerlist.c index d8165e63bd..1419ae4665 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -1591,28 +1591,42 @@ smartlist_choose_by_bandwidth(smartlist_t *sl, bandwidth_weight_rule_t rule, int32_t flags = 0; uint32_t this_bw = 0; if (statuses) { - /* need to extract router info */ status = smartlist_get(sl, i); if (router_digest_is_me(status->identity_digest)) me_idx = i; router = router_get_by_digest(status->identity_digest); is_exit = status->is_exit; is_guard = status->is_possible_guard; - if (router) { - this_bw = router_get_advertised_bandwidth(router); + if (status->has_bandwidth) { + this_bw = status->bandwidth*1000; } else { /* guess */ + /* XXX022 once consensuses always list bandwidths, we can take + * this guessing business out. -RD */ is_known = 0; flags = status->is_fast ? 1 : 0; flags |= is_exit ? 2 : 0; flags |= is_guard ? 4 : 0; } } else { + routerstatus_t *rs; router = smartlist_get(sl, i); + rs = router_get_consensus_status_by_id( + router->cache_info.identity_digest); if (router_digest_is_me(router->cache_info.identity_digest)) me_idx = i; is_exit = router->is_exit; is_guard = router->is_possible_guard; - this_bw = router_get_advertised_bandwidth(router); + if (rs && rs->has_bandwidth) { + this_bw = rs->bandwidth*1000; + } else if (rs) { /* guess; don't trust the descriptor */ + /* XXX022 once consensuses always list bandwidths, we can take + * this guessing business out. -RD */ + is_known = 0; + flags = router->is_fast ? 1 : 0; + flags |= is_exit ? 2 : 0; + flags |= is_guard ? 4 : 0; + } else /* bridge or other descriptor not in our consensus */ + this_bw = router_get_advertised_bandwidth(router); } if (is_exit) bitarray_set(exit_bits, i); From b91428cfd36d1014bbd77ea1a53cddded92a6d14 Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Sun, 21 Jun 2009 08:55:12 -0400 Subject: [PATCH 05/21] add a changelog entry: clients use bw in consensus --- ChangeLog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ChangeLog b/ChangeLog index f7da7c4cba..a150710767 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,13 @@ Changes in version 0.2.1.17-?? - 2009-??-?? - Serve the DirPortFrontPage page even when we have been approaching our quotas recently. Fixes bug 1013; bugfix on 0.2.1.8-alpha. + o Major features: + - Clients now use the bandwidth values in the consensus, rather than + the bandwidth values in each relay descriptor. This approach opens + the door to more accurate bandwidth estimates once the directory + authorities start doing active measurements. Implements more of + proposal 141. + Changes in version 0.2.1.16-rc - 2009-06-20 o Security fixes: From fa89c9f0868d4902e0298ac9ef23e521633f933b Mon Sep 17 00:00:00 2001 From: Marcus Griep Date: Tue, 23 Jun 2009 23:09:27 -0400 Subject: [PATCH 06/21] Flush long replies over control port on QUIT Marks the control port connection for flushing before closing when the QUIT command is issued. This allows a QUIT to be issued during a long reply over the control port, flushing the reply and then closing the connection. Fixes bug 1015. --- src/or/control.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/or/control.c b/src/or/control.c index 486ccc4c75..98c6aa458c 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -2892,6 +2892,7 @@ connection_control_process_inbuf(control_connection_t *conn) if (!strcasecmp(conn->incoming_cmd, "QUIT")) { connection_write_str_to_buf("250 closing connection\r\n", conn); connection_mark_for_close(TO_CONN(conn)); + conn->_base.hold_open_until_flushed = 1; return 0; } From d3087389196b585ab4e0b5ee64fc36b16f071eef Mon Sep 17 00:00:00 2001 From: Marcus Griep Date: Tue, 23 Jun 2009 23:14:44 -0400 Subject: [PATCH 07/21] Ignore control port commands after a QUIT When a QUIT has been issued on a control port connection, then ignore further commands on that port. This fixes bug 1016. --- src/or/control.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/or/control.c b/src/or/control.c index 98c6aa458c..90c99fd51a 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -2888,7 +2888,12 @@ connection_control_process_inbuf(control_connection_t *conn) --data_len; } - /* Quit is always valid. */ + /* If the connection is already closing, ignore further commands */ + if (TO_CONN(conn)->marked_for_close) { + return 0; + } + + /* Otherwise, Quit is always valid. */ if (!strcasecmp(conn->incoming_cmd, "QUIT")) { connection_write_str_to_buf("250 closing connection\r\n", conn); connection_mark_for_close(TO_CONN(conn)); From cea85b4066f8f279f8de2563a7830b136fdc059f Mon Sep 17 00:00:00 2001 From: Marcus Griep Date: Wed, 24 Jun 2009 00:06:53 -0400 Subject: [PATCH 08/21] Added ChangeLog entry for control port fix --- ChangeLog | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ChangeLog b/ChangeLog index a150710767..dba7e36dbc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,16 @@ Changes in version 0.2.1.17-?? - 2009-??-?? authorities start doing active measurements. Implements more of proposal 141. + o Minor bugfixes (on 0.2.0.x): + - Control port would close the connection before flushing long + replies, such as the network consensus, if a QUIT command was + issued before the reply had completed. Now, the control port + flushes all pending replies before closing the connection. + Also fixed a condition where a QUIT command issued after a + malformed or rejected AUTHENTICATE command, but before the + connection was closed would result in a warning in the logger + for a doubly-closed connection. Fixes bugs 1015 and 1016. + Changes in version 0.2.1.16-rc - 2009-06-20 o Security fixes: From 9fc3d8782776d6feff8fb6e239a66cc3c0f26d37 Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Thu, 25 Jun 2009 10:55:08 -0400 Subject: [PATCH 09/21] stop capping bandwidths we see in the consensus but continue capping bandwidths we see in local server descriptors, if we have no consensus weights for them. --- ChangeLog | 2 ++ src/or/routerlist.c | 34 +++++++++------------------------- 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index dba7e36dbc..bce39ced94 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,8 @@ Changes in version 0.2.1.17-?? - 2009-??-?? o Minor bugfixes: - Serve the DirPortFrontPage page even when we have been approaching our quotas recently. Fixes bug 1013; bugfix on 0.2.1.8-alpha. + - Do not cap bandwidths reported by directory authorities; they are + already adjusted to reflect reality. o Major features: - Clients now use the bandwidth values in the consensus, rather than diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 1419ae4665..392b07b629 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -1523,15 +1523,12 @@ router_get_advertised_bandwidth_capped(routerinfo_t *router) return result; } -/** Eventually, the number we return will come from the directory - * consensus, so clients can dynamically update to better numbers. - * - * But for now, or in case there is no consensus available, just return - * a sufficient default. */ -static uint32_t -get_max_believable_bandwidth(void) +/** Return bw*1000, unless bw*1000 would overflow, in which case return + * INT32_MAX. */ +static INLINE int32_t +kb_to_bytes(uint32_t bw) { - return DEFAULT_MAX_BELIEVABLE_BANDWIDTH; + return (bw > (INT32_MAX/1000)) ? INT32_MAX : bw*1000; } /** Helper function: @@ -1568,7 +1565,6 @@ smartlist_choose_by_bandwidth(smartlist_t *sl, bandwidth_weight_rule_t rule, int n_unknown = 0; bitarray_t *exit_bits; bitarray_t *guard_bits; - uint32_t max_believable_bw = get_max_believable_bandwidth(); int me_idx = -1; /* Can't choose exit and guard at same time */ @@ -1598,7 +1594,7 @@ smartlist_choose_by_bandwidth(smartlist_t *sl, bandwidth_weight_rule_t rule, is_exit = status->is_exit; is_guard = status->is_possible_guard; if (status->has_bandwidth) { - this_bw = status->bandwidth*1000; + this_bw = kb_to_bytes(status->bandwidth); } else { /* guess */ /* XXX022 once consensuses always list bandwidths, we can take * this guessing business out. -RD */ @@ -1617,7 +1613,7 @@ smartlist_choose_by_bandwidth(smartlist_t *sl, bandwidth_weight_rule_t rule, is_exit = router->is_exit; is_guard = router->is_possible_guard; if (rs && rs->has_bandwidth) { - this_bw = rs->bandwidth*1000; + this_bw = kb_to_bytes(rs->bandwidth); } else if (rs) { /* guess; don't trust the descriptor */ /* XXX022 once consensuses always list bandwidths, we can take * this guessing business out. -RD */ @@ -1626,27 +1622,15 @@ smartlist_choose_by_bandwidth(smartlist_t *sl, bandwidth_weight_rule_t rule, flags |= is_exit ? 2 : 0; flags |= is_guard ? 4 : 0; } else /* bridge or other descriptor not in our consensus */ - this_bw = router_get_advertised_bandwidth(router); + this_bw = router_get_advertised_bandwidth_capped(router); } if (is_exit) bitarray_set(exit_bits, i); if (is_guard) bitarray_set(guard_bits, i); - /* if they claim something huge, don't believe it */ - if (this_bw > max_believable_bw) { - char fp[HEX_DIGEST_LEN+1]; - base16_encode(fp, sizeof(fp), statuses ? - status->identity_digest : - router->cache_info.identity_digest, - DIGEST_LEN); - log_fn(LOG_PROTOCOL_WARN, LD_DIR, - "Bandwidth %d for router %s (%s) exceeds allowed max %d, capping", - this_bw, router ? router->nickname : "(null)", - fp, max_believable_bw); - this_bw = max_believable_bw; - } if (is_known) { bandwidths[i] = (int32_t) this_bw; // safe since MAX_BELIEVABLE= 0); if (is_guard) total_guard_bw += this_bw; else From 7ce767181f42879d48737ba69c4ce99963d76d9f Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 30 Jun 2009 10:05:42 -0400 Subject: [PATCH 10/21] Have eventdns set the "truncated" bit correctly. Fixed bug 1022; This isn't actually a live bug in Tor, since in Tor we never generate large DNS replies. --- src/or/eventdns.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/or/eventdns.c b/src/or/eventdns.c index 4464148141..4ae17a40c3 100644 --- a/src/or/eventdns.c +++ b/src/or/eventdns.c @@ -1842,7 +1842,7 @@ evdns_server_request_format_response(struct server_request *req, int err) if (j > 512) { overflow: j = 512; - buf[3] |= 0x02; /* set the truncated bit. */ + buf[2] |= 0x02; /* set the truncated bit. */ } req->response_len = (size_t)j; From 0cd16c4ad3aee87c385d62f9af7af64a7a99335c Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Sat, 20 Jun 2009 01:37:09 -0400 Subject: [PATCH 11/21] the first piece of bug 969 fixing tell the rephist module that a given relay is down whenever we determine that it's down, not just when we thought it used to be up. --- src/or/dirserv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/or/dirserv.c b/src/or/dirserv.c index 88afe9fccc..55c3302c6e 100644 --- a/src/or/dirserv.c +++ b/src/or/dirserv.c @@ -951,8 +951,8 @@ dirserv_set_router_is_running(routerinfo_t *router, time_t now) answer = get_options()->AssumeReachable || now < router->last_reachable + REACHABLE_TIMEOUT; - if (router->is_running && !answer) { - /* it was running but now it's not. tell rephist. */ + if (!answer) { + /* not considered reachable. tell rephist. */ rep_hist_note_router_unreachable(router->cache_info.identity_digest, now); } From bdca5476daa900813fcc3ad04b3e952dcaddc994 Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Sat, 20 Jun 2009 01:52:59 -0400 Subject: [PATCH 12/21] the second piece of bug 969 fixing whenever we remove a relay from the main routerlist, tell the rephist module that it's no longer running. --- src/or/dirserv.c | 2 +- src/or/or.h | 3 ++- src/or/routerlist.c | 7 +++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/or/dirserv.c b/src/or/dirserv.c index 55c3302c6e..a64a01bb80 100644 --- a/src/or/dirserv.c +++ b/src/or/dirserv.c @@ -797,7 +797,7 @@ directory_remove_invalid(void) if (r & FP_REJECT) { log_info(LD_DIRSERV, "Router '%s' is now rejected: %s", ent->nickname, msg?msg:""); - routerlist_remove(rl, ent, 0); + routerlist_remove(rl, ent, 0, time(NULL)); i--; changed = 1; continue; diff --git a/src/or/or.h b/src/or/or.h index f84485f2f4..f37b417fe5 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -4411,7 +4411,8 @@ void routerinfo_free(routerinfo_t *router); void extrainfo_free(extrainfo_t *extrainfo); void routerlist_free(routerlist_t *rl); void dump_routerlist_mem_usage(int severity); -void routerlist_remove(routerlist_t *rl, routerinfo_t *ri, int make_old); +void routerlist_remove(routerlist_t *rl, routerinfo_t *ri, int make_old, + time_t now); void routerlist_free_all(void); void routerlist_reset_warnings(void); void router_set_status(const char *digest, int up); diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 392b07b629..42b385b101 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -2629,7 +2629,7 @@ routerlist_insert_old(routerlist_t *rl, routerinfo_t *ri) * If make_old is true, instead of deleting the router, we try adding * it to rl->old_routers. */ void -routerlist_remove(routerlist_t *rl, routerinfo_t *ri, int make_old) +routerlist_remove(routerlist_t *rl, routerinfo_t *ri, int make_old, time_t now) { routerinfo_t *ri_tmp; extrainfo_t *ei_tmp; @@ -2637,6 +2637,9 @@ routerlist_remove(routerlist_t *rl, routerinfo_t *ri, int make_old) tor_assert(0 <= idx && idx < smartlist_len(rl->routers)); tor_assert(smartlist_get(rl->routers, idx) == ri); + /* make sure the rephist module knows that it's not running */ + rep_hist_note_router_unreachable(ri->cache_info.identity_digest, now); + ri->cache_info.routerlist_index = -1; smartlist_del(rl->routers, idx); if (idx < smartlist_len(rl->routers)) { @@ -3328,7 +3331,7 @@ routerlist_remove_old_routers(void) log_info(LD_DIR, "Forgetting obsolete (too old) routerinfo for router '%s'", router->nickname); - routerlist_remove(routerlist, router, 1); + routerlist_remove(routerlist, router, 1, now); i--; } } From e7bc189f7c8fb4c2a490f10bd26d81893626ade1 Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Sat, 20 Jun 2009 05:25:14 -0400 Subject: [PATCH 13/21] the third piece of bug 969 fixing when we write out our stability info, detect relays that have slipped through the cracks. log about them and correct the problem. if we continue to see a lot of these over time, it means there's another spot where relays fall out of the routerlist without being marked as unreachable. --- src/or/main.c | 9 +++++---- src/or/or.h | 2 +- src/or/rephist.c | 20 ++++++++++++++++++-- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/or/main.c b/src/or/main.c index 8fc712bba3..60c42aaae3 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -903,7 +903,7 @@ run_scheduled_events(time_t now) time_to_downrate_stability = rep_hist_downrate_old_runs(now); if (authdir_mode_tests_reachability(options)) { if (time_to_save_stability < now) { - if (time_to_save_stability && rep_hist_record_mtbf_data()<0) { + if (time_to_save_stability && rep_hist_record_mtbf_data(now, 1)<0) { log_warn(LD_GENERAL, "Couldn't store mtbf data."); } #define SAVE_STABILITY_INTERVAL (30*60) @@ -1955,14 +1955,15 @@ tor_cleanup(void) /* Remove our pid file. We don't care if there was an error when we * unlink, nothing we could do about it anyways. */ if (options->command == CMD_RUN_TOR) { + time_t now = time(NULL); if (options->PidFile) unlink(options->PidFile); if (accounting_is_enabled(options)) - accounting_record_bandwidth_usage(time(NULL), get_or_state()); + accounting_record_bandwidth_usage(now, get_or_state()); or_state_mark_dirty(get_or_state(), 0); /* force an immediate save. */ - or_state_save(time(NULL)); + or_state_save(now); if (authdir_mode_tests_reachability(options)) - rep_hist_record_mtbf_data(); + rep_hist_record_mtbf_data(now, 0); } #ifdef USE_DMALLOC dmalloc_log_stats(); diff --git a/src/or/or.h b/src/or/or.h index f37b417fe5..eddeda1531 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -3970,7 +3970,7 @@ void rep_history_clean(time_t before); void rep_hist_note_router_reachable(const char *id, time_t when); void rep_hist_note_router_unreachable(const char *id, time_t when); -int rep_hist_record_mtbf_data(void); +int rep_hist_record_mtbf_data(time_t now, int missing_means_down); int rep_hist_load_mtbf_data(time_t now); time_t rep_hist_downrate_old_runs(time_t now); diff --git a/src/or/rephist.c b/src/or/rephist.c index 11e040c945..13fdb58b5e 100644 --- a/src/or/rephist.c +++ b/src/or/rephist.c @@ -683,9 +683,13 @@ rep_history_clean(time_t before) } } -/** Write MTBF data to disk. Returns 0 on success, negative on failure. */ +/** Write MTBF data to disk. Return 0 on success, negative on failure. + * + * If missing_means_down, then if we're about to write an entry + * that is still considered up but isn't in our routerlist, consider it + * to be down. */ int -rep_hist_record_mtbf_data(void) +rep_hist_record_mtbf_data(time_t now, int missing_means_down) { char time_buf[ISO_TIME_LEN+1]; @@ -745,6 +749,18 @@ rep_hist_record_mtbf_data(void) hist = (or_history_t*) or_history_p; base16_encode(dbuf, sizeof(dbuf), digest, DIGEST_LEN); + + if (missing_means_down && hist->start_of_run && + !router_get_by_digest(digest)) { + /* We think this relay is running, but it's not listed in our + * routerlist. Somehow it fell out without telling us it went + * down. Complain and also correct it. */ + log_info(LD_HIST, + "Relay '%s' is listed as up in rephist, but it's not in " + "our routerlist. Correcting.", dbuf); + rep_hist_note_router_unreachable(digest, now); + } + PRINTF((f, "R %s\n", dbuf)); if (hist->start_of_run > 0) { format_iso_time(time_buf, hist->start_of_run); From 1ace3799facd9cae6f16f64647fec2281333539f Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Sat, 20 Jun 2009 06:14:32 -0400 Subject: [PATCH 14/21] and give the bug 969 fixes a changelog --- ChangeLog | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ChangeLog b/ChangeLog index bce39ced94..dc0f3a2e35 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,14 @@ Changes in version 0.2.1.17-?? - 2009-??-?? + o Major bugfixes: + - Directory authorities were neglecting to mark relays down in their + internal histories if the relays fall off the routerlist without + ever being found unreachable. So there were relays in the histories + that haven't been seen for eight months, and are listed as being + up for eight months. This wreaked havoc on the "median wfu" + and "median mtbf" calculations, in turn making Guard and Stable + flags very wrong, hurting network performance. Fixes bugs 696 and + 969. Bugfix on 0.2.0.6-alpha. + o Minor bugfixes: - Serve the DirPortFrontPage page even when we have been approaching our quotas recently. Fixes bug 1013; bugfix on 0.2.1.8-alpha. From 690db1331dcaed2ee4c8eb38cca53b97f25bd75d Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Tue, 30 Jun 2009 10:14:15 -0400 Subject: [PATCH 15/21] another minor patch to add to 0.2.1.x o Minor features: - If we're a relay and we change our IP address, be more verbose about the reason that made us change. Should help track down further bugs for relays on dynamic IP addresses. --- src/or/router.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/or/router.c b/src/or/router.c index 658c567db1..93afe4fad5 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -1509,8 +1509,8 @@ log_addr_has_changed(int severity, uint32_t prev, uint32_t cur, addrbuf_prev, addrbuf_cur, source); else log_notice(LD_GENERAL, - "Guessed our IP address as %s.", - addrbuf_cur); + "Guessed our IP address as %s (source: %s).", + addrbuf_cur, source); } /** Check whether our own address as defined by the Address configuration @@ -1533,7 +1533,7 @@ check_descriptor_ipaddress_changed(time_t now) } if (prev != cur) { - log_addr_has_changed(LOG_INFO, prev, cur, "resolve"); + log_addr_has_changed(LOG_NOTICE, prev, cur, "resolve"); ip_address_changed(0); } } From 0cbc0c463bcd5f3a80fe9388f778d4b6e09e0815 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Fri, 26 Jun 2009 02:13:52 +0200 Subject: [PATCH 16/21] Update the year for the copyright statement in two more files --- LICENSE | 2 +- Makefile.am | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/LICENSE b/LICENSE index 197c92a974..bb1ebd4e48 100644 --- a/LICENSE +++ b/LICENSE @@ -14,7 +14,7 @@ Tor is distributed under this license: Copyright (c) 2001-2004, Roger Dingledine Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson -Copyright (c) 2007-2008, The Tor Project, Inc. +Copyright (c) 2007-2009, The Tor Project, Inc. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are diff --git a/Makefile.am b/Makefile.am index b6e559ef0c..ec8b4f1a66 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,7 +1,7 @@ # $Id$ # Copyright (c) 2001-2004, Roger Dingledine # Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson -# Copyright (c) 2007-2008, The Tor Project, Inc. +# Copyright (c) 2007-2009, The Tor Project, Inc. # See LICENSE for licensing information AUTOMAKE_OPTIONS = foreign From 3e6bb050dd46491ac044808782a489bdf0c23f6d Mon Sep 17 00:00:00 2001 From: Karsten Loesing Date: Tue, 30 Jun 2009 20:35:03 +0200 Subject: [PATCH 17/21] Make an attempt to fix bug 1024. The internal error "could not find intro key" occurs when we want to send an INTRODUCE1 cell over a recently finished introduction circuit and think we built the introduction circuit with a v2 hidden service descriptor, but cannot find the introduction key in our descriptor. My first guess how we can end up in this situation is that we are wrong in thinking that we built the introduction circuit based on a v2 hidden service descriptor. This patch checks if we have a v0 descriptor, too, and uses that instead. --- ChangeLog | 3 +++ src/or/rendclient.c | 20 ++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index dc0f3a2e35..55f0f2c95a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -14,6 +14,9 @@ Changes in version 0.2.1.17-?? - 2009-??-?? our quotas recently. Fixes bug 1013; bugfix on 0.2.1.8-alpha. - Do not cap bandwidths reported by directory authorities; they are already adjusted to reflect reality. + - When we can't find an intro key for a v2 hidden service descriptor, + fall back to the v0 hidden service descriptor and log a bug message. + Workaround for bug1024. o Major features: - Clients now use the bandwidth values in the consensus, rather than diff --git a/src/or/rendclient.c b/src/or/rendclient.c index 5b18a519b0..a5d7c1016e 100644 --- a/src/or/rendclient.c +++ b/src/or/rendclient.c @@ -94,8 +94,24 @@ rend_client_send_introduction(origin_circuit_t *introcirc, } }); if (!intro_key) { - log_warn(LD_BUG, "Internal error: could not find intro key."); - goto err; + if (rend_cache_lookup_entry(introcirc->rend_data->onion_address, + 0, &entry) > 0) { + log_warn(LD_BUG, "We have both a v0 and a v2 rend desc for this " + "service. The v2 desc doesn't contain the introduction " + "point (and key) to send an INTRODUCE1/2 cell to this " + "introduction point. Assuming the introduction point " + "is for v0 rend clients and using the service key " + "from the v0 desc instead. (This is probably a bug, " + "because we shouldn't even have both a v0 and a v2 " + "descriptor for the same service.)"); + /* See flyspray task 1024. */ + intro_key = entry->parsed->pk; + } else { + log_warn(LD_BUG, "Internal error: could not find intro key; we " + "only have a v2 rend desc with %d intro points.", + smartlist_len(entry->parsed->intro_nodes)); + goto err; + } } } if (crypto_pk_get_digest(intro_key, payload)<0) { From 4e8d22846b4eed41525fb9e5f755b56515f0dd5a Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Thu, 2 Jul 2009 10:13:01 -0400 Subject: [PATCH 18/21] Revise 0.2.1.17-rc changelog. --- ChangeLog | 49 ++++++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index 55f0f2c95a..a3199c787e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,19 @@ -Changes in version 0.2.1.17-?? - 2009-??-?? +Changes in version 0.2.1.17-rc - 2009-07-02 + o Major features: + - Clients now use the bandwidth values in the consensus, rather than + the bandwidth values in each relay descriptor. This approach opens + the door to more accurate bandwidth estimates once the directory + authorities start doing active measurements. Implements more of + proposal 141. + o Major bugfixes: + - When Tor clients restart after 1-5 days, they discard all their + cached descriptors as too old, but they still use the cached + consensus document. This approach is good for robustness, but + bad for performance: since they don't know any bandwidths, they + end up choosing at random rather than weighting their choice by + speed. Fixed by the above feature of putting bandwidths in the + consensus. Bugfix on 0.2.0.x. - Directory authorities were neglecting to mark relays down in their internal histories if the relays fall off the routerlist without ever being found unreachable. So there were relays in the histories @@ -11,29 +25,22 @@ Changes in version 0.2.1.17-?? - 2009-??-?? o Minor bugfixes: - Serve the DirPortFrontPage page even when we have been approaching - our quotas recently. Fixes bug 1013; bugfix on 0.2.1.8-alpha. - - Do not cap bandwidths reported by directory authorities; they are - already adjusted to reflect reality. + our quotas recently. Fixes bug 1013; bugfix on 0.2.1.8-alpha. + - The control port would close the connection before flushing long + replies, such as the network consensus, if a QUIT command was issued + before the reply had completed. Now, the control port flushes all + pending replies before closing the connection. Also fixed a spurious + warning when a QUIT command is issued after a malformed or rejected + AUTHENTICATE command, but before the connection was closed. Patch + by Marcus Griep. Bugfix on 0.2.0.x; fixes bugs 1015 and 1016. - When we can't find an intro key for a v2 hidden service descriptor, fall back to the v0 hidden service descriptor and log a bug message. - Workaround for bug1024. + Workaround for bug 1024. - o Major features: - - Clients now use the bandwidth values in the consensus, rather than - the bandwidth values in each relay descriptor. This approach opens - the door to more accurate bandwidth estimates once the directory - authorities start doing active measurements. Implements more of - proposal 141. - - o Minor bugfixes (on 0.2.0.x): - - Control port would close the connection before flushing long - replies, such as the network consensus, if a QUIT command was - issued before the reply had completed. Now, the control port - flushes all pending replies before closing the connection. - Also fixed a condition where a QUIT command issued after a - malformed or rejected AUTHENTICATE command, but before the - connection was closed would result in a warning in the logger - for a doubly-closed connection. Fixes bugs 1015 and 1016. + o Minor features: + - If we're a relay and we change our IP address, be more verbose + about the reason that made us change. Should help track down + further bugs for relays on dynamic IP addresses. Changes in version 0.2.1.16-rc - 2009-06-20 From 2c221e923b1ff7d8693d8a8b9e6bb5474956349e Mon Sep 17 00:00:00 2001 From: Andrew Lewman Date: Thu, 2 Jul 2009 17:57:47 -0400 Subject: [PATCH 19/21] updated rpm instructions for realtime libevent. --- doc/tor-rpm-creation.txt | 69 ++++++++++------------------------------ 1 file changed, 17 insertions(+), 52 deletions(-) diff --git a/doc/tor-rpm-creation.txt b/doc/tor-rpm-creation.txt index a8280fe367..3fc6bde79c 100644 --- a/doc/tor-rpm-creation.txt +++ b/doc/tor-rpm-creation.txt @@ -2,60 +2,25 @@ ## The process used to create the official rpms is as follows: -Download and Extract the latest tor source code from https://www.torproject.org/. +Download latest stable libevent from +http://www.monkey.org/~provos/libevent/ + +The first step of compiling libevent is to configure it as follows: +./configure --enable-static --disable-shared + +Complete the "make" and "make install". You will need to be root, +or sudo -s, to complete the "make install". + +Check for a successful universal binary of libevent.a in, by default, +/usr/local/lib by using the following command: + "file /usr/local/lib/libevent.a" + +Download and Extract the latest tor source code from +https://www.torproject.org/download + In the resulting directory: -./configure +LIBS=-lrt ./configure make dist-rpm You should have at least two, maybe three, rpms. There should be the binary i386.rpm, a src.rpm, and on redhat/centos machines, a debuginfo.rpm. - -## Optional customization -## -If you wish to further tune Tor binaries in rpm format beyond this list, -see the GCC doc page for further options: -http://gcc.gnu.org/onlinedocs/gcc-4.0.2/gcc/ - -The tor.spec.in file contains the basic info needed to tune the binaries -produced in rpm format. The key parameters to tune are located in the -third section of the tor.spec.in file. Locate the section similar to -this: - -## Target a specific arch and OS -# -# default is i386 linux -%define target gnu -%define target_cpu i386 -%define target_os linux - -The three parameters: target, target_cpu, and target_os are used -throughout the "make dist-rpm" process. They control the parameters -passed to "configure" and the final tuning of the binaries produced. -The default settings, as shown above, create binaries for the widest -range of Intel x86 or x86-compatible architectures. - -The parameters can be set as follows: - -The "target" parameter: -This should be "gnu", "redhat", or the short name of your linux distribution. -Other possibilities are "mandrake" or "suse". This is passed to -"configure" through the --host, --build, and --target parameters. -Therefore, this "target" parameter must be a valid OS for "configure" as -well. - -The "target_cpu" parameter: -This parameter controls the optimization and tuning of your binaries via -gcc and "configure". This parameter is passed to gcc via the -mtune= or --mcpu= options. The "configure" script will also receive this parameter -through the --host, --build, and --target parameters. Therefore, this -"target_cpu" parameter must be valid for both gcc and "configure". A -few common options for this parameter may be "athlon64, i686, pentium4" or -others. - -The "target_os" parameter: -This parameter controls the target operating system. Normally, this is -only "linux". If you wish to build rpms for a non-linux operating -system, you can replace "linux" with your operating system. - - - From 258b980331f4a6c208144b80df4d4ce7de5caa58 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 7 Jul 2009 12:19:04 -0400 Subject: [PATCH 20/21] Make "Invalid onion hostname" msg respect SafeLogging. Patch by Roger; fixes bug 1027. --- ChangeLog | 4 +++- src/or/connection_edge.c | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index a3199c787e..d368871079 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,4 @@ -Changes in version 0.2.1.17-rc - 2009-07-02 +Changes in version 0.2.1.17-rc - 2009-07-07 o Major features: - Clients now use the bandwidth values in the consensus, rather than the bandwidth values in each relay descriptor. This approach opens @@ -36,6 +36,8 @@ Changes in version 0.2.1.17-rc - 2009-07-02 - When we can't find an intro key for a v2 hidden service descriptor, fall back to the v0 hidden service descriptor and log a bug message. Workaround for bug 1024. + - Fix a log message that did not respect the SafeLogging option. + Resolves bug 1027. o Minor features: - If we're a relay and we change our IP address, be more verbose diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c index 1ef87dbffa..d699591cdc 100644 --- a/src/or/connection_edge.c +++ b/src/or/connection_edge.c @@ -1484,7 +1484,8 @@ connection_ap_handshake_rewrite_and_attach(edge_connection_t *conn, addresstype = parse_extended_hostname(socks->address); if (addresstype == BAD_HOSTNAME) { - log_warn(LD_APP, "Invalid hostname %s; rejecting", socks->address); + log_warn(LD_APP, "Invalid onion hostname %s; rejecting", + safe_str(socks->address)); control_event_client_status(LOG_WARN, "SOCKS_BAD_HOSTNAME HOSTNAME=%s", escaped(socks->address)); connection_mark_unattached_ap(conn, END_STREAM_REASON_TORPROTOCOL); From 32d40607246e357d905bdf17acc20f6c863afd2b Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 7 Jul 2009 12:22:46 -0400 Subject: [PATCH 21/21] Bump version to 0.2.1.17-rc --- configure.in | 2 +- contrib/tor-mingw.nsi.in | 2 +- src/win32/orconfig.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.in b/configure.in index 8d97c8e80a..e704249457 100644 --- a/configure.in +++ b/configure.in @@ -5,7 +5,7 @@ dnl Copyright (c) 2007-2008, The Tor Project, Inc. dnl See LICENSE for licensing information AC_INIT -AM_INIT_AUTOMAKE(tor, 0.2.1.16-rc-dev) +AM_INIT_AUTOMAKE(tor, 0.2.1.17-rc) AM_CONFIG_HEADER(orconfig.h) AC_CANONICAL_HOST diff --git a/contrib/tor-mingw.nsi.in b/contrib/tor-mingw.nsi.in index 4e1df5e63a..743e915a57 100644 --- a/contrib/tor-mingw.nsi.in +++ b/contrib/tor-mingw.nsi.in @@ -9,7 +9,7 @@ !include "FileFunc.nsh" !insertmacro GetParameters -!define VERSION "0.2.1.16-rc-dev" +!define VERSION "0.2.1.17-rc" !define INSTALLER "tor-${VERSION}-win32.exe" !define WEBSITE "https://www.torproject.org/" !define LICENSE "LICENSE" diff --git a/src/win32/orconfig.h b/src/win32/orconfig.h index eede82385f..a13b4139c3 100644 --- a/src/win32/orconfig.h +++ b/src/win32/orconfig.h @@ -226,6 +226,6 @@ #define USING_TWOS_COMPLEMENT /* Version number of package */ -#define VERSION "0.2.1.16-rc-dev" +#define VERSION "0.2.1.17-rc"