diff options
author | David Goulet <dgoulet@torproject.org> | 2022-02-03 22:44:25 +0000 |
---|---|---|
committer | Mike Perry <mikeperry-git@torproject.org> | 2022-02-22 19:28:35 +0000 |
commit | 729dd14fdec9ece47142a5dc1434d32da109982e (patch) | |
tree | 10f76bdd984bec56955ac1d25fe9ac7b968d7d04 /src/feature/hs | |
parent | 38e9d9b465f5ae825d054b7baf06a851ad6b371a (diff) | |
download | tor-729dd14fdec9ece47142a5dc1434d32da109982e.tar.gz tor-729dd14fdec9ece47142a5dc1434d32da109982e.zip |
hs: Decode and cache the INTRODUCE cell congestion control extension
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/feature/hs')
-rw-r--r-- | src/feature/hs/hs_cell.c | 41 | ||||
-rw-r--r-- | src/feature/hs/hs_cell.h | 4 |
2 files changed, 45 insertions, 0 deletions
diff --git a/src/feature/hs/hs_cell.c b/src/feature/hs/hs_cell.c index 4b961a6add..b7ab68f7c4 100644 --- a/src/feature/hs/hs_cell.c +++ b/src/feature/hs/hs_cell.c @@ -14,6 +14,7 @@ #include "feature/hs/hs_cell.h" #include "feature/hs/hs_ob.h" #include "core/crypto/hs_ntor.h" +#include "core/or/congestion_control_common.h" #include "core/or/origin_circuit_st.h" @@ -783,6 +784,31 @@ get_introduce2_keys_and_verify_mac(hs_cell_introduce2_data_t *data, return intro_keys_result; } +/** Parse the given INTRODUCE cell extension. Update the data object + * accordingly depending on the extension. */ +static void +parse_introduce_cell_extension(hs_cell_introduce2_data_t *data, + const trn_extension_field_t *field) +{ + trn_extension_field_cc_t *cc_field = NULL; + + tor_assert(data); + tor_assert(field); + + switch (trn_extension_field_get_field_type(field)) { + case TRUNNEL_EXT_TYPE_CC_FIELD_REQUEST: + /* CC requests, enable it. */ + data->cc_enabled = 1; + data->pv.protocols_known = 1; + data->pv.supports_congestion_control = data->cc_enabled; + break; + default: + break; + } + + trn_extension_field_cc_free(cc_field); +} + /** Parse the INTRODUCE2 cell using data which contains everything we need to * do so and contains the destination buffers of information we extract and * compute from the cell. Return 0 on success else a negative value. The @@ -911,6 +937,21 @@ hs_cell_parse_introduce2(hs_cell_introduce2_data_t *data, smartlist_add(data->link_specifiers, lspec_dup); } + /* Extract any extensions. */ + const trn_extension_t *extensions = + trn_cell_introduce_encrypted_get_extensions(enc_cell); + if (extensions != NULL) { + for (size_t idx = 0; idx < trn_extension_get_num(extensions); idx++) { + const trn_extension_field_t *field = + trn_extension_getconst_fields(extensions, idx); + if (BUG(field == NULL)) { + /* The number of extensions should match the number of fields. */ + break; + } + parse_introduce_cell_extension(data, field); + } + } + /* Success. */ ret = 0; log_info(LD_REND, "Valid INTRODUCE2 cell. Launching rendezvous circuit."); diff --git a/src/feature/hs/hs_cell.h b/src/feature/hs/hs_cell.h index 43be038a93..c76a0690a8 100644 --- a/src/feature/hs/hs_cell.h +++ b/src/feature/hs/hs_cell.h @@ -84,6 +84,10 @@ typedef struct hs_cell_introduce2_data_t { smartlist_t *link_specifiers; /** Replay cache of the introduction point. */ replaycache_t *replay_cache; + /** Flow control negotiation parameters. */ + protover_summary_flags_t pv; + /** Congestion control parameters. */ + unsigned int cc_enabled : 1; } hs_cell_introduce2_data_t; /* Build cell API. */ |