aboutsummaryrefslogtreecommitdiff
path: root/src/core/or/relay.c
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2019-01-09 11:03:49 -0500
committerDavid Goulet <dgoulet@torproject.org>2019-04-29 12:17:57 -0400
commit0e6e800c89c7cfef255491179473e13de5f72d03 (patch)
treeef6485687e1ef21246fb10c6266fb39b60558bc9 /src/core/or/relay.c
parent8e38791baf48ca2a4c865f3b7fc264392e63f426 (diff)
downloadtor-0e6e800c89c7cfef255491179473e13de5f72d03.tar.gz
tor-0e6e800c89c7cfef255491179473e13de5f72d03.zip
sendme: Always close stream if deliver window is negative
Previously, we would only close the stream when our deliver window was negative at the circuit-level but _not_ at the stream-level when receiving a DATA cell. This commit adds an helper function connection_edge_end_close() which sends an END and then mark the stream for close for a given reason. That function is now used both in case the deliver window goes below zero for both circuit and stream level. Part of #26840 Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/core/or/relay.c')
-rw-r--r--src/core/or/relay.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/core/or/relay.c b/src/core/or/relay.c
index 06e201f20d..6ff053d8a0 100644
--- a/src/core/or/relay.c
+++ b/src/core/or/relay.c
@@ -1550,17 +1550,12 @@ connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ,
++stats_n_data_cells_received;
/* Update our circuit-level deliver window that we received a DATA cell.
- * If the deliver window goes below 0, we end the connection due to a
- * protocol failure. */
+ * If the deliver window goes below 0, we end the circuit and stream due
+ * to a protocol failure. */
if (sendme_circuit_data_received(circ, layer_hint) < 0) {
log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
"(relay data) circ deliver_window below 0. Killing.");
- if (conn) {
- /* XXXX Do we actually need to do this? Will killing the circuit
- * not send an END and mark the stream for close as appropriate? */
- connection_edge_end(conn, END_STREAM_REASON_TORPROTOCOL);
- connection_mark_for_close(TO_CONN(conn));
- }
+ connection_edge_end_close(conn, END_STREAM_REASON_TORPROTOCOL);
return -END_CIRC_REASON_TORPROTOCOL;
}
@@ -1590,11 +1585,12 @@ connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ,
/* Update our stream-level deliver window that we just received a DATA
* cell. Going below 0 means we have a protocol level error so the
- * circuit is closed. */
+ * stream and circuit are closed. */
if (sendme_stream_data_received(conn) < 0) {
log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
"(relay data) conn deliver_window below 0. Killing.");
+ connection_edge_end_close(conn, END_STREAM_REASON_TORPROTOCOL);
return -END_CIRC_REASON_TORPROTOCOL;
}
/* Total all valid application bytes delivered */