Opened 6 years ago

Closed 6 years ago

#9926 closed defect (fixed)

Stop being willing to build 2-hop circuits when there aren't 3 relays

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

Description

new_route_len() ends with

  if (num_acceptable_routers < 2) {
    log_info(LD_CIRC,
             "Not enough acceptable routers (%d). Discarding this circuit.",
             num_acceptable_routers);
    return -1;
  }

  if (num_acceptable_routers < routelen) {
    log_info(LD_CIRC,"Not enough routers: cutting routelen from %d to %d.",
             routelen, num_acceptable_routers);
    routelen = num_acceptable_routers;
  }

We should replace this with the simpler

  if (num_acceptable_routers < 3) {
    log_info(LD_CIRC,
             "Not enough acceptable routers (%d). Discarding this circuit.",
             num_acceptable_routers);
    return -1;
  } 

to simplify things.

Note that the "oh hey let's just use two hops" case doesn't trigger in a real Tor network, because we won't be willing to make circuits if we don't have at least x% of the descriptors, so this code only comes into play when the consensus says there are 5 or something relays total.

Child Tickets

Change History (5)

comment:1 Changed 6 years ago by nickm

Keywords: tor-client easy added

Agreed, or just replace it with:

  if (num_acceptable_routers < 3 || num_acceptable_routers < routelen) {
    log_info(LD_CIRC,
             "Not enough acceptable routers (%d). Discarding this circuit.",
             num_acceptable_routers);
    return -1;
  }

In case we need to deal better with long paths in the future.

comment:2 Changed 6 years ago by arma

works for me

comment:3 Changed 6 years ago by nickm

Actually, routelen can't be less than 3 in that code, so I'm just going to have the check be "num_acceptable_routers < routelen".

Merged as c8c2298.

comment:4 Changed 6 years ago by arma

nickm: ok to close?

comment:5 Changed 6 years ago by nickm

Resolution: fixed
Status: newclosed

Indeed so.

Note: See TracTickets for help on using tickets.