aboutsummaryrefslogtreecommitdiff
path: root/src/core/or/relay.c
AgeCommit message (Collapse)Author
2020-07-02Extract extend_info manipulation functions into a new file.Nick Mathewson
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-04-30net: Make all address bytes functions take uint8_t *teor
Part of 33817.
2020-03-20relay: Split out relay-only circuit buildingteor
Move the relay-only circuit building functions into a new file. Part of 33633.
2020-01-08It's 2020. Update the copyright dates with "make update-copyright"Nick Mathewson
2019-08-08Move the connection_edge_process_relay_cell() assignments out of if ↵Neel
statements in circuit_receive_relay_cell()
2019-08-08Merge branch 'tor-github/pr/1183'David Goulet
2019-08-05Rename handle_relay_command to handle_relay_cell_command .George Kadianakis
As per David's review.
2019-08-05Test that regular cells get ignored in padding circuits.George Kadianakis
2019-08-05Ignore regular cells in padding circuits.George Kadianakis
Padding circuits were regular cells that got closed before their padding machine could finish. This means that they can still receive regular cells from their past life, but they have no way or reason to answer them anymore. Hence let's ignore them before they even get to the proper subsystems.
2019-08-05Split connection_edge_process_relay_cell() in two functions.George Kadianakis
One function does the validation, the other does the handling.
2019-08-05Ignore regular cells in padding circuits.George Kadianakis
Padding circuits were regular cells that got closed before their padding machine could finish. This means that they can still receive regular cells from their past life, but they have no way or reason to answer them anymore. Hence let's ignore them before they even get to the proper subsystems.
2019-07-19Space out first connection_edge_process_relay_cell() line in ↵Neel Chauhan
circuit_receive_relay_cell()
2019-05-27Tests for deciding how full our relay cells should beNick Mathewson
2019-05-27Make sure that we send at least some random data in RELAY_DATA cellsNick Mathewson
Proposal 289 prevents SENDME-flooding by requiring the other side to authenticate the data it has received. But this data won't actually be random if they are downloading a known resource. "No problem", we said, "let's fell the empty parts of our cells with some randomness!" and we did that in #26871. Unfortunately, if the relay data payloads are all completely full, there won't be any empty parts for us to randomize. Therefore, we now pick random "randomness windows" between CIRCWINDOW_INCREMENT/2 and CIRCWINDOW_INCREMENT. We remember whether we have sent a cell containing at least 16 bytes of randomness in that window. If we haven't, then when the window is exhausted, we send one. (This window approach is designed to lower the number of rng checks we have to do. The number 16 is pulled out of a hat to change the attacker's guessing difficulty to "impossible".) Implements 28646.
2019-05-23Extract length-deciding function from package_raw_inbuf.Nick Mathewson
2019-05-23refactor logic to decide how much to package from inbufRoger Dingledine
no actual changes in behavior
2019-05-22Merge branch 'ticket30428_041_02_squashed'Nick Mathewson
2019-05-22sendme: Properly record SENDMEs on both edgesDavid Goulet
Turns out that we were only recording the "b_digest" but to have bidirectionnal authenticated SENDMEs, we need to use the "f_digest" in the forward cell situation. Because of the cpath refactoring, this commit plays with the crypt_path_ and relay_crypto_t API a little bit in order to respect the abstractions. Previously, we would record the cell digest as the SENDME digest in the decrypt cell function but to avoid code duplication (both directions needs to record), we now do that right after iff the cell is recognized (at the edge). It is now done in circuit_receive_relay_cell() instead. We now also record the cell digest as the SENDME digest in both relay cell encryption functions since they are split depending on the direction. relay_encrypt_cell_outbound() and relay_encrypt_cell_inbound() need to consider recording the cell digest depending on their direction (f vs b digest). Fixes #30428 Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-05-22sendme: Record cell digest on both client and exitDavid Goulet
It turns out that only the exit side is validating the authenticated SENDME v1 logic and never the client side. Which means that if a client ever uploaded data towards an exit, the authenticated SENDME logic wouldn't apply. For this to work, we have to record the cell digest client side as well which introduced a new function that supports both type of edges. This also removes a test that is not valid anymore which was that we didn't allow cell recording on an origin circuit (client). Part of #30428 Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-05-15fix typos, whitespace, commentsRoger Dingledine
2019-05-13Merge remote-tracking branch 'tor-github/pr/998'Nick Mathewson
2019-05-01Bug 29231: Report correct padding write totals and enabled totals.Mike Perry
2019-04-29sendme: Better function namesDavid Goulet
From nickm's review, improve the names of some functions. Part of #26288 Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-04-29sendme: Better handle the random paddingDavid Goulet
We add random padding to every cell if there is room. This commit not only fixes how we compute that random padding length/offset but also improves its safety with helper functions and a unit test. Part of #26288 Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-04-29prop289: Skip the first 4 unused bytes in a cellDavid Goulet
When adding random to a cell, skip the first 4 bytes and leave them zeroed. It has been very useful in the past for us to keep bytes like this. Some code trickery was added to make sure we have enough room for this 4 bytes offset when adding random. Part of #26288 Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-04-29prop289: Rename packaged functions with better nameDavid Goulet
The circuit and stream level functions that update the package window have been renamed to have a "_note_" in them to make their purpose more clear. Part of #26288 Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-04-29prop289: Move SENDME cell processing in a separate functionDavid Goulet
No behavior change. Only moving code and fixing part of it in order to use the parameters passed as pointers. Part of #26288 Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-04-29prop289: Add random bytes to the unused portion of the cellDavid Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-04-29prop289: Remember the last cell digest for v1 SENDMEsDavid Goulet
In order to do so, depending on where the cell is going, we'll keep the last cell digest that is either received inbound or sent outbound. Then it can be used for validation. Part of #26288 Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-04-29prop289: Keep track of the last seen cell digestsDavid Goulet
This makes tor remember the last seen digest of a cell if that cell is the last one before a SENDME on the Exit side. Closes #26839 Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-04-29prop289: Support SENDME v1 cell parsingDavid Goulet
This commit makes tor able to parse and handle a SENDME version 1. It will look at the consensus parameter "sendme_accept_min_version" to know what is the minimum version it should look at. IMPORTANT: At this commit, the validation of the cell is not fully implemented. For this, we need #26839 to be completed that is to match the SENDME digest with the last cell digest. Closes #26841 Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-04-29prop289: Support sending SENDME version 1David Goulet
This code will obey the consensus parameter "sendme_emit_min_version" to know which SENDME version it should send. For now, the default is 0 and the parameter is not yet used in the consensus. This commit adds the support to send version 1 SENDMEs but aren't sent on the wire at this commit. Closes #26840 Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-04-29sendme: Always close stream if deliver window is negativeDavid Goulet
Previously, we would only close the stream when our deliver window was negative at the circuit-level but _not_ at the stream-level when receiving a DATA cell. This commit adds an helper function connection_edge_end_close() which sends an END and then mark the stream for close for a given reason. That function is now used both in case the deliver window goes below zero for both circuit and stream level. Part of #26840 Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-04-29sendme: Add helper functions for DATA cell packagingDavid Goulet
When we are about to send a DATA cell, we have to decrement the package window for both the circuit and stream level. This commit adds helper functions to handle the package window decrement. Part of #26288 Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-04-29sendme: Add helper functions for DATA cell deliveryDavid Goulet
When we get a relay DATA cell delivered, we have to decrement the deliver window on both the circuit and stream level. This commit adds helper functions to handle the deliver window decrement. Part of #26840 Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-04-29sendme: Refactor SENDME cell processingDavid Goulet
This is a bit of a complicated commit. It moves code but also refactors part of it. No behavior change, the idea is to split things up so we can better handle and understand how SENDME cells are processed where ultimately it will be easier to handle authenticated SENDMEs (prop289) using the intermediate functions added in this commit. The entry point for the cell arriving at the edge (Client or Exit), is connection_edge_process_relay_cell() for which we look if it is a circuit or stream level SENDME. This commit refactors that part where two new functions are introduced to process each of the SENDME types. The sendme_process_circuit_level() has basically two code paths. If we are a Client (the circuit is origin) or we are an Exit. Depending on which, the package window is updated accordingly. Then finally, we resume the reading on every edge streams on the circuit. The sendme_process_stream_level() applies on the edge connection which will update the package window if needed and then will try to empty the inbuf if need be because we can now deliver more cells. Again, no behavior change but in order to split that code properly into their own functions and outside the relay.c file, code modification was needed. Part of #26840. Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-04-29sendme: Move code to the new files sendme.{c|h}David Goulet
Take apart the SENDME cell specific code and put it in sendme.{c|h}. This is part of prop289 that implements authenticated SENDMEs. Creating those new files allow for the already huge relay.c to not grow in LOC and makes it easier to handle and test the SENDME cells in an isolated way. This commit only moves code. No behavior change. Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-03-25Split all controller events code into a new control_events.cNick Mathewson
Also, split the formatting code shared by control.c and control_events.c into controller_fmt.c.
2019-02-20Remove all uses of weak_rng.Nick Mathewson
I'm not removing the weak_rng code itself yet, since it is possible that we will want to revert one of these.
2019-01-16Bump copyright date to 2019Nick Mathewson
2019-01-10Misc trivial improvements around circpadding code.George Kadianakis
2019-01-02Add relay crypto mock points for tests.Mike Perry
Co-authored-by: George Kadianakis <desnacked@riseup.net>
2019-01-02Circuit padding cell event callbacks.Mike Perry
These callbacks allow the padding state machines to react to various types of sent and received relay cells. Co-authored-by: George Kadianakis <desnacked@riseup.net>
2019-01-02Circuit padding machine creation events.Mike Perry
These event callbacks allow circuit padding to decide when to attempt to launch and negotiate new padding machines, and when to tear old ones down. Co-authored-by: George Kadianakis <desnacked@riseup.net>
2018-11-14Move buffers.c out of lib/containers to resolve a circularity.Nick Mathewson
2018-10-01Remove routerparse include from files that dont use itNick Mathewson
2018-10-01Move routerparse and parsecommon to their own module.Nick Mathewson
2018-09-27Split geoip from geoip-related stats.Nick Mathewson
This commit just moves the code to two separate files. The geoip code still has a few needless dependencies on core/* and features/*.