Ticket #21425: b21425-p003.diff

File b21425-p003.diff, 4.4 KB (added by neel, 14 months ago)

Make entry_list_is_constrained() use guard_selection_t (Revision 3)

  • new file changes/ticket21425

    From d322bcb8cf35ad0fb4a92e39dde28c11b8ac2ddd Mon Sep 17 00:00:00 2001
    From: Neel Chauhan <neel@neelc.org>
    Date: Mon, 12 Feb 2018 20:35:56 -0500
    Subject: [PATCH] Remove the return value of node_get_prim_orport() and
     node_get_prim_dirport()
    
    ---
     changes/ticket21425 |  3 +++
     src/or/circuituse.c |  4 ++--
     src/or/directory.c  |  2 +-
     src/or/entrynodes.c | 19 ++++++++++---------
     src/or/entrynodes.h |  4 ++--
     5 files changed, 18 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..0d4475069 100644
    a b entry_guard_free_(entry_guard_t *e) 
    31243124  tor_free(e);
    31253125}
    31263126
     3127/** What is the minumum number of guards we can consider a client
     3128 * non-constrained, so we don't have to continue looking for
     3129 * additional guards? */
     3130#define MAX_CONSTRAINED_ENTRY_LIST_COUNT 50
     3131
    31273132/** Return 0 if we're fine adding arbitrary routers out of the
    31283133 * directory to our entry guard list, or return 1 if we have a
    31293134 * list already and we must stick to it.
    31303135 */
    31313136int
    3132 entry_list_is_constrained(const or_options_t *options)
     3137entry_list_is_constrained(guard_selection_t *gs)
    31333138{
    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;
     3139  return
     3140    (gs->sampled_entry_guards->capacity > MAX_CONSTRAINED_ENTRY_LIST_COUNT);
    31403141}
    31413142
    31423143/** Return the number of bridges that have descriptors that are marked with
    guards_choose_dirguard(uint8_t dir_purpose, 
    35613562 * usable.  Return 1 if we do; 0 if we don't.
    35623563 */
    35633564int
    3564 guards_retry_optimistic(const or_options_t *options)
     3565guards_retry_optimistic(void)
    35653566{
    3566   if (! entry_list_is_constrained(options))
     3567  if (!entry_list_is_constrained(get_guard_selection_info()))
    35673568    return 0;
    35683569
    35693570  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);