[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/main] Use protover to signal support for ntor3 + congestion control.



commit baaabb503c9c9fc81e0d95b2d5baeefef7423b7a
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Tue Sep 14 16:31:48 2021 -0400

    Use protover to signal support for ntor3 + congestion control.
---
 src/core/or/circuituse.c               |  3 ++-
 src/core/or/extendinfo.c               | 14 ++++++++++----
 src/core/or/extendinfo.h               |  3 ++-
 src/core/or/or.h                       |  4 ++++
 src/core/or/protover.c                 |  2 ++
 src/core/or/versions.c                 |  9 +++++++++
 src/feature/hs/hs_common.c             |  6 +++++-
 src/feature/nodelist/nodelist.c        |  2 +-
 src/feature/relay/circuitbuild_relay.c |  3 ++-
 src/feature/relay/selftest.c           |  3 ++-
 src/test/test_circuitpadding.c         |  2 +-
 src/test/test_hs_client.c              |  8 ++++----
 12 files changed, 44 insertions(+), 15 deletions(-)

diff --git a/src/core/or/circuituse.c b/src/core/or/circuituse.c
index 2ec391eca0..104e898d6c 100644
--- a/src/core/or/circuituse.c
+++ b/src/core/or/circuituse.c
@@ -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. */
diff --git a/src/core/or/extendinfo.c b/src/core/or/extendinfo.c
index f33e887e7d..ca2288e0a4 100644
--- a/src/core/or/extendinfo.c
+++ b/src/core/or/extendinfo.c
@@ -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);
diff --git a/src/core/or/extendinfo.h b/src/core/or/extendinfo.h
index ffe8317431..8781cc7047 100644
--- a/src/core/or/extendinfo.h
+++ b/src/core/or/extendinfo.h
@@ -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);
diff --git a/src/core/or/or.h b/src/core/or/or.h
index 3911797563..409f4a0fea 100644
--- a/src/core/or/or.h
+++ b/src/core/or/or.h
@@ -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;
diff --git a/src/core/or/protover.c b/src/core/or/protover.c
index bd9cc60115..63e9a33b72 100644
--- a/src/core/or/protover.c
+++ b/src/core/or/protover.c
@@ -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 "
diff --git a/src/core/or/versions.c b/src/core/or/versions.c
index b9fad22c04..322121b43f 100644
--- a/src/core/or/versions.c
+++ b/src/core/or/versions.c
@@ -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);
diff --git a/src/feature/hs/hs_common.c b/src/feature/hs/hs_common.c
index c9195c2934..ee4ec25b01 100644
--- a/src/feature/hs/hs_common.c
+++ b/src/feature/hs/hs_common.c
@@ -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;
 }
diff --git a/src/feature/nodelist/nodelist.c b/src/feature/nodelist/nodelist.c
index c676e8dfb4..b895a2c7f8 100644
--- a/src/feature/nodelist/nodelist.c
+++ b/src/feature/nodelist/nodelist.c
@@ -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. */
diff --git a/src/feature/relay/circuitbuild_relay.c b/src/feature/relay/circuitbuild_relay.c
index 2d346b1809..af3b488ae1 100644
--- a/src/feature/relay/circuitbuild_relay.c
+++ b/src/feature/relay/circuitbuild_relay.c
@@ -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));
diff --git a/src/feature/relay/selftest.c b/src/feature/relay/selftest.c
index d029c05053..d52fea3c11 100644
--- a/src/feature/relay/selftest.c
+++ b/src/feature/relay/selftest.c
@@ -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;
 }
diff --git a/src/test/test_circuitpadding.c b/src/test/test_circuitpadding.c
index 6ced3f4111..5dc5fc5201 100644
--- a/src/test/test_circuitpadding.c
+++ b/src/test/test_circuitpadding.c
@@ -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);
 
diff --git a/src/test/test_hs_client.c b/src/test/test_hs_client.c
index 15573d945c..3d84238249 100644
--- a/src/test/test_hs_client.c
+++ b/src/test/test_hs_client.c
@@ -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);



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits