Opened 5 years ago

Closed 5 years ago

Last modified 4 years ago

#13223 closed defect (fixed)

Refactor rend_client_refetch_v2_renddesc()

Reported by: arma Owned by:
Priority: Medium Milestone: Tor: 0.2.6.x-final
Component: Core Tor/Tor Version:
Severity: Keywords: tor-hs
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor: SponsorR

Description

  /* Randomly iterate over the replicas until a descriptor can be fetched
   * from one of the consecutive nodes, or no options are left. */
  tries_left = REND_NUMBER_OF_NON_CONSECUTIVE_REPLICAS;
  for (i = 0; i < REND_NUMBER_OF_NON_CONSECUTIVE_REPLICAS; i++)
    replicas_left_to_try[i] = i;
  while (tries_left > 0) {
    int rand = crypto_rand_int(tries_left);
    int chosen_replica = replicas_left_to_try[rand];
    replicas_left_to_try[rand] = replicas_left_to_try[--tries_left];
    [...]

Wow.

I don't know if there are bugs in there or not. I'm not even sure what it's trying to do. And since REND_NUMBER_OF_NON_CONSECUTIVE_REPLICAS is just 2, this sure could get simpler.

It looks like it chooses one of two replicas to start, and then once it's picked those, it picks one of the three relays at that replica? Is that the same distribution as "pick one of the six hsdirs uniformly at random"?

Child Tickets

Change History (3)

comment:1 Changed 5 years ago by nickm

Milestone: Tor: 0.2.6.x-finalTor: 0.2.7.x-final

comment:2 Changed 5 years ago by nickm

Milestone: Tor: 0.2.7.x-finalTor: 0.2.6.x-final
Resolution: fixed
Status: newclosed

I hear this was done as part of #14847

comment:3 Changed 4 years ago by dgoulet

Keywords: SponsorR removed
Sponsor: SponsorR
Note: See TracTickets for help on using tickets.