summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Perry <mikeperry-git@torproject.org>2023-06-10 16:00:56 +0000
committerMike Perry <mikeperry-git@torproject.org>2023-06-13 18:18:07 +0000
commitdbd37c0e7bb872208d4282d58f5b66d2fced781f (patch)
treecfdecf4c6063be0506de42c1a7f11c5fddd921fc
parent0149c1ff980414fca36c3aa4530ed25daf4e7553 (diff)
downloadtor-dbd37c0e7bb872208d4282d58f5b66d2fced781f.tar.gz
tor-dbd37c0e7bb872208d4282d58f5b66d2fced781f.zip
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
-rw-r--r--src/core/or/conflux_util.c42
1 files 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);
+ }
}