[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] prop224: Register RP circuit when it opens



commit dca105d58853c7ba6f8ef594cca34230dbb87394
Author: David Goulet <dgoulet@xxxxxxxxxxxxxx>
Date:   Thu Aug 24 08:49:24 2017 -0400

    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@xxxxxxxxxxxxxx>
---
 src/or/hs_circuit.c         |  4 ----
 src/or/hs_circuitmap.c      | 13 ++++++++++---
 src/or/hs_client.c          |  6 ++++++
 src/test/test_circuitlist.c |  2 +-
 4 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/src/or/hs_circuit.c b/src/or/hs_circuit.c
index 7d41a33c8..2bfeac747 100644
--- a/src/or/hs_circuit.c
+++ b/src/or/hs_circuit.c
@@ -1070,10 +1070,6 @@ hs_circ_send_introduce1(origin_circuit_t *intro_circ,
     goto done;
   }
 
-  /* Register rend circuit in circuitmap */
-  hs_circuitmap_register_rend_circ_client_side(rend_circ,
-                              rend_circ->hs_ident->rendezvous_cookie);
-
   /* Success. */
   ret = 0;
   goto done;
diff --git a/src/or/hs_circuitmap.c b/src/or/hs_circuitmap.c
index f235ecc82..09704d796 100644
--- a/src/or/hs_circuitmap.c
+++ b/src/or/hs_circuitmap.c
@@ -408,7 +408,8 @@ hs_circuitmap_get_rend_circ_service_side(const uint8_t *cookie)
 
 /* Public function: Return client-side rendezvous circuit with rendezvous
  * <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. */
 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,
                                           REND_TOKEN_LEN, cookie,
                                  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;
 }
 
@@ -472,8 +480,7 @@ hs_circuitmap_register_rend_circ_client_side(origin_circuit_t *or_circ,
 {
   circuit_t *circ = TO_CIRCUIT(or_circ);
   { /* Basic circ purpose sanity checking */
-    tor_assert_nonfatal(circ->purpose == CIRCUIT_PURPOSE_C_REND_READY ||
-                    circ->purpose == CIRCUIT_PURPOSE_C_REND_READY_INTRO_ACKED);
+    tor_assert_nonfatal(circ->purpose == CIRCUIT_PURPOSE_C_ESTABLISH_REND);
   }
 
   hs_circuitmap_register_circuit(circ, HS_TOKEN_REND_CLIENT_SIDE,
diff --git a/src/or/hs_client.c b/src/or/hs_client.c
index 57bd87079..3e25126a6 100644
--- a/src/or/hs_client.c
+++ b/src/or/hs_client.c
@@ -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
    * will be marked for close. */
   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
diff --git a/src/test/test_circuitlist.c b/src/test/test_circuitlist.c
index 6b8dae31f..f622704ec 100644
--- a/src/test/test_circuitlist.c
+++ b/src/test/test_circuitlist.c
@@ -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));
 
   /* 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);
 
   tt_ptr_op(c5, OP_EQ, hs_circuitmap_get_rend_circ_client_side(tok1));



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits