]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Make extend_info_supports_ntor_v3 correct.
authorNick Mathewson <nickm@torproject.org>
Mon, 2 Jun 2025 21:05:08 +0000 (17:05 -0400)
committerNick Mathewson <nickm@torproject.org>
Tue, 10 Jun 2025 23:06:47 +0000 (19:06 -0400)
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.

src/core/or/extend_info_st.h
src/core/or/extendinfo.c
src/core/or/or.h
src/core/or/versions.c
src/feature/nodelist/nodelist.c
src/test/test_ntor_v3.c

index 71fa260d7592aae9a11462187b1ecf9dbc44dc59..a6c5f24cc60cf985fc79375d1662d8385f2bd5c6 100644 (file)
@@ -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 */
index 458b2afd33c3ba08cf251e3e28fba8feb65b48cb..7ee0d26a125621a4bdcfc3255d95996255cc7923 100644 (file)
@@ -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?
index 1f06574ecfe2b3269eb9f264d1229fa84da54708..0d8f63da0279510d5c03444037deb1eb7043021c 100644 (file)
@@ -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;
index 782cdf4142882c27a4773d1d02cf2aea31fad199..b1d31f8c6a1077eaf031abc71ef15efd4cbebb9a 100644 (file)
@@ -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,
index 105368b728c925d9d6d47c563f5a3e5540d97d53..0c1c044e9a3b54d3dd7bbec4160885b80585d587 100644 (file)
@@ -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. */
index 8106b6f6483241cc7b5e7d2a2b23c925bed39d42..45fca5bb6152af84abd12a75af3e5d2788893266 100644 (file)
@@ -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,