From: David Goulet Date: Thu, 24 Aug 2023 18:29:03 +0000 (-0400) Subject: protover: Add the RelayCell=1 new protocol version X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b4646ed06121719cef6931f68b6b110412e67462;p=thirdparty%2Ftor.git protover: Add the RelayCell=1 new protocol version Signed-off-by: David Goulet --- diff --git a/src/core/or/or.h b/src/core/or/or.h index af3518cd5e..39b9a254c3 100644 --- a/src/core/or/or.h +++ b/src/core/or/or.h @@ -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; diff --git a/src/core/or/protover.c b/src/core/or/protover.c index 53c4198b48..1eef2b8f7e 100644 --- a/src/core/or/protover.c +++ b/src/core/or/protover.c @@ -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; } /* diff --git a/src/core/or/protover.h b/src/core/or/protover.h index 9efa2201a7..af1c940b65 100644 --- a/src/core/or/protover.h +++ b/src/core/or/protover.h @@ -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); diff --git a/src/core/or/versions.c b/src/core/or/versions.c index a33c5f15a5..901dbbfb35 100644 --- a/src/core/or/versions.c +++ b/src/core/or/versions.c @@ -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); diff --git a/src/feature/nodelist/nodelist.c b/src/feature/nodelist/nodelist.c index efea56ed77..189d72250e 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,0,0,0,0,0,0 }; /** Return the protover_summary_flags for a given node. */