rephist: Stop tracking EXTEND attempts

This removes the code that tracks the extend attemps a client makes. We don't
use it and it was only used to provide statistics on a SIGUSR1 from the
rephist dump stats function.

Part of #25163

Signed-off-by: David Goulet <dgoulet@torproject.org>
This commit is contained in:
David Goulet 2018-02-06 12:43:55 -05:00
parent 6961609a1c
commit 199bc37290
5 changed files with 6 additions and 183 deletions

View File

@ -347,45 +347,6 @@ circuit_log_path(int severity, unsigned int domain, origin_circuit_t *circ)
tor_free(s);
}
/** Tell the rep(utation)hist(ory) module about the status of the links
* in <b>circ</b>. Hops that have become OPEN are marked as successfully
* extended; the _first_ hop that isn't open (if any) is marked as
* unable to extend.
*/
/* XXXX Someday we should learn from OR circuits too. */
void
circuit_rep_hist_note_result(origin_circuit_t *circ)
{
crypt_path_t *hop;
const char *prev_digest = NULL;
hop = circ->cpath;
if (!hop) /* circuit hasn't started building yet. */
return;
if (server_mode(get_options())) {
const routerinfo_t *me = router_get_my_routerinfo();
if (!me)
return;
prev_digest = me->cache_info.identity_digest;
}
do {
const node_t *node = node_get_by_id(hop->extend_info->identity_digest);
if (node) { /* Why do we check this? We know the identity. -NM XXXX */
if (prev_digest) {
if (hop->state == CPATH_STATE_OPEN)
rep_hist_note_extend_succeeded(prev_digest, node->identity);
else {
rep_hist_note_extend_failed(prev_digest, node->identity);
break;
}
}
prev_digest = node->identity;
} else {
prev_digest = NULL;
}
hop=hop->next;
} while (hop!=circ->cpath);
}
/** Return 1 iff every node in circ's cpath definitely supports ntor. */
static int
circuit_cpath_supports_ntor(const origin_circuit_t *circ)
@ -1075,7 +1036,6 @@ circuit_build_no_more_hops(origin_circuit_t *circ)
}
pathbias_count_build_success(circ);
circuit_rep_hist_note_result(circ);
if (is_usable_for_streams)
circuit_has_opened(circ); /* do other actions as necessary */

View File

@ -17,7 +17,6 @@ char *circuit_list_path(origin_circuit_t *circ, int verbose);
char *circuit_list_path_for_controller(origin_circuit_t *circ);
void circuit_log_path(int severity, unsigned int domain,
origin_circuit_t *circ);
void circuit_rep_hist_note_result(origin_circuit_t *circ);
origin_circuit_t *origin_circuit_init(uint8_t purpose, int flags);
origin_circuit_t *circuit_establish_circuit(uint8_t purpose,
extend_info_t *exit,

View File

@ -1986,8 +1986,7 @@ circuit_mark_all_dirty_circs_as_unusable(void)
* - If state is onionskin_pending, remove circ from the onion_pending
* list.
* - If circ isn't open yet: call circuit_build_failed() if we're
* the origin, and in either case call circuit_rep_hist_note_result()
* to note stats.
* the origin.
* - If purpose is C_INTRODUCE_ACK_WAIT, report the intro point
* failure we just had to the hidden service client module.
* - If purpose is C_INTRODUCING and <b>reason</b> isn't TIMEOUT,
@ -2123,7 +2122,6 @@ circuit_about_to_free(circuit_t *circ)
if (CIRCUIT_IS_ORIGIN(circ)) {
origin_circuit_t *ocirc = TO_ORIGIN_CIRCUIT(circ);
circuit_build_failed(ocirc); /* take actions if necessary */
circuit_rep_hist_note_result(ocirc);
}
}
if (circ->state == CIRCUIT_STATE_CHAN_WAIT) {

View File

@ -110,18 +110,6 @@ uint32_t rephist_total_num=0;
* 20X as much as one that ended a month ago, and routers that have had no
* uptime data for about half a year will get forgotten.) */
/** History of an OR-\>OR link. */
typedef struct link_history_t {
/** When did we start tracking this list? */
time_t since;
/** When did we most recently note a change to this link */
time_t changed;
/** How many times did extending from OR1 to OR2 succeed? */
unsigned long n_extend_ok;
/** How many times did extending from OR1 to OR2 fail? */
unsigned long n_extend_fail;
} link_history_t;
/** History of an OR. */
typedef struct or_history_t {
/** When did we start tracking this OR? */
@ -163,10 +151,6 @@ typedef struct or_history_t {
time_t start_of_downtime;
unsigned long weighted_uptime;
unsigned long total_weighted_time;
/** Map from hex OR2 identity digest to a link_history_t for the link
* from this OR to OR2. */
digestmap_t *link_history_map;
} or_history_t;
/**
@ -232,7 +216,6 @@ get_or_history(const char* id)
hist = tor_malloc_zero(sizeof(or_history_t));
rephist_total_alloc += sizeof(or_history_t);
rephist_total_num++;
hist->link_history_map = digestmap_new();
hist->since = hist->changed = time(NULL);
tor_addr_make_unspec(&hist->last_reached_addr);
digestmap_set(history_map, id, hist);
@ -240,44 +223,11 @@ get_or_history(const char* id)
return hist;
}
/** Return the link_history_t for the link from the first named OR to
* the second, creating it if necessary. (ORs are identified by
* identity digest.)
*/
static link_history_t *
get_link_history(const char *from_id, const char *to_id)
{
or_history_t *orhist;
link_history_t *lhist;
orhist = get_or_history(from_id);
if (!orhist)
return NULL;
if (tor_digest_is_zero(to_id))
return NULL;
lhist = digestmap_get(orhist->link_history_map, to_id);
if (!lhist) {
lhist = tor_malloc_zero(sizeof(link_history_t));
rephist_total_alloc += sizeof(link_history_t);
lhist->since = lhist->changed = time(NULL);
digestmap_set(orhist->link_history_map, to_id, lhist);
}
return lhist;
}
/** Helper: free storage held by a single link history entry. */
static void
free_link_history_(void *val)
{
rephist_total_alloc -= sizeof(link_history_t);
tor_free(val);
}
/** Helper: free storage held by a single OR history entry. */
static void
free_or_history(void *_hist)
{
or_history_t *hist = _hist;
digestmap_free(hist->link_history_map, free_link_history_);
rephist_total_alloc -= sizeof(or_history_t);
rephist_total_num--;
tor_free(hist);
@ -715,56 +665,18 @@ rep_hist_have_measured_enough_stability(void)
return started_tracking_stability < time(NULL) - 4*60*60;
}
/** Remember that we successfully extended from the OR with identity
* digest <b>from_id</b> to the OR with identity digest
* <b>to_name</b>.
*/
void
rep_hist_note_extend_succeeded(const char *from_id, const char *to_id)
{
link_history_t *hist;
/* log_fn(LOG_WARN, "EXTEND SUCCEEDED: %s->%s",from_name,to_name); */
hist = get_link_history(from_id, to_id);
if (!hist)
return;
++hist->n_extend_ok;
hist->changed = time(NULL);
}
/** Remember that we tried to extend from the OR with identity digest
* <b>from_id</b> to the OR with identity digest <b>to_name</b>, but
* failed.
*/
void
rep_hist_note_extend_failed(const char *from_id, const char *to_id)
{
link_history_t *hist;
/* log_fn(LOG_WARN, "EXTEND FAILED: %s->%s",from_name,to_name); */
hist = get_link_history(from_id, to_id);
if (!hist)
return;
++hist->n_extend_fail;
hist->changed = time(NULL);
}
/** Log all the reliability data we have remembered, with the chosen
* severity.
*/
void
rep_hist_dump_stats(time_t now, int severity)
{
digestmap_iter_t *lhist_it;
digestmap_iter_t *orhist_it;
const char *name1, *name2, *digest1, *digest2;
const char *name1, *digest1;
char hexdigest1[HEX_DIGEST_LEN+1];
char hexdigest2[HEX_DIGEST_LEN+1];
or_history_t *or_history;
link_history_t *link_history;
void *or_history_p, *link_history_p;
void *or_history_p;
double uptime;
char buffer[2048];
size_t len;
int ret;
unsigned long upt, downt;
const node_t *node;
@ -802,35 +714,6 @@ rep_hist_dump_stats(time_t now, int severity)
or_history->n_conn_ok, or_history->n_conn_fail+or_history->n_conn_ok,
upt, upt+downt, uptime*100.0,
stability/3600, (stability/60)%60, stability%60);
if (!digestmap_isempty(or_history->link_history_map)) {
strlcpy(buffer, " Extend attempts: ", sizeof(buffer));
len = strlen(buffer);
for (lhist_it = digestmap_iter_init(or_history->link_history_map);
!digestmap_iter_done(lhist_it);
lhist_it = digestmap_iter_next(or_history->link_history_map,
lhist_it)) {
digestmap_iter_get(lhist_it, &digest2, &link_history_p);
if ((node = node_get_by_id(digest2)) && node_get_nickname(node))
name2 = node_get_nickname(node);
else
name2 = "(unknown)";
link_history = (link_history_t*) link_history_p;
base16_encode(hexdigest2, sizeof(hexdigest2), digest2, DIGEST_LEN);
ret = tor_snprintf(buffer+len, 2048-len, "%s [%s](%ld/%ld); ",
name2,
hexdigest2,
link_history->n_extend_ok,
link_history->n_extend_ok+link_history->n_extend_fail);
if (ret<0)
break;
else
len += ret;
}
tor_log(severity, LD_HIST, "%s", buffer);
}
}
}
@ -842,10 +725,9 @@ rep_history_clean(time_t before)
{
int authority = authdir_mode(get_options());
or_history_t *or_history;
link_history_t *link_history;
void *or_history_p, *link_history_p;
digestmap_iter_t *orhist_it, *lhist_it;
const char *d1, *d2;
void *or_history_p;
digestmap_iter_t *orhist_it;
const char *d1;
orhist_it = digestmap_iter_init(history_map);
while (!digestmap_iter_done(orhist_it)) {
@ -862,19 +744,6 @@ rep_history_clean(time_t before)
free_or_history(or_history);
continue;
}
for (lhist_it = digestmap_iter_init(or_history->link_history_map);
!digestmap_iter_done(lhist_it); ) {
digestmap_iter_get(lhist_it, &d2, &link_history_p);
link_history = link_history_p;
if (link_history->changed < before) {
lhist_it = digestmap_iter_next_rmv(or_history->link_history_map,
lhist_it);
rephist_total_alloc -= sizeof(link_history_t);
tor_free(link_history);
continue;
}
lhist_it = digestmap_iter_next(or_history->link_history_map,lhist_it);
}
orhist_it = digestmap_iter_next(history_map, orhist_it);
}
}

View File

@ -17,9 +17,6 @@ void rep_hist_note_connect_failed(const char* nickname, time_t when);
void rep_hist_note_connect_succeeded(const char* nickname, time_t when);
void rep_hist_note_disconnect(const char* nickname, time_t when);
void rep_hist_note_connection_died(const char* nickname, time_t when);
void rep_hist_note_extend_succeeded(const char *from_name,
const char *to_name);
void rep_hist_note_extend_failed(const char *from_name, const char *to_name);
void rep_hist_dump_stats(time_t now, int severity);
void rep_hist_note_bytes_read(size_t num_bytes, time_t when);
void rep_hist_note_bytes_written(size_t num_bytes, time_t when);