prop224: Register RP circuit when it opens

Only register the RP circuit when it opens and not when we send the INTRODUCE1
cell else, when re-extending to a new IP, we would register the same RP
circuit with the same cookie twice leading to the circuit being closed.

Signed-off-by: David Goulet <dgoulet@torproject.org>
This commit is contained in:
David Goulet 2017-08-24 08:49:24 -04:00
parent 954f663831
commit dca105d588
4 changed files with 17 additions and 8 deletions

View File

@ -1070,10 +1070,6 @@ hs_circ_send_introduce1(origin_circuit_t *intro_circ,
goto done; goto done;
} }
/* Register rend circuit in circuitmap */
hs_circuitmap_register_rend_circ_client_side(rend_circ,
rend_circ->hs_ident->rendezvous_cookie);
/* Success. */ /* Success. */
ret = 0; ret = 0;
goto done; goto done;

View File

@ -408,7 +408,8 @@ hs_circuitmap_get_rend_circ_service_side(const uint8_t *cookie)
/* Public function: Return client-side rendezvous circuit with rendezvous /* Public function: Return client-side rendezvous circuit with rendezvous
* <b>cookie</b>. It will first lookup for the CIRCUIT_PURPOSE_C_REND_READY * <b>cookie</b>. It will first lookup for the CIRCUIT_PURPOSE_C_REND_READY
* purpose and then try for CIRCUIT_PURPOSE_C_REND_READY_INTRO_ACKED. * purpose and then try for CIRCUIT_PURPOSE_C_REND_READY_INTRO_ACKED and then
* finally tries for CIRCUIT_PURPOSE_C_ESTABLISH_REND.
* *
* Return NULL if no such circuit is found in the circuitmap. */ * Return NULL if no such circuit is found in the circuitmap. */
origin_circuit_t * origin_circuit_t *
@ -426,6 +427,13 @@ hs_circuitmap_get_rend_circ_client_side(const uint8_t *cookie)
circ = hs_circuitmap_get_origin_circuit(HS_TOKEN_REND_CLIENT_SIDE, circ = hs_circuitmap_get_origin_circuit(HS_TOKEN_REND_CLIENT_SIDE,
REND_TOKEN_LEN, cookie, REND_TOKEN_LEN, cookie,
CIRCUIT_PURPOSE_C_REND_READY_INTRO_ACKED); CIRCUIT_PURPOSE_C_REND_READY_INTRO_ACKED);
if (circ) {
return circ;
}
circ = hs_circuitmap_get_origin_circuit(HS_TOKEN_REND_CLIENT_SIDE,
REND_TOKEN_LEN, cookie,
CIRCUIT_PURPOSE_C_ESTABLISH_REND);
return circ; return circ;
} }
@ -472,8 +480,7 @@ hs_circuitmap_register_rend_circ_client_side(origin_circuit_t *or_circ,
{ {
circuit_t *circ = TO_CIRCUIT(or_circ); circuit_t *circ = TO_CIRCUIT(or_circ);
{ /* Basic circ purpose sanity checking */ { /* Basic circ purpose sanity checking */
tor_assert_nonfatal(circ->purpose == CIRCUIT_PURPOSE_C_REND_READY || tor_assert_nonfatal(circ->purpose == CIRCUIT_PURPOSE_C_ESTABLISH_REND);
circ->purpose == CIRCUIT_PURPOSE_C_REND_READY_INTRO_ACKED);
} }
hs_circuitmap_register_circuit(circ, HS_TOKEN_REND_CLIENT_SIDE, hs_circuitmap_register_circuit(circ, HS_TOKEN_REND_CLIENT_SIDE,

View File

@ -434,6 +434,12 @@ client_rendezvous_circ_has_opened(origin_circuit_t *circ)
/* Ignore returned value, nothing we can really do. On failure, the circuit /* Ignore returned value, nothing we can really do. On failure, the circuit
* will be marked for close. */ * will be marked for close. */
hs_circ_send_establish_rendezvous(circ); hs_circ_send_establish_rendezvous(circ);
/* Register rend circuit in circuitmap if it's still alive. */
if (!TO_CIRCUIT(circ)->marked_for_close) {
hs_circuitmap_register_rend_circ_client_side(circ,
circ->hs_ident->rendezvous_cookie);
}
} }
/* This is an helper function that convert a descriptor intro point object ip /* This is an helper function that convert a descriptor intro point object ip

View File

@ -267,7 +267,7 @@ test_rend_token_maps(void *arg)
tt_ptr_op(NULL, OP_EQ, hs_circuitmap_get_intro_circ_v2_relay_side(tok3)); tt_ptr_op(NULL, OP_EQ, hs_circuitmap_get_intro_circ_v2_relay_side(tok3));
/* Now let's do a check for the client-side rend circuitmap */ /* Now let's do a check for the client-side rend circuitmap */
c5->base_.purpose = CIRCUIT_PURPOSE_C_REND_READY; c5->base_.purpose = CIRCUIT_PURPOSE_C_ESTABLISH_REND;
hs_circuitmap_register_rend_circ_client_side(c5, tok1); hs_circuitmap_register_rend_circ_client_side(c5, tok1);
tt_ptr_op(c5, OP_EQ, hs_circuitmap_get_rend_circ_client_side(tok1)); tt_ptr_op(c5, OP_EQ, hs_circuitmap_get_rend_circ_client_side(tok1));