From b8aa14a39b2f96edad8ca0b5a9ea5be218837ce0 Mon Sep 17 00:00:00 2001 From: Sebastian Hahn Date: Tue, 3 Aug 2010 13:57:13 +0200 Subject: Handle EHOSTUNREACH in errno_to_stream_end_reason() We used to not recognize it and returned END_STREAM_REASON_MISC. Instead, return END_STREAM_REASON_INTERNAL. --- src/or/reasons.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/or/reasons.c b/src/or/reasons.c index 45b592367..27abb790d 100644 --- a/src/or/reasons.c +++ b/src/or/reasons.c @@ -161,6 +161,7 @@ errno_to_stream_end_reason(int e) E_CASE(EACCES): S_CASE(ENOTCONN): S_CASE(ENETUNREACH): + E_CASE(EHOSTUNREACH): return END_STREAM_REASON_INTERNAL; S_CASE(ECONNREFUSED): return END_STREAM_REASON_CONNECTREFUSED; -- cgit v1.2.3 From 150ed553dfce93c6dd32ee59b8df0422e04cd699 Mon Sep 17 00:00:00 2001 From: Sebastian Hahn Date: Tue, 3 Aug 2010 16:46:28 +0200 Subject: Introduce END_STREAM_REASON_NOROUTE --- changes/misc-reason | 3 ++- doc/spec/tor-spec.txt | 5 ++--- src/or/or.h | 2 +- src/or/reasons.c | 7 ++++++- 4 files changed, 11 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/changes/misc-reason b/changes/misc-reason index 2559fe634..cd2171853 100644 --- a/changes/misc-reason +++ b/changes/misc-reason @@ -1,3 +1,4 @@ o Minor bugfixes: - Exit nodes didn't recognize EHOSTUNREACH as a stream ending reason - and sent back misc. Bugfix on 0.1.0.1-rc; fixes bug 1793. + and sent back END_STREAM_REASON_NOROUTE. Also update the spec to + reflect this new reason. Bugfix on 0.1.0.1-rc; fixes bug 1793. diff --git a/doc/spec/tor-spec.txt b/doc/spec/tor-spec.txt index a321aa869..511f137e8 100644 --- a/doc/spec/tor-spec.txt +++ b/doc/spec/tor-spec.txt @@ -831,7 +831,8 @@ see tor-design.pdf. 6 -- REASON_DONE (Anonymized TCP connection was closed) 7 -- REASON_TIMEOUT (Connection timed out, or OR timed out while connecting) - 8 -- (unallocated) [**] + 8 -- REASON_NOROUTE (Routing error while attempting to + contact destination) 9 -- REASON_HIBERNATING (OR is temporarily hibernating) 10 -- REASON_INTERNAL (Internal error at the OR) 11 -- REASON_RESOURCELIMIT (OR has no resources to fulfill request) @@ -853,8 +854,6 @@ see tor-design.pdf. [*] Older versions of Tor also send this reason when connections are reset. - [**] Due to a bug in versions of Tor through 0095, error reason 8 must - remain allocated until that version is obsolete. --- [The rest of this section describes unimplemented functionality.] diff --git a/src/or/or.h b/src/or/or.h index a2a6d380d..910e612a0 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -544,7 +544,7 @@ typedef enum { #define END_STREAM_REASON_DESTROY 5 #define END_STREAM_REASON_DONE 6 #define END_STREAM_REASON_TIMEOUT 7 -/* 8 is unallocated for historical reasons. */ +#define END_STREAM_REASON_NOROUTE 8 #define END_STREAM_REASON_HIBERNATING 9 #define END_STREAM_REASON_INTERNAL 10 #define END_STREAM_REASON_RESOURCELIMIT 11 diff --git a/src/or/reasons.c b/src/or/reasons.c index 27abb790d..0679119b6 100644 --- a/src/or/reasons.c +++ b/src/or/reasons.c @@ -26,6 +26,7 @@ stream_end_reason_to_control_string(int reason) case END_STREAM_REASON_DESTROY: return "DESTROY"; case END_STREAM_REASON_DONE: return "DONE"; case END_STREAM_REASON_TIMEOUT: return "TIMEOUT"; + case END_STREAM_REASON_NOROUTE: "return "NOROUTE"; case END_STREAM_REASON_HIBERNATING: return "HIBERNATING"; case END_STREAM_REASON_INTERNAL: return "INTERNAL"; case END_STREAM_REASON_RESOURCELIMIT: return "RESOURCELIMIT"; @@ -60,6 +61,7 @@ stream_end_reason_to_string(int reason) case END_STREAM_REASON_DESTROY: return "destroyed"; case END_STREAM_REASON_DONE: return "closed normally"; case END_STREAM_REASON_TIMEOUT: return "gave up (timeout)"; + case END_STREAM_REASON_NOROUTE: return "no route to host"; case END_STREAM_REASON_HIBERNATING: return "server is hibernating"; case END_STREAM_REASON_INTERNAL: return "internal error at server"; case END_STREAM_REASON_RESOURCELIMIT: return "server out of resources"; @@ -102,6 +104,8 @@ stream_end_reason_to_socks5_response(int reason) return SOCKS5_SUCCEEDED; case END_STREAM_REASON_TIMEOUT: return SOCKS5_TTL_EXPIRED; + case END_STREAM_REASON_NOROUTE: + return SOCKS5_HOST_UNREACHABLE; case END_STREAM_REASON_RESOURCELIMIT: return SOCKS5_GENERAL_ERROR; case END_STREAM_REASON_HIBERNATING: @@ -161,8 +165,9 @@ errno_to_stream_end_reason(int e) E_CASE(EACCES): S_CASE(ENOTCONN): S_CASE(ENETUNREACH): - E_CASE(EHOSTUNREACH): return END_STREAM_REASON_INTERNAL; + E_CASE(EHOSTUNREACH): + return END_STREAM_REASON_NOROUTE; S_CASE(ECONNREFUSED): return END_STREAM_REASON_CONNECTREFUSED; S_CASE(ECONNRESET): -- cgit v1.2.3 From 161b275028e90d38582c3cddf65d906e8a181368 Mon Sep 17 00:00:00 2001 From: Sebastian Hahn Date: Wed, 4 Aug 2010 00:51:39 +0200 Subject: Retry streams that ended with NOROUTE error Also add the NOROUTE reason to control-spec. --- doc/spec/control-spec.txt | 2 +- src/or/relay.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/doc/spec/control-spec.txt b/doc/spec/control-spec.txt index cf92e2b9e..948b7ed79 100644 --- a/doc/spec/control-spec.txt +++ b/doc/spec/control-spec.txt @@ -1029,7 +1029,7 @@ $Id$ Reason = "MISC" / "RESOLVEFAILED" / "CONNECTREFUSED" / "EXITPOLICY" / "DESTROY" / "DONE" / "TIMEOUT" / - "HIBERNATING" / "INTERNAL"/ "RESOURCELIMIT" / + "NOROUTE" / "HIBERNATING" / "INTERNAL"/ "RESOURCELIMIT" / "CONNRESET" / "TORPROTOCOL" / "NOTDIRECTORY" / "END" The "REASON" field is provided only for FAILED, CLOSED, and DETACHED diff --git a/src/or/relay.c b/src/or/relay.c index 2082da94f..320c27037 100644 --- a/src/or/relay.c +++ b/src/or/relay.c @@ -743,6 +743,7 @@ connection_ap_process_end_not_open( case END_STREAM_REASON_RESOLVEFAILED: case END_STREAM_REASON_TIMEOUT: case END_STREAM_REASON_MISC: + case END_STREAM_REASON_NOROUTE: if (client_dns_incr_failures(conn->socks_request->address) < MAX_RESOLVE_FAILURES) { /* We haven't retried too many times; reattach the connection. */ -- cgit v1.2.3