summaryrefslogtreecommitdiff
path: root/src/or/rephist.c
diff options
context:
space:
mode:
authorSebastian Hahn <sebastian@torproject.org>2011-02-07 16:31:20 +0100
committerSebastian Hahn <sebastian@torproject.org>2011-02-08 00:38:48 +0100
commit9b64227ffd38e9406c5c88ace137a0eae010771d (patch)
treeb533ef2a0ef94cbc9329a0261ea516dac6f9f9d3 /src/or/rephist.c
parenta68e2043aba4d33e39a8cb47be5dc3082f27ad07 (diff)
downloadtor-9b64227ffd38e9406c5c88ace137a0eae010771d.tar.gz
tor-9b64227ffd38e9406c5c88ace137a0eae010771d.zip
Routers count as down when they change ORPort, too
rransom noticed that a change of ORPort is just as bad as a change of IP address from a client's perspective, because both mean that the relay is not available to them while the new information hasn't propagated. Change the bug1035 fix accordingly. Also make sure we don't log a bridge's IP address (which might happen when we are the bridge authority).
Diffstat (limited to 'src/or/rephist.c')
-rw-r--r--src/or/rephist.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/or/rephist.c b/src/or/rephist.c
index 28699901fa..7c570e26a6 100644
--- a/src/or/rephist.c
+++ b/src/or/rephist.c
@@ -78,6 +78,9 @@ typedef struct or_history_t {
* successfully. */
tor_addr_t last_reached_addr;
+ /** The port at which we most recently connected to this OR successfully */
+ uint16_t last_reached_port;
+
/* === For MTBF tracking: */
/** Weighted sum total of all times that this router has been online.
*/
@@ -296,17 +299,18 @@ rep_hist_note_connection_died(const char* id, time_t when)
* reachable, meaning we will give it a "Running" flag for the next while. */
void
rep_hist_note_router_reachable(const char *id, const tor_addr_t *at_addr,
- time_t when)
+ const uint16_t at_port, time_t when)
{
or_history_t *hist = get_or_history(id);
int was_in_run = 1;
char tbuf[ISO_TIME_LEN+1];
- int addr_changed;
+ int addr_changed, port_changed;
tor_assert(hist);
addr_changed = at_addr &&
tor_addr_compare(at_addr, &hist->last_reached_addr, CMP_EXACT) != 0;
+ port_changed = at_port && at_port != hist->last_reached_port;
if (!started_tracking_stability)
started_tracking_stability = time(NULL);
@@ -326,7 +330,7 @@ rep_hist_note_router_reachable(const char *id, const tor_addr_t *at_addr,
down_length = when - hist->start_of_downtime;
hist->total_weighted_time += down_length;
hist->start_of_downtime = 0;
- } else if (addr_changed) {
+ } else if (addr_changed || port_changed) {
/* If we're reachable, but the address changed, treat this as some
* downtime. */
int penalty = get_options()->TestingTorNetwork ? 240 : 3600;
@@ -342,12 +346,13 @@ rep_hist_note_router_reachable(const char *id, const tor_addr_t *at_addr,
penalty = (int)(fresh_interval + live_interval) / 2;
}
format_local_iso_time(tbuf, hist->start_of_run);
- log_info(LD_HIST,"Router %s still seems Running, but its address appears "
- "to have changed since the last time it was reachable. I'm "
- "going to treat it as having been down for %d seconds",
- hex_str(id, DIGEST_LEN), penalty);
+ if (!authdir_mode_bridge(get_options()))
+ log_info(LD_HIST,"Router %s still seems Running, but its address appears "
+ "to have changed since the last time it was reachable. I'm "
+ "going to treat it as having been down for %d seconds",
+ hex_str(id, DIGEST_LEN), penalty);
rep_hist_note_router_unreachable(id, when-penalty);
- rep_hist_note_router_reachable(id, NULL, when);
+ rep_hist_note_router_reachable(id, NULL, 0, when);
} else {
format_local_iso_time(tbuf, hist->start_of_run);
if (was_in_run)
@@ -359,6 +364,8 @@ rep_hist_note_router_reachable(const char *id, const tor_addr_t *at_addr,
}
if (at_addr)
tor_addr_copy(&hist->last_reached_addr, at_addr);
+ if (at_port)
+ hist->last_reached_port = at_port;
}
/** We have just decided that this router is unreachable, meaning