summaryrefslogtreecommitdiff
path: root/crates/tor-proto
Commit message (Collapse)AuthorAgeFilesLines
...
| * tor-proto: Remove now-unused Reactor::send_outbound().Gabriela Moldovan2025-01-291-74/+0
| | | | | | | | This is now handled in `Reactor::ready_streams_iterator()`.
| * tor-proto: Remove old Reactor::run_once().Gabriela Moldovan2025-01-291-66/+0
| | | | | | | | | | | | | | | | | | This is replaced by the new `Reactor::run_once()` impl. Note: this removal is in a separate commit to make the diff of the refactoring commits easier to review (the diff between the old and the new impl is not meaningful because the new impl is practically a rewrite).
| * tor-proto: Remove now-unused CellStatus enum.Gabriela Moldovan2025-01-291-9/+0
| | | | | | | | This is replaced by `Option<RunOnceCmdInner>`.
| * tor-proto: Rewrite circuit reactor run_once() loop to use select! (fmt).Gabriela Moldovan2025-01-292-27/+29
| |
| * tor-proto: Rewrite circuit reactor run_once() loop to use select!.Gabriela Moldovan2025-01-297-207/+650
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * tor-proto: Use SendRelayCell within CtrlMsg::SendRelayCell.Gabriela Moldovan2025-01-293-8/+8
| |
| * tor-proto: Add enums for representing run_once() commands.Gabriela Moldovan2025-01-291-0/+104
| |
| * tor-proto: Move SendMsgAndInstallHandler handling to a separate function.Gabriela Moldovan2025-01-291-13/+24
| |
| * tor-proto: Move the CircuitExtender to a separate module.Gabriela Moldovan2025-01-292-266/+295
| |
| * tor-proto: Move CtrlMsg to its own module.Gabriela Moldovan2025-01-292-181/+209
| | | | | | | | No functional changes, just code motion.
| * tor-async-utils: Make SometimesUnboundedSink::send_unbounded() pub(crate).Gabriela Moldovan2025-01-291-2/+1
| | | | | | | | | | We are about to use this in the circuit reactor (instead of `pollish_send_unbounded`).
* | fix: fix typosDimitris Apostolou2025-01-304-8/+8
|/
* tor-proto: Use SENDME_TAG_LEN constant instead of magic value.Gabriela Moldovan2025-01-282-7/+8
|
* tor-proto: Use CircTag::try_from for clarity.Gabriela Moldovan2025-01-282-7/+12
|
* tor-proto: Use CircTag instead of raw byte slice.Gabriela Moldovan2025-01-282-7/+6
|
* tor-proto: Move stream msg delivery to a separate function (fmt).Gabriela Moldovan2025-01-281-33/+32
|
* tor-proto: Move stream msg delivery to a separate function.Gabriela Moldovan2025-01-281-33/+47
| | | | | | | This is mostly code motion (I recommend reviewing with `--color-moved`). The code is intentionally misindented to make diffing easier. A future commit will fix the indentation.
* tor-proto: Move stream ID extraction out of handle_relay_msg().Gabriela Moldovan2025-01-281-9/+18
|
* tor-proto: Wrap an extra long lone.Gabriela Moldovan2025-01-281-1/+5
|
* tor-proto: Use continue instead of () for clarity.Gabriela Moldovan2025-01-281-1/+1
|
* tor-proto: Adjust handle_cell() docs.Gabriela Moldovan2025-01-281-1/+1
|
* tor-proto: Split handle_relay_cell().Gabriela Moldovan2025-01-281-4/+15
|
* tor-proto: Split out send_relay_cell().Gabriela Moldovan2025-01-282-13/+28
|
* tor-proto: Group imports.Gabriela Moldovan2025-01-281-2/+1
|
* tor-proto: Replace fully-qualified paths with use.Gabriela Moldovan2025-01-281-6/+6
| | | | For readability.
* tor-proto: Derive Default for MutableState.Gabriela Moldovan2025-01-282-4/+2
| | | | | This enables us to get rid of two lines from the circuit reactor constructor.
* Merge branch 'test-sleep' into 'main'David Goulet2025-01-161-15/+5
|\ | | | | | | | | tor-proto: Replace sleep() in test with advance_until_stalled(). See merge request tpo/core/arti!2721
| * tor-proto: Replace sleep() in test with advance_until_stalled().Gabriela Moldovan2025-01-161-15/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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()`.
* | tor-proto: Replace std::result::Result with shorter alias.Gabriela Moldovan2025-01-161-5/+6
| | | | | | | | | | | | The more concise name makes the code a bit more readable, IMO (and it's consistent with the `Result` type-aliasing style we've been using in the rest of the codebase).
* | tor-proto: Remove unnecessary fully qualified path.Gabriela Moldovan2025-01-161-1/+1
| | | | | | | | It's not needed because `CircHop` is defined in the same file.
* | tor-proto: Move outbound message sending out of circuit run_once() (fmt).Gabriela Moldovan2025-01-161-64/+64
| | | | | | | | No functional changes, just `cargo fmt`.
* | tor-proto: Move outbound message sending out of circuit run_once().Gabriela Moldovan2025-01-161-13/+23
|/ | | | | | | | | This is mostly code motion in preparation for refactoring `run_once()` to use `select!` instead of the hand-rolled `poll_fn` impl. Note: the code here is intentionally mis-indented, to simplify diffing (I recommend using `git diff --color-moved`). A future commit will fix the indentation.
* Add missing semver.md filesDavid Goulet2025-01-161-0/+1
| | | | | | Both in tor-proto and tor-circmgr. Signed-off-by: David Goulet <[email protected]>
* congestion: Use getters for all parametersDavid Goulet2025-01-164-68/+94
| | | | | | Allows us to remove the pub. Signed-off-by: David Goulet <[email protected]>
* congestion: Remove Default from every parametersDavid Goulet2025-01-162-24/+6
| | | | | | | Important to enforce that every field is explicitely set so we avoid forgetting fields. Signed-off-by: David Goulet <[email protected]>
* congestion: Make the cc_alg values a caret_int for better code semanticDavid Goulet2025-01-162-0/+15
| | | | Signed-off-by: David Goulet <[email protected]>
* congestion: Move test code in test module for VegasDavid Goulet2025-01-161-16/+15
| | | | Signed-off-by: David Goulet <[email protected]>
* congestion: Remove duplicated commentsDavid Goulet2025-01-161-13/+0
| | | | | | No need to have these comments in the implementation of the Trait. Signed-off-by: David Goulet <[email protected]>
* congestion: Move code to test moduleDavid Goulet2025-01-161-10/+14
| | | | | | | Put code for test inside the test module instead of gated by a cfg(test). Signed-off-by: David Goulet <[email protected]>
* congestion: Remove FixedWindow start window default valueDavid Goulet2025-01-163-13/+18
| | | | | | | | 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]>
* congestion: Add standard clippy checks to testsDavid Goulet2025-01-163-0/+42
| | | | Signed-off-by: David Goulet <[email protected]>
* congestion: Some comments and mod syntax tweakingDavid Goulet2025-01-161-7/+1
| | | | | | | Don't put in the comments, let the top-level module comments do that job. Signed-off-by: David Goulet <[email protected]>
* congestion: Make a test_utils.rsDavid Goulet2025-01-164-45/+60
| | | | | | | | Instead of having the congestion.rs test module public, make a test_utils.rs file that contains code for other unit tests within the congestion module. Signed-off-by: David Goulet <[email protected]>
* congestion: Remove duplicate RttParameters structDavid Goulet2025-01-161-39/+7
| | | | | | | Turns out that RoundTripEstimatorParams is the same exact thing so one less data structure. Signed-off-by: David Goulet <[email protected]>
* test: Fix circuit unit testsDavid Goulet2025-01-162-5/+9
| | | | Signed-off-by: David Goulet <[email protected]>
* proto: Remove unused circuit/sendme.rsDavid Goulet2025-01-162-459/+0
| | | | Signed-off-by: David Goulet <[email protected]>
* proto: Notify CC when a SENDME is receivedDavid Goulet2025-01-162-8/+27
| | | | | | | | | We also pass along congestion signals that may or may not be used by our congestion control algorithm. Part of #534 Signed-off-by: David Goulet <[email protected]>
* proto: Use congestion control in circuit reactorDavid Goulet2025-01-166-49/+48
| | | | | | | | | | 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]>
* circmgr: Modify CircParameters for congestion controlDavid Goulet2025-01-163-51/+23
| | | | | | | | | | | | | | 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]>
* proto: Add Vegas congestion control algorithmDavid Goulet2025-01-163-0/+599
| | | | | | | | | | | The big one! This is the Vegas algorithm implementation that is hooked to the CongestionControl object by implementing the algorithm trait. Still, at this commit, nothing is being used by the circuit reactor yet. Related #534 Signed-off-by: David Goulet <[email protected]>