| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
| |
This is just code motion (I suggest reviewing with `--color-moved`).
This also moves the implementation-agnostic parts from
`tor_proto::client::circuit` to a new `tor_proto::circuit` module.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
Move StreamTarget to the tunnel module and the circuit module.
From now on streams will be implemented on tunnels, not circuits.
This moves `StreamTarget` to the tunnel module. A future change will
replace `ClientCirc` with `ClientTunnel` inside `StreamTarget`.
This is mostly code motion, best reviewed with `--color-moved`.
Signed-off-by: David Goulet <[email protected]>
|
| |
|
|
|
|
|
| |
We're about to need this in `tor_proto::tunnel` which is from the
Conflux work.
In the spirit of upstreaming as much as possible, it is done now.
|
| |
|
|
|
| |
This moves the `CreateHandshakeWrap` and its implementors to
`reactor::create` (none of these are used outside of the reactor).
|
| | |
|
| | |
|
| | |
|
| |
|
|
|
|
|
| |
All `CtrlMsg`s to which the reactor did not respond by sending a cell
down the channel are now `CtrlCmd`s.
Most of this is code motion, best reviewed with `--color-moved`.
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
It is unused but most importantly it allows any RELAY cell to be sent
from anywhere in the code which is really not desirable because it is
skipping congestion control.
It also allows us to remove the `control_tx` from the reactor which is
one less channel to track/understand/think about.
This opens up the door to all sorts of problems especially side channel
that can be exploited if we are not careful.
We can always bring this back if we need it but for now, it is unused
and allows us to remove the `CtrlMsg::SendRelayCell` control message.
No code behavior change.
Signed-off-by: David Goulet <[email protected]>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This hopefully fixes #1832.
I haven't been able to repro the failure from #1832 locally, but judging
from the logs, I suspect it's triggered by interleavings like:
- `extend_fut` executes up until `circ.extend_ntor(..).await`, where
it's blocked `await`ing a completion notification from the circuit
reactor
- `reply_fut` starts running:
* `CircuitExtender` installs a meta-handler in the circuit reactor,
and waits for an `EXTENDED2` cell
* `test_extend()` reads a cell from the receiving end of the fake
channel's output sink (`rx`)
* `test_extend()` sends the `EXTENDED2` cell to the circuit reactor
over `CircuitRxSender`
* `rx` is dropped
- `reply_fut` completes
- in the channel reactor's `run_once()`, `select_biased!` resolves
to an error, because the receiving end of the `output` sink (`rx`) was
dropped. The reactor logs `got sink error: SendError { kind:
Disconnected }` (see [`SendError`]), and exits
- the circuit reactor exits too, because the receiving end of its
`chan_sender` (which was in the channel reactor) was dropped
Returning the `rx` of the fake channel's output sink from `reply_fut`
*should* stop it from being dropped, and fix #1832.
[`SendError`]: https://docs.rs/futures/latest/futures/channel/mpsc/struct.SendError.html#method.is_disconnected
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This rewrites the circuit reactor main loop to use `select_biased!` to poll
multiple futures simultaneously.
The new `run_once()`, like the old, first waits for an initial
`CtrlMsg::Create`. Then, it uses a `select_biased!` to poll the
`chan_sender` sink and shutdown channel for readiness.
When the channel sink is ready, we poll the `control` and `input`
channels like before, as well as the new `ready_streams` `Stream`
(`ready_streams` is a `futures::Stream` that replaces the previous
`send_outbound()` function).
Most of the implementation remains unchanged, except the `handle_input`,
`handle_cell` and `handle_control` functions no longer send anything on
the `chan_sender` channel. Instead, they may do some (synchronous)
processing, and send instructions for the remaining work that needs to
be done (for example, for writing the cell to the `chan_sender`
channel). These instructions are handled at the end of `run_once()`,
and are encoded in the `RunOnceCmdInner` enum.
What this change does **not** do:
* the control channel *still* bypasses congestion control. We could
fix this by making the various reactor functions send the
`RunOnceCmdInner` commands to `run_once()` via a channel
(instead of returning them). This would enable the reactor to stop
reading the commands (except for handle `Sendme`, which would be
handled separately) if it's blocked on congestion control.
|
| | |
|
| |
|
|
|
| |
This enables us to get rid of two lines from the circuit reactor
constructor.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This test spuriously failed on my !2720 branch
(https://gitlab.torproject.org/gabi-250/arti/-/jobs/811495):
```
failures:
---- circuit::test::invalid_circ_sendme stdout ----
E tor_proto::channel::reactor: UniqId(71): Running reactor
E tor_proto::circuit::reactor: Circ 23.17: Running circuit reactor
E tor_proto::circuit::reactor: Circ 23.17: reactor received AddFakeHop { relay_cell_format: V0, fwd_lasthop: false, rev_lasthop: false, params: CircParameters { extend_by_ed25519_id: true, ccontrol: CongestionControlParams { alg: FixedWindow(FixedWindowParams { circ_window_start: 1000, circ_window_min: 100, circ_window_max: 1000 }), cwnd_params: CongestionWindowParams { cwnd_init: 124, cwnd_inc_pct_ss: Percentage { value: 100 }, cwnd_inc: 1, cwnd_inc_rate: 31, cwnd_min: 124, cwnd_max: 4294967295, sendme_inc: 31 }, rtt_params: RoundTripEstimatorParams { ewma_cwnd_pct: Percentage { value: 50 }, ewma_max: 10, ewma_ss_max: 2, rtt_reset_pct: Percentage { value: 100 } } } }, done: Sender { complete: false } }
E tor_proto::circuit::reactor: Circ 23.17: reactor received AddFakeHop { relay_cell_format: V0, fwd_lasthop: true, rev_lasthop: true, params: CircParameters { extend_by_ed25519_id: true, ccontrol: CongestionControlParams { alg: FixedWindow(FixedWindowParams { circ_window_start: 1000, circ_window_min: 100, circ_window_max: 1000 }), cwnd_params: CongestionWindowParams { cwnd_init: 124, cwnd_inc_pct_ss: Percentage { value: 100 }, cwnd_inc: 1, cwnd_inc_rate: 31, cwnd_min: 124, cwnd_max: 4294967295, sendme_inc: 31 }, rtt_params: RoundTripEstimatorParams { ewma_cwnd_pct: Percentage { value: 50 }, ewma_max: 10, ewma_ss_max: 2, rtt_reset_pct: Percentage { value: 100 } } } }, done: Sender { complete: false } }
E tor_proto::circuit::reactor: Circ 23.17: reactor received BeginStream { hop_num: HopNum(2), message: Begin(Begin { addr: [119, 119, 119, 46, 101, 120, 97, 109, 112, 108, 101, 46, 99, 111, 109], port: 443, flags: BeginFlags(IPV6_OKAY) }), sender: Sender { tx: Sender { closed: false }, mq: TypedParticipation(Participation(Noop)) }, rx: Receiver { inner: ReceiverInner { state: Mutex { data: Ok(ReceiverState { rx: StreamUnobtrusivePeeker { buffered: None, poll_waker: None, inner: Some(Receiver { closed: false }) }, mq: TypedParticipation(Participation(Noop)), collapse_callbacks: 0 }), poisoned: false, .. } } }, done: Sender { complete: false }, cmd_checker: DataCmdChecker { expecting_connected: true } }
Using RNG seed ARTI_TEST_PRNG=62d085c0fb1213c4f41d1a0a5c3f92dd10223a27c42bfda3caedfe60e011e95d
E tor_proto::circuit::reactor: Circ 23.17: handling cell: Relay(Relay { body: .. })
Using RNG seed ARTI_TEST_PRNG=fd2f2f045a7340f1189972b13645346943efa2c42f43afd2161420c692bb4ff0
E tor_proto::circuit::reactor: Circ 23.17: handling cell: Relay(Relay { body: .. })
E tor_proto::circuit::reactor: Circ 23.17: Circuit reactor stopped: Err(CircProto("Mismatched tag on circuit SENDME"))
E tor_proto::channel::reactor: UniqId(71): reactor received CloseCircuit(CircId(128))
E tor_proto::channel::reactor: UniqId(71): Circuit 128 is gone; sending DESTROY
thread 'circuit::test::invalid_circ_sendme' panicked at crates/tor-proto/src/circuit.rs:2262:21:
reactor continued running after invalid sendme
failures:
circuit::test::invalid_circ_sendme
test result: FAILED. 142 passed; 1 failed; 1 ignored; 0 measured; 0 filtered out; finished in 4.93s
```
This is probably because of the `sleep()`-based check. This branch
changes the test to use `MockRuntime`, replacing the `sleep()` with
`advance_until_stalled()`.
|
| |
|
|
|
|
|
|
| |
In unit tests, we set a 1000 by default but else, we don't set a default
so our implementation doesn't forget to set the right value from the
consensus.
Signed-off-by: David Goulet <[email protected]>
|
| |
|
|
| |
Signed-off-by: David Goulet <[email protected]>
|
| |
|
|
| |
Signed-off-by: David Goulet <[email protected]>
|
| |
|
|
|
|
|
|
|
|
| |
It is official, congestion control is now used at this commit by the
circuit reactor making circuit/sendme.rs unused. Will be removed with
another commit.
Related #534
Signed-off-by: David Goulet <[email protected]>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
The congestion control parameters are created from the consensus
parameters (netparams) and then put into the CircParameters object that
is then passed down the tor-proto crate.
Because different parameters are selected depending on the circuit type
(onion vs exit vs sbws), a CircuitType enum is introduced for the sole
purpose of being used to select the right parameters.
Related #534
Signed-off-by: David Goulet <[email protected]>
|
| |
|
|
| |
(We don't add it to the handful of unit tests that don't use an executor.)
|
| |
|
|
| |
These are new in Rust 1.83.
|
| |\
| |
| |
| |
| | |
memquota: Fix account lifetime bugs, and arrange to test mq in shadow
See merge request tpo/core/arti!2560
|
| | |
| |
| |
| |
| |
| |
| |
| |
| | |
We need the mq account for the stream not to collapse. The
ResolveStream object needs to contain a strong reference to it.
Have begin_stream_impl return the StreamAccount, rather than taking it
as a parameter. That makes this bug a little more obvious. It also
centralises the StreamAccount creation.
|
| | | |
|
| | |
| |
| |
| |
| |
| | |
Now that it doesn't call CircuitAccount::new() it has no error paths,
and clippy demands we remove the Result, so it must once again become
infallible.
|
| | |
| |
| |
| |
| |
| |
| |
| | |
We foolishly made *two* CircuitAccounts, one of which gets immediately
dropped. But we need to hold onto the account somewhere, because an
mq_queue doesn't keep the account alive.
Otherwise everything breaks when mq tracking is enabled.
|
| |/ |
|
| | |
|
| |\
| |
| |
| |
| |
| |
| | |
Use memquota queue for channel->circuit RX data
Closes #1682
See merge request tpo/core/arti!2518
|
| | | |
|
| | |
| |
| |
| |
| |
| | |
Fixes #1682.
(This involves some noise in the tests.)
|
| | |
| |
| |
| |
| | |
This is neater and will make changing the type (in a moment) less
noisy.
|
| |/
|
|
| |
Fixes: #628
|
| | |
|
| | |
|
| | |
|
| | |
|
| |
|
|
| |
Change the typss of StreamMpscSender and StreamMpscReceiver.
|
| | |
|
| | |
|
| | |
|
| |\
| |
| |
| |
| | |
tor-proto: Introduce type aliases for some queues
See merge request tpo/core/arti!2484
|
| | | |
|
| | |
| |
| |
| | |
This will make it easier to change their types.
|
| |/
|
|
| |
This prepares us to change the types of these queues.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
Having this in the `tor-async-utils` crate prevents us from doing both
of the following without introducing a circular dependency:
* using it in `tor-rtmock` (which we currently do, particularly in
tests).
* using `tor-rtmock` to test things in `tor-async-utils`. We don't do
this yet, but it is generally sensible to do so. In particular we
want to move the `stream_peak` module there, which is currently tested
with `tor-rtmock`.
Moving this into its own crate avoids this circular dependency.
|
| |
|
|
|
| |
There is now (sendme-style) flow control, and some fairness
(via round robin scheduling of streams).
|
| |
|
|
|
|
| |
There is a mutex for some of the "mutable state", but the reactor only
needs to lock it when adding a hop. It's not needed "to process a cell"
or when streams send. Probably not worth calling out here.
|
| | |
|