]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
hs: Retry service rendezvous on circuit close
authorDavid Goulet <dgoulet@torproject.org>
Wed, 19 Oct 2022 19:27:22 +0000 (15:27 -0400)
committerDavid Goulet <dgoulet@torproject.org>
Wed, 26 Oct 2022 19:10:39 +0000 (15:10 -0400)
Move the retry from circuit_expire_building() to when the offending
circuit is being closed.

Fixes #40695

Signed-off-by: David Goulet <dgoulet@torproject.org>
src/core/or/circuituse.c
src/core/or/origin_circuit_st.h
src/feature/hs/hs_circuit.c
src/feature/hs/hs_circuit.h
src/feature/hs/hs_service.c

index acb9a7fba195391c12206ae37537c6a952c3e280..dbeea1082153f2c7e982b5edee7d329363007fc5 100644 (file)
@@ -759,7 +759,6 @@ circuit_expire_building(void)
                (unsigned)victim->n_circ_id,
                victim->state, circuit_state_to_string(victim->state),
                victim->purpose);
-      hs_circ_retry_service_rendezvous_point(TO_ORIGIN_CIRCUIT(victim));
       /* We'll close as a timeout the victim circuit. The rendezvous point
        * won't keep both circuits, it only keeps the newest (for the same
        * cookie). */
index 2cd8a33abcc2cc64841996b6c1048979caafc72d..73b971f72da80a4d4c5413d7c70ad9c6afbe65f1 100644 (file)
@@ -209,14 +209,6 @@ struct origin_circuit_t {
    * no circuits have opened. Used to prevent spamming logs. */
   unsigned int relaxed_timeout : 1;
 
-  /** Set iff this is a service-side rendezvous circuit for which a
-   * new connection attempt has been launched.  We consider launching
-   * a new service-side rend circ to a client when the previous one
-   * fails; now that we don't necessarily close a service-side rend
-   * circ when we launch a new one to the same client, this flag keeps
-   * us from launching two retries for the same failed rend circ. */
-  unsigned int hs_service_side_rend_circ_has_been_relaunched : 1;
-
   /** What commands were sent over this circuit that decremented the
    * RELAY_EARLY counter? This is for debugging task 878. */
   uint8_t relay_early_commands[MAX_RELAY_EARLY_CELLS_PER_CIRCUIT];
index 42d3bedc3e2de72da94d4c44971ca77eee256670..53855d40a9c947a0d231dd045fafe912b6034e08 100644 (file)
@@ -433,16 +433,6 @@ can_relaunch_service_rendezvous_point(const origin_circuit_t *circ)
 
   /* XXX: Retrying under certain condition. This is related to #22455. */
 
-  /* Avoid to relaunch twice a circuit to the same rendezvous point at the
-   * same time. */
-  if (circ->hs_service_side_rend_circ_has_been_relaunched) {
-    log_info(LD_REND, "Rendezvous circuit to %s has already been retried. "
-                      "Skipping retry.",
-             safe_str_client(
-                  extend_info_describe(circ->build_state->chosen_exit)));
-    goto disallow;
-  }
-
   /* We check failure_count >= hs_get_service_max_rend_failures()-1 below, and
    * the -1 is because we increment the failure count for our current failure
    * *after* this clause. */
@@ -684,7 +674,7 @@ hs_circ_service_get_established_intro_circ(const hs_service_intro_point_t *ip)
  * - We've already retried this specific rendezvous circuit.
  */
 void
-hs_circ_retry_service_rendezvous_point(origin_circuit_t *circ)
+hs_circ_retry_service_rendezvous_point(const origin_circuit_t *circ)
 {
   tor_assert(circ);
   tor_assert(TO_CIRCUIT(circ)->purpose == CIRCUIT_PURPOSE_S_CONNECT_REND);
@@ -694,10 +684,6 @@ hs_circ_retry_service_rendezvous_point(origin_circuit_t *circ)
     goto done;
   }
 
-  /* Flag the circuit that we are relaunching, to avoid to relaunch twice a
-   * circuit to the same rendezvous point at the same time. */
-  circ->hs_service_side_rend_circ_has_been_relaunched = 1;
-
   /* Legacy services don't have a hidden service ident. */
   if (circ->hs_ident) {
     retry_service_rendezvous_point(circ);
index 808e648951467ce827931b8a37c4877a37be1ead..afbff7b894bd43bd3f53546c81b9af6f26c6449e 100644 (file)
@@ -33,7 +33,7 @@ int hs_circ_launch_intro_point(hs_service_t *service,
 int hs_circ_launch_rendezvous_point(const hs_service_t *service,
                                     const curve25519_public_key_t *onion_key,
                                     const uint8_t *rendezvous_cookie);
-void hs_circ_retry_service_rendezvous_point(origin_circuit_t *circ);
+void hs_circ_retry_service_rendezvous_point(const origin_circuit_t *circ);
 
 origin_circuit_t *hs_circ_service_get_intro_circ(
                                       const hs_service_intro_point_t *ip);
index ff34e5dc44878efc70c1de62a0329c06e07a500c..1caa5ab64a615c105e6695f2a029322c105efc1d 100644 (file)
@@ -3675,6 +3675,9 @@ hs_service_circuit_cleanup_on_close(const circuit_t *circ)
     hs_metrics_close_established_rdv(
       &CONST_TO_ORIGIN_CIRCUIT(circ)->hs_ident->identity_pk);
     break;
+  case CIRCUIT_PURPOSE_S_CONNECT_REND:
+    hs_circ_retry_service_rendezvous_point(CONST_TO_ORIGIN_CIRCUIT(circ));
+    break;
   default:
     break;
   }