From: Nick Mathewson Date: Mon, 2 Jun 2025 21:05:08 +0000 (-0400) Subject: Make extend_info_supports_ntor_v3 correct. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=22c4a2d5db421b684f2ff11d6c84b5046edb871d;p=thirdparty%2Ftor.git 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. --- diff --git a/src/core/or/extend_info_st.h b/src/core/or/extend_info_st.h index 71fa260d75..a6c5f24cc6 100644 --- 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 index 458b2afd33..7ee0d26a12 100644 --- 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 index 1f06574ecf..0d8f63da02 100644 --- 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 index 782cdf4142..b1d31f8c6a 100644 --- 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 index 105368b728..0c1c044e9a 100644 --- 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 index 8106b6f648..45fca5bb61 100644 --- 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,