Commit Graph

3053 Commits

Author SHA1 Message Date
Nick Mathewson 5f5cbdc08e GuardMgr: publish skew estimates.
Instead of just having a function that recalculates the latest clock
skew, instead recalculate the clock skew when it may have changed,
and notify other processes via a postage::watch.
2022-04-12 08:03:49 -04:00
Nick Mathewson 61080dcaec guardmgr: fix a unit test panic.
Apparently on OSX you are not allowed to construct an Instant that is a
long time before the time when the test is running.

Also, fix the length of a year in this test.
2022-04-11 14:13:17 -04:00
Nick Mathewson 9f7a80b5f2 Merge branch 'record-skew-v3' into 'main'
Collect and analyze clock skew information

See merge request tpo/core/arti!450
2022-04-11 17:27:14 +00:00
Nick Mathewson 4efe45ce6e handshake.rs: Document the time for clock skew authentication. 2022-04-11 12:34:16 -04:00
Nick Mathewson c909926302 Fold FallbackStatus into Entry.
This simplifies the code a lot.
2022-04-11 12:34:16 -04:00
Nick Mathewson 452e1c0935 Add a couple of TODO items to clock-skew estimator. 2022-04-11 12:34:16 -04:00
Nick Mathewson cf362fac9f Implement a better clock skew estimator.
This time, our estimator discards outliers, takes the mean of what's
left, and uses the standard deviation to try to figure out how
seriously to take our report of skew/not-skew.

These estimates are still not actually used.
2022-04-11 12:34:16 -04:00
Nick Mathewson adb94f8047 Merge branch 'cargo-audit' into 'main'
fix maint/cargo_audit not propagating error and add temporary exceptions

See merge request tpo/core/arti!452
2022-04-08 15:55:05 +00:00
Nick Mathewson 0fb3728145 Merge branch 'stable-coverage' into 'main'
use rustc 1.60 for coverage

See merge request tpo/core/arti!451
2022-04-08 15:17:44 +00:00
trinity-1686a 777eb8a5fc fix maint/cargo_audit not propagating error and add temporary exceptions 2022-04-08 16:51:35 +02:00
trinity-1686a 7c4ad15fc3 use default toolchain from rustup instead of stable for coverage
using stable doesn't work for CI because a specific version like 1.60 is installed
2022-04-08 16:19:28 +02:00
trinity-1686a 98ed22ba55 bring back RUST_COVERAGE_TOOLCHAIN 2022-04-08 15:46:46 +02:00
trinity-1686a c113c607ac use rustc 1.60 (stable) for coverage 2022-04-07 23:04:10 +02:00
Nick Mathewson eedee51899 Initial functions to determine and expose a clock skew estimate.
(This is just a placeholder; I'm going to make the functions
smarter in the next commit.)
2022-04-07 16:01:46 -04:00
Nick Mathewson ae92f626fb Reformat tor-guardmgr/Cargo.toml 2022-04-07 12:11:09 -04:00
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