[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor] 02/10: Add conflux logs to diagnose cases where RTTs are absent/zero.
This is an automated email from the git hooks/post-receive script.
dgoulet pushed a commit to branch main
in repository tor.
commit 176f0929bb3c8ffe2765fc47a24ee44a66ffd217
Author: Mike Perry <mikeperry-git@xxxxxxxxxxxxxx>
AuthorDate: Thu Mar 30 23:43:34 2023 +0000
Add conflux logs to diagnose cases where RTTs are absent/zero.
---
src/core/or/conflux.c | 8 +++++++-
src/core/or/conflux_pool.c | 50 ++++++++++++++++++++++++++++++++++++++++------
2 files changed, 51 insertions(+), 7 deletions(-)
diff --git a/src/core/or/conflux.c b/src/core/or/conflux.c
index 5f6af9268b..3330de81ba 100644
--- a/src/core/or/conflux.c
+++ b/src/core/or/conflux.c
@@ -21,6 +21,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 "core/or/conflux_cell.h"
#include "lib/time/compat_time.h"
@@ -548,11 +549,16 @@ conflux_pick_first_leg(conflux_t *cfx)
}
} CONFLUX_FOR_EACH_LEG_END(leg);
- if (BUG(!min_leg)) {
+ if (!min_leg) {
// Get the 0th leg; if it does not exist, assert
tor_assert(smartlist_len(cfx->legs) > 0);
min_leg = smartlist_get(cfx->legs, 0);
tor_assert(min_leg);
+ if (BUG(min_leg->linked_sent_usec == 0)) {
+ log_warn(LD_BUG, "Conflux has no legs with non-zero RTT. "
+ "Using first leg.");
+ conflux_log_set(cfx, CIRCUIT_IS_ORIGIN(min_leg->circ));
+ }
}
// TODO-329-TUNING: We may want to initialize this to a cwnd, to
diff --git a/src/core/or/conflux_pool.c b/src/core/or/conflux_pool.c
index 53985df810..7e38e151a8 100644
--- a/src/core/or/conflux_pool.c
+++ b/src/core/or/conflux_pool.c
@@ -822,10 +822,29 @@ record_rtt_client(const circuit_t *circ)
tor_assert(CIRCUIT_IS_ORIGIN(circ));
leg_t *leg = unlinked_leg_find(circ, true);
- if (leg && leg->link_sent_usec > 0) {
- leg->rtt_usec = monotime_absolute_usec() - leg->link_sent_usec;
- return leg->rtt_usec;
+
+ if (BUG(!leg || leg->link_sent_usec == 0)) {
+ log_warn(LD_BUG,
+ "Conflux: Trying to record client RTT without a timestamp");
+ goto err;
+ }
+
+ uint64_t now = monotime_absolute_usec();
+ tor_assert_nonfatal(now >= leg->link_sent_usec);
+ leg->rtt_usec = now - leg->link_sent_usec;
+ if (leg->rtt_usec == 0) {
+ log_warn(LD_CIRC, "Clock appears stalled for conflux.");
+ // TODO-329-TUNING: For now, let's accept this case. We need to do
+ // tuning and clean up the tests such that they use RTT in order to
+ // fail here.
+ //goto err;
}
+ return leg->rtt_usec;
+
+ err:
+ // Avoid using this leg until a timestamp comes in
+ if (leg)
+ leg->rtt_usec = UINT64_MAX;
return UINT64_MAX;
}
@@ -842,10 +861,26 @@ record_rtt_exit(const circuit_t *circ)
tor_assert(CIRCUIT_IS_ORCIRC(circ));
conflux_leg_t *leg = conflux_get_leg(circ->conflux, circ);
- if (leg && leg->linked_sent_usec > 0) {
- leg->circ_rtts_usec = monotime_absolute_usec() - leg->linked_sent_usec;
- return leg->circ_rtts_usec;
+
+ if (BUG(!leg || leg->linked_sent_usec == 0)) {
+ log_warn(LD_BUG,
+ "Conflux: Trying to record exit RTT without a timestamp");
+ goto err;
}
+
+ uint64_t now = monotime_absolute_usec();
+ tor_assert_nonfatal(now >= leg->linked_sent_usec);
+ leg->circ_rtts_usec = now - leg->linked_sent_usec;
+
+ if (leg->circ_rtts_usec == 0) {
+ log_warn(LD_CIRC, "Clock appears stalled for conflux.");
+ goto err;
+ }
+ return leg->circ_rtts_usec;
+
+ err:
+ if (leg)
+ leg->circ_rtts_usec = UINT64_MAX;
return UINT64_MAX;
}
@@ -863,6 +898,9 @@ record_rtt(const circuit_t *circ, bool is_client)
if (is_client) {
rtt_usec = record_rtt_client(circ);
+ if (rtt_usec == UINT64_MAX)
+ return false;
+
if (rtt_usec >= get_circuit_build_timeout_ms()*1000) {
log_info(LD_CIRC, "Conflux leg RTT is above circuit build time out "
"currently at %f msec. Relaunching.",
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits