summaryrefslogtreecommitdiff
path: root/crates/tor-circmgr/src/mgr.rs
Commit message (Collapse)AuthorAgeFilesLines
* circmgr: limit circuit attempts when launch_parallelism > 1.Nick Mathewson2022-03-301-1/+21
| | | | | | | | | | | Previously, if we had launch_parallelism > 1, and we were willing to retry building a circuit max_retries times, then we'd launch up to max_retries * launch_parallelism circuits before giving up. Ouch! With this patch, we try to keep the total number of circuits planned and attempted to the actual max_retries limit. Part of #329; found with arti-testing.
* Turn FallbackList into a real type, and store one in GuardMgr.Nick Mathewson2022-03-301-2/+4
| | | | | | | | | | | | | | The guard manager is responsible for handing out the first hops of tor circuits, keeping track of their successes and failures, and remembering their states. Given that, it makes sense to store this information here. It is not yet used; I'll be fixing that in upcoming commits. Arguably, this information no longer belongs in the directory manager: I've added a todo about moving it. This commit will break compilation on its own in a couple of places; subsequent commits will fix it up.
* Move fallback.rs into guardmgr.Nick Mathewson2022-03-301-1/+1
| | | | | | | This is the logical place for it, I think: the GuardMgr's job is to pick the first hop for a circuit depending on remembered status for possible first hops. Making this change will let us streamline the code that interacts with these objects.
* move isolation in separate moduletrinity-1686a2022-03-241-1/+1
|
* rename *_isolation_group to *_isolationtrinity-1686a2022-03-241-6/+6
|
* circmgr: When planning, only keep one error; log them all.Nick Mathewson2022-03-211-3/+6
|
* circmgr: Change API for using FallbackDirsNick Mathewson2022-03-211-1/+1
| | | | | | It'll soon more convenient to pass in FallbackDirs as a slice of references, rather than just a slice of FallbackDirs: I'm going to be changing how we handle these in tor-dirmgr.
* circmgr: use AllGuardsDown to retry betterNick Mathewson2022-03-211-7/+35
| | | | | | | | | | | | | If all guards are down and they won't be retriable for a while, try waiting that long to get whichever guard _is_ retriable. Additionally, if we are making multiple circuit plans in parallel, only report our planning as having failed if we failed at making _all_ the plans. Previously we treated any failure as fatal for the other plans, which could lead to trouble in the case when guards were all down or pending. Part of #407.
* add trait to help test isolation related codetrinity-1686a2022-03-161-9/+26
|
* Replace manual Debug impl with std derive in tor-circmgrIan Jackson2022-03-021-10/+3
| | | | | | | | | | | | | | | | | When I wrote this, I arranged to skip dumping the field `pending`. This must have been because I thought that either (a) PendingEntry couldn't `#[derive(Debug)]` (but it can) and/or (b) Some of the fields of PendingEntry ought not to be dumped because they might contain (eg) packet data. But I think they don't: there's just the spec, and the Result which is (basically) a Circ. I tried preseving something closer to the original using educe, but educe gets somehow tangled up with the generics, and the result fails to compile. I haven't investigated this further.
* resolve commenttrinity-1686a2022-02-281-1/+6
|
* add some error to retry_error instead of dropping ittrinity-1686a2022-02-281-45/+45
|
* Merge branch 'teardown' into 'main'Nick Mathewson2022-02-281-1/+12
|\ | | | | | | | | | | | | tor-circmgr: take_action: Handle Cancelled from the oneshot Closes #365 See merge request tpo/core/arti!363
| * Add a debug! log message for source cancellationIan Jackson2022-02-281-0/+4
| |
| * Fix rustfmtIan Jackson2022-02-281-1/+1
| |
| * tor-circmgr: take_action: Handle Cancelled from the oneshotIan Jackson2022-02-251-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes #365 Inspection of the code and logs shows that: * One of the plan futures' oneshots must be returning Cancelled * This means that the corresponding sender must have been dropped * The sender is owned by the task spawned by spawn_launch Presumably that entire task gets dropped as part of executor shutdown, or something. The correct response in this situation is to declare that we are shutting down, and stop trying to do stuff. Unfortunately, despite trying quite hard by putting sleeps in various strategic places, I have not been able to reproduce the problem. So I can't be 100% sure that the new behaviour is correct. But I am reasonably confident that this ought not to be able to occur unless either 1. the task from spawn_launch is dropped, or 2. that task somehow panics despite its attempts to trap panics and report them as errors through the oneshot. So this "burn it all down" action ought only to occur in actually serious situations. I observe that 3ff9b187ea26aaec4875067fcdbf485ecc9f597d Handle panics from circuit construction. changed the EK for PendingCanceled to EK::ReactorShuttingDown, and there's From impl. I think, therefore, that it is right to reuse this Error variant. I don't quite understand why when take_action gets an actual error it doesn't push it, but just logs it. But I am not changing that for now. Arguably the two instances of retry_error.push are a sign of an inferior flow control pattern - maybe the loop body including the code I am adding ought to be an IEFE returning `Result<Option<circ>, crate::Error>`.
* | Merge branch 'fix/210' into 'main'Nick Mathewson2022-02-281-1/+1
|\ \ | | | | | | | | | | | | | | | | | | don't return already errored pending circuit when searching new circuit matching spec Closes #210 See merge request tpo/core/arti!366
| * | don't return already errored pending circuit when searching new circuit ↵trinity-1686a2022-02-271-1/+1
| |/ | | | | | | matching spec
* | Fix two typosNick Mathewson2022-02-281-1/+1
| |
* | impl Debug for various internal typesIan Jackson2022-02-251-3/+12
|/ | | | | | | | I wanted this while debugging something. The ad-hoc impl Debug with f.debug_struct is getting repetitive and I've already perpetrated one copy-paste mistake. We should consider using something like the `educe` crate's Clone.
* Handle panics from circuit construction.Nick Mathewson2022-02-181-1/+12
| | | | | | | | | | | | We handle them by reporting them to task that's waiting for the circuit, then relaying the panic. Doing so allows the waiting task to distinguish panics (EK::Internal) from cases where the reactor dropped the task entirely (EK::ReactorShuttingDown). And doing _that_ removes one case of EK::Canceled, which helps us on our goals towards #348. Closes #347.
* Move the main body of our circuit-launching task into a new functionNick Mathewson2022-02-181-47/+55
| | | | This reduces our nesting, and will help us handle panics.
* Merge branch 'remaining-errors'Nick Mathewson2022-02-171-6/+7
|\
| * Clarify and rename PendingCanceledNick Mathewson2022-02-161-2/+2
| | | | | | | | | | | | | | | | From its old name, this error had implied that we were giving no useful information when we were waiting on a pending cirucit request that failed. In fact, this error would only happen if we dropped the `mpsc::Sender` for a circuit attempt without reporting success or failure.
| * Add kinds for *most* circmgr errors.Nick Mathewson2022-02-161-4/+5
| | | | | | | | There are a couple of tricky ones I'll do separately.
* | Add a comment about "&mut [&mut ]"Ian Jackson2022-02-171-0/+1
| |
* | Re-enable clippy::ptr_arg where it had been disabled.Nick Mathewson2022-02-161-2/+2
|/ | | | | | | | | | In one of the two places, nightly no longer warns. In the other place, it's fine for nightly to warn: I just fixed the code to take a slice instead. Partial revert of 856aca879151c622512bc4b15c6307808fc83e82. Resolves part of #310.
* tor-circmgr: Turn a type annotation comment into codeIan Jackson2022-02-041-2/+1
| | | | | | | | The type annotation may not be necessary for inference, but as a comment it risks becoming false. So it should be uncommented, or deleted. Error types round here are not entirely trivial so uncomment it.
* Merge branch 'typos' into 'main'eta2022-02-031-1/+1
|\ | | | | | | | | Fix typos See merge request tpo/core/arti!285
| * Fix typosDimitris Apostolou2022-02-021-1/+1
| |
* | Temporarily disable some clippy lints on nightlyIan Jackson2022-02-021-1/+1
|/
* circmgr: Fix a pair of clippy warnings.Nick Mathewson2022-01-071-2/+2
|
* tor-circmgr: Remove Arc around ClientCircIan Jackson2022-01-071-11/+11
| | | | | | See the new commentary text on `ClientCirc` for the rationale. Signed-off-by: Ian Jackson <[email protected]>
* tor-circmgr: tests: Do fake circuit equality by idIan Jackson2022-01-071-2/+2
| | | | | | | | | We are going to get rid of the Arc. Happily there is an id which is always constructed uniquely and preserved by clone. (auto-deref lets us make the function take &Self instead of &Arc) Signed-off-by: Ian Jackson <[email protected]>
* tor-circmgr: tests: Introduce and use FakeCirc::eq()Ian Jackson2022-01-071-13/+19
| | | | | | This removes a lot of open-coded Arc::ptr_eq() calls Signed-off-by: Ian Jackson <[email protected]>
* tor-circmgr: Replace some Arc::clone with .clone()Ian Jackson2022-01-071-5/+5
| | | | | | This will make the code work when it's not an Arc any more. Signed-off-by: Ian Jackson <[email protected]>
* tor-circmgr: Require that AbstractCirc are CloneIan Jackson2022-01-071-1/+1
| | | | | | | We are going to get rid of a lot of Arc, so we need the underlying thing to be Clone. Signed-off-by: Ian Jackson <[email protected]>
* Remove XXXs from tor-circmgr::mgrNick Mathewson2021-12-201-4/+0
| | | | | | IIUC, these anticipatd a need to store min_exit_circs_per_port in CircMgr. But the current design, where it goes into preemptive.rs and thence to usage, seems to work fine.
* Do not treat spawn failure as a fatal error.Nick Mathewson2021-12-151-12/+12
|
* Expand some comments about circuit expiration.Nick Mathewson2021-12-151-4/+9
| | | | | Emphasize that circuit expiration functions _decide whether to expire the circuit_, and don't expire it automatically.
* Add spawn_expiration_task function in circuit managerYuan Lyu2021-12-151-23/+103
|
* Make circuit_timing reconfigurable.Nick Mathewson2021-12-071-12/+18
|
* Allow on-the-fly changing of path_rulesNick Mathewson2021-12-071-7/+33
| | | | | | | | | | | | And now the complexity begins: when the user changes the path_rules, they not only want new circuits to obey those rules: they want _all new requests_ to be put onto circuits that obey those rules. That means that when the path rules become more restrictive, we need to retire all the circuits, and make sure that currently pending circuits aren't used for any requests. If it's any comfort, doing this was even more complicated in C tor. ;)
* Sketch API for reconfiguration.Nick Mathewson2021-12-071-0/+7
| | | | | | | This patch doesn't actually make anything reconfigurable, but it does create an API that will tell you "you can't change the value of that!" If the API looks reasonable, I can start making it possible to change the values of individual items.
* Allow configurability on preemptive circuitsNeel Chauhan2021-12-071-3/+11
|
* Merge remote-tracking branch 'origin/mr/154'Nick Mathewson2021-11-301-24/+195
|\
| * Add tests & address review commentaryeta2021-11-301-7/+155
| |
| * Introduce PreemptiveCircuitPredictor and TargetCircUsage::Preemptiveeta2021-11-231-23/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In preparation for making Arti build circuits preemptively, this commit introduces `TargetCircUsage::Preemptive`, a circuit usage that works somewhat differently from other ones: it requires at least 2 circuits to exist that can exit the port it contains in order for an existing circuit to match against it (path-spec.txt § 2.1.1); if that's not the case, that usage will require building new circuits (in order that we build enough to have 2 available). This required refactoring how circuit reuse worked; now, `CircList::find_open` uses the new `AbstractSpec::find_supported` trait method, which we customize to implement the above check in the case of `Preemptive` circuit usages. To make that work, `OpenEntry` now takes two type parameters (the spec and circuit types), instead of taking a builder type parameter and using its associated types. (We also got rid of type constraints on that struct, yay!) A WIP implementation of a preemptive circuit predictor that implements path-spec.txt § 2.1.1 is also included, but this will require additional effort to wire it up with the `CircMgr` properly.
* | Merge remote-tracking branch 'origin/mr/148'Nick Mathewson2021-11-291-10/+2
|\ \
| * | In struct PendingEntry, remove circ_specNeel Chauhan2021-11-281-10/+2
| |/