tor

The Tor anonymity network
git clone https://git.dasho.dev/tor.git
Log | Files | Refs | README | LICENSE

commit 22c4a2d5db421b684f2ff11d6c84b5046edb871d
parent 76040d86911323e90a5905fd9d429d9687291104
Author: Nick Mathewson <nickm@torproject.org>
Date:   Mon,  2 Jun 2025 17:05:08 -0400

Make extend_info_supports_ntor_v3 correct.

Previously it returned true if the extend_info was for an exit where we
intended to use congestion control, which is not exactly the same thing
as supporting ntor v3.

Diffstat:
Msrc/core/or/extend_info_st.h | 2++
Msrc/core/or/extendinfo.c | 5+++--
Msrc/core/or/or.h | 3+++
Msrc/core/or/versions.c | 4++++
Msrc/feature/nodelist/nodelist.c | 2+-
Msrc/test/test_ntor_v3.c | 1+
6 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/src/core/or/extend_info_st.h b/src/core/or/extend_info_st.h @@ -36,6 +36,8 @@ struct extend_info_t { tor_addr_port_t orports[EXTEND_INFO_MAX_ADDRS]; /** Ntor onion key for this hop. */ curve25519_public_key_t curve25519_onion_key; + /** True if this hop supports ntor v3. */ + bool supports_ntor_v3; /** True if this hop is to be used as an _exit_, * and it also supports supports NtorV3 _and_ negotiation * of congestion control parameters */ diff --git a/src/core/or/extendinfo.c b/src/core/or/extendinfo.c @@ -62,6 +62,8 @@ extend_info_new(const char *nickname, } if (pv) { + info->supports_ntor_v3 = pv->supports_ntor_v3; + // XXXX cgo Decide whether to set this! info->enable_cgo = pv->supports_cgo; } @@ -211,8 +213,7 @@ int extend_info_supports_ntor_v3(const extend_info_t *ei) { tor_assert(ei); - return extend_info_supports_ntor(ei) && - ei->exit_supports_congestion_control; + return ei->supports_ntor_v3; } /* Does ei have an onion key which it would prefer to use? diff --git a/src/core/or/or.h b/src/core/or/or.h @@ -834,6 +834,9 @@ typedef struct protover_summary_flags_t { /** True iff this router supports CGO. */ unsigned int supports_cgo : 1; + + /** True iff this router supports ntorv3 */ + unsigned int supports_ntor_v3 : 1; } protover_summary_flags_t; typedef struct routerinfo_t routerinfo_t; diff --git a/src/core/or/versions.c b/src/core/or/versions.c @@ -495,6 +495,10 @@ memoize_protover_summary(protover_summary_flags_t *out, protocol_list_supports_protocol(protocols, PRT_CONFLUX, PROTOVER_CONFLUX_V1); + out->supports_ntor_v3 = + protocol_list_supports_protocol(protocols, PRT_RELAY, + PROTOVER_RELAY_NTOR_V3); + /* CGO requires congestion control and subproto negotiation. */ out->supports_cgo = protocol_list_supports_protocol(protocols, PRT_FLOWCTRL, diff --git a/src/feature/nodelist/nodelist.c b/src/feature/nodelist/nodelist.c @@ -1239,7 +1239,7 @@ node_ed25519_id_matches(const node_t *node, const ed25519_public_key_t *id) /** Dummy object that should be unreturnable. Used to ensure that * node_get_protover_summary_flags() always returns non-NULL. */ static const protover_summary_flags_t zero_protover_flags = { - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; /** Return the protover_summary_flags for a given node. */ diff --git a/src/test/test_ntor_v3.c b/src/test/test_ntor_v3.c @@ -192,6 +192,7 @@ run_full_handshake(circuit_params_t *serv_params_in, uint8_t client_keys[CELL_PAYLOAD_SIZE]; uint8_t rend_auth[DIGEST_LEN]; + info.supports_ntor_v3 = true; info.exit_supports_congestion_control = 1; unhex(relay_onion_key.seckey.secret_key,