From 85c598cbc2d4ca1a7c729864002b5b222980ce19 Mon Sep 17 00:00:00 2001 From: teor Date: Tue, 8 Jan 2019 18:21:10 +1000 Subject: [PATCH 1/4] stats: Make PaddingStatistics depend on ExtraInfoStatistics When ExtraInfoStatistics is 0, stop including PaddingStatistics in relay and bridge extra-info documents. Fixes bug 29017; bugfix on 0.3.1.1-alpha. --- changes/bug29017 | 4 ++++ doc/tor.1.txt | 2 +- src/or/router.c | 11 +++++------ 3 files changed, 10 insertions(+), 7 deletions(-) create mode 100644 changes/bug29017 diff --git a/changes/bug29017 b/changes/bug29017 new file mode 100644 index 0000000000..5c4a53c43f --- /dev/null +++ b/changes/bug29017 @@ -0,0 +1,4 @@ + o Minor bugfixes (stats): + - When ExtraInfoStatistics is 0, stop including PaddingStatistics in + relay and bridge extra-info documents. Fixes bug 29017; + bugfix on 0.3.1.1-alpha. diff --git a/doc/tor.1.txt b/doc/tor.1.txt index c089bffbb0..790ac6f6ae 100644 --- a/doc/tor.1.txt +++ b/doc/tor.1.txt @@ -2266,7 +2266,7 @@ is non-zero): extra-info document. (Default: 0) [[PaddingStatistics]] **PaddingStatistics** **0**|**1**:: - Relays only. + Relays and bridges only. When this option is enabled, Tor collects statistics for padding cells sent and received by this relay, in addition to total cell counts. These statistics are rounded, and omitted if traffic is low. This diff --git a/src/or/router.c b/src/or/router.c index edaa040dd7..c308bcfae1 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -3304,12 +3304,11 @@ extrainfo_dump_to_string(char **s_out, extrainfo_t *extrainfo, "conn-bi-direct", now, &contents) > 0) { smartlist_add(chunks, contents); } - } - - if (options->PaddingStatistics) { - contents = rep_hist_get_padding_count_lines(); - if (contents) - smartlist_add(chunks, contents); + if (options->PaddingStatistics) { + contents = rep_hist_get_padding_count_lines(); + if (contents) + smartlist_add(chunks, contents); + } } /* Add information about the pluggable transports we support. */ From b4e44a371f077f5a9fca19f94e6ff5f604f3e9d3 Mon Sep 17 00:00:00 2001 From: David Goulet Date: Fri, 8 Mar 2019 09:54:54 -0500 Subject: [PATCH 2/4] hs-v2: Copy needed information between service on prunning Turns out that when reloading a tor configured with hidden service(s), we weren't copying all the needed information between the old service object to the new one. For instance, the desc_is_dirty timestamp wasn't which could lead to the service uploading its descriptor much later than it would need to. The replaycache wasn't also moved over and some intro point information as well. Fixes #23790 Signed-off-by: David Goulet --- changes/bug23790 | 6 ++++++ src/or/rendservice.c | 27 +++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 changes/bug23790 diff --git a/changes/bug23790 b/changes/bug23790 new file mode 100644 index 0000000000..4aaf616e4d --- /dev/null +++ b/changes/bug23790 @@ -0,0 +1,6 @@ + o Minor bugfixes (hidden service v2): + - When reloading tor (HUP) configured with hidden service(s), some + information weren't copy to the new service object. One problem with this + was that tor would wait at least the RendPostPeriod time before uploading + the descriptor if the reload happened before the descriptor needed to be + published. Fixes bug 23790; bugfix on 0.2.1.9-alpha. diff --git a/src/or/rendservice.c b/src/or/rendservice.c index da200d1381..32b856452d 100644 --- a/src/or/rendservice.c +++ b/src/or/rendservice.c @@ -532,6 +532,30 @@ rend_service_check_dir_and_add(smartlist_t *service_list, } } +/* Copy relevant data from service src to dst while pruning the service lists. + * This should only be called during the pruning process which takes existing + * services and copy their data to the newly configured services. The src + * service replaycache will be set to NULL after this call. */ +static void +copy_service_on_prunning(rend_service_t *dst, rend_service_t *src) +{ + tor_assert(dst); + tor_assert(src); + + /* Keep the timestamps for when the content changed and the next upload + * time so we can properly upload the descriptor if needed for the new + * service object. */ + dst->desc_is_dirty = src->desc_is_dirty; + dst->next_upload_time = src->next_upload_time; + /* Move the replaycache to the new object. */ + dst->accepted_intro_dh_parts = src->accepted_intro_dh_parts; + src->accepted_intro_dh_parts = NULL; + /* Copy intro point information to destination service. */ + dst->intro_period_started = src->intro_period_started; + dst->n_intro_circuits_launched = src->n_intro_circuits_launched; + dst->n_intro_points_wanted = src->n_intro_points_wanted; +} + /** Set up rend_service_list, based on the values of HiddenServiceDir and * HiddenServicePort in options. Return 0 on success and -1 on * failure. (If validate_only is set, parse, warn and return as @@ -812,6 +836,9 @@ rend_config_services(const or_options_t *options, int validate_only) smartlist_add_all(new->expiring_nodes, old->expiring_nodes); smartlist_clear(old->expiring_nodes); smartlist_add(surviving_services, old); + + /* Copy service flags to the new service object. */ + copy_service_on_prunning(new, old); break; } } SMARTLIST_FOREACH_END(old); From add0f89c14b4aab6726e11acdcd864ee0c91543b Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Sat, 9 Mar 2019 02:55:28 -0500 Subject: [PATCH 3/4] relays shouldn't close idle rend circuits Allow connections to single onion services to remain idle without being disconnected. Relays acting as rendezvous points for single onion services were mistakenly closing idle established rendezvous circuits after 60 seconds, thinking that they are unused directory-fetching circuits that had served their purpose. Fixes bug 29665; bugfix on 0.2.1.26. --- changes/bug29665 | 7 +++++++ src/or/circuituse.c | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 changes/bug29665 diff --git a/changes/bug29665 b/changes/bug29665 new file mode 100644 index 0000000000..d89046faf5 --- /dev/null +++ b/changes/bug29665 @@ -0,0 +1,7 @@ + o Minor bugfixes (single onion services): + - Allow connections to single onion services to remain idle without + being disconnected. Relays acting as rendezvous points for + single onion services were mistakenly closing idle established + rendezvous circuits after 60 seconds, thinking that they are unused + directory-fetching circuits that had served their purpose. Fixes + bug 29665; bugfix on 0.2.1.26. diff --git a/src/or/circuituse.c b/src/or/circuituse.c index 96cd3cd7e8..7c0b60293d 100644 --- a/src/or/circuituse.c +++ b/src/or/circuituse.c @@ -1381,10 +1381,13 @@ circuit_expire_old_circuits_serverside(time_t now) or_circ = TO_OR_CIRCUIT(circ); /* If the circuit has been idle for too long, and there are no streams * on it, and it ends here, and it used a create_fast, mark it for close. + * + * Also if there is a rend_splice on it, it's a single onion service + * circuit and we should not close it. */ if (or_circ->is_first_hop && !circ->n_chan && !or_circ->n_streams && !or_circ->resolving_streams && - or_circ->p_chan && + or_circ->p_chan && !or_circ->rend_splice && channel_when_last_xmit(or_circ->p_chan) <= cutoff) { log_info(LD_CIRC, "Closing circ_id %u (empty %d secs ago)", (unsigned)or_circ->p_circ_id, From a3bc950e4201fe49e7a0996753a4af83d822828b Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Sat, 9 Mar 2019 03:18:25 -0500 Subject: [PATCH 4/4] relays shouldn't close idle rend circuits Allow connections to single onion services to remain idle without being disconnected. Relays acting as rendezvous points for single onion services were mistakenly closing idle established rendezvous circuits after 60 seconds, thinking that they are unused directory-fetching circuits that had served their purpose. Fixes bug 29665; bugfix on 0.2.1.26. --- changes/bug29665 | 7 +++++++ src/or/circuituse.c | 4 ++++ 2 files changed, 11 insertions(+) create mode 100644 changes/bug29665 diff --git a/changes/bug29665 b/changes/bug29665 new file mode 100644 index 0000000000..d89046faf5 --- /dev/null +++ b/changes/bug29665 @@ -0,0 +1,7 @@ + o Minor bugfixes (single onion services): + - Allow connections to single onion services to remain idle without + being disconnected. Relays acting as rendezvous points for + single onion services were mistakenly closing idle established + rendezvous circuits after 60 seconds, thinking that they are unused + directory-fetching circuits that had served their purpose. Fixes + bug 29665; bugfix on 0.2.1.26. diff --git a/src/or/circuituse.c b/src/or/circuituse.c index 8e007ce920..03f2ae52cf 100644 --- a/src/or/circuituse.c +++ b/src/or/circuituse.c @@ -1560,10 +1560,14 @@ circuit_expire_old_circuits_serverside(time_t now) or_circ = TO_OR_CIRCUIT(circ); /* If the circuit has been idle for too long, and there are no streams * on it, and it ends here, and it used a create_fast, mark it for close. + * + * Also if there is a rend_splice on it, it's a single onion service + * circuit and we should not close it. */ if (or_circ->p_chan && channel_is_client(or_circ->p_chan) && !circ->n_chan && !or_circ->n_streams && !or_circ->resolving_streams && + !or_circ->rend_splice && channel_when_last_xmit(or_circ->p_chan) <= cutoff) { log_info(LD_CIRC, "Closing circ_id %u (empty %d secs ago)", (unsigned)or_circ->p_circ_id,