Some final (?) cleanups of proposal 166 implementation.

This commit is contained in:
Karsten Loesing 2009-08-19 23:36:27 +02:00
parent 93fd0d3755
commit 75c59d1a92
6 changed files with 53 additions and 24 deletions

View File

@ -4,20 +4,21 @@ Changes in version 0.2.2.1-alpha - 2009-0?-??
via new AccelName and AccelDir options. via new AccelName and AccelDir options.
o New options for gathering stats safely: o New options for gathering stats safely:
- Directories that set "DirReqStatistics 1" write directory request - Directories that set "DirReqStatistics 1" write statistics on
stats to disk every 24 hours. As compared to the --enable-geoip-stats directory request to disk every 24 hours. As compared to the
flag in 0.2.1.x, there are a few improvements: 1) stats are written --enable-geoip-stats flag in 0.2.1.x, there are a few improvements:
to disk exactly every 24 hours; 2) estimated shares of v2 and v3 1) stats are written to disk exactly every 24 hours; 2) estimated
requests are determined as mean values, not at the end of a shares of v2 and v3 requests are determined as mean values, not at
measurement period; 3) unresolved requests are listed with country the end of a measurement period; 3) unresolved requests are listed
code '??'; 4) directories also measure download times. with country code '??'; 4) directories also measure download times.
- Exit nodes that set "ExitPortStatistics 1" write statistics on the - Exit nodes that set "ExitPortStatistics 1" write statistics on the
number of exit streams and transferred bytes per port to disk every number of exit streams and transferred bytes per port to disk every
24 hours. 24 hours.
- Relays that set "CellStatistics 1" write statistics to disk every - Relays that set "CellStatistics 1" write statistics on how long
24 hours on how long cells spend in their circuit queues. cells spend in their circuit queues to disk every 24 hours.
- Entry nodes that set "EntryStatistics 1" write statistics to disk - Entry nodes that set "EntryStatistics 1" write statistics on the
every 24 hours on the rough number and origins of connecting clients. rough number and origins of connecting clients to disk every 24
hours.
- Relays that write any of the above statistics to disk and set - Relays that write any of the above statistics to disk and set
"ExtraInfoStatistics 1" include the past 24 hours of statistics in "ExtraInfoStatistics 1" include the past 24 hours of statistics in
their extra-info documents. their extra-info documents.

View File

@ -86,7 +86,7 @@ Proposals by number:
163 Detecting whether a connection comes from a client [OPEN] 163 Detecting whether a connection comes from a client [OPEN]
164 Reporting the status of server votes [OPEN] 164 Reporting the status of server votes [OPEN]
165 Easy migration for voting authority sets [OPEN] 165 Easy migration for voting authority sets [OPEN]
166 Including Network Statistics in Extra-Info Documents [OPEN] 166 Including Network Statistics in Extra-Info Documents [ACCEPTED]
Proposals by status: Proposals by status:
@ -114,7 +114,6 @@ Proposals by status:
163 Detecting whether a connection comes from a client [for 0.2.2] 163 Detecting whether a connection comes from a client [for 0.2.2]
164 Reporting the status of server votes [for 0.2.2] 164 Reporting the status of server votes [for 0.2.2]
165 Easy migration for voting authority sets 165 Easy migration for voting authority sets
166 Including Network Statistics in Extra-Info Documents [for 0.2.2]
ACCEPTED: ACCEPTED:
110 Avoiding infinite length circuits [for 0.2.1.x] [in 0.2.1.3-alpha] 110 Avoiding infinite length circuits [for 0.2.1.x] [in 0.2.1.3-alpha]
117 IPv6 exits [for 0.2.1.x] 117 IPv6 exits [for 0.2.1.x]
@ -122,6 +121,7 @@ Proposals by status:
140 Provide diffs between consensuses [for 0.2.2.x] 140 Provide diffs between consensuses [for 0.2.2.x]
147 Eliminate the need for v2 directories in generating v3 directories [for 0.2.1.x] 147 Eliminate the need for v2 directories in generating v3 directories [for 0.2.1.x]
157 Make certificate downloads specific [for 0.2.1.x] 157 Make certificate downloads specific [for 0.2.1.x]
166 Including Network Statistics in Extra-Info Documents [for 0.2.2]
META: META:
000 Index of Tor Proposals 000 Index of Tor Proposals
001 The Tor Proposal Process 001 The Tor Proposal Process

View File

@ -3,7 +3,7 @@ Title: Including Network Statistics in Extra-Info Documents
Author: Karsten Loesing Author: Karsten Loesing
Created: 21-Jul-2009 Created: 21-Jul-2009
Target: 0.2.2 Target: 0.2.2
Status: Open Status: Accepted
Change history: Change history:

View File

@ -388,6 +388,36 @@ geoip_note_client_seen(geoip_client_action_t action,
return; return;
} }
/* As a bridge that doesn't rotate request periods every 24 hours,
* possibly rotate now. */
if (options->BridgeRelay) {
while (current_request_period_starts + REQUEST_HIST_PERIOD < now) {
if (!geoip_countries)
geoip_countries = smartlist_create();
if (!current_request_period_starts) {
current_request_period_starts = now;
break;
}
/* Also discard all items in the client history that are too old.
* (This only works here because bridge and directory stats are
* independent. Otherwise, we'd only want to discard those items
* with action GEOIP_CLIENT_NETWORKSTATUS{_V2}.) */
geoip_remove_old_clients(current_request_period_starts);
/* Now rotate request period */
SMARTLIST_FOREACH(geoip_countries, geoip_country_t *, c, {
memmove(&c->n_v2_ns_requests[0], &c->n_v2_ns_requests[1],
sizeof(uint32_t)*(REQUEST_HIST_LEN-1));
memmove(&c->n_v3_ns_requests[0], &c->n_v3_ns_requests[1],
sizeof(uint32_t)*(REQUEST_HIST_LEN-1));
c->n_v2_ns_requests[REQUEST_HIST_LEN-1] = 0;
c->n_v3_ns_requests[REQUEST_HIST_LEN-1] = 0;
});
current_request_period_starts += REQUEST_HIST_PERIOD;
if (n_old_request_periods < REQUEST_HIST_LEN-1)
++n_old_request_periods;
}
}
lookup.ipaddr = addr; lookup.ipaddr = addr;
lookup.action = (int)action; lookup.action = (int)action;
ent = HT_FIND(clientmap, &client_history, &lookup); ent = HT_FIND(clientmap, &client_history, &lookup);
@ -949,7 +979,8 @@ geoip_dirreq_stats_write(time_t now)
if (!out) if (!out)
goto done; goto done;
if (fprintf(out, "dirreq-stats-end %s (%d s)\ndirreq-v3-ips %s\n" if (fprintf(out, "dirreq-stats-end %s (%d s)\ndirreq-v3-ips %s\n"
"dirreq-v2-ips %s\n", written, REQUEST_HIST_PERIOD, "dirreq-v2-ips %s\n", written,
(unsigned) (now - start_of_dirreq_stats_interval),
data_v3 ? data_v3 : "", data_v2 ? data_v2 : "") < 0) data_v3 ? data_v3 : "", data_v2 ? data_v2 : "") < 0)
goto done; goto done;
tor_free(data_v2); tor_free(data_v2);

View File

@ -962,7 +962,6 @@ run_scheduled_events(time_t now)
*/ */
if (time_to_write_stats_files >= 0 && time_to_write_stats_files < now) { if (time_to_write_stats_files >= 0 && time_to_write_stats_files < now) {
#define WRITE_STATS_INTERVAL (24*60*60) #define WRITE_STATS_INTERVAL (24*60*60)
or_options_t *options = get_options();
if (options->CellStatistics || options->DirReqStatistics || if (options->CellStatistics || options->DirReqStatistics ||
options->EntryStatistics || options->ExitPortStatistics) { options->EntryStatistics || options->ExitPortStatistics) {
if (!time_to_write_stats_files) { if (!time_to_write_stats_files) {

View File

@ -1847,18 +1847,18 @@ load_stats_file(const char *filename, const char *end_line, time_t after,
if (start != contents) if (start != contents)
start++; /* Avoid infinite loops. */ start++; /* Avoid infinite loops. */
if (!(start = strstr(start, end_line))) if (!(start = strstr(start, end_line)))
goto err; goto notfound;
if (strlen(start) < strlen(end_line) + sizeof(timestr)) if (strlen(start) < strlen(end_line) + 1 + sizeof(timestr))
goto err; goto notfound;
strlcpy(timestr, start + 1 + strlen(end_line), sizeof(timestr)); strlcpy(timestr, start + 1 + strlen(end_line), sizeof(timestr));
if (parse_iso_time(timestr, &written) < 0) if (parse_iso_time(timestr, &written) < 0)
goto err; goto notfound;
} while (written < after); } while (written <= after);
*out = tor_malloc(strlen(start)); *out = tor_malloc(strlen(start));
strlcpy(*out, start, strlen(start)); strlcpy(*out, start, strlen(start));
r = 1; r = 1;
} }
err: notfound:
tor_free(contents); tor_free(contents);
break; break;
case FN_NOENT: case FN_NOENT:
@ -2011,8 +2011,6 @@ extrainfo_dump_to_string(char *s, size_t maxlen, extrainfo_t *extrainfo,
extrainfo_free(ei_tmp); extrainfo_free(ei_tmp);
} }
log_info(LD_GENERAL, "Done with dumping our extra-info descriptor.");
return (int)strlen(s)+1; return (int)strlen(s)+1;
} }