[or-cvs] Retry non-final-hop rendezvous failures
Nick Mathewson
nickm at seul.org
Wed Apr 14 21:40:52 UTC 2004
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv8617/src/or
Modified Files:
circuit.c or.h rendservice.c
Log Message:
Retry non-final-hop rendezvous failures
Index: circuit.c
===================================================================
RCS file: /home/or/cvsroot/src/or/circuit.c,v
retrieving revision 1.208
retrieving revision 1.209
diff -u -d -r1.208 -r1.209
--- circuit.c 14 Apr 2004 04:32:49 -0000 1.208
+++ circuit.c 14 Apr 2004 21:40:50 -0000 1.209
@@ -1253,7 +1253,14 @@
/* we should examine circ and see if it failed because of
* the last hop or an earlier hop. then use this info below.
*/
- //int failed_at_last_hop;
+ int failed_at_last_hop = 0;
+ /* If the last hop isn't open, and the second-to-last is, we failed
+ * at the last hop. */
+ if (circ->cpath &&
+ circ->cpath->prev->state != CPATH_STATE_OPEN &&
+ circ->cpath->prev->prev->state == CPATH_STATE_OPEN) {
+ failed_at_last_hop = 1;
+ }
switch(circ->purpose) {
case CIRCUIT_PURPOSE_C_GENERAL:
@@ -1291,7 +1298,13 @@
/* at Bob, connecting to rend point */
/* Don't increment failure count, since Alice may have picked
* the rendezvous point maliciously */
- log_fn(LOG_INFO,"Couldn't connect to Alice's chosen rend point %s. Sucks to be Alice.", circ->build_state->chosen_exit);
+ if (failed_at_last_hop) {
+ log_fn(LOG_INFO,"Couldn't connect to Alice's chosen rend point %s. Sucks to be Alice.", circ->build_state->chosen_exit);
+ } else {
+ log_fn(LOG_INFO,"Couldn't connect to Alice's chosen rend point %s, because an earlier node failed.",
+ circ->build_state->chosen_exit);
+ rend_service_relaunch_rendezvous(circ);
+ }
break;
default:
/* Other cases are impossible, since this function is only called with
Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.318
retrieving revision 1.319
diff -u -d -r1.318 -r1.319
--- or.h 13 Apr 2004 22:56:24 -0000 1.318
+++ or.h 14 Apr 2004 21:40:50 -0000 1.319
@@ -500,6 +500,8 @@
char *chosen_exit;
/* cpath to append after rendezvous. */
struct crypt_path_t *pending_final_cpath;
+ /* How many times has building a circuit for this task failed? */
+ int failure_count;
} cpath_build_state_t;
/* struct for a path (circuit) through the network */
@@ -1095,6 +1097,7 @@
int rend_service_intro_established(circuit_t *circuit, const char *request, int request_len);
void rend_service_rendezvous_is_ready(circuit_t *circuit);
int rend_service_introduce(circuit_t *circuit, const char *request, int request_len);
+void rend_service_relaunch_rendezvous(circuit_t *oldcirc);
int rend_service_set_connection_addr_port(connection_t *conn, circuit_t *circ);
void rend_service_dump_stats(int severity);
Index: rendservice.c
===================================================================
RCS file: /home/or/cvsroot/src/or/rendservice.c,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -d -r1.51 -r1.52
--- rendservice.c 14 Apr 2004 04:19:12 -0000 1.51
+++ rendservice.c 14 Apr 2004 21:40:50 -0000 1.52
@@ -457,6 +457,44 @@
return -1;
}
+#define MAX_REND_FAILURES 3
+void
+rend_service_relaunch_rendezvous(circuit_t *oldcirc)
+{
+ circuit_t *newcirc;
+ cpath_build_state_t *newstate, *oldstate;
+
+ /* XXXX assert type and build_state */
+
+ if (!oldcirc->build_state ||
+ oldcirc->build_state->failure_count > MAX_REND_FAILURES) {
+ log_fn(LOG_INFO,"Attempt to build circuit to %s for rendezvous has failed too many times; giving up.",
+ oldcirc->build_state->chosen_exit);
+ return;
+ }
+
+ log_fn(LOG_INFO,"Reattempting rendezvous circuit to %s",
+ oldcirc->build_state->chosen_exit);
+
+ newcirc = circuit_launch_new(CIRCUIT_PURPOSE_S_CONNECT_REND,
+ oldcirc->build_state->chosen_exit);
+ if (!newcirc) {
+ log_fn(LOG_WARN,"Couldn't relaunch rendezvous circuit to %s",
+ oldcirc->build_state->chosen_exit);
+ return;
+ }
+ oldstate = oldcirc->build_state;
+ newstate = newcirc->build_state;
+ assert(newstate && oldstate);
+ newstate->failure_count = oldstate->failure_count+1;
+ newstate->pending_final_cpath = oldstate->pending_final_cpath;
+ oldstate->pending_final_cpath = NULL;
+
+ memcpy(newcirc->rend_query, oldcirc->rend_query, REND_SERVICE_ID_LEN+1);
+ memcpy(newcirc->rend_pk_digest, oldcirc->rend_pk_digest, DIGEST_LEN);
+ memcpy(newcirc->rend_splice, oldcirc->rend_splice, REND_COOKIE_LEN);
+}
+
/* Launch a circuit to serve as an introduction point.
*/
static int
More information about the tor-commits
mailing list