mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
Implement congestion control parameter negotiation
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user