Commit Graph

3038 Commits

Author SHA1 Message Date
Nick Mathewson 99146da2c2 GuardMgr: record clock skew information.
(It is not yet actually used.)
2022-04-07 11:33:34 -04:00
Nick Mathewson c3c43b088e Create and use API to report guard/fallback skew.
(The information is not yet recorded.)
2022-04-07 10:47:45 -04:00
Nick Mathewson 0050045867 ChanMgr: Return provenance information from get_or_launch
We need this since we want to report certain conditions only when
they happen on a new channel, not if we observe them on a
preexisting channel.
2022-04-07 10:46:06 -04:00
Nick Mathewson 9160b55c57 chanmgr: bubble ClockSkew up through the Error object.
Fortunately, we don't need a separate type here: authenticated
clock skew can only come attached to a `tor_proto::Error`.

We also remove skew from `tor_proto::Error::HandshakeCertsExpired`,
since it would now be redundant.
2022-04-07 10:15:28 -04:00
Nick Mathewson 7656ab0931 Channel: Expose our view of whether the clock is skewed, and the age
of a channel.

At first I wanted to have this information not be a part of channels
at all, but it is a fairly tiny amount of data, and the alternatives
are pretty crufty.
2022-04-07 10:07:35 -04:00
Nick Mathewson d81de1580b Merge branch 'downgrade_rlimit' into 'main'
Downgrade `rlimit` to 0.7.

See merge request tpo/core/arti!449
2022-04-06 15:16:01 +00:00
Nick Mathewson 4acba0df9b Downgrade `rlimit` to 0.7.
Upstream 0.8.2 has broken compilation with Rust 1.53; versions
0.8.{0,1} have been yanked.

Possibly by the time the next arti version comes out, they'll have
fixed this situation, or we'll have upgraded our MSRV.

Upstream issue at https://github.com/Nugine/rlimit/issues/42 .
2022-04-06 10:21:33 -04:00
Nick Mathewson 142e28cd96 Merge branch 'main' into 'separate_dir_status'
# Conflicts:
#   doc/semver_status.md
2022-04-06 13:33:01 +00:00
eta 1cc7e48cff Merge branch 'untimely_dir_is_failed' into 'main'
Treat expired/not-yet-valid directory objects as Errors.

Closes #431

See merge request tpo/core/arti!448
2022-04-06 12:54:28 +00:00
Nick Mathewson d05022dea4 Treat expired/not-yet-valid directory objects as Errors.
Doing this will make us treat caches that send us these objects as
not-working, and close circuits to them instead of trying over and
over.

The case where we add a document from the cache requires special
handling: it isn't actually a error to find an expired document in
our cache (unless the passage of time itself is erroneous, which is
a debatable proposition at best).

Fixes #431.
2022-04-05 15:54:37 -04:00
Nick Mathewson 430611ba3a Fix a rustdoc link 2022-04-05 12:37:36 -04:00
Nick Mathewson 94050aa90f Merge branch 'retriable' into 'main'
Improved handling for retriable errors in circmgr

Closes #427 and #421

See merge request tpo/core/arti!443
2022-04-05 15:33:20 +00:00
Nick Mathewson 2c51316604 Merge branch 'main' into 'retriable'
# Conflicts:
#   doc/semver_status.md
2022-04-05 14:48:51 +00:00
Nick Mathewson fe43f0ddb5 GuardMgr: Tests for copy_status_from. 2022-04-05 10:36:29 -04:00
Nick Mathewson 3b32e635cd GuardMgr: Tests for note_external_{success,failure}. 2022-04-05 10:01:30 -04:00
Nick Mathewson 3ba9b47000 Rewrite and fix Guard::copy_status_from.
The old version of this function was error-prone, and in fact had
errors: it was too easy to forget to add non-persistent fields, and
that's exactly what we forgot in a few cases
(`microdescriptor_missing`, `circ_history`, and
`suspicious_behavior_warned`).

The new version of this function consumes both of the incoming
Guards, and constructs every field explicitly so that we can't
forget to list any.

Closes #429.
2022-04-05 09:37:44 -04:00
Nick Mathewson b3e06b93b6 GuardMgr: Track directory status and circuit status separately.
Previously, we treated successfully building a circuit to a guard as
a "success", and any failure, including a directory cache failure,
as a failure.  With this change, guards now have separate
success/failure and retry status for circuit usage and directory
usage.

This change is needed for guard-as-directory retry to have
reasonable behavior.  Otherwise, when a guard succeeds at building a
circuit, that clears the directory-is-failing status and makes us
retry the guards to quickly.
2022-04-05 09:18:04 -04:00
Nick Mathewson 52c7a0e26a Allow DirStatus objects to have different timeout floors
This will help when we give Guards a DirStatus as well.
2022-04-04 12:32:19 -04:00
Nick Mathewson 57608f9609 Add RetrySchedule::reset()
Previously the code would do stuff like

```
    schedule = RetrySchedule::new(INITIAL_DELAY);
```

which is needlessly verbose, since the schedule already keeps track
of its initial delay.
2022-04-04 12:32:18 -04:00
Nick Mathewson 75fd63a120 Rename fallback::status::Status to DirStatus.
It's about to be shared between fallbacks and guards.
2022-04-04 12:31:41 -04:00
Nick Mathewson 36440a957c Distinguish UsageMismatch cases by whether a race is possible
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).
2022-04-04 11:41:00 -04:00
Nick Mathewson 414763b6e2 RetryTime: Improve documentation.
For each case, describe its semantics (in addition to when you would
create it).

Explain the relationship between After and At.

Stop saying "Strategy": we renamed this type to "RetryTime".
2022-04-04 11:22:40 -04:00
Nick Mathewson 81ebbc8e74 RetryTime: make loose_cmp pub. 2022-04-04 11:15:18 -04:00
Nick Mathewson 160cb91669 RetryTime: use strum::EnumDiscriminants to simplify loose_cmp.
Also add tests for RetryTime comparison functions to make sure they
work as expected.
2022-04-04 11:15:18 -04:00
Nick Mathewson 6d8a6b42e7 circmgr: Improve retry-and-or-delay logic.
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.
2022-04-04 11:15:18 -04:00
Nick Mathewson c3b2bcc91e circmgr: implement HasRetryTime. 2022-04-04 11:15:18 -04:00
Nick Mathewson 6872555302 guardmgr: implement HasRetryTime. 2022-04-04 11:15:18 -04:00
Nick Mathewson 936439858b chanmgr: implement HasRetryTime. 2022-04-04 11:15:18 -04:00
Nick Mathewson f7810d42eb circmgr: Improve reporting of error origins.
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.
2022-04-04 11:15:18 -04:00
Nick Mathewson 86c59dd1f3 circmgr: Avoid a race condition in circuit usage restriction
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.)
2022-04-04 11:14:52 -04:00
Nick Mathewson 3676826d03 tor-error: Add a new RetryTime type and related trait. 2022-04-04 11:09:25 -04:00
Nick Mathewson a044d4bcfe Reformat tor-error/Cargo.toml 2022-04-04 11:09:25 -04:00
eta 314f5707b5 Merge branch 'coverage_20220402' into 'main'
Miscellaneous test coverage work

See merge request tpo/core/arti!446
2022-04-04 14:36:17 +00:00
Nick Mathewson 24b30c56db chanmgr: tests for ConnStatus::usable 2022-04-02 16:06:59 -04:00
Nick Mathewson f59f68d32d chanmgr: add a test for AbstractChannel::duration_unused 2022-04-02 16:05:00 -04:00
Nick Mathewson 8d823dd2e5 chanmgr: add tests for connect_one. 2022-04-02 15:50:56 -04:00
Nick Mathewson 58a1e89c8d rtmock: add the ability to make a connection time out. 2022-04-02 15:48:41 -04:00
Nick Mathewson 95c8b518a7 checkable: additional unit tests for more APIs. 2022-04-02 12:19:13 -04:00
Nick Mathewson 3103549cba socksproto: remove some unused accessors. 2022-04-02 12:01:20 -04:00
Nick Mathewson e6c6628adb Update rlimit to 0.8.1
This is necessary to fix build for M1 apples.
2022-04-02 08:10:18 -04:00
Nick Mathewson 52783f9ed1 Cargo.toml: Edit crate list to reflect dependencies 2022-04-01 11:19:32 -04:00
Nick Mathewson 4a3df6a26f Clean out semver_status.md 2022-04-01 11:18:35 -04:00
Nick Mathewson b03bf29259 Merge branch '020_versions' into 'main'
Bump versions in preparation for 0.2.0 release.

See merge request tpo/core/arti!445
2022-04-01 14:34:49 +00:00
Nick Mathewson 5b2fc118df Bump all arti*, tor* crates to 0.2.0
Not all of these strictly need to be bumped to 0.2.0; many could go
to 0.1.1 instead.  But since everything at the tor-rtcompat and
higher layers has had breaking API changes, it seems not so useful
to distinguish.  (It seems unlikely that anybody at this stage is
depending on e.g. tor-protover but not arti-client.)
2022-04-01 09:15:18 -04:00
Nick Mathewson aae242af22 Bump caret, retry-error to 0.1.1
Unlike the rest of the crates, these don't have a "tor-" or "arti-"
prefix, and are potentially used by code outside arti.  With that in
mind, it's probably for the best not to bump them to 0.2.0 along
with the rest of our crates.

They have had no changes since 0.1.0 other than refactoring and
changing of clippy lints.  Therefore, I'm not bumping the
dependencies from other crates onto these: it's fine whether our
other crates use caret/retry-error 0.1.0 or 0.1.1.
2022-04-01 09:14:46 -04:00
Nick Mathewson a7cf65ca0d Update Cargo.lock based on build. 2022-04-01 09:03:25 -04:00
Nick Mathewson 392a176b00 CHANGELOG: Fix another sentence 2022-04-01 09:02:35 -04:00
Nick Mathewson 91982fa123 CHANGELOG: rephrase a sentence. 2022-04-01 08:58:18 -04:00
Nick Mathewson ae387f5eeb Merge branch 'upgrade_pre_020' into 'main'
Run cargo upgrade/update in preparation for 0.2.0

See merge request tpo/core/arti!444
2022-04-01 12:48:50 +00:00
Nick Mathewson 6a1dc1d053 CHANGELOG: spelling fixes 2022-04-01 08:47:21 -04:00