[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/main] hs: Decode and cache the INTRODUCE cell congestion control extension
commit 729dd14fdec9ece47142a5dc1434d32da109982e
Author: David Goulet <dgoulet@xxxxxxxxxxxxxx>
Date: Thu Feb 3 22:44:25 2022 +0000
hs: Decode and cache the INTRODUCE cell congestion control extension
Signed-off-by: David Goulet <dgoulet@xxxxxxxxxxxxxx>
---
src/feature/hs/hs_cell.c | 41 +++++++++++++++++++++++++++++++++++++++++
src/feature/hs/hs_cell.h | 4 ++++
2 files changed, 45 insertions(+)
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. */
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits