diff options
author | Mike Perry <mikeperry-git@torproject.org> | 2018-08-07 04:23:33 +0000 |
---|---|---|
committer | Mike Perry <mikeperry-git@torproject.org> | 2018-08-29 04:12:15 +0000 |
commit | ce894e20b597d2d21b56ac8a8f13d1ea4063731d (patch) | |
tree | 95930c637439f03361b36de439192ac425af762b /src/test/test_relaycell.c | |
parent | 144647031aa9e7eacc6f7cdd8fed663c7229b2aa (diff) | |
download | tor-ce894e20b597d2d21b56ac8a8f13d1ea4063731d.tar.gz tor-ce894e20b597d2d21b56ac8a8f13d1ea4063731d.zip |
Ticket #25573: Count TRUNCATED cells.
TRUNCATED cells were ignored while in path bias. Now they are obeyed, and
cause us to tear down the circuit. The actual impact is minimal, since we
would just wait around for a probe that would never arrive before.
This commit changes client behavior.
Diffstat (limited to 'src/test/test_relaycell.c')
-rw-r--r-- | src/test/test_relaycell.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/test/test_relaycell.c b/src/test/test_relaycell.c index 4c406a9b76..3f84ee8303 100644 --- a/src/test/test_relaycell.c +++ b/src/test/test_relaycell.c @@ -116,6 +116,16 @@ mock_connection_mark_unattached_ap_(entry_connection_t *conn, int endreason, } static void +mock_mark_circ_for_close(circuit_t *circ, int reason, int line, + const char *file) +{ + (void)reason; (void)line; (void)file; + + circ->marked_for_close = 1; + return; +} + +static void mock_mark_for_close(connection_t *conn, int line, const char *file) { @@ -694,6 +704,7 @@ test_circbw_relay(void *arg) MOCK(connection_start_reading, mock_start_reading); MOCK(connection_mark_for_close_internal_, mock_mark_for_close); MOCK(relay_send_command_from_edge_, mock_send_command); + MOCK(circuit_mark_for_close_, mock_mark_circ_for_close); circ = helper_create_origin_circuit(CIRCUIT_PURPOSE_C_GENERAL, 0); circ->cpath->state = CPATH_STATE_AWAITING_KEYS; @@ -856,11 +867,18 @@ test_circbw_relay(void *arg) if (!subtest_circbw_halfclosed(circ, 6)) goto done; + /* Path bias: truncated */ + tt_int_op(circ->base_.marked_for_close, OP_EQ, 0); + PACK_CELL(0, RELAY_COMMAND_TRUNCATED, "Data1234"); + pathbias_count_valid_cells(circ, &cell); + tt_int_op(circ->base_.marked_for_close, OP_EQ, 1); + done: UNMOCK(connection_start_reading); UNMOCK(connection_mark_unattached_ap_); UNMOCK(connection_mark_for_close_internal_); UNMOCK(relay_send_command_from_edge_); + UNMOCK(circuit_mark_for_close_); circuit_free_(TO_CIRCUIT(circ)); connection_free_minimal(ENTRY_TO_CONN(entryconn1)); } |