aboutsummaryrefslogtreecommitdiff
path: root/src/core/or/circuituse.c
AgeCommit message (Collapse)Author
2023-05-10hs_pow: client side effort adjustmentMicah Elizabeth Scott
The goal of this patch is to add an additional mechanism for adjusting PoW effort upwards, where clients rather than services can choose to solve their puzzles at a higher effort than what was suggested in the descriptor. I wanted to use hs_cache's existing unreachability stats to drive this effort bump, but this revealed some cases where a circuit (intro or rend) closed early on can end up in hs_cache with an all zero intro point key, where nobody will find it. This moves intro_auth_pk initialization earlier in a couple places and adds nonfatal asserts to catch the problem if it shows up elsewhere. The actual effort adjustment method I chose is to multiply the suggested effort by (1 + unresponsive_count), then ensure the result is at least 1. If a service has suggested effort of 0 but we fail to connect, retries will all use an effort of 1. If the suggestion was 50, we'll try 50, 100, 150, 200, etc. This is bounded both by our client effort limit and by the limit on unresponsive_count (currently 5). Signed-off-by: Micah Elizabeth Scott <beth@torproject.org>
2023-05-10compute the client-side pow in a cpuworker threadRoger Dingledine
We mark the intro circuit with a new flag saying that the pow is in the cpuworker queue. When the cpuworker comes back, it either has a solution, in which case we proceed with sending the intro1 cell, or it has no solution, in which case we unmark the intro circuit and let the whole process restart on the next iteration of connection_ap_handshake_attach_circuit().
2023-05-10hs: Don't expire RP circuits to HS with PoWDavid Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
2023-04-06Avoid closing dirty circs with active half-edgesMike Perry
In https://gitlab.torproject.org/tpo/core/tor/-/issues/40623, we changed the DESTROY propogation to ensure memory was freed quickly at relays. This was a good move, but it exacerbates the condition where a stream is closed on a circuit, and then it is immediately closed because it is dirty. This creates a race between the DESTROY and the last data sent on the stream. This race is visible in shadow, and does happen. This could be backported. A better solution to these kinds of problems is to create an ENDED cell, and not close any circuits until the ENDED comes back. But this will also require thinking, since this ENDED cell can also get lost, so some kind of timeout may be needed either way. The ENDED cell could just allow us to have much longer timeouts for this case.
2023-04-06Prop#329 Pool: Handle pre-building and using conflux sets.David Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
2023-04-06Prop#329 Pool: Handle linking, unlinking, and relaunching conflux circuit legs.David Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
2023-04-06Prop#329 streams: Handle stream usage with confluxMike Perry
This adds utility functions to help stream block decisions, as well as cpath layer_hint checks for stream cell acceptance, and syncing stream lists for conflux circuits. These functions are then called throughout the codebase to properly manage conflux streams.
2023-04-06Refactor stream blocking due to channel cell queuesMike Perry
Streams can get blocked on a circuit in two ways: 1. When the circuit package window is full 2. When the channel's cell queue is too high Conflux needs to decouple stream blocking from both of these conditions, because streams can continue on another circuit, even if the primary circuit is blocked for either of these cases. However, both conflux and congestion control need to know if the channel's cell queue hit the highwatermark and is still draining, because this condition is used by those components, independent of stream state. Therefore, this commit renames the 'streams_blocked_on_chan' variable to signify that it refers to the cell queue state, and also refactors the actual stream blocking bits out, so they can be handled separately if conflux is present.
2023-04-06Prop#329: Add purposes for conflux circuitsMike Perry
Because UNLINKED circuits must never be used for streams, but LINKED circuits can be, we want these separate.
2023-03-07metrics: Add a `reason` label to the HS error metrics.Gabriela Moldovan
This adds a `reason` label to the `hs_intro_rejected_intro_req_count` and `hs_rdv_error_count` metrics introduced in #40755. Metric look up and intialization is now more a bit more involved. This may be fine for now, but it will become unwieldy if/when we add more labels (and as such will need to be refactored). Also, in the future, we may want to introduce finer grained `reason` labels. For example, the `invalid_introduce2` label actually covers multiple types of errors that can happen during the processing of an INTRODUCE2 cell (such as cell parse errors, replays, decryption errors). Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2023-02-16metrics: Add metrics for rendezvous and introduction request failures.Gabriela Moldovan
This introduces a couple of new service side metrics: * `hs_intro_rejected_intro_req_count`, which counts the number of introduction requests rejected by the hidden service * `hs_rdv_error_count`, which counts the number of rendezvous errors as seen by the hidden service (this number includes the number of circuit establishment failures, failed retries, end-to-end circuit setup failures) Closes #40755. This partially addresses #40717. Signed-off-by: Gabriela Moldovan <gabi@torproject.org>
2022-10-19hs: Retry service rendezvous on circuit closeDavid Goulet
Move the retry from circuit_expire_building() to when the offending circuit is being closed. Fixes #40695 Signed-off-by: David Goulet <dgoulet@torproject.org>
2022-10-19circ: Get rid of hs_circ_has_timed_outDavid Goulet
Logic is too convoluted and we can't efficiently apply a specific timeout depending on the purpose. Remove it and instead rely on the right circuit cutoff instead of keeping this flagged circuit open forever. Part of #40694 Signed-off-by: David Goulet <dgoulet@torproject.org>
2022-10-19circ: Set proper timeout cutoff for HS circuitsDavid Goulet
Explicitly set the S_CONNECT_REND purpose to a 4-hop cutoff. As for the established rendezvous circuit waiting on the RENDEZVOUS2, set one that is very long considering the possible waiting time for the service to get the request and join our rendezvous. Part of #40694 Signed-off-by: David Goulet <dgoulet@torproject.org>
2022-02-22Hook up client usage of congestion control negotiationMike Perry
2022-02-22Use protover to signal support for ntor3 + congestion control.Nick Mathewson
2021-07-01Simplify cannibalization logic now that all HS is vanguardsGeorge Kadianakis
Co-authored-by: Mike Perry <mikeperry-git@torproject.org>
2021-07-01Preemptive circuits for HSes should now be vanguard circuitsGeorge Kadianakis
Co-authored-by: Mike Perry <mikeperry-git@torproject.org>
2021-07-01Use L2 vanguards during path selectionGeorge Kadianakis
Co-authored-by: Mike Perry <mikeperry-git@torproject.org>
2021-05-07Merge branch 'maint-0.4.5' into maint-0.4.6Nick Mathewson
2021-05-07Merge branch 'maint-0.4.4' into maint-0.4.5Nick Mathewson
2021-05-07Merge branch 'maint-0.3.5' into maint-0.4.4Nick Mathewson
2021-05-07Reindent a few lines to fix a GCC warning.Nick Mathewson
As of GCC 11.1.1, the compiler warns us about code like this: if (a) b; c; and that's a good thing: we wouldn't want to "goto fail". But we had an instance if this in circuituse.c, which was making our compilation sad. Fixes bug 40380; bugfix on 0.3.0.1-alpha.
2021-03-12Update copyrights to 2021, using "make update-copyright"Nick Mathewson
2021-02-22relay: Remove dirport reachability self testDavid Goulet
Regular relays are about to get their DirPort removed so that reachability test is not useful anymore Authorities will still use the DirPort but because network reentry towards their DirPort is now denied network wide, this test is not useful anymore and so it should simply be considered reachable at all time. Part of #40282 Signed-off-by: David Goulet <dgoulet@torproject.org>
2021-02-19hs-v2: Removal of service and relay supportDavid Goulet
This is unfortunately massive but both functionalities were extremely intertwined and it would have required us to actually change the HSv2 code in order to be able to split this into multiple commits. After this commit, there are still artefacts of v2 in the code but there is no more support for service, intro point and HSDir. The v2 support for rendezvous circuit is still available since that code is the same for the v3 and we will leave it in so if a client is able to rendezvous on v2 then it can still transfer traffic. Once the entire network has moved away from v2, we can remove v2 rendezvous point support. Related to #40266 Signed-off-by: David Goulet <dgoulet@torproject.org>
2021-02-19hs-v2: Remove client supportDavid Goulet
Related to #40266 Signed-off-by: David Goulet <dgoulet@torproject.org>
2021-02-09Fix coverity warnings 1472846 / 1472845.George Kadianakis
2021-02-08Add stream ID to ADDRMAP control eventNeel Chauhan
2020-11-12Fix typos.Samanta Navarro
Typos found with codespell. Please keep in mind that this should have impact on actual code and must be carefully evaluated: src/core/or/lttng_circuit.inc - ctf_enum_value("CONTROLER", CIRCUIT_PURPOSE_CONTROLLER) + ctf_enum_value("CONTROLLER", CIRCUIT_PURPOSE_CONTROLLER)
2020-10-26Merge remote-tracking branch 'tor-gitlab/mr/169' into masterGeorge Kadianakis
2020-10-13Make OptimisticData always-on.Nick Mathewson
We've been using it for years, and it seems to work just fine. This patch removes the option and its network parameter. Part of #40139
2020-10-12Pass the SOCKS request address in relay begin cellsNeel Chauhan
2020-07-24Don't let a bad IPv6 orport stop our IPv4 bandwidth test.Nick Mathewson
Specifically: do not close IPv4 bandwidth-testing circuits just because our IPv6 orport is unreachable. Attempted fix for #40068.
2020-07-16Collapse channel_get_*_remote_addr() into a single function.Nick Mathewson
Since we can list the real address and the canonical one in a human-readable format we don't need to pick.
2020-07-08trace: Helper macro to disambiguate identifiersDavid Goulet
In order to disambiguate the subsystem and event_name identifiers in the tor_trace() macro, add TR_SUBSYS() and TR_EV() which help to identify the parameters of tor_trace() explicitly. Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-08trace: Add four generic circuit tracepointsDavid Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-08trace: Add four more circuit subsystem tracepointsDavid Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-08trace: Add single tracepoint in circuit subsystemDavid Goulet
This is the very first tracepoint in tor. It is in the circuit subsystem for when a new circuit opens. LTTng instrumentation requires lot more around a tracepoint than USDT thus this commit only adds one tracepoint in order to outline a base to add more tracepoints later. The idea is that we separate subsystem into what LTTng defines as "providers" so the circuit provider contains the tracepoint definitions for the circuit subsystem. Signed-off-by: David Goulet <dgoulet@torproject.org> Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-02Add a function for comparing the orport on an extendinfo.Nick Mathewson
2020-07-02Extract extend_info manipulation functions into a new file.Nick Mathewson
2020-06-24Rename router_should_skip_orport_reachability_check.Nick Mathewson
This was supposed to happen in #40012, but the command line was wrong. This is an automated commit, generated by this command: ./scripts/maint/rename_c_identifier.py \ router_should_skip_orport_reachability_check router_all_orports_seem_reachable
2020-06-09Merge remote-tracking branch 'tor-github/pr/1888/head'Nick Mathewson
2020-05-11circuit: Add flags for IPv6 extendsteor
But don't implement the actual node selection yet. Part of 33226.
2020-05-07Wrap long linesteor
2020-05-07Replace several C identifiers.teor
This is an automated commit, generated by this command: ./scripts/maint/rename_c_identifier.py \ router_skip_orport_reachability_check router_should_skip_orport_reachability_check \ router_skip_dirport_reachability_check router_should_skip_dirport_reachability_check \ router_connect_assume_or_reachable client_or_conn_should_skip_reachable_address_check \ router_connect_assume_dir_reachable client_dir_conn_should_skip_reachable_address_check It was generated with --no-verify, so it probably breaks some commit hooks. The commiter should be sure to fix them up in a subsequent commit.
2020-05-06Merge branch 'maint-0.4.3'Nick Mathewson
Amazingly, this time we had no merge conflicts with "falls through" comments.
2020-05-06Use __attribute__((fallthrough)) rather than magic GCC comments.Nick Mathewson
GCC added an implicit-fallthrough warning a while back, where it would complain if you had a nontrivial "case:" block that didn't end with break, return, or something like that. Clang recently added the same thing. GCC, however, would let you annotate a fall-through as intended by any of various magic "/* fall through */" comments. Clang, however, only seems to like "__attribute__((fallthrough))". Fortunately, GCC accepts that too. A previous commit in this branch defined a FALLTHROUGH macro to do the right thing if GNUC is defined; here we replace all of our "fall through" comments with uses of that macro. This is an automated commit, made with the following perl one-liner: #!/usr/bin/perl -i -p s#/\* *falls? ?thr.*?\*/#FALLTHROUGH;#i; (In order to avoid conflicts, I'm applying this script separately to each maint branch. This is the 0.4.3 version.)
2020-05-06Use __attribute__((fallthrough)) rather than magic GCC comments.Nick Mathewson
GCC added an implicit-fallthrough warning a while back, where it would complain if you had a nontrivial "case:" block that didn't end with break, return, or something like that. Clang recently added the same thing. GCC, however, would let you annotate a fall-through as intended by any of various magic "/* fall through */" comments. Clang, however, only seems to like "__attribute__((fallthrough))". Fortunately, GCC accepts that too. A previous commit in this branch defined a FALLTHROUGH macro to do the right thing if GNUC is defined; here we replace all of our "fall through" comments with uses of that macro. This is an automated commit, made with the following perl one-liner: #!/usr/bin/perl -i -p s#/\* *falls? ?thr.*?\*/#FALLTHROUGH;#i;
2020-05-05core/or: Lift slow call out of loop, #33977Alex Xu (Hello71)