[tor-bugs] #18873 [Core Tor/Tor]: Refactor circuit_predict_and_launch_new()

Tor Bug Tracker & Wiki blackhole at torproject.org
Sat Oct 29 21:34:42 UTC 2016


#18873: Refactor circuit_predict_and_launch_new()
--------------------------+------------------------------------
 Reporter:  asn           |          Owner:
     Type:  defect        |         Status:  needs_review
 Priority:  Low           |      Milestone:  Tor: 0.3.0.x-final
Component:  Core Tor/Tor  |        Version:
 Severity:  Normal        |     Resolution:
 Keywords:  refactoring   |  Actual Points:
Parent ID:                |         Points:
 Reviewer:  dgoulet       |        Sponsor:
--------------------------+------------------------------------

Comment (by chelseakomlo):

 Ok, so here are the updates from teor's review. I couldn't think of how to
 extract add_flags in a clean way, so I kept this as it was before the
 refactor. I also added the recommended defines.

 See branch `circuituse`, `git at github.com:chelseakomlo/tor_patches.git`

 I added a separate commit for the refactor to remove the check for
 CIRCUIT_IS_ORIGIN in circuit_is_available_for_use. The refactor is because
 we first check the purpose of the circuit to see if it is an origin
 circuit, but then we later reject all cicuits that do not have the purpose
 CIRCUIT_PURPOSE_C_GENERAL.

 We shouldn't need to use the BUG macro because
 circuit_is_available_for_use should be able to accept both origin and non-
 origin circuits, and silently return if the circuit's purpose is not
 CIRCUIT_PURPOSE_C_GENERAL (which I believe also entails that it is an
 origin circuit).

 `#define CIRCUIT_PURPOSE_IS_ORIGIN(p) ((p)>CIRCUIT_PURPOSE_OR_MAX_)`
 `#define CIRCUIT_PURPOSE_OR_MAX_ 4`
 `#define CIRCUIT_PURPOSE_C_GENERAL 5`

 If this is the case, we shouldn't be able to crash in TO_ORIGIN_CIRCUIT()
 as all circuits that reach this point will have the purpose
 CIRCUIT_PURPOSE_C_GENERAL and therefore (I think) are origin circuits.

 Let me know what you think!

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/18873#comment:8>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list