]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Remove redundant relay_cell_proto fields
authorNick Mathewson <nickm@torproject.org>
Fri, 18 Apr 2025 00:31:44 +0000 (20:31 -0400)
committerNick Mathewson <nickm@torproject.org>
Mon, 5 May 2025 17:07:37 +0000 (13:07 -0400)
These did not turn out to be useful for anything.

src/core/or/cell_st.h
src/core/or/relay.c
src/core/or/relay_msg.c
src/core/or/relay_msg_st.h
src/test/test_cell_formats.c

index 230b4f84327e5459a6963ed12ef48ec21e56e580..77e12c0c2cc1bb7ad1ec700f71f61974025ea60a 100644 (file)
@@ -18,11 +18,6 @@ struct cell_t {
   circid_t circ_id; /**< Circuit which received the cell. */
   uint8_t command; /**< Type of the cell: one of CELL_PADDING, CELL_CREATE,
                     * CELL_DESTROY, etc */
-  /* Relay cell protocol version. This tells us which format to use when
-   * parsing the payload. */
-  /* TODO #41051: Use an enum. */
-  /* TODO #41051: Reconsider whether this field belongs here. */
-  uint8_t relay_cell_proto;
   uint8_t payload[CELL_PAYLOAD_SIZE]; /**< Cell body. */
 };
 
index 9aed85f31f6022a46c3bc49780a513a24319e2e2..5fdf5715bb3cd729d25e6983a2bf63c5eea02d91 100644 (file)
@@ -265,7 +265,6 @@ circuit_receive_relay_cell(cell_t *cell, circuit_t *circ,
      * the SENDME if need be. */
     sendme_record_received_cell_digest(circ, layer_hint);
 
-    cell->relay_cell_proto = format; // ????? TODO #41051.
     // TODO #41051: This also doesn't need to copy!
     relay_msg_t *msg = relay_msg_decode_cell(format, cell);
 
@@ -634,7 +633,6 @@ relay_send_command_from_edge_,(streamid_t stream_id, circuit_t *orig_circ,
       return -1;
     }
 
-    msg.relay_cell_proto = cell_format;
     msg.command = relay_command;
     msg.stream_id = stream_id;
     msg.length = payload_len;
index f69f6b2667b915641589215ce8a4d2e87c0b02d0..330bbf714c5f9a7266b4fd64171e936a8962f627 100644 (file)
@@ -80,7 +80,7 @@ relay_msg_set(const uint8_t relay_cell_proto, const uint8_t cmd,
               const uint16_t payload_len, relay_msg_t *msg)
 {
   // TODO #41051: Should this free msg->body?
-  msg->relay_cell_proto = relay_cell_proto;
+  (void) relay_cell_proto;
   msg->command = cmd;
   msg->stream_id = stream_id;
 
@@ -244,7 +244,6 @@ relay_msg_encode_cell(relay_cell_fmt_t format,
                       cell_t *cell_out)
 {
   memset(cell_out, 0, sizeof(cell_t));
-  cell_out->relay_cell_proto = format;
   cell_out->command = msg->is_relay_early ?
     CELL_RELAY_EARLY : CELL_RELAY;
 
@@ -269,10 +268,6 @@ relay_msg_t *
 relay_msg_decode_cell(relay_cell_fmt_t format,
                       const cell_t *cell)
 {
-  // TODO #41051: Either remove the format argument here,
-  // or the format field in cell_t.
-  tor_assert(cell->relay_cell_proto == format);
-
   switch (format) {
     case RELAY_CELL_FORMAT_V0:
       return decode_v0_cell(cell);
index 75292b7f89147401cf58db795a61cb028b6f712e..5b59adc0b27ed71b1a3ce17f8d847a0ff7f619e1 100644 (file)
@@ -19,8 +19,6 @@
  *
  * This CAN NOT be made opaque so to avoid heap allocation in the fast path. */
 typedef struct relay_msg_t {
-  /* Relay cell protocol version of this message. */
-  relay_cell_fmt_t relay_cell_proto;
   /* Relay command of a message. */
   uint8_t command;
   /* Length of the message body. */
index 0c02325facc49c18acfd3674195b10ab0ef56cd7..9bf70427874ab59c60e53fcc8e4de954bcc67286 100644 (file)
@@ -1459,7 +1459,6 @@ test_cfmt_relay_msg_decoding_simple(void *arg)
   s = "02" "0000" "0250" "00000000" "000B"
       "68656c6c6f20776f726c64" "00000000";
   base16_decode((char*)cell.payload, sizeof(cell.payload), s, strlen(s));
-  cell.relay_cell_proto = RELAY_CELL_FORMAT_V0;
   msg1 = relay_msg_decode_cell(RELAY_CELL_FORMAT_V0, &cell);
   tt_assert(msg1);
 
@@ -1487,7 +1486,6 @@ test_cfmt_relay_msg_decoding_simple(void *arg)
       "05" "0014"
       "68656c6c6f206920616d2061207461672e2e2e2e" "00000000";
   base16_decode((char*)cell.payload, sizeof(cell.payload), s, strlen(s));
-  cell.relay_cell_proto = RELAY_CELL_FORMAT_V1;
 
   msg1 = relay_msg_decode_cell(RELAY_CELL_FORMAT_V1, &cell);
   tt_assert(msg1);
@@ -1554,14 +1552,12 @@ test_cfmt_relay_msg_decoding_error(void *arg)
 
   // V0, too long.
   cell.command = CELL_RELAY;
-  cell.relay_cell_proto = RELAY_CELL_FORMAT_V0;
   s = "02" "0000" "0250" "00000000" "01F3";
   base16_decode((char*)cell.payload, sizeof(cell.payload), s, strlen(s));
   msg1 = relay_msg_decode_cell(RELAY_CELL_FORMAT_V0, &cell);
   tt_ptr_op(msg1, OP_EQ, NULL);
 
   // V1, command unrecognized.
-  cell.relay_cell_proto = RELAY_CELL_FORMAT_V1;
   s = "00000000000000000000000000000000"
       "F0" "000C" "0250";
   base16_decode((char*)cell.payload, sizeof(cell.payload), s, strlen(s));