summaryrefslogtreecommitdiff
path: root/src/test/test_channel.c
AgeCommit message (Collapse)Author
2020-04-29relay/circuitbuild: Re-use IPv6 connections for circuitsteor
Search for existing connections using the remote IPv4 and IPv6 addresses. Part of 33817.
2020-04-15test/channel: Fix a comment typoteor
2020-01-14Merge branch 'ticket32892_043_01_squashed'Nick Mathewson
2020-01-14chan: Remove dead var cell handler from channel_tDavid Goulet
The variable lenght cells are handled directly by channel_tls_handle_var_cell() from an OR connection reading its inbuf. The channel var cell handler (agnostic) was never used. Closes #32892 Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-01-08It's 2020. Update the copyright dates with "make update-copyright"Nick Mathewson
2019-12-20Replace several C identifiers.teor
This is an automated commit, generated by this command: ./scripts/maint/rename_c_identifier.py \ EXPOSE_CLEAN_BACKTRACE BACKTRACE_PRIVATE \ TOR_CHANNEL_INTERNAL_ CHANNEL_OBJECT_PRIVATE \ CHANNEL_PRIVATE_ CHANNEL_FILE_PRIVATE \ EXPOSE_ROUTERDESC_TOKEN_TABLE ROUTERDESC_TOKEN_TABLE_PRIVATE \ SCHEDULER_PRIVATE_ SCHEDULER_PRIVATE
2019-05-16test_channel_listener: free 'chan' explicitlyNick Mathewson
This should fix CID 1437442, where coverity can't tell that channel_free_all() frees the fake channel we allocated.
2019-03-14circ: Remove n_mux and p_mux membersDavid Goulet
They are simply not used apart from assigning a pointer and asserting on the pointer depending on the cell direction. Closes #29196. Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-01-16Bump copyright date to 2019Nick Mathewson
2018-07-05Fix every include path changed in the previous commit (automated)Nick Mathewson
I am very glad to have written this script.
2018-07-03Replace U64_LITERAL with the standard UINT64_CNick Mathewson
2018-06-21Rectify include paths (automated)Nick Mathewson
2018-06-20Run rectify_include_paths.pyNick Mathewson
2018-06-20Update copyrights to 2018.Nick Mathewson
2018-06-15Extract cell type and their queues into new headersNick Mathewson
Since packed_cell and destroy_cell exist only to be queued, they go in the same headers as the queues.
2018-06-15Extract routerstatus_t into its own header.Nick Mathewson
2018-06-15Extract networkstatus_t and ..sr_info_t into their own headersNick Mathewson
2018-06-15Extract {or,origin}_circuit_t into their own headersNick Mathewson
2018-05-11Merge remote-tracking branch 'public/bug25994'Nick Mathewson
2018-05-03Merge remote-tracking branch 'isis/bug24660_r1'Nick Mathewson
2018-05-01Hold monotonic time constant during channel/outbound_cell testNick Mathewson
This change should make it impossible for the monotonic time to roll over from one EWMA tick to the next during this test, and make it so that this test never invokes scale_active_circuits() (which it doesn't test). (Earlier changes during the 0.3.4 series should make this call even rarer than it was before, since we fixed #25927 and removed cached_gettimeofday. Because this test didn't update cached_gettimeofday, the chance of rolling over a 10-second interval was much higher.) Closes ticket 25994; bugfix on 0.3.3.1-alpha when this test was introduced.
2018-04-26Rewrite time-handling in circuitmux_ewma to use monotime_coarseNick Mathewson
This part of the code was the only part that used "cached getttimeofday" feature, which wasn't monotonic, which we updated at slight expense, and which I'd rather not maintain.
2018-04-06crypto: Refactor (P)RNG functionality into new crypto_rand module.Isis Lovecruft
* ADD new /src/common/crypto_rand.[ch] module. * ADD new /src/common/crypto_util.[ch] module (contains the memwipe() function, since all crypto_* modules need this). * FIXES part of #24658: https://bugs.torproject.org/24658
2018-02-15cmux: Remove round-robin circuit policyDavid Goulet
Since 0.2.4, tor uses EWMA circuit policy to prioritize. The previous algorithm, round-robin, hasn't been used since then but was still used as a fallback. Now that EWMA is mandatory, remove that code entirely and enforce a cmux policy to be set. This is part of a circuitmux cleanup to improve performance and reduce complexity in the code. We'll be able to address future optimization with this work. Closes #25268 Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-02-15cmux: Make EWMA policy mandatoryDavid Goulet
To achieve this, a default value for the CircuitPriorityHalflife option was needed. We still look in the options and then the consensus but in case no value can be found, the default CircuitPriorityHalflifeMsec=30000 is used. It it the value we've been using since 0.2.4.4-alpha. This means that EWMA, our only policy, can not be disabled anymore fallbacking to the round robin algorithm. Unneeded code to control that is removed in this commit. Part of #25268 Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-12-21Fix a compilation error in the channel tests.Nick Mathewson
This would only show up on systems like windows where monotime_t and monotime_coarse_t are different types.
2017-12-13Use monotime_coarse for transfer times and padding timesNick Mathewson
Using absolute_msec requires a 64-bit division operation every time we calculate it, which gets expensive on 32-bit architectures. Instead, just use the lazy "monotime_coarse_get()" operation, and don't convert to milliseconds until we absolutely must. In this case, it seemed fine to use a full monotime_coarse_t rather than a truncated "stamp" as we did to solve this problem for the timerstamps in buf_t and packed_cell_t: There are vastly more cells and buffer chunks than there are channels, and using 16 bytes per channel in the worst case is not a big deal. There are still more millisecond operations here than strictly necessary; let's see any divisions show up in profiles.
2017-12-08Merge branch 'macro_free_v2_squashed'Nick Mathewson
2017-12-08Convert remaining function (mostly static) to new free styleNick Mathewson
2017-12-08test: Make older GCC happy and thus our oniongit pipelineDavid Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-12-08chan: Do not re-queue after a fail cell writeDavid Goulet
Couple things happen in this commit. First, we do not re-queue a cell back in the circuit queue if the write packed cell failed. Currently, it is close to impossible to have it failed but just in case, the channel is mark as closed and we move on. The second thing is that the channel_write_packed_cell() always took ownership of the cell whatever the outcome. This means, on success or failure, it needs to free it. It turns out that that we were using the wrong free function in one case and not freeing it in an other possible code path. So, this commit makes sure we only free it in one place that is at the very end of channel_write_packed_cell() which is the top layer of the channel abstraction. This makes also channel_tls_write_packed_cell_method() return a negative value on error. Two unit tests had to be fixed (quite trivial) due to a double free of the packed cell in the test since now we do free it in all cases correctly. Part of #23709 Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-11-22test: Cleanup unused code in test_channel.cDavid Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-11-22test: Add unit test for channel_listener_tDavid Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-11-22test: Add unit test for channel_get_for_extend()David Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-11-22test: Add unit test for channel_check_for_duplicates()David Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-11-22test: Add channel state unit testDavid Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-11-22test: Fix channel dumpstats testDavid Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-11-22test: Fix channel lifecycle and lifecycle_2David Goulet
They were broken due to previous commit. Fixes are trivial. Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-11-22test: Add outbound channel cell testDavid Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-11-22test: Improve the inbound channel cell testDavid Goulet
First, that test was broken from the previous commit because the channel_queue_cell() has been removed. This now tests the channel_process_cell() directly. Second, it wasn't testing much except if the channel subsystem actually went through the cell handler. This commit adds more checks on the state of a channel going from open, receiving a cell and closing. Third, this and the id_map unit test are working, not the others so they've been marked as not working and future commit will improve and fix those. Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-11-22channel: Remove unused write cell functionsDavid Goulet
The channel_write_cell() and channel_write_var_cell() can't be possibly called nor are used by tor. We only write on the connection outbuf packed cell coming from the scheduler that takes them from the circuit queue. This makes channel_write_packed_cell() the only usable function. It is simplify and now returns a code value. The reason for this is that in the next commit(s), we'll re-queue the cell onto the circuit queue if the write fails. Finally, channel unit tests are being removed with this commit because they do not match the new semantic. They will be re-written in future commits. Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-11-22channel: Remove everything related to queue sizeDavid Goulet
The channel subsystem was doing a whole lot to track and try to predict the channel queue size but they are gone due to previous commit. Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-11-22channel: Remove incoming/outgoing queueDavid Goulet
For the rationale, see ticket #23709. This is a pretty massive commit. Those queues were everywhere in channel.c and it turns out that it was used by lots of dead code. The channel subsystem *never* handles variable size cell (var_cell_t) or unpacked cells (cell_t). The variable ones are only handled in channeltls and outbound cells are always packed from the circuit queue so this commit removes code related to variable and unpacked cells. However, inbound cells are unpacked (cell_t), that is untouched and is handled via channel_process_cell() function. In order to make the commit compile, test have been modified but not passing at this commit. Also, many tests have been removed but better improved ones get added in future commits. This commit also adds a XXX: which indicates that the handling process of outbound cells isn't fully working. This as well is fixed in a future commit. Finally, at this commit, more dead code remains, it will be cleanup in future commits. Fixes #23709 Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24Ensure that `make check-spaces` is happy.Alexander Færøy
The `test-operator-cleanup` patch, and related coccinelle patches, don't do any checks for line length. This patch fixes the line length issues caused by the previous commits.
2017-08-24apply ahf's test_assert_null.cocciNick Mathewson
2017-08-24apply ahf's test_assert_int.cocciNick Mathewson
2017-08-24Fix operator usage in src/test/*.cAlexander Færøy
This patch fixes the operator usage in src/test/*.c to use the symbolic operators instead of the normal C comparison operators. This patch was generated using: ./scripts/coccinelle/test-operator-cleanup src/test/*.[ch]
2017-06-21Extract channel_do_open_actions() from non-open _change_state casesNick Mathewson
This reduces the size of the largest SCC in the callgraph by 30 functions, from 58 to 28.
2017-03-15Run the copyright update script.Nick Mathewson
2016-12-08Fix a completely stupid stack-protector warning in test_channels.cNick Mathewson
This was breaking the build on debian precise, since it thought that using a 'const int' to dimension an array made that array variable-size, and made us not get protection. Bug not in any released version of Tor. I will insist that this one wasn't my fault. "Variables won't. Constants aren't." -- Osborn's Law