From 2b63fa40e8349e0e6c40d0660d9df5b0ba73937e Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Mon, 27 Jul 2009 21:01:24 -0400 Subject: [PATCH 1/7] three hacks to workaround bug 1038 The problem is that clients and hidden services are receiving relay_early cells, and they tear down the circuit. Hack #1 is for rendezvous points to rewrite relay_early cells to relay cells. That way there are never any incoming relay_early cells. Hack #2 is for clients and hidden services to never send a relay_early cell on an established rendezvous circuit. That works around rendezvous points that haven't upgraded yet. Hack #3 is for clients and hidden services to not tear down the circuit when they receive an inbound relay_early cell. We already refuse extend cells at clients. --- ChangeLog | 6 ++++++ src/or/command.c | 8 ++------ src/or/or.h | 5 +++++ src/or/relay.c | 17 ++++++++++++----- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 66664c18d1..59404929cf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Changes in version 0.2.1.19 - 2009-07-?? + o Major bugfixes: + - Make accessing hidden services on 0.2.1.x work right + again. Bugfix on 0.2.1.3-alpha; workaround for bug 1038. + + Changes in version 0.2.1.18 - 2009-07-24 o Build fixes: - Add LIBS=-lrt to Makefile.am so the Tor RPMs use a static libevent. diff --git a/src/or/command.c b/src/or/command.c index 9481e5bcc6..c36874be5c 100644 --- a/src/or/command.c +++ b/src/or/command.c @@ -395,12 +395,8 @@ command_process_relay_cell(cell_t *cell, or_connection_t *conn) * gotten no more than MAX_RELAY_EARLY_CELLS_PER_CIRCUIT of them. */ if (cell->command == CELL_RELAY_EARLY) { if (direction == CELL_DIRECTION_IN) { - log_fn(LOG_PROTOCOL_WARN, LD_OR, - "Received an inbound RELAY_EARLY cell on circuit %d from %s:%d." - " Closing circuit.", - cell->circ_id, conn->_base.address, conn->_base.port); - circuit_mark_for_close(circ, END_CIRC_REASON_TORPROTOCOL); - return; + /* XXX Allow an unlimited number of inbound relay_early cells for + * now, for hidden service compatibility. See bug 1038. -RD */ } else { or_circuit_t *or_circ = TO_OR_CIRCUIT(circ); if (or_circ->remaining_relay_early_cells == 0) { diff --git a/src/or/or.h b/src/or/or.h index eddeda1531..fba7af0da0 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -488,6 +488,11 @@ typedef enum { (p)<=_CIRCUIT_PURPOSE_C_MAX) /** True iff the circuit_t c is actually an origin_circuit_t. */ #define CIRCUIT_IS_ORIGIN(c) (CIRCUIT_PURPOSE_IS_ORIGIN((c)->purpose)) +/** True iff the circuit purpose p is for an established rendezvous + * circuit. */ +#define CIRCUIT_PURPOSE_IS_ESTABLISHED_REND(p) \ + ((p) == CIRCUIT_PURPOSE_C_REND_JOINED || \ + (p) == CIRCUIT_PURPOSE_S_REND_JOINED) /** How many circuits do we want simultaneously in-progress to handle * a given stream? */ diff --git a/src/or/relay.c b/src/or/relay.c index 8099f4f072..3419e3d190 100644 --- a/src/or/relay.c +++ b/src/or/relay.c @@ -208,6 +208,7 @@ circuit_receive_relay_cell(cell_t *cell, circuit_t *circ, tor_assert(circ->purpose == CIRCUIT_PURPOSE_REND_ESTABLISHED); tor_assert(splice->_base.purpose == CIRCUIT_PURPOSE_REND_ESTABLISHED); cell->circ_id = splice->p_circ_id; + cell->command = CELL_RELAY; /* can't be relay_early anyway */ if ((reason = circuit_receive_relay_cell(cell, TO_CIRCUIT(splice), CELL_DIRECTION_IN)) < 0) { log_warn(LD_REND, "Error relaying cell across rendezvous; closing " @@ -541,11 +542,17 @@ relay_send_command_from_edge(uint16_t stream_id, circuit_t *circ, origin_circuit_t *origin_circ = TO_ORIGIN_CIRCUIT(circ); if (origin_circ->remaining_relay_early_cells > 0 && (relay_command == RELAY_COMMAND_EXTEND || - cpath_layer != origin_circ->cpath)) { - /* If we've got any relay_early cells left, and we're sending a relay - * cell or we're not talking to the first hop, use one of them. Don't - * worry about the conn protocol version: append_cell_to_circuit_queue - * will fix it up. */ + (cpath_layer != origin_circ->cpath && + !CIRCUIT_PURPOSE_IS_ESTABLISHED_REND(circ->purpose)))) { + /* If we've got any relay_early cells left, and we're sending + * an extend cell or (we're not talking to the first hop and we're + * not talking to a rendezvous circuit), use one of them. + * Don't worry about the conn protocol version: + * append_cell_to_circuit_queue will fix it up. */ + /* XXX For now, clients don't use RELAY_EARLY cells when sending + * relay cells on rendezvous circuits. See bug 1038. Eventually, + * we can take this behavior away in favor of having clients avoid + * rendezvous points running 0.2.1.3-alpha through 0.2.1.18. -RD */ cell.command = CELL_RELAY_EARLY; --origin_circ->remaining_relay_early_cells; log_debug(LD_OR, "Sending a RELAY_EARLY cell; %d remaining.", From 0a4e2397c0f184a1717ec7475381f9d12f189cb7 Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Mon, 27 Jul 2009 22:38:09 -0400 Subject: [PATCH 2/7] Don't leak memory if we get too many create cells Specifically, every time we get a create cell but we have so many already queued that we refuse it. Bugfix on 0.2.0.19-alpha; fixes bug 1034. Reported by BarkerJr. --- ChangeLog | 5 +++++ src/or/cpuworker.c | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 59404929cf..fed57aaf4f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,11 @@ Changes in version 0.2.1.19 - 2009-07-?? - Make accessing hidden services on 0.2.1.x work right again. Bugfix on 0.2.1.3-alpha; workaround for bug 1038. + o Minor bugfixes: + - Avoid leaking memory every time we get a create cell but we have + so many already queued that we refuse it. Bugfix on 0.2.0.19-alpha; + fixes bug 1034. Reported by BarkerJr. + Changes in version 0.2.1.18 - 2009-07-24 o Build fixes: diff --git a/src/or/cpuworker.c b/src/or/cpuworker.c index 99829e89b5..219fb9d9be 100644 --- a/src/or/cpuworker.c +++ b/src/or/cpuworker.c @@ -444,8 +444,10 @@ assign_onionskin_to_cpuworker(connection_t *cpuworker, if (1) { if (num_cpuworkers_busy == num_cpuworkers) { log_debug(LD_OR,"No idle cpuworkers. Queuing."); - if (onion_pending_add(circ, onionskin) < 0) + if (onion_pending_add(circ, onionskin) < 0) { + tor_free(onionskin); return -1; + } return 0; } From a73acdd46f946a18f678167f2f8083cac18ebe01 Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Mon, 27 Jul 2009 22:51:20 -0400 Subject: [PATCH 3/7] Write fingerprint to file and log without spaces Now it will look like the fingerprints in our bridges documentation, and confuse fewer users. --- ChangeLog | 6 ++++++ src/or/router.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index fed57aaf4f..2747420dd6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,12 @@ Changes in version 0.2.1.19 - 2009-07-?? - Make accessing hidden services on 0.2.1.x work right again. Bugfix on 0.2.1.3-alpha; workaround for bug 1038. + o Minor features: + - When a relay/bridge is writing out its identity key fingerprint to + the "fingerprint" file and to its logs, write it without spaces. Now + it will look like the fingerprints in our bridges documentation, + and confuse fewer users. + o Minor bugfixes: - Avoid leaking memory every time we get a create cell but we have so many already queued that we refuse it. Bugfix on 0.2.0.19-alpha; diff --git a/src/or/router.c b/src/or/router.c index 93afe4fad5..6f899854e3 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -568,7 +568,7 @@ init_keys(void) /* 5. Dump fingerprint to 'fingerprint' */ keydir = get_datadir_fname("fingerprint"); log_info(LD_GENERAL,"Dumping fingerprint to \"%s\"...",keydir); - if (crypto_pk_get_fingerprint(get_identity_key(), fingerprint, 1)<0) { + if (crypto_pk_get_fingerprint(get_identity_key(), fingerprint, 0)<0) { log_err(LD_GENERAL,"Error computing fingerprint"); tor_free(keydir); return -1; From 3e454451045ae032f0e78e48f8f72c1592cc0658 Mon Sep 17 00:00:00 2001 From: Sebastian Hahn Date: Tue, 7 Jul 2009 18:04:00 +0200 Subject: [PATCH 4/7] Changing MaxAdvertisedBW may not need a republish Relays no longer publish a new server descriptor if they change their MaxAdvertisedBandwidth config option but it doesn't end up changing their advertised bandwidth numbers. Bugfix on 0.2.0.28-rc; fixes bug 1026. Patch from Sebastian. --- ChangeLog | 4 ++++ src/or/config.c | 35 ++++++++++++++++++++++++++++------- src/or/or.h | 3 +++ src/or/router.c | 12 ++---------- 4 files changed, 37 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2747420dd6..97972e8a12 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,10 @@ Changes in version 0.2.1.19 - 2009-07-?? and confuse fewer users. o Minor bugfixes: + - Relays no longer publish a new server descriptor if they change + their MaxAdvertisedBandwidth config option but it doesn't end up + changing their advertised bandwidth numbers. Bugfix on 0.2.0.28-rc; + fixes bug 1026. Patch from Sebastian. - Avoid leaking memory every time we get a create cell but we have so many already queued that we refuse it. Bugfix on 0.2.0.19-alpha; fixes bug 1034. Reported by BarkerJr. diff --git a/src/or/config.c b/src/or/config.c index b744f8faf4..3f45b1e5e2 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -1222,6 +1222,30 @@ options_need_geoip_info(or_options_t *options, const char **reason_out) return bridge_usage || routerset_usage; } +/** Return the bandwidthrate that we are going to report to the authorities + * based on the config options. */ +int +get_effective_bwrate(or_options_t *options) +{ + int bw = (int)options->BandwidthRate; + if (bw > options->MaxAdvertisedBandwidth) + bw = (int)options->MaxAdvertisedBandwidth; + if (options->RelayBandwidthRate > 0 && bw > options->RelayBandwidthRate) + bw = (int)options->RelayBandwidthRate; + return bw; +} + +/** Return the bandwidthburst that we are going to report to the authorities + * based on the config options. */ +int +get_effective_bwburst(or_options_t *options) +{ + int bw = (int)options->BandwidthBurst; + if (options->RelayBandwidthBurst > 0 && bw > options->RelayBandwidthBurst) + bw = (int)options->RelayBandwidthBurst; + return bw; +} + /** Fetch the active option list, and take actions based on it. All of the * things we do should survive being done repeatedly. If present, * old_options contains the previous value of the options. @@ -3744,9 +3768,7 @@ options_transition_affects_descriptor(or_options_t *old_options, or_options_t *new_options) { /* XXX We can be smarter here. If your DirPort isn't being - * published and you just turned it off, no need to republish. If - * you changed your bandwidthrate but maxadvertisedbandwidth still - * trumps, no need to republish. Etc. */ + * published and you just turned it off, no need to republish. Etc. */ if (!opt_streq(old_options->DataDirectory, new_options->DataDirectory) || !opt_streq(old_options->Nickname,new_options->Nickname) || !opt_streq(old_options->Address,new_options->Address) || @@ -3759,10 +3781,9 @@ options_transition_affects_descriptor(or_options_t *old_options, old_options->NoPublish != new_options->NoPublish || old_options->_PublishServerDescriptor != new_options->_PublishServerDescriptor || - old_options->BandwidthRate != new_options->BandwidthRate || - old_options->BandwidthBurst != new_options->BandwidthBurst || - old_options->MaxAdvertisedBandwidth != - new_options->MaxAdvertisedBandwidth || + get_effective_bwrate(old_options) != get_effective_bwrate(new_options) || + get_effective_bwburst(old_options) != + get_effective_bwburst(new_options) || !opt_streq(old_options->ContactInfo, new_options->ContactInfo) || !opt_streq(old_options->MyFamily, new_options->MyFamily) || !opt_streq(old_options->AccountingStart, new_options->AccountingStart) || diff --git a/src/or/or.h b/src/or/or.h index fba7af0da0..1dcff28d6d 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -2926,6 +2926,9 @@ int options_need_geoip_info(or_options_t *options, const char **reason_out); int getinfo_helper_config(control_connection_t *conn, const char *question, char **answer); +int get_effective_bwrate(or_options_t *options); +int get_effective_bwburst(or_options_t *options); + #ifdef CONFIG_PRIVATE /* Used only by config.c and test.c */ or_options_t *options_new(void); diff --git a/src/or/router.c b/src/or/router.c index 6f899854e3..859a1e805a 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -1300,18 +1300,10 @@ router_rebuild_descriptor(int force) ri->platform = tor_strdup(platform); /* compute ri->bandwidthrate as the min of various options */ - ri->bandwidthrate = (int)options->BandwidthRate; - if (ri->bandwidthrate > options->MaxAdvertisedBandwidth) - ri->bandwidthrate = (int)options->MaxAdvertisedBandwidth; - if (options->RelayBandwidthRate > 0 && - ri->bandwidthrate > options->RelayBandwidthRate) - ri->bandwidthrate = (int)options->RelayBandwidthRate; + ri->bandwidthrate = get_effective_bwrate(options); /* and compute ri->bandwidthburst similarly */ - ri->bandwidthburst = (int)options->BandwidthBurst; - if (options->RelayBandwidthBurst > 0 && - ri->bandwidthburst > options->RelayBandwidthBurst) - ri->bandwidthburst = (int)options->RelayBandwidthBurst; + ri->bandwidthburst = get_effective_bwburst(options); ri->bandwidthcapacity = hibernating ? 0 : rep_hist_bandwidth_assess(); From 146eae318fe897be61087b525f4b43a1c6b59e6b Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Tue, 28 Jul 2009 17:39:12 -0400 Subject: [PATCH 5/7] document my new relay-early behavior --- doc/spec/tor-spec.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/spec/tor-spec.txt b/doc/spec/tor-spec.txt index 77a91cad8e..a321aa8694 100644 --- a/doc/spec/tor-spec.txt +++ b/doc/spec/tor-spec.txt @@ -661,8 +661,11 @@ see tor-design.pdf. is speaking v2 of the link protocol or later, the OR relays the cell as a RELAY_EARLY cell. Otherwise, it relays it as a RELAY cell. - If a node ever receives more than 8 RELAY_EARLY cells on a given circuit, - it SHOULD close the circuit. + If a node ever receives more than 8 RELAY_EARLY cells on a given + outbound circuit, it SHOULD close the circuit. (For historical reasons, + we don't limit the number of inbound RELAY_EARLY cells; they should + be harmless anyway because clients won't accept extend requests. See + bug 1038.) When speaking v2 of the link protocol or later, clients MUST only send EXTEND cells inside RELAY_EARLY cells. Clients SHOULD send the first ~8 From 69706f99e80aec9414e6a54e76346d4cf89f1a4c Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Tue, 28 Jul 2009 17:39:51 -0400 Subject: [PATCH 6/7] bump to 0.2.1.19 --- ChangeLog | 2 +- configure.in | 2 +- contrib/tor-mingw.nsi.in | 2 +- src/win32/orconfig.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 97972e8a12..ed76e22f95 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,4 @@ -Changes in version 0.2.1.19 - 2009-07-?? +Changes in version 0.2.1.19 - 2009-07-28 o Major bugfixes: - Make accessing hidden services on 0.2.1.x work right again. Bugfix on 0.2.1.3-alpha; workaround for bug 1038. diff --git a/configure.in b/configure.in index 081e176780..5b30198f22 100644 --- a/configure.in +++ b/configure.in @@ -5,7 +5,7 @@ dnl Copyright (c) 2007-2008, The Tor Project, Inc. dnl See LICENSE for licensing information AC_INIT -AM_INIT_AUTOMAKE(tor, 0.2.1.18) +AM_INIT_AUTOMAKE(tor, 0.2.1.19) AM_CONFIG_HEADER(orconfig.h) AC_CANONICAL_HOST diff --git a/contrib/tor-mingw.nsi.in b/contrib/tor-mingw.nsi.in index a403ad7517..053c142159 100644 --- a/contrib/tor-mingw.nsi.in +++ b/contrib/tor-mingw.nsi.in @@ -9,7 +9,7 @@ !include "FileFunc.nsh" !insertmacro GetParameters -!define VERSION "0.2.1.18" +!define VERSION "0.2.1.19" !define INSTALLER "tor-${VERSION}-win32.exe" !define WEBSITE "https://www.torproject.org/" !define LICENSE "LICENSE" diff --git a/src/win32/orconfig.h b/src/win32/orconfig.h index fa8943f7c6..03e615850f 100644 --- a/src/win32/orconfig.h +++ b/src/win32/orconfig.h @@ -226,6 +226,6 @@ #define USING_TWOS_COMPLEMENT /* Version number of package */ -#define VERSION "0.2.1.18" +#define VERSION "0.2.1.19" From 3d99723411bd3a89b8910cdcced2e29218535d3e Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Wed, 29 Jul 2009 12:18:25 +0200 Subject: [PATCH 7/7] New upstream version --- debian/changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/debian/changelog b/debian/changelog index 6ca97ef3d0..262058fe52 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +tor (0.2.1.19-1) unstable; urgency=low + + * New upstream version. + + -- Peter Palfrader Wed, 29 Jul 2009 12:18:14 +0200 + tor (0.2.1.18-1) unstable; urgency=low * New upstream version.