summaryrefslogtreecommitdiff
path: root/src/or/command.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2008-07-23 15:58:38 +0000
committerNick Mathewson <nickm@torproject.org>2008-07-23 15:58:38 +0000
commitea95ce25b63e6a291d9c816308919caf887fa7ea (patch)
tree46fcdd336a7197acf4b3fb6b861d9c9068be3ef3 /src/or/command.c
parent2748afe60961596791bceb842dce2385c5b4db7e (diff)
downloadtor-ea95ce25b63e6a291d9c816308919caf887fa7ea.tar.gz
tor-ea95ce25b63e6a291d9c816308919caf887fa7ea.zip
r17323@aud-055: nickm | 2008-07-23 17:58:25 +0200
Implement most of proposal 110. svn:r16156
Diffstat (limited to 'src/or/command.c')
-rw-r--r--src/or/command.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/or/command.c b/src/or/command.c
index 4a08842396..89bc72ef1f 100644
--- a/src/or/command.c
+++ b/src/or/command.c
@@ -353,8 +353,8 @@ command_process_created_cell(cell_t *cell, or_connection_t *conn)
}
}
-/** Process a 'relay' <b>cell</b> that just arrived from <b>conn</b>. Make sure
- * it came in with a recognized circ_id. Pass it on to
+/** Process a 'relay' or 'relay_early' <b>cell</b> that just arrived from
+ * <b>conn</b>. Make sure it came in with a recognized circ_id. Pass it on to
* circuit_receive_relay_cell() for actual processing.
*/
static void
@@ -390,6 +390,30 @@ command_process_relay_cell(cell_t *cell, or_connection_t *conn)
else
direction = CELL_DIRECTION_IN;
+ /* If we have a relay_early cell, make sure that it's outbound, and we've
+ * gotten no more than MAX_RELAY_EARLY_CELLS_PER_CIRCUIT of them. */
+ if (cell->command == CELL_RELAY_EARLY) {
+ if (direction == CELL_DIRECTION_IN) {
+ log_fn(LOG_PROTOCOL_WARN, LD_OR,
+ "Received an inbound RELAY_EARLY cell on circuit %d from %s:%d."
+ " Closing circuit.",
+ cell->circ_id, conn->_base.address, conn->_base.port);
+ circuit_mark_for_close(circ, END_CIRC_REASON_TORPROTOCOL);
+ return;
+ } else {
+ or_circuit_t *or_circ = TO_OR_CIRCUIT(circ);
+ if (or_circ->remaining_relay_early_cells == 0) {
+ log_fn(LOG_PROTOCOL_WARN, LD_OR,
+ "Received too many RELAY_EARLY cells on circ %d from %s:%d."
+ " Closing circuit.",
+ cell->circ_id, safe_str(conn->_base.address), conn->_base.port);
+ circuit_mark_for_close(circ, END_CIRC_REASON_TORPROTOCOL);
+ return;
+ }
+ --or_circ->remaining_relay_early_cells;
+ }
+ }
+
if ((reason = circuit_receive_relay_cell(cell, circ, direction)) < 0) {
log_fn(LOG_PROTOCOL_WARN,LD_PROTOCOL,"circuit_receive_relay_cell "
"(%s) failed. Closing.",