Merge remote-tracking branch 'tor-github/pr/998'

This commit is contained in:
Nick Mathewson 2019-05-13 14:25:54 -04:00
commit c6523a6398
8 changed files with 26 additions and 7 deletions

4
changes/bug29231 Normal file
View File

@ -0,0 +1,4 @@
o Minor bugfixes (Channel padding statistics):
- Channel padding write totals and padding-enabled totals are now
counted properly in relay extrainfo descriptors. Fixes bug 29231;
bugfix on 0.3.1.1-alpha

View File

@ -72,7 +72,7 @@ problem include-count /src/core/mainloop/mainloop.c 66
problem function-size /src/core/mainloop/mainloop.c:conn_close_if_marked() 108 problem function-size /src/core/mainloop/mainloop.c:conn_close_if_marked() 108
problem function-size /src/core/mainloop/mainloop.c:run_connection_housekeeping() 123 problem function-size /src/core/mainloop/mainloop.c:run_connection_housekeeping() 123
problem function-size /src/core/mainloop/mainloop.c:CALLBACK() 116 problem function-size /src/core/mainloop/mainloop.c:CALLBACK() 116
problem file-size /src/core/or/channel.c 3476 problem file-size /src/core/or/channel.c 3487
problem function-size /src/core/or/channeltls.c:channel_tls_handle_var_cell() 160 problem function-size /src/core/or/channeltls.c:channel_tls_handle_var_cell() 160
problem function-size /src/core/or/channeltls.c:channel_tls_process_versions_cell() 170 problem function-size /src/core/or/channeltls.c:channel_tls_process_versions_cell() 170
problem function-size /src/core/or/channeltls.c:channel_tls_process_netinfo_cell() 214 problem function-size /src/core/or/channeltls.c:channel_tls_process_netinfo_cell() 214
@ -112,7 +112,7 @@ problem function-size /src/core/or/connection_edge.c:connection_ap_handshake_sen
problem function-size /src/core/or/connection_edge.c:connection_ap_handshake_socks_resolved() 106 problem function-size /src/core/or/connection_edge.c:connection_ap_handshake_socks_resolved() 106
problem function-size /src/core/or/connection_edge.c:connection_exit_begin_conn() 184 problem function-size /src/core/or/connection_edge.c:connection_exit_begin_conn() 184
problem function-size /src/core/or/connection_edge.c:connection_exit_connect() 102 problem function-size /src/core/or/connection_edge.c:connection_exit_connect() 102
problem file-size /src/core/or/connection_or.c 3121 problem file-size /src/core/or/connection_or.c 3124
problem include-count /src/core/or/connection_or.c 51 problem include-count /src/core/or/connection_or.c 51
problem function-size /src/core/or/connection_or.c:connection_or_group_set_badness_() 105 problem function-size /src/core/or/connection_or.c:connection_or_group_set_badness_() 105
problem function-size /src/core/or/connection_or.c:connection_or_client_learned_peer_id() 144 problem function-size /src/core/or/connection_or.c:connection_or_client_learned_peer_id() 144

View File

@ -1418,6 +1418,7 @@ write_packed_cell(channel_t *chan, packed_cell_t *cell)
{ {
int ret = -1; int ret = -1;
size_t cell_bytes; size_t cell_bytes;
uint8_t command = packed_cell_get_command(cell, chan->wide_circ_ids);
tor_assert(chan); tor_assert(chan);
tor_assert(cell); tor_assert(cell);
@ -1452,6 +1453,16 @@ write_packed_cell(channel_t *chan, packed_cell_t *cell)
/* Successfully sent the cell. */ /* Successfully sent the cell. */
ret = 0; 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: done:
return ret; return ret;
} }

View File

@ -1094,13 +1094,13 @@ channel_tls_handle_cell(cell_t *cell, or_connection_t *conn)
entry_guards_note_internet_connectivity(get_guard_selection_info()); entry_guards_note_internet_connectivity(get_guard_selection_info());
rep_hist_padding_count_read(PADDING_TYPE_TOTAL); 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); rep_hist_padding_count_read(PADDING_TYPE_ENABLED_TOTAL);
switch (cell->command) { switch (cell->command) {
case CELL_PADDING: case CELL_PADDING:
rep_hist_padding_count_read(PADDING_TYPE_CELL); 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); rep_hist_padding_count_read(PADDING_TYPE_ENABLED_CELL);
++stats_n_padding_cells_processed; ++stats_n_padding_cells_processed;
/* do nothing */ /* do nothing */

View File

@ -1020,6 +1020,7 @@ circpad_send_padding_cell_for_callback(circpad_machine_runtime_t *mi)
"Callback: Sending padding to non-origin circuit."); "Callback: Sending padding to non-origin circuit.");
relay_send_command_from_edge(0, mi->on_circ, RELAY_COMMAND_DROP, NULL, relay_send_command_from_edge(0, mi->on_circ, RELAY_COMMAND_DROP, NULL,
0, NULL); 0, NULL);
rep_hist_padding_count_write(PADDING_TYPE_DROP);
} else { } else {
static ratelim_t cell_lim = RATELIM_INIT(600); static ratelim_t cell_lim = RATELIM_INIT(600);
log_fn_ratelim(&cell_lim,LOG_NOTICE,LD_CIRC, 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, /* This is a padding cell sent from the client or from the middle node,
* (because it's invoked from circuitpadding.c) */ * (because it's invoked from circuitpadding.c) */
circpad_cell_event_padding_sent(circ); circpad_cell_event_padding_sent(circ);

View File

@ -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); 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); rep_hist_padding_count_write(PADDING_TYPE_TOTAL);
if (cell->command == CELL_PADDING) if (cell->command == CELL_PADDING)
rep_hist_padding_count_write(PADDING_TYPE_CELL); 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) { if (conn->chan) {
channel_timestamp_active(TLS_CHAN_TO_BASE(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); rep_hist_padding_count_write(PADDING_TYPE_ENABLED_TOTAL);
if (cell->command == CELL_PADDING) if (cell->command == CELL_PADDING)
rep_hist_padding_count_write(PADDING_TYPE_ENABLED_CELL); 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) if (conn->base_.state == OR_CONN_STATE_OR_HANDSHAKING_V3)
or_handshake_state_record_var_cell(conn, conn->handshake_state, cell, 0); 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 */ /* Touch the channel's active timestamp if there is one */
if (conn->chan) if (conn->chan)
channel_timestamp_active(TLS_CHAN_TO_BASE(conn->chan)); channel_timestamp_active(TLS_CHAN_TO_BASE(conn->chan));

View File

@ -2758,7 +2758,7 @@ set_streams_blocked_on_circ(circuit_t *circ, channel_t *chan,
} }
/** Extract the command from a packed cell. */ /** 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) packed_cell_get_command(const packed_cell_t *cell, int wide_circ_ids)
{ {
if (wide_circ_ids) { if (wide_circ_ids) {

View File

@ -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); 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); 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 #ifdef RELAY_PRIVATE
STATIC int connected_cell_parse(const relay_header_t *rh, const cell_t *cell, STATIC int connected_cell_parse(const relay_header_t *rh, const cell_t *cell,