diff options
author | Nick Mathewson <nickm@torproject.org> | 2019-05-13 14:25:54 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2019-05-13 14:25:54 -0400 |
commit | c6523a6398efb07831ede8234486ee8f385ed558 (patch) | |
tree | 68e3e09f04797a28d79db0f3f36a8265fd022527 /src | |
parent | def96ce83858b214ebc01797e41e4f0419f9d104 (diff) | |
parent | e1771aeb51fd8f92db66fc1e9d0d8aad5ff9f169 (diff) | |
download | tor-c6523a6398efb07831ede8234486ee8f385ed558.tar.gz tor-c6523a6398efb07831ede8234486ee8f385ed558.zip |
Merge remote-tracking branch 'tor-github/pr/998'
Diffstat (limited to 'src')
-rw-r--r-- | src/core/or/channel.c | 11 | ||||
-rw-r--r-- | src/core/or/channeltls.c | 4 | ||||
-rw-r--r-- | src/core/or/circuitpadding.c | 2 | ||||
-rw-r--r-- | src/core/or/connection_or.c | 5 | ||||
-rw-r--r-- | src/core/or/relay.c | 2 | ||||
-rw-r--r-- | src/core/or/relay.h | 1 |
6 files changed, 20 insertions, 5 deletions
diff --git a/src/core/or/channel.c b/src/core/or/channel.c index fd7bf62789..0e190809ba 100644 --- a/src/core/or/channel.c +++ b/src/core/or/channel.c @@ -1418,6 +1418,7 @@ write_packed_cell(channel_t *chan, packed_cell_t *cell) { int ret = -1; size_t cell_bytes; + uint8_t command = packed_cell_get_command(cell, chan->wide_circ_ids); tor_assert(chan); tor_assert(cell); @@ -1452,6 +1453,16 @@ write_packed_cell(channel_t *chan, packed_cell_t *cell) /* Successfully sent the cell. */ ret = 0; + /* Update padding statistics for the packed codepath.. */ + rep_hist_padding_count_write(PADDING_TYPE_TOTAL); + if (command == CELL_PADDING) + rep_hist_padding_count_write(PADDING_TYPE_CELL); + if (chan->padding_enabled) { + rep_hist_padding_count_write(PADDING_TYPE_ENABLED_TOTAL); + if (command == CELL_PADDING) + rep_hist_padding_count_write(PADDING_TYPE_ENABLED_CELL); + } + done: return ret; } diff --git a/src/core/or/channeltls.c b/src/core/or/channeltls.c index 772f583f2e..5442cae938 100644 --- a/src/core/or/channeltls.c +++ b/src/core/or/channeltls.c @@ -1094,13 +1094,13 @@ channel_tls_handle_cell(cell_t *cell, or_connection_t *conn) entry_guards_note_internet_connectivity(get_guard_selection_info()); rep_hist_padding_count_read(PADDING_TYPE_TOTAL); - if (TLS_CHAN_TO_BASE(chan)->currently_padding) + if (TLS_CHAN_TO_BASE(chan)->padding_enabled) rep_hist_padding_count_read(PADDING_TYPE_ENABLED_TOTAL); switch (cell->command) { case CELL_PADDING: rep_hist_padding_count_read(PADDING_TYPE_CELL); - if (TLS_CHAN_TO_BASE(chan)->currently_padding) + if (TLS_CHAN_TO_BASE(chan)->padding_enabled) rep_hist_padding_count_read(PADDING_TYPE_ENABLED_CELL); ++stats_n_padding_cells_processed; /* do nothing */ diff --git a/src/core/or/circuitpadding.c b/src/core/or/circuitpadding.c index d30edf9db8..9253c9e282 100644 --- a/src/core/or/circuitpadding.c +++ b/src/core/or/circuitpadding.c @@ -1020,6 +1020,7 @@ circpad_send_padding_cell_for_callback(circpad_machine_runtime_t *mi) "Callback: Sending padding to non-origin circuit."); relay_send_command_from_edge(0, mi->on_circ, RELAY_COMMAND_DROP, NULL, 0, NULL); + rep_hist_padding_count_write(PADDING_TYPE_DROP); } else { static ratelim_t cell_lim = RATELIM_INIT(600); log_fn_ratelim(&cell_lim,LOG_NOTICE,LD_CIRC, @@ -1028,7 +1029,6 @@ circpad_send_padding_cell_for_callback(circpad_machine_runtime_t *mi) } } - rep_hist_padding_count_write(PADDING_TYPE_DROP); /* This is a padding cell sent from the client or from the middle node, * (because it's invoked from circuitpadding.c) */ circpad_cell_event_padding_sent(circ); diff --git a/src/core/or/connection_or.c b/src/core/or/connection_or.c index e9b4b21955..830e09fd54 100644 --- a/src/core/or/connection_or.c +++ b/src/core/or/connection_or.c @@ -2308,6 +2308,8 @@ connection_or_write_cell_to_buf(const cell_t *cell, or_connection_t *conn) cell_pack(&networkcell, cell, conn->wide_circ_ids); + /* We need to count padding cells from this non-packed code path + * since they are sent via chan->write_cell() (which is not packed) */ rep_hist_padding_count_write(PADDING_TYPE_TOTAL); if (cell->command == CELL_PADDING) rep_hist_padding_count_write(PADDING_TYPE_CELL); @@ -2318,7 +2320,7 @@ connection_or_write_cell_to_buf(const cell_t *cell, or_connection_t *conn) if (conn->chan) { channel_timestamp_active(TLS_CHAN_TO_BASE(conn->chan)); - if (TLS_CHAN_TO_BASE(conn->chan)->currently_padding) { + if (TLS_CHAN_TO_BASE(conn->chan)->padding_enabled) { rep_hist_padding_count_write(PADDING_TYPE_ENABLED_TOTAL); if (cell->command == CELL_PADDING) rep_hist_padding_count_write(PADDING_TYPE_ENABLED_CELL); @@ -2348,6 +2350,7 @@ connection_or_write_var_cell_to_buf,(const var_cell_t *cell, if (conn->base_.state == OR_CONN_STATE_OR_HANDSHAKING_V3) or_handshake_state_record_var_cell(conn, conn->handshake_state, cell, 0); + rep_hist_padding_count_write(PADDING_TYPE_TOTAL); /* Touch the channel's active timestamp if there is one */ if (conn->chan) channel_timestamp_active(TLS_CHAN_TO_BASE(conn->chan)); diff --git a/src/core/or/relay.c b/src/core/or/relay.c index 1b2aafb866..8b3a1be18e 100644 --- a/src/core/or/relay.c +++ b/src/core/or/relay.c @@ -2758,7 +2758,7 @@ set_streams_blocked_on_circ(circuit_t *circ, channel_t *chan, } /** Extract the command from a packed cell. */ -static uint8_t +uint8_t packed_cell_get_command(const packed_cell_t *cell, int wide_circ_ids) { if (wide_circ_ids) { diff --git a/src/core/or/relay.h b/src/core/or/relay.h index 2248cdf381..97d5d6d0f2 100644 --- a/src/core/or/relay.h +++ b/src/core/or/relay.h @@ -95,6 +95,7 @@ const uint8_t *decode_address_from_payload(tor_addr_t *addr_out, void circuit_clear_cell_queue(circuit_t *circ, channel_t *chan); circid_t packed_cell_get_circid(const packed_cell_t *cell, int wide_circ_ids); +uint8_t packed_cell_get_command(const packed_cell_t *cell, int wide_circ_ids); #ifdef RELAY_PRIVATE STATIC int connected_cell_parse(const relay_header_t *rh, const cell_t *cell, |