This is an automated email from the git hooks/post-receive script.
dgoulet pushed a commit to branch main in repository tor.
commit dbd37c0e7bb872208d4282d58f5b66d2fced781f Author: Mike Perry mikeperry-git@torproject.org AuthorDate: Sat Jun 10 16:00:56 2023 +0000
Bug 40810: Improve validation checks to ignore 0-RTT legs
Also add calls to dump the legs of a conflux set if we have too many --- src/core/or/conflux_util.c | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-)
diff --git a/src/core/or/conflux_util.c b/src/core/or/conflux_util.c index 855d477428..589db41e83 100644 --- a/src/core/or/conflux_util.c +++ b/src/core/or/conflux_util.c @@ -20,6 +20,7 @@ #include "core/or/conflux.h" #include "core/or/conflux_params.h" #include "core/or/conflux_util.h" +#include "core/or/conflux_pool.h" #include "core/or/conflux_st.h" #include "lib/time/compat_time.h" #include "app/config/config.h" @@ -372,22 +373,39 @@ void conflux_validate_legs(const conflux_t *cfx) { tor_assert(cfx); - // TODO-329-UDP: Eventually we want to allow three legs for the - // exit case, to allow reconnection of legs to hit an RTT target. - // For now, this validation helps find bugs. - if (BUG(smartlist_len(cfx->legs) > conflux_params_get_num_legs_set())) { - log_warn(LD_BUG, "Number of legs is above maximum of %d allowed: %d\n", - conflux_params_get_num_legs_set(), smartlist_len(cfx->legs)); - } - + bool is_client = false; + int num_legs = 0; CONFLUX_FOR_EACH_LEG_BEGIN(cfx, leg) { - /* Ensure we have no pending nonce on the circ */ - tor_assert_nonfatal(leg->circ->conflux_pending_nonce == NULL); - tor_assert_nonfatal(leg->circ->conflux != NULL); - if (CIRCUIT_IS_ORIGIN(leg->circ)) { tor_assert_nonfatal(leg->circ->purpose == CIRCUIT_PURPOSE_CONFLUX_LINKED); + is_client = true; + } + + /* Ensure we have no pending nonce on the circ */ + if (BUG(leg->circ->conflux_pending_nonce != NULL)) { + conflux_log_set(cfx, is_client); + continue; + } + + /* Ensure we have a conflux object */ + if (BUG(leg->circ->conflux == NULL)) { + conflux_log_set(cfx, is_client); + continue; + } + + /* Only count legs that have a valid RTT */ + if (leg->circ_rtts_usec > 0) { + num_legs++; } } CONFLUX_FOR_EACH_LEG_END(leg); + + // TODO-329-UDP: Eventually we want to allow three legs for the + // exit case, to allow reconnection of legs to hit an RTT target. + // For now, this validation helps find bugs. + if (BUG(num_legs > conflux_params_get_num_legs_set())) { + log_warn(LD_BUG, "Number of legs is above maximum of %d allowed: %d\n", + conflux_params_get_num_legs_set(), smartlist_len(cfx->legs)); + conflux_log_set(cfx, is_client); + } }