From 6b1dba214db3058b143bbb4d4c4bdfee32d100f1 Mon Sep 17 00:00:00 2001 From: David Goulet Date: Thu, 15 Feb 2018 13:45:21 -0500 Subject: cmux: Make EWMA policy mandatory To achieve this, a default value for the CircuitPriorityHalflife option was needed. We still look in the options and then the consensus but in case no value can be found, the default CircuitPriorityHalflifeMsec=30000 is used. It it the value we've been using since 0.2.4.4-alpha. This means that EWMA, our only policy, can not be disabled anymore fallbacking to the round robin algorithm. Unneeded code to control that is removed in this commit. Part of #25268 Signed-off-by: David Goulet --- src/or/networkstatus.c | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'src/or/networkstatus.c') diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c index 31ecb20985..80cdc9e5b4 100644 --- a/src/or/networkstatus.c +++ b/src/or/networkstatus.c @@ -1779,7 +1779,6 @@ networkstatus_set_current_consensus(const char *consensus, consensus_waiting_for_certs_t *waiting = NULL; time_t current_valid_after = 0; int free_consensus = 1; /* Free 'c' at the end of the function */ - int old_ewma_enabled; int checked_protocols_already = 0; if (flav < 0) { @@ -2003,17 +2002,8 @@ networkstatus_set_current_consensus(const char *consensus, /* XXXXNM Microdescs: needs a non-ns variant. ???? NM*/ update_consensus_networkstatus_fetch_time(now); - /* Update ewma and adjust policy if needed; first cache the old value */ - old_ewma_enabled = cell_ewma_enabled(); /* Change the cell EWMA settings */ cell_ewma_set_scale_factor(options, c); - /* If we just enabled ewma, set the cmux policy on all active channels */ - if (cell_ewma_enabled() && !old_ewma_enabled) { - channel_set_cmux_policy_everywhere(&ewma_policy); - } else if (!cell_ewma_enabled() && old_ewma_enabled) { - /* Turn it off everywhere */ - channel_set_cmux_policy_everywhere(NULL); - } /* XXXX this call might be unnecessary here: can changing the * current consensus really alter our view of any OR's rate limits? */ -- cgit v1.2.3-54-g00ecf From 9af5b625e8be64ed63ad5b19ae6c4b450e977ce0 Mon Sep 17 00:00:00 2001 From: David Goulet Date: Thu, 15 Feb 2018 13:51:34 -0500 Subject: cmux: Rename cell_ewma_set_scale_factor() It is rename to something more meaningful that explains what it does exactly which is sets the EWMA options (currently only one exists). The new name is cmux_ewma_set_options(). Also, remove a public function from circuitmux_ewma.h that is only used in the C file. Make it static inline as well. Signed-off-by: David Goulet --- src/or/circuitmux_ewma.c | 18 +++++++++--------- src/or/circuitmux_ewma.h | 6 +++--- src/or/config.c | 2 +- src/or/networkstatus.c | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) (limited to 'src/or/networkstatus.c') diff --git a/src/or/circuitmux_ewma.c b/src/or/circuitmux_ewma.c index d9ee8d3ef5..b2ace8a9fa 100644 --- a/src/or/circuitmux_ewma.c +++ b/src/or/circuitmux_ewma.c @@ -241,6 +241,13 @@ circuitmux_policy_t ewma_policy = { /*** EWMA method implementations using the below EWMA helper functions ***/ +/** Compute and return the current cell_ewma tick. */ +static inline unsigned int +cell_ewma_get_tick(void) +{ + return ((unsigned)approx_time() / EWMA_TICK_LEN); +} + /** * Allocate an ewma_policy_data_t and upcast it to a circuitmux_policy_data_t; * this is called when setting the policy on a circuitmux_t to ewma_policy. @@ -610,13 +617,6 @@ cell_ewma_tick_from_timeval(const struct timeval *now, return res; } -/** Compute and return the current cell_ewma tick. */ -unsigned int -cell_ewma_get_tick(void) -{ - return ((unsigned)approx_time() / EWMA_TICK_LEN); -} - /* Default value for the CircuitPriorityHalflifeMsec consensus parameter in * msec. */ #define CMUX_PRIORITY_HALFLIFE_MSEC_DEFAULT 30000 @@ -672,8 +672,8 @@ get_circuit_priority_halflife(const or_options_t *options, /** Adjust the global cell scale factor based on options */ void -cell_ewma_set_scale_factor(const or_options_t *options, - const networkstatus_t *consensus) +cmux_ewma_set_options(const or_options_t *options, + const networkstatus_t *consensus) { double halflife; const char *source; diff --git a/src/or/circuitmux_ewma.h b/src/or/circuitmux_ewma.h index 4e9e512df9..2ef8c2586d 100644 --- a/src/or/circuitmux_ewma.h +++ b/src/or/circuitmux_ewma.h @@ -12,12 +12,12 @@ #include "or.h" #include "circuitmux.h" +/* The public EWMA policy callbacks object. */ extern circuitmux_policy_t ewma_policy; /* Externally visible EWMA functions */ -unsigned int cell_ewma_get_tick(void); -void cell_ewma_set_scale_factor(const or_options_t *options, - const networkstatus_t *consensus); +void cmux_ewma_set_options(const or_options_t *options, + const networkstatus_t *consensus); #endif /* !defined(TOR_CIRCUITMUX_EWMA_H) */ diff --git a/src/or/config.c b/src/or/config.c index 0ac7779213..107f9ac5fd 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -2073,7 +2073,7 @@ options_act(const or_options_t *old_options) configure_accounting(time(NULL)); /* Change the cell EWMA settings */ - cell_ewma_set_scale_factor(options, networkstatus_get_latest_consensus()); + cmux_ewma_set_options(options, networkstatus_get_latest_consensus()); /* Update the BridgePassword's hashed version as needed. We store this as a * digest so that we can do side-channel-proof comparisons on it. diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c index 80cdc9e5b4..3455a7bb64 100644 --- a/src/or/networkstatus.c +++ b/src/or/networkstatus.c @@ -2003,7 +2003,7 @@ networkstatus_set_current_consensus(const char *consensus, update_consensus_networkstatus_fetch_time(now); /* Change the cell EWMA settings */ - cell_ewma_set_scale_factor(options, c); + cmux_ewma_set_options(options, c); /* XXXX this call might be unnecessary here: can changing the * current consensus really alter our view of any OR's rate limits? */ -- cgit v1.2.3-54-g00ecf