[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor] 02/05: relay: Add the onion_queue_wait_cutoff consensus param



This is an automated email from the git hooks/post-receive script.

dgoulet pushed a commit to branch main
in repository tor.

commit 9c8c7804d535b4248e7e029c969d9a77a54947f6
Author: David Goulet <dgoulet@xxxxxxxxxxxxxx>
AuthorDate: Wed Nov 9 10:29:47 2022 -0500

    relay: Add the onion_queue_wait_cutoff consensus param
    
    Transform the hardcoded value ONIONQUEUE_WAIT_CUTOFF into a consensus
    parameter so we can control it network wide.
    
    Closes #40704
    
    Signed-off-by: David Goulet <dgoulet@xxxxxxxxxxxxxx>
---
 changes/ticket40704             |  4 ++++
 src/feature/relay/onion_queue.c | 19 +++++++++++++++----
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/changes/ticket40704 b/changes/ticket40704
new file mode 100644
index 0000000000..b65e88ea09
--- /dev/null
+++ b/changes/ticket40704
@@ -0,0 +1,4 @@
+  o Minor feature (relay):
+    - Two new consensus parameters are added to control the wait time in queue
+      of the onionskins. One of them is the torrc MaxOnionQueueDelay options
+      which supersedes the consensus parameter. Closes ticket 40704.
diff --git a/src/feature/relay/onion_queue.c b/src/feature/relay/onion_queue.c
index 3c18713a22..5897ee8a48 100644
--- a/src/feature/relay/onion_queue.c
+++ b/src/feature/relay/onion_queue.c
@@ -48,9 +48,6 @@ typedef struct onion_queue_t {
   time_t when_added;
 } onion_queue_t;
 
-/** 5 seconds on the onion queue til we just send back a destroy */
-#define ONIONQUEUE_WAIT_CUTOFF 5
-
 TOR_TAILQ_HEAD(onion_queue_head_t, onion_queue_t);
 typedef struct onion_queue_head_t onion_queue_head_t;
 
@@ -71,6 +68,20 @@ static int ol_entries[MAX_QUEUE_IDX+1];
 static int num_ntors_per_tap(void);
 static void onion_queue_entry_remove(onion_queue_t *victim);
 
+/** Return the onion queue wait cutoff value from the consensus parameter. */
+static time_t
+get_onionqueue_wait_cutoff(void)
+{
+/* In seconds. */
+#define ONION_QUEUE_WAIT_CUTOFF_DEFAULT 5
+#define ONION_QUEUE_WAIT_CUTOFF_MIN 0
+#define ONION_QUEUE_WAIT_CUTOFF_MAX INT32_MAX
+  return networkstatus_get_param(NULL, "onion_queue_wait_cutoff",
+                                 ONION_QUEUE_WAIT_CUTOFF_DEFAULT,
+                                 ONION_QUEUE_WAIT_CUTOFF_MIN,
+                                 ONION_QUEUE_WAIT_CUTOFF_MAX);
+}
+
 /** Return the max onion queue delay value either from the torrc options (if
  * the user explicitly set it) else from the consensus parameter. */
 static uint64_t
@@ -242,7 +253,7 @@ onion_pending_add(or_circuit_t *circ, create_cell_t *onionskin)
   /* cull elderly requests. */
   while (1) {
     onion_queue_t *head = TOR_TAILQ_FIRST(&ol_list[queue_idx]);
-    if (now - head->when_added < (time_t)ONIONQUEUE_WAIT_CUTOFF)
+    if (now - head->when_added < get_onionqueue_wait_cutoff())
       break;
 
     circ = head->circ;

-- 
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