From 1755f792ed265dcea70a199c19ffde47aae7544b Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 15 Jun 2012 10:16:00 -0400 Subject: Refactor GETINFO process/descriptor-limit Previously it duplicated some getrlimit code and content from compat.c; now it doesn't. --- changes/descriptor_limit | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changes/descriptor_limit (limited to 'changes') diff --git a/changes/descriptor_limit b/changes/descriptor_limit new file mode 100644 index 000000000..29be3d981 --- /dev/null +++ b/changes/descriptor_limit @@ -0,0 +1,2 @@ + o Code simplification and refactoring: + - Remove duplicate code for invoking getrlimit() from control.c. -- cgit v1.2.3 From e62104a7d21432380c66db1901215412e9c53ad7 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 15 Jun 2012 10:31:34 -0400 Subject: Move tor_gettimeofday_cached() into compat_libevent --- changes/move_cached_gtod | 3 +++ src/common/compat_libevent.c | 34 ++++++++++++++++++++++++++++++++++ src/common/compat_libevent.h | 3 +++ src/or/relay.c | 23 ----------------------- src/or/relay.h | 2 -- 5 files changed, 40 insertions(+), 25 deletions(-) create mode 100644 changes/move_cached_gtod (limited to 'changes') diff --git a/changes/move_cached_gtod b/changes/move_cached_gtod new file mode 100644 index 000000000..53d80920f --- /dev/null +++ b/changes/move_cached_gtod @@ -0,0 +1,3 @@ + o Code simplification and refactoring: + - Move tor_gettimeofday_cached() into compat_libevent.c, and use + Libevent's notion of cached time when possible. diff --git a/src/common/compat_libevent.c b/src/common/compat_libevent.c index 9f7ac6323..544d16a21 100644 --- a/src/common/compat_libevent.c +++ b/src/common/compat_libevent.c @@ -689,3 +689,37 @@ tor_add_bufferevent_to_rate_limit_group(struct bufferevent *bev, } #endif +#if defined(LIBEVENT_VERSION_NUMBER) && LIBEVENT_VERSION_NUMBER >= V(2,1,1) +void +tor_gettimeofday_cached(struct timeval *tv) +{ + event_base_gettimeofday_cached(the_event_base, tv); +} +void +tor_gettimeofday_cache_clear(void) +{ + event_base_update_cache_time(the_event_base); +} +#else +/** Cache the current hi-res time; the cache gets reset when libevent + * calls us. */ +static struct timeval cached_time_hires = {0, 0}; + +/** Return a fairly recent view of the current time. */ +void +tor_gettimeofday_cached(struct timeval *tv) +{ + if (cached_time_hires.tv_sec == 0) { + tor_gettimeofday(&cached_time_hires); + } + *tv = cached_time_hires; +} + +/** Reset the cached view of the current time, so that the next time we try + * to learn it, we will get an up-to-date value. */ +void +tor_gettimeofday_cache_clear(void) +{ + cached_time_hires.tv_sec = 0; +} +#endif diff --git a/src/common/compat_libevent.h b/src/common/compat_libevent.h index 224c76fda..56285ef80 100644 --- a/src/common/compat_libevent.h +++ b/src/common/compat_libevent.h @@ -88,5 +88,8 @@ int tor_add_bufferevent_to_rate_limit_group(struct bufferevent *bev, struct bufferevent_rate_limit_group *g); #endif +void tor_gettimeofday_cached(struct timeval *tv); +void tor_gettimeofday_cache_clear(void); + #endif diff --git a/src/or/relay.c b/src/or/relay.c index 8bbc9891e..3f894bfe1 100644 --- a/src/or/relay.c +++ b/src/or/relay.c @@ -52,11 +52,6 @@ static int circuit_consider_stop_edge_reading(circuit_t *circ, crypt_path_t *layer_hint); static int circuit_queue_streams_are_blocked(circuit_t *circ); -/* XXXX023 move this all to compat_libevent */ -/** Cache the current hi-res time; the cache gets reset when libevent - * calls us. */ -static struct timeval cached_time_hires = {0, 0}; - /** Stop reading on edge connections when we have this many cells * waiting on the appropriate queue. */ #define CELL_QUEUE_HIGHWATER_SIZE 256 @@ -64,24 +59,6 @@ static struct timeval cached_time_hires = {0, 0}; * cells. */ #define CELL_QUEUE_LOWWATER_SIZE 64 -/** Return a fairly recent view of the current time. */ -static void -tor_gettimeofday_cached(struct timeval *tv) -{ - if (cached_time_hires.tv_sec == 0) { - tor_gettimeofday(&cached_time_hires); - } - *tv = cached_time_hires; -} - -/** Reset the cached view of the current time, so that the next time we try - * to learn it, we will get an up-to-date value. */ -void -tor_gettimeofday_cache_clear(void) -{ - cached_time_hires.tv_sec = 0; -} - /** Stats: how many relay cells have originated at this hop, or have * been relayed onward (not recognized at this hop)? */ diff --git a/src/or/relay.h b/src/or/relay.h index 6a5437365..41675e210 100644 --- a/src/or/relay.h +++ b/src/or/relay.h @@ -64,8 +64,6 @@ void cell_ewma_set_scale_factor(const or_options_t *options, const networkstatus_t *consensus); void circuit_clear_cell_queue(circuit_t *circ, or_connection_t *orconn); -void tor_gettimeofday_cache_clear(void); - #ifdef RELAY_PRIVATE int relay_crypt(circuit_t *circ, cell_t *cell, cell_direction_t cell_direction, crypt_path_t **layer_hint, char *recognized); -- cgit v1.2.3 From 32bf25888110482255cda8bcc77fb4fc7d8c0d38 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 15 Jun 2012 10:40:37 -0400 Subject: Change a silent ignore-the-bug in microdesc.c to a LOG_INFO I don't believe this bug occurs, but there was an XXX023 to make sure it doesn't. --- changes/log_bad_md_entry | 3 +++ src/or/microdesc.c | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 changes/log_bad_md_entry (limited to 'changes') diff --git a/changes/log_bad_md_entry b/changes/log_bad_md_entry new file mode 100644 index 000000000..3c653277c --- /dev/null +++ b/changes/log_bad_md_entry @@ -0,0 +1,3 @@ + o Minor features (debugging): + - Log a BUG message at INFO if we have a networkstatus with a missing + entry for some microdescriptor. diff --git a/src/or/microdesc.c b/src/or/microdesc.c index 10dab2533..d5a27d527 100644 --- a/src/or/microdesc.c +++ b/src/or/microdesc.c @@ -643,8 +643,13 @@ microdesc_list_missing_digest256(networkstatus_t *ns, microdesc_cache_t *cache, continue; if (skip && digestmap_get(skip, rs->descriptor_digest)) continue; - if (tor_mem_is_zero(rs->descriptor_digest, DIGEST256_LEN)) - continue; /* This indicates a bug somewhere XXXX023*/ + if (tor_mem_is_zero(rs->descriptor_digest, DIGEST256_LEN)) { + log_info(LD_BUG, "Found an entry in networktatus with no microdescriptor " + "digest. (Router %s=%s at %s:%d.)", rs->nickname, + hex_str(rs->identity_digest, DIGEST_LEN), + fmt_addr32(rs->addr), rs->or_port); + continue; + } /* XXXX Also skip if we're a noncache and wouldn't use this router. * XXXX NM Microdesc */ -- cgit v1.2.3 From cc21e56ed4cfc9c83b2cbfef9a8ff088471f7925 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 15 Jun 2012 10:50:41 -0400 Subject: Check the correct consensus before giving it to the client Previously, a directory would check the latest NS consensus for having the signatures the client wanted, and use that consensus's valid_until time to set the HTTP lifetime. With this patch, the directory looks at NS consensus or the microdesc consensus, depending on what the client asked for. --- changes/check_correct_flav_sigs | 4 ++++ src/or/directory.c | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 changes/check_correct_flav_sigs (limited to 'changes') diff --git a/changes/check_correct_flav_sigs b/changes/check_correct_flav_sigs new file mode 100644 index 000000000..db21182dd --- /dev/null +++ b/changes/check_correct_flav_sigs @@ -0,0 +1,4 @@ + o Minor bugfixes: + - When checking for requested signatures on the latest consensus before + serving it to a client, make sure to check the right consensus flavor. + Bugfix on 0.2.2.6-alpha. diff --git a/src/or/directory.c b/src/or/directory.c index ee05ff897..1fb4835d0 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -2775,10 +2775,11 @@ directory_handle_command_get(dir_connection_t *conn, const char *headers, else request_type = "/tor/status/?"; } else { - networkstatus_t *v = networkstatus_get_latest_consensus(); + networkstatus_t *v; time_t now = time(NULL); const char *want_fps = NULL; char *flavor = NULL; + int flav = FLAV_NS; #define CONSENSUS_URL_PREFIX "/tor/status-vote/current/consensus/" #define CONSENSUS_FLAVORED_PREFIX "/tor/status-vote/current/consensus-" /* figure out the flavor if any, and who we wanted to sign the thing */ @@ -2792,12 +2793,16 @@ directory_handle_command_get(dir_connection_t *conn, const char *headers, } else { flavor = tor_strdup(f); } + flav = networkstatus_parse_flavor_name(flavor); + if (flav < 0) + flav = FLAV_NS; } else { if (!strcmpstart(url, CONSENSUS_URL_PREFIX)) want_fps = url+strlen(CONSENSUS_URL_PREFIX); } - /* XXXX023 MICRODESC NM NM should check document of correct flavor */ + v = networkstatus_get_latest_consensus_by_flavor(flav); + if (v && want_fps && !client_likes_consensus(v, want_fps)) { write_http_status_line(conn, 404, "Consensus not signed by sufficient " -- cgit v1.2.3