[or-cvs] [tor/master 1/2] Backport END_STREAM_REASON_NOROUTE for client use.
nickm at torproject.org
nickm at torproject.org
Wed Aug 18 17:47:28 UTC 2010
Author: Sebastian Hahn <sebastian at torproject.org>
Date: Tue, 3 Aug 2010 16:46:28 +0200
Subject: Backport END_STREAM_REASON_NOROUTE for client use.
Commit: 78e4aa63fbc8b65ebf94234300b0d21e573ebe6e
(Partial backport of 150ed553dfce9, 161b275028e90, and 4c948ffd6.)
---
changes/misc-reason | 3 +++
src/or/or.h | 2 +-
src/or/reasons.c | 12 ++++++++++++
src/or/relay.c | 4 +++-
4 files changed, 19 insertions(+), 2 deletions(-)
create mode 100644 changes/misc-reason
diff --git a/changes/misc-reason b/changes/misc-reason
new file mode 100644
index 0000000..80db2d2
--- /dev/null
+++ b/changes/misc-reason
@@ -0,0 +1,3 @@
+ o Minor features:
+ - Have clients begin understanding the new END_STREAM_REASON_NOROUTE
+ error code.
diff --git a/src/or/or.h b/src/or/or.h
index a2a6d38..910e612 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 45b5923..82e5f99 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:
@@ -162,6 +166,14 @@ errno_to_stream_end_reason(int e)
S_CASE(ENOTCONN):
S_CASE(ENETUNREACH):
return END_STREAM_REASON_INTERNAL;
+ E_CASE(EHOSTUNREACH):
+ /* XXXX022
+ * The correct behavior is END_STREAM_REASON_NOROUTE, but older
+ * clients don't recognize it. So we're going to continue sending
+ * "MISC" until 0.2.1.27 or later is "well established".
+ */
+ /* return END_STREAM_REASON_NOROUTE; */
+ return END_STREAM_REASON_MISC;
S_CASE(ECONNREFUSED):
return END_STREAM_REASON_CONNECTREFUSED;
S_CASE(ECONNRESET):
diff --git a/src/or/relay.c b/src/or/relay.c
index 2082da9..b3d2fbb 100644
--- a/src/or/relay.c
+++ b/src/or/relay.c
@@ -648,7 +648,8 @@ edge_reason_is_retriable(int reason)
reason == END_STREAM_REASON_RESOURCELIMIT ||
reason == END_STREAM_REASON_EXITPOLICY ||
reason == END_STREAM_REASON_RESOLVEFAILED ||
- reason == END_STREAM_REASON_MISC;
+ reason == END_STREAM_REASON_MISC ||
+ reason == END_STREAM_REASON_NOROUTE;
}
/** Called when we receive an END cell on a stream that isn't open yet,
@@ -743,6 +744,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. */
--
1.7.1
More information about the tor-commits
mailing list