[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [tor-bugs] #21642 [Core Tor/Tor]: Prop275: Eliminate "published" times from microdescriptor consensus



#21642: Prop275: Eliminate "published" times from microdescriptor consensus
------------------------------------------------+--------------------------
 Reporter:  nickm                               |          Owner:  nickm
     Type:  enhancement                         |         Status:
                                                |  merge_ready
 Priority:  Medium                              |      Milestone:  Tor:
                                                |  0.3.1.x-final
Component:  Core Tor/Tor                        |        Version:
 Severity:  Normal                              |     Resolution:
 Keywords:  TorCoreTeam201703, review-group-17  |  Actual Points:  .5
Parent ID:                                      |         Points:  2
 Reviewer:                                      |        Sponsor:  Sponsor4
------------------------------------------------+--------------------------

Comment (by arma):

 Replying to [comment:16 arma]:
 > So I have resumed thinking that if we set published_on to always 2037,
 we will be disabling this hack. :(

 If we want to re-enable the hack (assuming that when we do the
 published_on change, we do it only in the microdescriptor consensus, and
 not in the vanilla consensus), here is code that would do that:

 {{{
 diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c
 index 2d39c90..3fde2a2 100644
 --- a/src/or/networkstatus.c
 +++ b/src/or/networkstatus.c
 @@ -811,6 +811,35 @@ we_want_to_fetch_flavor(const or_options_t *options,
 int f
 lavor)
    return flavor == usable_consensus_flavor();
  }

 +/** Helper function: return 1 if consensus <b>c</b> is non-null and from
 + * within the time bounds of [valid_after, valid_until]. Else return 0.
 */
 +static int
 +consensus_is_valid(networkstatus_t *c, time_t now)
 +{
 +  if (c && c->valid_after <= now && now <= c->valid_until)
 +    return 1;
 +  return 0;
 +}
 +
 +/** Return a valid consensus with the preferred flavor <b>flavor</b> if
 + * possible, else return any valid consensus if possible. */
 +networkstatus_t *
 +networkstatus_find_consensus_with_preferred_flavor(int flavor, time_t
 now)
 +{
 +  networkstatus_t *c;
 +
 +  /* One: If we fetch the preferred flavor type, great, use it. Else,
 switch
 +   * to one that we do fetch. */
 +  if (!we_want_to_fetch_flavor(get_options(), flavor))
 +    flavor = usable_consensus_flavor();
 +
 +  /* Two: See if we've got it, and if it's valid. */
 +  c = networkstatus_get_latest_consensus_by_flavor(flavor);
 +  if (!consensus_is_valid(c, now))
 +    return NULL;
 +  return c;
 +}
 +
  /** How long will we hang onto a possibly live consensus for which we're
   * fetching certs before we check whether there is a better one? */
  #define DELAY_WHILE_FETCHING_CERTS (20*60)
 diff --git a/src/or/networkstatus.h b/src/or/networkstatus.h
 index 71f36b6..c980da3 100644
 --- a/src/or/networkstatus.h
 +++ b/src/or/networkstatus.h
 @@ -66,6 +66,8 @@ const routerstatus_t
 *router_get_consensus_status_by_nickname(
                                     int warn_if_unnamed);
  const char *networkstatus_get_router_digest_by_nickname(const char
 *nickname);
  int networkstatus_nickname_is_unnamed(const char *nickname);
 +networkstatus_t *networkstatus_find_consensus_with_preferred_flavor(
 +                                   int flavor, time_t now);
  void networkstatus_consensus_download_failed(int status_code,
                                               const char *flavname);
  void update_consensus_networkstatus_fetch_time(time_t now);
 diff --git a/src/or/router.c b/src/or/router.c
 index 6d3a32a..e9378d8 100644
 --- a/src/or/router.c
 +++ b/src/or/router.c
 @@ -2391,11 +2391,17 @@ mark_my_descriptor_dirty_if_too_old(time_t now)
      mark_my_descriptor_dirty("time for new descriptor");
      return;
    }
 +
 +  /* Find a live consensus, so we can use it below to check if our entry
 +   * is up-to-date. We prefer the vanilla consensus flavor, because at
 some
 +   * point in the future we might stop listing useful published_on
 entries
 +   * in the microdescriptor consensus. */
 +  ns = networkstatus_find_consensus_with_preferred_flavor(FLAV_NS, now);
 +
    /* Now we see whether we want to be retrying frequently or no.  The
     * rule here is that we'll retry frequently if we aren't listed in the
     * live consensus we have, or if the publication time of the
     * descriptor listed for us in the consensus is very old. */
 -  ns = networkstatus_get_live_consensus(now);
    if (ns) {
      rs = networkstatus_vote_find_entry(ns, server_identitykey_digest);
      if (rs == NULL)
 }}}

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/21642#comment:17>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
_______________________________________________
tor-bugs mailing list
tor-bugs@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs