]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
protover: Add the RelayCell=1 new protocol version
authorDavid Goulet <dgoulet@torproject.org>
Thu, 24 Aug 2023 18:29:03 +0000 (14:29 -0400)
committerDavid Goulet <dgoulet@torproject.org>
Wed, 31 Jan 2024 15:16:02 +0000 (10:16 -0500)
Signed-off-by: David Goulet <dgoulet@torproject.org>
src/core/or/or.h
src/core/or/protover.c
src/core/or/protover.h
src/core/or/versions.c
src/feature/nodelist/nodelist.c

index af3518cd5ec10ba90c37de5aee7842d6a4e7dc6c..39b9a254c3e4330277e701b483f128b0d8966be5 100644 (file)
@@ -747,6 +747,9 @@ typedef struct protover_summary_flags_t {
   /** True iff this router supports ntorv3 subproto request extension. Requires
    * Relay=5. */
   unsigned int supports_ntorv3_subproto : 1;
+
+  /** True iff this router supports the RelayCell=1 protocol. */
+  unsigned int supports_relay_cell_proto : 1;
 } protover_summary_flags_t;
 
 typedef struct routerinfo_t routerinfo_t;
index 53c4198b48320aa2b081b214eabd255574388703..1eef2b8f7ea0a4bca459cf7720f482ed269b488f 100644 (file)
@@ -59,6 +59,7 @@ static const struct {
   { PRT_CONS, "Cons" },
   { PRT_FLOWCTRL, "FlowCtrl"},
   { PRT_CONFLUX, "Conflux"},
+  { PRT_RELAY_CELL, "RelayCell"},
 };
 
 #define N_PROTOCOL_NAMES ARRAY_LENGTH(PROTOCOL_NAMES)
@@ -406,7 +407,8 @@ protocol_list_supports_protocol_or_later(const char *list,
 #endif
 #define PR_MICRODESC_V "1-2"
 #define PR_PADDING_V   "2"
-#define PR_RELAY_V     "1-4"
+#define PR_RELAY_V     "1-5"
+#define PR_RELAY_CELL_V "1"
 
 /** Return the string containing the supported version for the given protocol
  * type. */
@@ -427,6 +429,7 @@ protover_get_supported(const protocol_type_t type)
   case PRT_MICRODESC: return PR_MICRODESC_V;
   case PRT_PADDING: return PR_PADDING_V;
   case PRT_RELAY: return PR_RELAY_V;
+  case PRT_RELAY_CELL: return PR_RELAY_CELL_V;
   default:
     tor_assert_unreached();
   }
@@ -489,7 +492,8 @@ protover_get_supported_protocols(void)
     "LinkAuth=" PR_LINKAUTH_V " "
     "Microdesc=" PR_MICRODESC_V " "
     "Padding=" PR_PADDING_V " "
-    "Relay=" PR_RELAY_V;
+    "Relay=" PR_RELAY_V " "
+    "RelayCell=" PR_RELAY_CELL_V;
 }
 
 /*
index 9efa2201a76995eafd9600fe9d636c61e8977441..af1c940b6525dceacda89344f3c04a5eb68ba990 100644 (file)
@@ -65,23 +65,27 @@ struct smartlist_t;
 /** The protover that signals support for ntorv3 subprotocol request. */
 #define PROTOVER_RELAY_NTORV3_SUBPROTO 5
 
+/** The protover that signals support for relay cell protocol. */
+#define PROTOVER_RELAY_CELL_PROTO 1
+
 /** List of recognized subprotocols. */
 /// C_RUST_COUPLED: src/rust/protover/ffi.rs `translate_to_rust`
 /// C_RUST_COUPLED: src/rust/protover/protover.rs `Proto`
 typedef enum protocol_type_t {
-  PRT_LINK      = 0,
-  PRT_LINKAUTH  = 1,
-  PRT_RELAY     = 2,
-  PRT_DIRCACHE  = 3,
-  PRT_HSDIR     = 4,
-  PRT_HSINTRO   = 5,
-  PRT_HSREND    = 6,
-  PRT_DESC      = 7,
-  PRT_MICRODESC = 8,
-  PRT_CONS      = 9,
-  PRT_PADDING   = 10,
-  PRT_FLOWCTRL  = 11,
-  PRT_CONFLUX   = 12,
+  PRT_LINK       = 0,
+  PRT_LINKAUTH   = 1,
+  PRT_RELAY      = 2,
+  PRT_DIRCACHE   = 3,
+  PRT_HSDIR      = 4,
+  PRT_HSINTRO    = 5,
+  PRT_HSREND     = 6,
+  PRT_DESC       = 7,
+  PRT_MICRODESC  = 8,
+  PRT_CONS       = 9,
+  PRT_PADDING    = 10,
+  PRT_FLOWCTRL   = 11,
+  PRT_CONFLUX    = 12,
+  PRT_RELAY_CELL = 13,
 } protocol_type_t;
 
 bool protover_list_is_invalid(const char *s);
index a33c5f15a59fd1ffcf8a0516dec59eafe2762fb2..901dbbfb35c9763f9628f55fea8daf8b8e87d0f3 100644 (file)
@@ -499,6 +499,10 @@ memoize_protover_summary(protover_summary_flags_t *out,
     protocol_list_supports_protocol(protocols, PRT_RELAY,
                                     PROTOVER_RELAY_NTORV3_SUBPROTO);
 
+  out->supports_relay_cell_proto =
+    protocol_list_supports_protocol(protocols, PRT_RELAY_CELL,
+                                    PROTOVER_RELAY_CELL_PROTO);
+
   protover_summary_flags_t *new_cached = tor_memdup(out, sizeof(*out));
   cached = strmap_set(protover_summary_map, protocols, new_cached);
   tor_assert(!cached);
index efea56ed77e66c0b9b98c6048a66c1c126966a6a..189d72250e6ab0b653f23bb90e475e6bad75fe11 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,0,0,0,0,0,0
 };
 
 /** Return the protover_summary_flags for a given node. */