]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Use protover to signal support for ntor3 + congestion control.
authorNick Mathewson <nickm@torproject.org>
Tue, 14 Sep 2021 20:31:48 +0000 (16:31 -0400)
committerMike Perry <mikeperry-git@torproject.org>
Tue, 22 Feb 2022 19:28:33 +0000 (19:28 +0000)
12 files changed:
src/core/or/circuituse.c
src/core/or/extendinfo.c
src/core/or/extendinfo.h
src/core/or/or.h
src/core/or/protover.c
src/core/or/versions.c
src/feature/hs/hs_common.c
src/feature/nodelist/nodelist.c
src/feature/relay/circuitbuild_relay.c
src/feature/relay/selftest.c
src/test/test_circuitpadding.c
src/test/test_hs_client.c

index 2ec391eca0495e0d74043071a590b3b258bb7588..104e898d6cc47d1063746914bf3927e3c42080e1 100644 (file)
@@ -2462,7 +2462,8 @@ circuit_get_open_circ_or_launch(entry_connection_t *conn,
                                           digest,
                                           NULL, /* Ed25519 ID */
                                           NULL, NULL, /* onion keys */
-                                          &addr, conn->socks_request->port);
+                                          &addr, conn->socks_request->port,
+                                          NULL);
           } else { /* ! (want_onehop && conn->chosen_exit_name[0] == '$') */
             /* We will need an onion key for the router, and we
              * don't have one. Refuse or relax requirements. */
index f33e887e7daf463582a6813ae523510f57d447a5..ca2288e0a44578a9dd2b7bb4ee4c0900679ac880 100644 (file)
@@ -35,7 +35,8 @@ extend_info_new(const char *nickname,
                 const ed25519_public_key_t *ed_id,
                 crypto_pk_t *onion_key,
                 const curve25519_public_key_t *ntor_key,
-                const tor_addr_t *addr, uint16_t port)
+                const tor_addr_t *addr, uint16_t port,
+                const protover_summary_flags_t *pv)
 {
   extend_info_t *info = tor_malloc_zero(sizeof(extend_info_t));
   if (rsa_id_digest)
@@ -57,7 +58,10 @@ extend_info_new(const char *nickname,
     extend_info_add_orport(info, addr, port);
   }
 
-  info->supports_ntor3_and_param_negotiation = false; // TODO: set this.
+  if (pv) {
+    info->supports_ntor3_and_param_negotiation =
+      pv->supports_ntor3_and_param_negotiation;
+  }
 
   return info;
 }
@@ -152,7 +156,8 @@ extend_info_from_node(const node_t *node, int for_direct_connect)
                            rsa_pubkey,
                            curve_pubkey,
                            &ap.addr,
-                           ap.port);
+                           ap.port,
+                           &node->ri->pv);
   } else if (valid_addr && node->rs && node->md) {
     info = extend_info_new(node->rs->nickname,
                            node->identity,
@@ -160,7 +165,8 @@ extend_info_from_node(const node_t *node, int for_direct_connect)
                            rsa_pubkey,
                            curve_pubkey,
                            &ap.addr,
-                           ap.port);
+                           ap.port,
+                           &node->rs->pv);
   }
 
   crypto_pk_free(rsa_pubkey);
index ffe831743188cfc0cd221002c26a04caecee4902..8781cc70470454ce51a5137a98d7b43fc9151f00 100644 (file)
@@ -17,7 +17,8 @@ extend_info_t *extend_info_new(const char *nickname,
                                const struct ed25519_public_key_t *ed_id,
                                crypto_pk_t *onion_key,
                                const struct curve25519_public_key_t *ntor_key,
-                               const tor_addr_t *addr, uint16_t port);
+                               const tor_addr_t *addr, uint16_t port,
+                               const struct protover_summary_flags_t *pv);
 extend_info_t *extend_info_from_node(const node_t *r, int for_direct_connect);
 extend_info_t *extend_info_dup(extend_info_t *info);
 void extend_info_free_(extend_info_t *info);
index 39117975633e18bdd2c0c7a214a35386a17355f3..409f4a0fea2c1d7c53519faf30c3b7cdb4eb99da 100644 (file)
@@ -732,6 +732,10 @@ typedef struct protover_summary_flags_t {
    * negotiate hs circuit setup padding. Requires Padding=2. */
   unsigned int supports_hs_setup_padding : 1;
 
+  /** True iff this router supports ntor3 _and_ supports negotiating
+   * additional circuit parameters via the handshake used in ntor3.
+   */
+  unsigned int supports_ntor3_and_param_negotiation : 1;
 } protover_summary_flags_t;
 
 typedef struct routerinfo_t routerinfo_t;
index bd9cc601151bf78e4067df42f9fc04cb7acd54b2..63e9a33b724f73a7a74fe8a2a488b64171284845 100644 (file)
@@ -430,6 +430,8 @@ protover_get_supported_protocols(void)
    * XXX: WARNING!
    */
 
+  /* TODO: Add a new Relay=* and a new FlowCtrl=* version to indicate support
+   * for Ntorv3 and prop324.  Make sure they get into the spec. */
   return
     "Cons=1-2 "
     "Desc=1-2 "
index b9fad22c046005426ac7ecccc0b1e83c1d0203d0..322121b43fbb19c79a4f30e581c40d5f97d43ed5 100644 (file)
@@ -482,6 +482,15 @@ memoize_protover_summary(protover_summary_flags_t *out,
     protocol_list_supports_protocol(protocols, PRT_PADDING,
                                     PROTOVER_HS_SETUP_PADDING);
 
+  /* TODO: Set these flags based on real values.
+  out->supports_ntor3_and_param_negotiation =
+    protocol_list_supports_protocol(protocols, PRT_RELAY,
+                                    XXXX)
+    &&
+    protocol_list_supports_protocol(protocols, PRT_FLOWCTRL,
+                                    XXXX);
+  */
+
   protover_summary_flags_t *new_cached = tor_memdup(out, sizeof(*out));
   cached = strmap_set(protover_summary_map, protocols, new_cached);
   tor_assert(!cached);
index c9195c293473640f2b57ca7af452870d9ae69517..ee4ec25b010e2f3fb218a3b29b0a46b782714d18 100644 (file)
@@ -1687,7 +1687,11 @@ hs_get_extend_info_from_lspecs(const smartlist_t *lspecs,
   /* We do have everything for which we think we can connect successfully. */
   info = extend_info_new(NULL, legacy_id,
                          (have_ed25519_id) ? &ed25519_pk : NULL, NULL,
-                         onion_key, &ap.addr, ap.port);
+                         onion_key, &ap.addr, ap.port,
+                         /* TODO: The protover summary here needs to explain
+                            if we support the newer congestion control or
+                            not.  This may require new specification stuff */
+                         NULL);
  done:
   return info;
 }
index c676e8dfb4cec19e59b2ebc48c0188da049cd466..b895a2c7f80d7be6ac4409daf910c3d54a863354 100644 (file)
@@ -1205,7 +1205,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
 };
 
 /** Return the protover_summary_flags for a given node. */
index 2d346b1809f407766842f3173e5325793b7de71d..af3b488ae1c283c806a6b532e25ae1b292c430aa 100644 (file)
@@ -392,7 +392,8 @@ circuit_open_connection_for_extend(const struct extend_cell_t *ec,
                                 NULL, /*onion_key*/
                                 NULL, /*curve25519_key*/
                                 &chosen_ap->addr,
-                                chosen_ap->port);
+                                chosen_ap->port,
+                                NULL /* protover summary */);
 
   circ->n_chan_create_cell = tor_memdup(&ec->create_cell,
                                         sizeof(ec->create_cell));
index d029c050530c86fa9bd910004a736ec2ae742a9c..d52fea3c11a8f2a29d6c2037598665fb2def903c 100644 (file)
@@ -228,7 +228,8 @@ extend_info_from_router(const routerinfo_t *r, int family)
   info = extend_info_new(r->nickname, r->cache_info.identity_digest,
                          ed_id_key,
                          rsa_pubkey, r->onion_curve25519_pkey,
-                         &ap.addr, ap.port);
+                         &ap.addr, ap.port,
+                         NULL /* should self-tests use ntor3? */);
   crypto_pk_free(rsa_pubkey);
   return info;
 }
index 6ced3f4111610b03db776012ff120aacce1668cd..5dc5fc5201aeff0281010356c34be930283cd805 100644 (file)
@@ -1609,7 +1609,7 @@ simulate_single_hop_extend(circuit_t *client, circuit_t *mid_relay,
   hop->extend_info = extend_info_new(
           padding ? "padding" : "non-padding",
           digest, NULL, NULL, NULL,
-          &addr, padding);
+          &addr, padding, NULL);
 
   cpath_init_circuit_crypto(hop, whatevs_key, sizeof(whatevs_key), 0, 0);
 
index 15573d945c8402060fc419fd2e60219712b9f5da..3d842382494d3d8f78d15d7206fdc3f8d9dd347a 100644 (file)
@@ -1186,7 +1186,7 @@ test_socks_hs_errors(void *arg)
   /* Code path will log this exit so build it. */
   ocirc->build_state->chosen_exit = extend_info_new("TestNickname", digest,
                                                     NULL, NULL, NULL, &addr,
-                                                    4242);
+                                                    4242, NULL);
   /* Attach socks connection to this rendezvous circuit. */
   ocirc->p_streams = ENTRY_TO_EDGE_CONN(socks_conn);
   /* Trigger the rendezvous failure. Timeout the circuit and free. */
@@ -1281,7 +1281,7 @@ test_close_intro_circuit_failure(void *arg)
   /* Code path will log this exit so build it. */
   ocirc->build_state->chosen_exit = extend_info_new("TestNickname", digest,
                                                     NULL, NULL, NULL, &addr,
-                                                    4242);
+                                                    4242, NULL);
   ed25519_pubkey_copy(&ocirc->hs_ident->intro_auth_pk, &intro_kp.pubkey);
 
   /* We'll make for close the circuit for a timeout failure. It should _NOT_
@@ -1308,7 +1308,7 @@ test_close_intro_circuit_failure(void *arg)
   /* Code path will log this exit so build it. */
   ocirc->build_state->chosen_exit = extend_info_new("TestNickname", digest,
                                                     NULL, NULL, NULL, &addr,
-                                                    4242);
+                                                    4242, NULL);
   ed25519_pubkey_copy(&ocirc->hs_ident->intro_auth_pk, &intro_kp.pubkey);
 
   /* On free, we should get an unreachable failure. */
@@ -1331,7 +1331,7 @@ test_close_intro_circuit_failure(void *arg)
   /* Code path will log this exit so build it. */
   ocirc->build_state->chosen_exit = extend_info_new("TestNickname", digest,
                                                     NULL, NULL, NULL, &addr,
-                                                    4242);
+                                                    4242, NULL);
   ed25519_pubkey_copy(&ocirc->hs_ident->intro_auth_pk, &intro_kp.pubkey);
 
   circuit_mark_for_close(circ, END_CIRC_REASON_TIMEOUT);