Commit 80031db3 authored by Nick Mathewson's avatar Nick Mathewson 🤹
Browse files

Merge remote-tracking branch 'tor-github/pr/1801/head'

parents 11fbd1f0 75aba30a
Loading
Loading
Loading
Loading

changes/ticket33633

0 → 100644
+6 −0
Original line number Diff line number Diff line
  o Code simplification and refactoring:
    - Move the circuit extend code to the relay module.
      Split the circuit extend function into smaller functions.
      Closes ticket 33633.
    - Move LOG_PROTOCOL_WARN to app/config.c. Resolves a dependency inversion.
      Closes ticket 33633.
+7 −8
Original line number Diff line number Diff line
@@ -83,9 +83,9 @@ problem dependency-violation /src/core/mainloop/netstatus.c 4
problem dependency-violation /src/core/mainloop/periodic.c 2
problem dependency-violation /src/core/or/address_set.c 1
problem dependency-violation /src/core/or/cell_queue_st.h 1
problem file-size /src/core/or/channel.c 3464
problem file-size /src/core/or/channel.c 3500
problem dependency-violation /src/core/or/channel.c 9
problem file-size /src/core/or/channel.h 775
problem file-size /src/core/or/channel.h 800
problem dependency-violation /src/core/or/channel.h 1
problem dependency-violation /src/core/or/channelpadding.c 6
problem function-size /src/core/or/channeltls.c:channel_tls_handle_var_cell() 160
@@ -94,9 +94,8 @@ problem function-size /src/core/or/channeltls.c:channel_tls_process_netinfo_cell
problem function-size /src/core/or/channeltls.c:channel_tls_process_certs_cell() 246
problem function-size /src/core/or/channeltls.c:channel_tls_process_authenticate_cell() 202
problem dependency-violation /src/core/or/channeltls.c 11
problem include-count /src/core/or/circuitbuild.c 54
problem include-count /src/core/or/circuitbuild.c 53
problem function-size /src/core/or/circuitbuild.c:get_unique_circ_id_by_chan() 128
problem function-size /src/core/or/circuitbuild.c:circuit_extend() 147
problem function-size /src/core/or/circuitbuild.c:choose_good_exit_server_general() 206
problem dependency-violation /src/core/or/circuitbuild.c 25
problem include-count /src/core/or/circuitlist.c 55
@@ -129,7 +128,7 @@ problem function-size /src/core/or/circuituse.c:connection_ap_handshake_attach_c
problem dependency-violation /src/core/or/circuituse.c 24
problem function-size /src/core/or/command.c:command_process_create_cell() 156
problem function-size /src/core/or/command.c:command_process_relay_cell() 132
problem dependency-violation /src/core/or/command.c 8
problem dependency-violation /src/core/or/command.c 9
problem file-size /src/core/or/connection_edge.c 4655
problem include-count /src/core/or/connection_edge.c 65
problem function-size /src/core/or/connection_edge.c:connection_ap_expire_beginning() 117
@@ -147,7 +146,7 @@ problem function-size /src/core/or/connection_or.c:connection_or_client_learned_
problem dependency-violation /src/core/or/connection_or.c 21
problem dependency-violation /src/core/or/dos.c 6
problem dependency-violation /src/core/or/onion.c 2
problem file-size /src/core/or/or.h 1107
problem file-size /src/core/or/or.h 1105
problem include-count /src/core/or/or.h 48
problem dependency-violation /src/core/or/or.h 1
problem dependency-violation /src/core/or/or_periodic.c 1
@@ -156,7 +155,7 @@ problem function-size /src/core/or/policies.c:policy_summarize() 107
problem dependency-violation /src/core/or/policies.c 14
problem function-size /src/core/or/protover.c:protover_all_supported() 117
problem dependency-violation /src/core/or/reasons.c 2
problem file-size /src/core/or/relay.c 3264
problem file-size /src/core/or/relay.c 3300
problem function-size /src/core/or/relay.c:circuit_receive_relay_cell() 127
problem function-size /src/core/or/relay.c:relay_send_command_from_edge_() 109
problem function-size /src/core/or/relay.c:connection_ap_process_end_not_open() 192
@@ -164,7 +163,7 @@ problem function-size /src/core/or/relay.c:connection_edge_process_relay_cell_no
problem function-size /src/core/or/relay.c:handle_relay_cell_command() 369
problem function-size /src/core/or/relay.c:connection_edge_package_raw_inbuf() 128
problem function-size /src/core/or/relay.c:circuit_resume_edge_reading_helper() 146
problem dependency-violation /src/core/or/relay.c 16
problem dependency-violation /src/core/or/relay.c 17
problem dependency-violation /src/core/or/scheduler.c 1
problem function-size /src/core/or/scheduler_kist.c:kist_scheduler_run() 171
problem dependency-violation /src/core/or/scheduler_kist.c 2
+2 −0
Original line number Diff line number Diff line
@@ -42,6 +42,8 @@ const char *escaped_safe_str(const char *address);
void init_protocol_warning_severity_level(void);
int get_protocol_warning_severity_level(void);

#define LOG_PROTOCOL_WARN (get_protocol_warning_severity_level())

/** An error from options_trial_assign() or options_init_from_string(). */
typedef enum setopt_err_t {
  SETOPT_OK = 0,
+1 −1
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@
 **/
#include "core/or/or.h"
#include "core/or/channel.h"
#include "core/or/circuitbuild.h"
#include "core/or/circuitlist.h"
#include "core/or/connection_or.h"
#include "app/config/config.h"
@@ -27,6 +26,7 @@
#include "lib/crypt_ops/crypto_rand.h"
#include "lib/crypt_ops/crypto_util.h"
#include "core/or/onion.h"
#include "feature/relay/circuitbuild_relay.h"
#include "feature/relay/onion_queue.h"
#include "feature/stats/rephist.h"
#include "feature/relay/router.h"
+19 −18
Original line number Diff line number Diff line
@@ -2359,19 +2359,22 @@ channel_is_better(channel_t *a, channel_t *b)
/**
 * Get a channel to extend a circuit.
 *
 * Pick a suitable channel to extend a circuit to given the desired digest
 * the address we believe is correct for that digest; this tries to see
 * if we already have one for the requested endpoint, but if there is no good
 * channel, set *msg_out to a message describing the channel's state
 * and our next action, and set *launch_out to a boolean indicated whether
 * the caller should try to launch a new channel with channel_connect().
 */
channel_t *
channel_get_for_extend(const char *rsa_id_digest,
 * Given the desired relay identity, pick a suitable channel to extend a
 * circuit to the target address requsted by the client. Search for an
 * existing channel for the requested endpoint. Make sure the channel is
 * usable for new circuits, and matches the target address.
 *
 * Try to return the best channel. But if there is no good channel, set
 * *msg_out to a message describing the channel's state and our next action,
 * and set *launch_out to a boolean indicated whether the caller should try to
 * launch a new channel with channel_connect().
 */
MOCK_IMPL(channel_t *,
channel_get_for_extend,(const char *rsa_id_digest,
                        const ed25519_public_key_t *ed_id,
                        const tor_addr_t *target_addr,
                        const char **msg_out,
                       int *launch_out)
                        int *launch_out))
{
  channel_t *chan, *best = NULL;
  int n_inprogress_goodaddr = 0, n_old = 0;
@@ -2382,9 +2385,7 @@ channel_get_for_extend(const char *rsa_id_digest,

  chan = channel_find_by_remote_identity(rsa_id_digest, ed_id);

  /* Walk the list, unrefing the old one and refing the new at each
   * iteration.
   */
  /* Walk the list of channels */
  for (; chan; chan = channel_next_with_rsa_identity(chan)) {
    tor_assert(tor_memeq(chan->identity_digest,
                         rsa_id_digest, DIGEST_LEN));
@@ -2819,8 +2820,8 @@ channel_get_actual_remote_address(channel_t *chan)
 * Subsequent calls to channel_get_{actual,canonical}_remote_{address,descr}
 * may invalidate the return value from this function.
 */
const char *
channel_get_canonical_remote_descr(channel_t *chan)
MOCK_IMPL(const char *,
channel_get_canonical_remote_descr,(channel_t *chan))
{
  tor_assert(chan);
  tor_assert(chan->get_remote_descr);
Loading