diff options
author | Mike Perry <mikeperry-git@torproject.org> | 2021-11-04 00:44:38 +0000 |
---|---|---|
committer | Mike Perry <mikeperry-git@torproject.org> | 2022-02-22 19:28:34 +0000 |
commit | b6d5fbba7d7e0e2cfa0c0cbb7f91e6039e3decf9 (patch) | |
tree | 454a617d1e465d5272c47acf58869402f53870e2 /src/core/mainloop | |
parent | 095224cdfa5563973e4832c46f0d162310393156 (diff) | |
download | tor-b6d5fbba7d7e0e2cfa0c0cbb7f91e6039e3decf9.tar.gz tor-b6d5fbba7d7e0e2cfa0c0cbb7f91e6039e3decf9.zip |
Implement congestion control parameter negotiation
Diffstat (limited to 'src/core/mainloop')
-rw-r--r-- | src/core/mainloop/cpuworker.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/core/mainloop/cpuworker.c b/src/core/mainloop/cpuworker.c index 7ca66a1c45..2cb667615d 100644 --- a/src/core/mainloop/cpuworker.c +++ b/src/core/mainloop/cpuworker.c @@ -21,6 +21,8 @@ #include "core/or/channel.h" #include "core/or/circuitlist.h" #include "core/or/connection_or.h" +#include "core/or/congestion_control_common.h" +#include "core/or/congestion_control_flow.h" #include "app/config/config.h" #include "core/mainloop/cpuworker.h" #include "lib/crypt_ops/crypto_rand.h" @@ -126,6 +128,11 @@ typedef struct cpuworker_request_t { /** A create cell for the cpuworker to process. */ create_cell_t create_cell; + /** + * A copy of this relay's consensus params that are relevant to + * the circuit, for use in negotiation. */ + circuit_params_t circ_ns_params; + /* Turn the above into a tagged union if needed. */ } cpuworker_request_t; @@ -381,6 +388,12 @@ cpuworker_onion_handshake_replyfn(void *work_) goto done_processing; } + /* If the client asked for congestion control, if our consensus parameter + * allowed it to negotiate as enabled, allocate a congestion control obj. */ + if (rpl.circ_params.cc_enabled) { + TO_CIRCUIT(circ)->ccontrol = congestion_control_new(&rpl.circ_params); + } + if (onionskin_answer(circ, &rpl.created_cell, (const char*)rpl.keys, sizeof(rpl.keys), @@ -390,9 +403,6 @@ cpuworker_onion_handshake_replyfn(void *work_) goto done_processing; } - /* TODO-324! We need to use rpl.circ_params here to initialize the congestion - control parameters of the circuit. */ - log_debug(LD_OR,"onionskin_answer succeeded. Yay."); done_processing: @@ -431,6 +441,7 @@ cpuworker_onion_handshake_threadfn(void *state_, void *work_) n = onion_skin_server_handshake(cc->handshake_type, cc->onionskin, cc->handshake_len, onion_keys, + &req.circ_ns_params, cell_out->reply, sizeof(cell_out->reply), rpl.keys, CPATH_KEY_MATERIAL_LEN, @@ -559,6 +570,11 @@ assign_onionskin_to_cpuworker(or_circuit_t *circ, if (should_time) tor_gettimeofday(&req.started_at); + /* Copy the current cached consensus params relevant to + * circuit negotiation into the CPU worker context */ + req.circ_ns_params.cc_enabled = congestion_control_enabled(); + req.circ_ns_params.sendme_inc_cells = congestion_control_sendme_inc(); + job = tor_malloc_zero(sizeof(cpuworker_job_t)); job->circ = circ; memcpy(&job->u.request, &req, sizeof(req)); |