summaryrefslogtreecommitdiff
path: root/crates/tor-circmgr/src/mgr.rs
Commit message (Collapse)AuthorAgeFilesLines
* Use ErrorReport - run rustfmtIan Jackson2023-01-301-2/+3
| | | | Split off for ease of review and possible rebase.
* Use ErrorReport for errors in warn! in tor-circmgrIan Jackson2023-01-301-1/+1
|
* Use ErrorReport for errors in info! in tor-circmgrIan Jackson2023-01-301-6/+6
|
* Allow clippy::unchecked_duration_subtraction in testsNick Mathewson2023-01-271-0/+1
| | | | | This panics on error, and we're fine with a panic on misbehavior in tests.
* test lint blocks: Add many many automaticallyIan Jackson2022-12-121-0/+8
| | | | | This is precisely the result of running the rune in maint/adhoc-add-lint-blocks.
* Even more comments explaining circuit cancellation.Nick Mathewson2022-11-221-3/+37
|
* Improve notes surrounding circuit cancellation.Nick Mathewson2022-11-221-5/+18
| | | | | | | It turns out that bug #656 is not a real bug, but it was easy to overlook the code that prevented it. Closes #656.
* Merge branch 'channel' into 'main'Ian Jackson2022-08-171-0/+7
|\ | | | | | | | | Channel padding See merge request tpo/core/arti!657
| * channel usage: Rename CU::UserTraffic from CU::ExitIan Jackson2022-08-171-1/+1
| | | | | | | | | | As suggested in https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/657#note_2827246
| * Move ChannelUsage from tor_proto to tor_chanmgrIan Jackson2022-08-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | Replace Channel::note_usage with Channel::engage_padding_activities, which unconditionally causes the channel to (start to) do netflow padding things. The condition now lives in chanmgr. Addresses https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/657#note_2826094
| * Provide ChannelUsage and plumb it all the way downIan Jackson2022-08-161-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | Channel padding depends on what the channel is being used for. We therefore need to let the channel code know this information. The implementation of the per-channel padding control logic will be in the new note_usage function, which for now is simply a stub. A future commit will introduce a `PaddingControlState` which lives in the channel frontend; consult the doc comment for that type to see why the plumbing through the channel manager terminates in the channel frontend.
* | Mark some circuit-building errors as "transient".Nick Mathewson2022-08-161-9/+35
|/ | | | | | | | | | | | A "transient" error is one that does not indicate a true failure, but rather an _expected_ need to retry. When we hit one of these, we do not count it against the total number of permitted failures. (We do impose a higher limit on "real failures plus transient failures", though, to prevent infinite loops in the event of a programming error. Closes #517.
* tor-netdir: Collapse by_id and by_relay_id into a single fn.Nick Mathewson2022-08-101-3/+4
| | | | | | There are some downstream changes required for this to work, but they are all just unit tests that could no longer infer the type of an Ed25519 key.
* fix runtime issues on iostrinity-1686a2022-07-301-4/+6
|
* circmgr: Use FilterCounts to explain why we couldn't build pathsNick Mathewson2022-07-121-1/+6
|
* tor-netdir: testnet: Make construct_netdir infallible (rustfmt)Ian Jackson2022-06-131-3/+1
| | | | | Run rustfmt. Separate commit to make review of the substantive commit easier.
* tor-netdir: testnet: Make construct_netdir infallibleIan Jackson2022-06-131-1/+0
| | | | | This is a *lot* of unwraps. The function takes no parameters and is used only for testing. It ought to be infallible.
* Resolve the new `derive_partial_eq_without_eq` lint.Nick Mathewson2022-05-231-3/+3
| | | | It's a little overzealous sometimes, but it's mostly to the good.
* squash! Bump every crate's edition to 2021.Nick Mathewson2022-04-251-1/+0
| | | | | Remove all `use` statements for `TryFrom` and `TryInto`. These are now redundant in Rust 2021.
* circmgr: Report CircProvenance from AbstractCircMgr.Nick Mathewson2022-04-121-21/+32
| | | | | | | This feature is similar to ChanProvenance from ChanMgr, except that we don't yet need to report it outside the crate. I'm going to use it to distinguish newly created circuits from existing circuits in the preemptive circuit builder.
* Distinguish UsageMismatch cases by whether a race is possibleNick Mathewson2022-04-041-0/+6
| | | | | | | This lets us say that the UsageMismatch cases in some parts of the code reflect a programming error (RetryTime::Never), whereas in other case it reflects another circuit request getting to the circuit first (RetryTime::Immediate).
* circmgr: Improve retry-and-or-delay logic.Nick Mathewson2022-04-041-26/+36
| | | | | | | | | Use the new RetryTime type and its associates to decide how long to wait (if at all) between attempts to build a circuit. Closes #421. Part of #329.
* circmgr: Improve reporting of error origins.Nick Mathewson2022-04-041-27/+70
| | | | | | | Previously we did not distinguish errors that came from pending circuits from errors that came from the circuits we were building. We also reported errors as coming from "Left" or "Right", instead of a more reasonable description.
* circmgr: Avoid a race condition in circuit usage restrictionNick Mathewson2022-04-041-5/+14
| | | | | | | | | | | | | | | | | | | | | | We were treating restrict_mut() failures as internal errors, and using internal errors to represent them. But in fact, these failures are entirely possible based on timing. Here's how it happens: * Two different circuit requests arrive at the same time, and both notice a pending circuit that they could use. * The pending circuit completes; both pending requests are notified. * The first request calls restrict_mut(), and restricts the request in such a way that the second couldn't use it. * The second request calls restrict_mut(), and gets a failure. Because of this issue, we treat these errors as transient failures and just wait for another circuit. Closes #427. (This is not a breaking API change, since `AbstractSpec` is a crate-private trait.)
* 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
| |