[tor-commits] [tor/master] Merge remote-tracking branch 'public/ticket6799_024_v2_squashed'

nickm at torproject.org nickm at torproject.org
Wed Jun 11 16:01:22 UTC 2014


commit 3a2e25969fbb7bf38fcfafce676e7f56a1aca118
Merge: 7f35630 bbb8f12
Author: Nick Mathewson <nickm at torproject.org>
Date:   Wed Jun 11 11:57:56 2014 -0400

    Merge remote-tracking branch 'public/ticket6799_024_v2_squashed'
    
    Conflicts:
    	src/or/channel.c
    	src/or/circuitlist.c
    	src/or/connection.c
    
    Conflicts involved removal of next_circ_id and addition of
    unusable-circid tracking.

 changes/bug6799        |   20 ++++++++++++++++++++
 src/or/channel.c       |   11 +++++------
 src/or/channel.h       |    6 ++++--
 src/or/channeltls.c    |    2 +-
 src/or/circuitlist.c   |   10 ++++++++--
 src/or/connection.c    |    4 +---
 src/or/connection_or.c |   46 ++++++++++++++++++++++++++++++++++++++++------
 src/or/connection_or.h |    2 ++
 src/or/main.c          |   38 ++++++++++++++++++++++----------------
 src/or/or.h            |    7 ++++---
 10 files changed, 107 insertions(+), 39 deletions(-)

diff --cc src/or/channel.c
index 63af2f9,ce2d012..1cc7864
--- a/src/or/channel.c
+++ b/src/or/channel.c
@@@ -726,10 -731,10 +728,10 @@@ channel_init(channel_t *chan
    chan->global_identifier = n_channels_allocated++;
  
    /* Init timestamp */
-   chan->timestamp_last_added_nonpadding = time(NULL);
+   chan->timestamp_last_had_circuits = time(NULL);
  
 -  /* Init next_circ_id */
 -  chan->next_circ_id = crypto_rand_int(1 << 15);
 +  /* Warn about exhausted circuit IDs no more than hourly. */
 +  chan->last_warned_circ_ids_exhausted.rate = 3600;
  
    /* Initialize queues. */
    TOR_SIMPLEQ_INIT(&chan->incoming_queue);
@@@ -1681,18 -1687,6 +1685,13 @@@ channel_write_cell_queue_entry(channel_
               chan->state == CHANNEL_STATE_OPEN ||
               chan->state == CHANNEL_STATE_MAINT);
  
-   /* Increment the timestamp unless it's padding */
-   if (!cell_queue_entry_is_padding(q)) {
-     chan->timestamp_last_added_nonpadding = approx_time();
-   }
- 
 +  {
 +    circid_t circ_id;
 +    if (is_destroy_cell(chan, q, &circ_id)) {
 +      channel_note_destroy_not_pending(chan, circ_id);
 +    }
 +  }
 +
    /* Can we send it right out?  If so, try */
    if (TOR_SIMPLEQ_EMPTY(&chan->outgoing_queue) &&
        chan->state == CHANNEL_STATE_OPEN) {
diff --cc src/or/circuitlist.c
index 6238e08,3cb429b..0140afc
--- a/src/or/circuitlist.c
+++ b/src/or/circuitlist.c
@@@ -319,23 -211,17 +319,26 @@@ channel_note_destroy_not_pending(channe
   * with the corresponding circuit ID, and add the circuit as appropriate
   * to the (chan,id)-\>circuit map. */
  void
 -circuit_set_p_circid_chan(or_circuit_t *circ, circid_t id,
 +circuit_set_p_circid_chan(or_circuit_t *or_circ, circid_t id,
                            channel_t *chan)
  {
 -  circuit_set_circid_chan_helper(TO_CIRCUIT(circ), CELL_DIRECTION_IN,
 -                                 id, chan);
 +  circuit_t *circ = TO_CIRCUIT(or_circ);
 +  channel_t *old_chan = or_circ->p_chan;
 +  circid_t old_id = or_circ->p_circ_id;
 +
 +  circuit_set_circid_chan_helper(circ, CELL_DIRECTION_IN, id, chan);
  
-   if (chan)
+   if (chan) {
 -    tor_assert(bool_eq(circ->p_chan_cells.n, circ->next_active_on_p_chan));
 +    tor_assert(bool_eq(or_circ->p_chan_cells.n,
 +                       or_circ->next_active_on_p_chan));
  
+     chan->timestamp_last_had_circuits = approx_time();
+   }
++
 +  if (circ->p_delete_pending && old_chan) {
 +    channel_mark_circid_unusable(old_chan, old_id);
 +    circ->p_delete_pending = 0;
 +  }
  }
  
  /** Set the n_conn field of a circuit <b>circ</b>, along
@@@ -345,18 -231,13 +348,21 @@@ voi
  circuit_set_n_circid_chan(circuit_t *circ, circid_t id,
                            channel_t *chan)
  {
 +  channel_t *old_chan = circ->n_chan;
 +  circid_t old_id = circ->n_circ_id;
 +
    circuit_set_circid_chan_helper(circ, CELL_DIRECTION_OUT, id, chan);
  
-   if (chan)
+   if (chan) {
      tor_assert(bool_eq(circ->n_chan_cells.n, circ->next_active_on_n_chan));
  
+     chan->timestamp_last_had_circuits = approx_time();
+   }
++
 +  if (circ->n_delete_pending && old_chan) {
 +    channel_mark_circid_unusable(old_chan, old_id);
 +    circ->n_delete_pending = 0;
 +  }
  }
  
  /** Change the state of <b>circ</b> to <b>state</b>, adding it to or removing
diff --cc src/or/connection.c
index cef9172,d99a54c..0b03092
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@@ -269,8 -249,8 +269,6 @@@ dir_connection_new(int socket_family
  /** Allocate and return a new or_connection_t, initialized as by
   * connection_init().
   *
-  * Set timestamp_last_added_nonpadding to now.
-  *
 - * Assign a pseudorandom next_circ_id between 0 and 2**15.
 - *
   * Initialize active_circuit_pqueue.
   *
   * Set active_circuit_pqueue_last_recalibrated to current cell_ewma tick.
@@@ -280,14 -260,10 +278,14 @@@ or_connection_new(int type, int socket_
  {
    or_connection_t *or_conn = tor_malloc_zero(sizeof(or_connection_t));
    time_t now = time(NULL);
 -  connection_init(now, TO_CONN(or_conn), CONN_TYPE_OR, socket_family);
 +  tor_assert(type == CONN_TYPE_OR || type == CONN_TYPE_EXT_OR);
 +  connection_init(now, TO_CONN(or_conn), type, socket_family);
  
-   or_conn->timestamp_last_added_nonpadding = time(NULL);
+   connection_or_set_canonical(or_conn, 0);
  
 +  if (type == CONN_TYPE_EXT_OR)
 +    connection_or_set_ext_or_identifier(or_conn);
 +
    return or_conn;
  }
  
diff --cc src/or/connection_or.h
index 8d93028,896556c..143540e
--- a/src/or/connection_or.h
+++ b/src/or/connection_or.h
@@@ -45,9 -45,10 +45,11 @@@ void connection_or_close_for_error(or_c
  
  void connection_or_report_broken_states(int severity, int domain);
  
 -int connection_tls_start_handshake(or_connection_t *conn, int receiving);
 +MOCK_DECL(int,connection_tls_start_handshake,(or_connection_t *conn,
 +                                              int receiving));
  int connection_tls_continue_handshake(or_connection_t *conn);
+ void connection_or_set_canonical(or_connection_t *or_conn,
+                                  int is_canonical);
  
  int connection_init_or_handshake_state(or_connection_t *conn,
                                         int started_here);
diff --cc src/or/or.h
index 6aa6b59,3ed9f9f..f1d68b7
--- a/src/or/or.h
+++ b/src/or/or.h
@@@ -1482,13 -1422,12 +1482,16 @@@ typedef struct or_connection_t 
    unsigned int is_outgoing:1;
    unsigned int proxy_type:2; /**< One of PROXY_NONE...PROXY_SOCKS5 */
    unsigned int wide_circ_ids:1;
 +  /** True iff this connection has had its bootstrap failure logged with
 +   * control_event_bootstrap_problem. */
 +  unsigned int have_noted_bootstrap_problem:1;
 +
    uint16_t link_proto; /**< What protocol version are we using? 0 for
                          * "none negotiated yet." */
- 
+   uint16_t idle_timeout; /**< How long can this connection sit with no
+                           * circuits on it before we close it? Based on
+                           * IDLE_CIRCUIT_TIMEOUT_{NON,}CANONICAL and
+                           * on is_canonical, randomized. */
    or_handshake_state_t *handshake_state; /**< If we are setting this connection
                                            * up, state information to do so. */
  





More information about the tor-commits mailing list