]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
hs: Setup congestion control on service rends using intro data
authorDavid Goulet <dgoulet@torproject.org>
Thu, 3 Feb 2022 21:18:52 +0000 (21:18 +0000)
committerMike Perry <mikeperry-git@torproject.org>
Tue, 22 Feb 2022 19:28:35 +0000 (19:28 +0000)
Signed-off-by: David Goulet <dgoulet@torproject.org>
src/feature/hs/hs_circuit.c
src/feature/hs/hs_common.c

index 10a6f51eb374814b5292d0e83851797055c973bc..f2953cfb0278a669edb639a23648aa495b3ef692 100644 (file)
@@ -17,6 +17,8 @@
 #include "core/or/relay.h"
 #include "core/or/crypt_path.h"
 #include "core/or/extendinfo.h"
+#include "core/or/congestion_control_common.h"
+#include "core/crypto/onion_crypto.h"
 #include "feature/client/circpathbias.h"
 #include "feature/hs/hs_cell.h"
 #include "feature/hs/hs_circuit.h"
@@ -408,6 +410,14 @@ launch_rendezvous_point_circuit,(const hs_service_t *service,
     tor_assert(circ->hs_ident);
   }
 
+  if (data->cc_enabled) {
+    circuit_params_t circ_params = {
+      .cc_enabled = data->cc_enabled,
+      .sendme_inc_cells = congestion_control_sendme_inc(),
+    };
+    TO_CIRCUIT(circ)->ccontrol = congestion_control_new(&circ_params);
+  }
+
  end:
   extend_info_free(info);
 }
@@ -504,6 +514,14 @@ retry_service_rendezvous_point(const origin_circuit_t *circ)
   new_circ->build_state->expiry_time = bstate->expiry_time;
   new_circ->hs_ident = hs_ident_circuit_dup(circ->hs_ident);
 
+  if (TO_CIRCUIT(circ)->ccontrol != NULL) {
+    circuit_params_t circ_params = {
+      .cc_enabled = 1,
+      .sendme_inc_cells = TO_CIRCUIT(circ)->ccontrol->sendme_inc,
+    };
+    TO_CIRCUIT(new_circ)->ccontrol = congestion_control_new(&circ_params);
+  }
+
  done:
   return;
 }
index 3036ce271013cf9b1b5ce7c03a8021f2fd36aabc..e326581dd1078c2a1398008296f8ddcf1efde6bc 100644 (file)
@@ -1687,18 +1687,7 @@ hs_get_extend_info_from_lspecs(const smartlist_t *lspecs,
   /* We do have everything for which we think we can connect successfully. */
   info = extend_info_new(NULL, legacy_id,
                          (have_ed25519_id) ? &ed25519_pk : NULL, NULL,
-                         onion_key, &ap.addr, ap.port,
-                         /* TODO-324: oh wow, this is a hard one.
-
-                            The protover summary here needs to explain
-                            if we support the newer congestion control or
-                            not.  This may require new specification changes.
-
-                            Probably there is some analogous service-side
-                            function that needs to initialize congestion
-                            control structures based on what the client says.
-                         */
-                         NULL, false);
+                         onion_key, &ap.addr, ap.port, NULL, false);
  done:
   return info;
 }