Generate non-padding circpad events for PADDING_NEGOTIATE(D).

As part of our machines, we need to know when a PADDING_NEGOATIATE(D) cell gets
sent out, so we add an event for this.
This commit is contained in:
George Kadianakis 2019-04-12 23:42:46 +03:00
parent 39c52d14a6
commit 5791bc9d76

View File

@ -1737,13 +1737,12 @@ circpad_estimate_circ_rtt_on_send(circuit_t *circ,
* to back. Stop estimating RTT in this case. Note that we only
* stop RTT update if the circuit is opened, to allow for RTT estimates
* of var cells during circ setup. */
mi->stop_rtt_update = 1;
if (!mi->rtt_estimate_usec) {
if (!mi->rtt_estimate_usec && !mi->stop_rtt_update) {
static ratelim_t rtt_lim = RATELIM_INIT(600);
log_fn_ratelim(&rtt_lim,LOG_NOTICE,LD_BUG,
"Circuit sent two cells back to back before estimating RTT.");
}
mi->stop_rtt_update = 1;
}
}
@ -2256,13 +2255,6 @@ circpad_deliver_recognized_relay_cell_events(circuit_t *circ,
uint8_t relay_command,
crypt_path_t *layer_hint)
{
/* Padding negotiate cells are ignored by the state machines
* for simplicity. */
if (relay_command == RELAY_COMMAND_PADDING_NEGOTIATE ||
relay_command == RELAY_COMMAND_PADDING_NEGOTIATED) {
return;
}
if (relay_command == RELAY_COMMAND_DROP) {
rep_hist_padding_count_read(PADDING_TYPE_DROP);
@ -2299,16 +2291,12 @@ void
circpad_deliver_sent_relay_cell_events(circuit_t *circ,
uint8_t relay_command)
{
/* Padding negotiate cells are ignored by the state machines
* for simplicity. */
if (relay_command == RELAY_COMMAND_PADDING_NEGOTIATE ||
relay_command == RELAY_COMMAND_PADDING_NEGOTIATED) {
return;
}
/* RELAY_COMMAND_DROP is the multi-hop (aka circuit-level) padding cell in
* tor. (CELL_PADDING is a channel-level padding cell, which is not relayed
* or processed here) */
* or processed here).
*
* We do generate events for PADDING_NEGOTIATE and PADDING_NEGOTIATED cells.
*/
if (relay_command == RELAY_COMMAND_DROP) {
/* Optimization: The event for RELAY_COMMAND_DROP is sent directly
* from circpad_send_padding_cell_for_callback(). This is to avoid
@ -2823,6 +2811,7 @@ circpad_handle_padding_negotiate(circuit_t *circ, cell_t *cell)
const circpad_machine_spec_t *, m) {
if (m->machine_num == negotiate->machine_type) {
circpad_setup_machine_on_circ(circ, m);
circpad_cell_event_nonpadding_received(circ);
goto done;
}
} SMARTLIST_FOREACH_END(m);