diff options
author | David Goulet <dgoulet@torproject.org> | 2019-01-11 11:36:08 -0500 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2019-04-29 12:17:57 -0400 |
commit | 8e38791baf48ca2a4c865f3b7fc264392e63f426 (patch) | |
tree | 8253f1fa78df87ac507efd2fd4c5060c86c46ff9 /src/core/or/relay.c | |
parent | 2d3c600915c22f1e9a7e9dcbba8358556ef64505 (diff) | |
download | tor-8e38791baf48ca2a4c865f3b7fc264392e63f426.tar.gz tor-8e38791baf48ca2a4c865f3b7fc264392e63f426.zip |
sendme: Add helper functions for DATA cell packaging
When we are about to send a DATA cell, we have to decrement the package window
for both the circuit and stream level.
This commit adds helper functions to handle the package window decrement.
Part of #26288
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/core/or/relay.c')
-rw-r--r-- | src/core/or/relay.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/core/or/relay.c b/src/core/or/relay.c index 0eb2ba3f67..06e201f20d 100644 --- a/src/core/or/relay.c +++ b/src/core/or/relay.c @@ -2062,15 +2062,17 @@ connection_edge_package_raw_inbuf(edge_connection_t *conn, int package_partial, return 0; } - if (!cpath_layer) { /* non-rendezvous exit */ - tor_assert(circ->package_window > 0); - circ->package_window--; - } else { /* we're an AP, or an exit on a rendezvous circ */ - tor_assert(cpath_layer->package_window > 0); - cpath_layer->package_window--; + /* Handle the circuit-level SENDME package window. */ + if (sendme_circuit_data_packaged(circ, cpath_layer) < 0) { + /* Package window has gone under 0. Protocol issue. */ + log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL, + "Circuit package window is below 0. Closing circuit."); + conn->end_reason = END_STREAM_REASON_TORPROTOCOL; + return -1; } - if (--conn->package_window <= 0) { /* is it 0 after decrement? */ + /* Handle the stream-level SENDME package window. */ + if (sendme_stream_data_packaged(conn) < 0) { connection_stop_reading(TO_CONN(conn)); log_debug(domain,"conn->package_window reached 0."); circuit_consider_stop_edge_reading(circ, cpath_layer); |