Ticket #21425: b21425-p002.diff

File b21425-p002.diff, 4.0 KB (added by neel, 13 months ago)

Make entry_list_is_constrained() use guard_selection_t (Revision 2)

  • new file changes/ticket21425

    From 1e9b55a07b4ffbbb733032fd06f83b235b3431a4 Mon Sep 17 00:00:00 2001
    From: Neel Chauhan <neel@neelc.org>
    Date: Mon, 12 Feb 2018 16:26:45 -0500
    Subject: [PATCH] Make entry_list_is_constrained() look at the
     guard_selection_t
    
    ---
     changes/ticket21425 |  3 +++
     src/or/circuituse.c |  4 ++--
     src/or/directory.c  |  2 +-
     src/or/entrynodes.c | 13 ++++---------
     src/or/entrynodes.h |  4 ++--
     5 files changed, 12 insertions(+), 14 deletions(-)
     create mode 100644 changes/ticket21425
    
    diff --git a/changes/ticket21425 b/changes/ticket21425
    new file mode 100644
    index 000000000..296a0a494
    - +  
     1  o Code simplification and refactoring:
     2    - Make entry_list_is_constrained() look at the guard sample size from
     3      guard_selection_t. Closes ticket 21425. Patch by Neel Chauhan.
  • src/or/circuituse.c

    diff --git a/src/or/circuituse.c b/src/or/circuituse.c
    index 1ac950a3c..ba5f2b025 100644
    a b circuit_get_open_circ_or_launch(entry_connection_t *conn, 
    22422242      int severity = LOG_NOTICE;
    22432243      /* Retry some stuff that might help the connection work. */
    22442244      /* If we are configured with EntryNodes or UseBridges */
    2245       if (entry_list_is_constrained(options)) {
     2245      if (entry_list_is_constrained(get_guard_selection_info())) {
    22462246        /* Retry all our guards / bridges.
    22472247         * guards_retry_optimistic() always returns true here. */
    2248         int rv = guards_retry_optimistic(options);
     2248        int rv = guards_retry_optimistic();
    22492249        tor_assert_nonfatal_once(rv);
    22502250        log_fn(severity, LD_APP|LD_DIR,
    22512251               "Application request when we haven't %s. "
  • src/or/directory.c

    diff --git a/src/or/directory.c b/src/or/directory.c
    index 983a3e2f3..88f4a915c 100644
    a b connection_dir_request_failed(dir_connection_t *conn) 
    863863  if (directory_conn_is_self_reachability_test(conn)) {
    864864    return; /* this was a test fetch. don't retry. */
    865865  }
    866   if (!entry_list_is_constrained(get_options()))
     866  if (!entry_list_is_constrained(get_guard_selection_info()))
    867867    router_set_status(conn->identity_digest, 0); /* don't try this one again */
    868868  if (conn->base_.purpose == DIR_PURPOSE_FETCH_SERVERDESC ||
    869869             conn->base_.purpose == DIR_PURPOSE_FETCH_EXTRAINFO) {
  • src/or/entrynodes.c

    diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c
    index 2b6ff38c9..37e4bde25 100644
    a b entry_guard_free_(entry_guard_t *e) 
    31293129 * list already and we must stick to it.
    31303130 */
    31313131int
    3132 entry_list_is_constrained(const or_options_t *options)
     3132entry_list_is_constrained(guard_selection_t *gs)
    31333133{
    3134   // XXXX #21425 look at the current selection.
    3135   if (options->EntryNodes)
    3136     return 1;
    3137   if (options->UseBridges)
    3138     return 1;
    3139   return 0;
     3134  return (gs->sampled_entry_guards->capacity > 50) ? 1 : 0;
    31403135}
    31413136
    31423137/** Return the number of bridges that have descriptors that are marked with
    guards_choose_dirguard(uint8_t dir_purpose, 
    35613556 * usable.  Return 1 if we do; 0 if we don't.
    35623557 */
    35633558int
    3564 guards_retry_optimistic(const or_options_t *options)
     3559guards_retry_optimistic(void)
    35653560{
    3566   if (! entry_list_is_constrained(options))
     3561  if (!entry_list_is_constrained(get_guard_selection_info()))
    35673562    return 0;
    35683563
    35693564  mark_primary_guards_maybe_reachable(get_guard_selection_info());
  • src/or/entrynodes.h

    diff --git a/src/or/entrynodes.h b/src/or/entrynodes.h
    index d56249831..07723857f 100644
    a b struct bridge_info_t; 
    593593void entry_guard_learned_bridge_identity(const tor_addr_port_t *addrport,
    594594                                         const uint8_t *rsa_id_digest);
    595595
    596 int entry_list_is_constrained(const or_options_t *options);
    597 int guards_retry_optimistic(const or_options_t *options);
     596int entry_list_is_constrained(guard_selection_t *gs);
     597int guards_retry_optimistic(void);
    598598int entry_guards_parse_state_for_guard_selection(
    599599    guard_selection_t *gs, or_state_t *state, int set, char **msg);
    600600int entry_guards_parse_state(or_state_t *state, int set, char **msg);