From: Nick Mathewson Date: Fri, 18 Apr 2025 00:31:44 +0000 (-0400) Subject: Remove redundant relay_cell_proto fields X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=89d870d32816c32a220f59debc1d8f3469e97a9a;p=thirdparty%2Ftor.git Remove redundant relay_cell_proto fields These did not turn out to be useful for anything. --- diff --git a/src/core/or/cell_st.h b/src/core/or/cell_st.h index 230b4f8432..77e12c0c2c 100644 --- a/src/core/or/cell_st.h +++ b/src/core/or/cell_st.h @@ -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. */ }; diff --git a/src/core/or/relay.c b/src/core/or/relay.c index 9aed85f31f..5fdf5715bb 100644 --- a/src/core/or/relay.c +++ b/src/core/or/relay.c @@ -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; diff --git a/src/core/or/relay_msg.c b/src/core/or/relay_msg.c index f69f6b2667..330bbf714c 100644 --- a/src/core/or/relay_msg.c +++ b/src/core/or/relay_msg.c @@ -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); diff --git a/src/core/or/relay_msg_st.h b/src/core/or/relay_msg_st.h index 75292b7f89..5b59adc0b2 100644 --- a/src/core/or/relay_msg_st.h +++ b/src/core/or/relay_msg_st.h @@ -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. */ diff --git a/src/test/test_cell_formats.c b/src/test/test_cell_formats.c index 0c02325fac..9bf7042787 100644 --- a/src/test/test_cell_formats.c +++ b/src/test/test_cell_formats.c @@ -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));