Remove TestingEnableTbEmptyEvent
This option was used for shadow testing previously, but is no longer used for anything. It interferes with refactoring our token buckets.
This commit is contained in:
parent
395fa0258d
commit
16f08de0fd
|
@ -0,0 +1,5 @@
|
||||||
|
o Removed features:
|
||||||
|
- The TestingEnableTbEmptyEvent option has been removed. It was used
|
||||||
|
in testing simulations to measure how often connection buckets were
|
||||||
|
emptied, in order to improve our scheduling, but it has not
|
||||||
|
been actively used in years. Closes ticket 25760.
|
|
@ -2896,7 +2896,6 @@ The following options are used for running a testing Tor network.
|
||||||
TestingDirConnectionMaxStall 30 seconds
|
TestingDirConnectionMaxStall 30 seconds
|
||||||
TestingEnableConnBwEvent 1
|
TestingEnableConnBwEvent 1
|
||||||
TestingEnableCellStatsEvent 1
|
TestingEnableCellStatsEvent 1
|
||||||
TestingEnableTbEmptyEvent 1
|
|
||||||
|
|
||||||
[[TestingV3AuthInitialVotingInterval]] **TestingV3AuthInitialVotingInterval** __N__ **minutes**|**hours**::
|
[[TestingV3AuthInitialVotingInterval]] **TestingV3AuthInitialVotingInterval** __N__ **minutes**|**hours**::
|
||||||
Like V3AuthVotingInterval, but for initial voting interval before the first
|
Like V3AuthVotingInterval, but for initial voting interval before the first
|
||||||
|
@ -3034,11 +3033,6 @@ The following options are used for running a testing Tor network.
|
||||||
events. Changing this requires that **TestingTorNetwork** is set.
|
events. Changing this requires that **TestingTorNetwork** is set.
|
||||||
(Default: 0)
|
(Default: 0)
|
||||||
|
|
||||||
[[TestingEnableTbEmptyEvent]] **TestingEnableTbEmptyEvent** **0**|**1**::
|
|
||||||
If this option is set, then Tor controllers may register for TB_EMPTY
|
|
||||||
events. Changing this requires that **TestingTorNetwork** is set.
|
|
||||||
(Default: 0)
|
|
||||||
|
|
||||||
[[TestingMinExitFlagThreshold]] **TestingMinExitFlagThreshold** __N__ **KBytes**|**MBytes**|**GBytes**|**TBytes**|**KBits**|**MBits**|**GBits**|**TBits**::
|
[[TestingMinExitFlagThreshold]] **TestingMinExitFlagThreshold** __N__ **KBytes**|**MBytes**|**GBytes**|**TBytes**|**KBits**|**MBits**|**GBits**|**TBits**::
|
||||||
Sets a lower-bound for assigning an exit flag when running as an
|
Sets a lower-bound for assigning an exit flag when running as an
|
||||||
authority on a testing network. Overrides the usual default lower bound
|
authority on a testing network. Overrides the usual default lower bound
|
||||||
|
|
|
@ -334,7 +334,7 @@ static config_var_t option_vars_[] = {
|
||||||
V(DownloadExtraInfo, BOOL, "0"),
|
V(DownloadExtraInfo, BOOL, "0"),
|
||||||
V(TestingEnableConnBwEvent, BOOL, "0"),
|
V(TestingEnableConnBwEvent, BOOL, "0"),
|
||||||
V(TestingEnableCellStatsEvent, BOOL, "0"),
|
V(TestingEnableCellStatsEvent, BOOL, "0"),
|
||||||
V(TestingEnableTbEmptyEvent, BOOL, "0"),
|
OBSOLETE("TestingEnableTbEmptyEvent"),
|
||||||
V(EnforceDistinctSubnets, BOOL, "1"),
|
V(EnforceDistinctSubnets, BOOL, "1"),
|
||||||
V(EntryNodes, ROUTERSET, NULL),
|
V(EntryNodes, ROUTERSET, NULL),
|
||||||
V(EntryStatistics, BOOL, "0"),
|
V(EntryStatistics, BOOL, "0"),
|
||||||
|
@ -704,7 +704,6 @@ static const config_var_t testing_tor_network_defaults[] = {
|
||||||
V(TestingDirConnectionMaxStall, INTERVAL, "30 seconds"),
|
V(TestingDirConnectionMaxStall, INTERVAL, "30 seconds"),
|
||||||
V(TestingEnableConnBwEvent, BOOL, "1"),
|
V(TestingEnableConnBwEvent, BOOL, "1"),
|
||||||
V(TestingEnableCellStatsEvent, BOOL, "1"),
|
V(TestingEnableCellStatsEvent, BOOL, "1"),
|
||||||
V(TestingEnableTbEmptyEvent, BOOL, "1"),
|
|
||||||
VAR("___UsingTestNetworkDefaults", BOOL, UsingTestNetworkDefaults_, "1"),
|
VAR("___UsingTestNetworkDefaults", BOOL, UsingTestNetworkDefaults_, "1"),
|
||||||
V(RendPostPeriod, INTERVAL, "2 minutes"),
|
V(RendPostPeriod, INTERVAL, "2 minutes"),
|
||||||
|
|
||||||
|
@ -4499,12 +4498,6 @@ options_validate(or_options_t *old_options, or_options_t *options,
|
||||||
"Tor networks!");
|
"Tor networks!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options->TestingEnableTbEmptyEvent &&
|
|
||||||
!options->TestingTorNetwork && !options->UsingTestNetworkDefaults_) {
|
|
||||||
REJECT("TestingEnableTbEmptyEvent may only be changed in testing "
|
|
||||||
"Tor networks!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options->TestingTorNetwork) {
|
if (options->TestingTorNetwork) {
|
||||||
log_warn(LD_CONFIG, "TestingTorNetwork is set. This will make your node "
|
log_warn(LD_CONFIG, "TestingTorNetwork is set. This will make your node "
|
||||||
"almost unusable in the public Tor network, and is "
|
"almost unusable in the public Tor network, and is "
|
||||||
|
|
|
@ -3019,57 +3019,6 @@ record_num_bytes_transferred_impl(connection_t *conn,
|
||||||
rep_hist_note_exit_bytes(conn->port, num_written, num_read);
|
rep_hist_note_exit_bytes(conn->port, num_written, num_read);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Helper: convert given <b>tvnow</b> time value to milliseconds since
|
|
||||||
* midnight. */
|
|
||||||
static uint32_t
|
|
||||||
msec_since_midnight(const struct timeval *tvnow)
|
|
||||||
{
|
|
||||||
return (uint32_t)(((tvnow->tv_sec % 86400L) * 1000L) +
|
|
||||||
((uint32_t)tvnow->tv_usec / (uint32_t)1000L));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Helper: return the time in milliseconds since <b>last_empty_time</b>
|
|
||||||
* when a bucket ran empty that previously had <b>tokens_before</b> tokens
|
|
||||||
* now has <b>tokens_after</b> tokens after refilling at timestamp
|
|
||||||
* <b>tvnow</b>, capped at <b>milliseconds_elapsed</b> milliseconds since
|
|
||||||
* last refilling that bucket. Return 0 if the bucket has not been empty
|
|
||||||
* since the last refill or has not been refilled. */
|
|
||||||
uint32_t
|
|
||||||
bucket_millis_empty(int tokens_before, uint32_t last_empty_time,
|
|
||||||
int tokens_after, int milliseconds_elapsed,
|
|
||||||
const struct timeval *tvnow)
|
|
||||||
{
|
|
||||||
uint32_t result = 0, refilled;
|
|
||||||
if (tokens_before <= 0 && tokens_after > tokens_before) {
|
|
||||||
refilled = msec_since_midnight(tvnow);
|
|
||||||
result = (uint32_t)((refilled + 86400L * 1000L - last_empty_time) %
|
|
||||||
(86400L * 1000L));
|
|
||||||
if (result > (uint32_t)milliseconds_elapsed)
|
|
||||||
result = (uint32_t)milliseconds_elapsed;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Check if a bucket which had <b>tokens_before</b> tokens and which got
|
|
||||||
* <b>tokens_removed</b> tokens removed at timestamp <b>tvnow</b> has run
|
|
||||||
* out of tokens, and if so, note the milliseconds since midnight in
|
|
||||||
* <b>timestamp_var</b> for the next TB_EMPTY event. */
|
|
||||||
void
|
|
||||||
connection_buckets_note_empty_ts(uint32_t *timestamp_var,
|
|
||||||
int tokens_before, size_t tokens_removed,
|
|
||||||
const struct timeval *tvnow)
|
|
||||||
{
|
|
||||||
if (tokens_before > 0 && (uint32_t)tokens_before <= tokens_removed)
|
|
||||||
*timestamp_var = msec_since_midnight(tvnow);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Last time at which the global or relay buckets were emptied in msec
|
|
||||||
* since midnight. */
|
|
||||||
static uint32_t global_relayed_read_emptied = 0,
|
|
||||||
global_relayed_write_emptied = 0,
|
|
||||||
global_read_emptied = 0,
|
|
||||||
global_write_emptied = 0;
|
|
||||||
|
|
||||||
/** We just read <b>num_read</b> and wrote <b>num_written</b> bytes
|
/** We just read <b>num_read</b> and wrote <b>num_written</b> bytes
|
||||||
* onto <b>conn</b>. Decrement buckets appropriately. */
|
* onto <b>conn</b>. Decrement buckets appropriately. */
|
||||||
static void
|
static void
|
||||||
|
@ -3094,30 +3043,6 @@ connection_buckets_decrement(connection_t *conn, time_t now,
|
||||||
if (!connection_is_rate_limited(conn))
|
if (!connection_is_rate_limited(conn))
|
||||||
return; /* local IPs are free */
|
return; /* local IPs are free */
|
||||||
|
|
||||||
/* If one or more of our token buckets ran dry just now, note the
|
|
||||||
* timestamp for TB_EMPTY events. */
|
|
||||||
if (get_options()->TestingEnableTbEmptyEvent) {
|
|
||||||
struct timeval tvnow;
|
|
||||||
tor_gettimeofday_cached(&tvnow);
|
|
||||||
if (connection_counts_as_relayed_traffic(conn, now)) {
|
|
||||||
connection_buckets_note_empty_ts(&global_relayed_read_emptied,
|
|
||||||
global_relayed_read_bucket, num_read, &tvnow);
|
|
||||||
connection_buckets_note_empty_ts(&global_relayed_write_emptied,
|
|
||||||
global_relayed_write_bucket, num_written, &tvnow);
|
|
||||||
}
|
|
||||||
connection_buckets_note_empty_ts(&global_read_emptied,
|
|
||||||
global_read_bucket, num_read, &tvnow);
|
|
||||||
connection_buckets_note_empty_ts(&global_write_emptied,
|
|
||||||
global_write_bucket, num_written, &tvnow);
|
|
||||||
if (connection_speaks_cells(conn) && conn->state == OR_CONN_STATE_OPEN) {
|
|
||||||
or_connection_t *or_conn = TO_OR_CONN(conn);
|
|
||||||
connection_buckets_note_empty_ts(&or_conn->read_emptied_time,
|
|
||||||
or_conn->read_bucket, num_read, &tvnow);
|
|
||||||
connection_buckets_note_empty_ts(&or_conn->write_emptied_time,
|
|
||||||
or_conn->write_bucket, num_written, &tvnow);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (connection_counts_as_relayed_traffic(conn, now)) {
|
if (connection_counts_as_relayed_traffic(conn, now)) {
|
||||||
global_relayed_read_bucket -= (int)num_read;
|
global_relayed_read_bucket -= (int)num_read;
|
||||||
global_relayed_write_bucket -= (int)num_written;
|
global_relayed_write_bucket -= (int)num_written;
|
||||||
|
@ -3238,12 +3163,6 @@ connection_bucket_refill(int milliseconds_elapsed, time_t now)
|
||||||
smartlist_t *conns = get_connection_array();
|
smartlist_t *conns = get_connection_array();
|
||||||
int bandwidthrate, bandwidthburst, relayrate, relayburst;
|
int bandwidthrate, bandwidthburst, relayrate, relayburst;
|
||||||
|
|
||||||
int prev_global_read = global_read_bucket;
|
|
||||||
int prev_global_write = global_write_bucket;
|
|
||||||
int prev_relay_read = global_relayed_read_bucket;
|
|
||||||
int prev_relay_write = global_relayed_write_bucket;
|
|
||||||
struct timeval tvnow; /*< Only used if TB_EMPTY events are enabled. */
|
|
||||||
|
|
||||||
bandwidthrate = (int)options->BandwidthRate;
|
bandwidthrate = (int)options->BandwidthRate;
|
||||||
bandwidthburst = (int)options->BandwidthBurst;
|
bandwidthburst = (int)options->BandwidthBurst;
|
||||||
|
|
||||||
|
@ -3278,32 +3197,6 @@ connection_bucket_refill(int milliseconds_elapsed, time_t now)
|
||||||
milliseconds_elapsed,
|
milliseconds_elapsed,
|
||||||
"global_relayed_write_bucket");
|
"global_relayed_write_bucket");
|
||||||
|
|
||||||
/* If buckets were empty before and have now been refilled, tell any
|
|
||||||
* interested controllers. */
|
|
||||||
if (get_options()->TestingEnableTbEmptyEvent) {
|
|
||||||
uint32_t global_read_empty_time, global_write_empty_time,
|
|
||||||
relay_read_empty_time, relay_write_empty_time;
|
|
||||||
tor_gettimeofday_cached(&tvnow);
|
|
||||||
global_read_empty_time = bucket_millis_empty(prev_global_read,
|
|
||||||
global_read_emptied, global_read_bucket,
|
|
||||||
milliseconds_elapsed, &tvnow);
|
|
||||||
global_write_empty_time = bucket_millis_empty(prev_global_write,
|
|
||||||
global_write_emptied, global_write_bucket,
|
|
||||||
milliseconds_elapsed, &tvnow);
|
|
||||||
control_event_tb_empty("GLOBAL", global_read_empty_time,
|
|
||||||
global_write_empty_time, milliseconds_elapsed);
|
|
||||||
relay_read_empty_time = bucket_millis_empty(prev_relay_read,
|
|
||||||
global_relayed_read_emptied,
|
|
||||||
global_relayed_read_bucket,
|
|
||||||
milliseconds_elapsed, &tvnow);
|
|
||||||
relay_write_empty_time = bucket_millis_empty(prev_relay_write,
|
|
||||||
global_relayed_write_emptied,
|
|
||||||
global_relayed_write_bucket,
|
|
||||||
milliseconds_elapsed, &tvnow);
|
|
||||||
control_event_tb_empty("RELAY", relay_read_empty_time,
|
|
||||||
relay_write_empty_time, milliseconds_elapsed);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* refill the per-connection buckets */
|
/* refill the per-connection buckets */
|
||||||
SMARTLIST_FOREACH_BEGIN(conns, connection_t *, conn) {
|
SMARTLIST_FOREACH_BEGIN(conns, connection_t *, conn) {
|
||||||
if (connection_speaks_cells(conn)) {
|
if (connection_speaks_cells(conn)) {
|
||||||
|
@ -3311,9 +3204,6 @@ connection_bucket_refill(int milliseconds_elapsed, time_t now)
|
||||||
int orbandwidthrate = or_conn->bandwidthrate;
|
int orbandwidthrate = or_conn->bandwidthrate;
|
||||||
int orbandwidthburst = or_conn->bandwidthburst;
|
int orbandwidthburst = or_conn->bandwidthburst;
|
||||||
|
|
||||||
int prev_conn_read = or_conn->read_bucket;
|
|
||||||
int prev_conn_write = or_conn->write_bucket;
|
|
||||||
|
|
||||||
if (connection_bucket_should_increase(or_conn->read_bucket, or_conn)) {
|
if (connection_bucket_should_increase(or_conn->read_bucket, or_conn)) {
|
||||||
connection_bucket_refill_helper(&or_conn->read_bucket,
|
connection_bucket_refill_helper(&or_conn->read_bucket,
|
||||||
orbandwidthrate,
|
orbandwidthrate,
|
||||||
|
@ -3328,27 +3218,6 @@ connection_bucket_refill(int milliseconds_elapsed, time_t now)
|
||||||
milliseconds_elapsed,
|
milliseconds_elapsed,
|
||||||
"or_conn->write_bucket");
|
"or_conn->write_bucket");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If buckets were empty before and have now been refilled, tell any
|
|
||||||
* interested controllers. */
|
|
||||||
if (get_options()->TestingEnableTbEmptyEvent) {
|
|
||||||
char *bucket;
|
|
||||||
uint32_t conn_read_empty_time, conn_write_empty_time;
|
|
||||||
tor_asprintf(&bucket, "ORCONN ID="U64_FORMAT,
|
|
||||||
U64_PRINTF_ARG(or_conn->base_.global_identifier));
|
|
||||||
conn_read_empty_time = bucket_millis_empty(prev_conn_read,
|
|
||||||
or_conn->read_emptied_time,
|
|
||||||
or_conn->read_bucket,
|
|
||||||
milliseconds_elapsed, &tvnow);
|
|
||||||
conn_write_empty_time = bucket_millis_empty(prev_conn_write,
|
|
||||||
or_conn->write_emptied_time,
|
|
||||||
or_conn->write_bucket,
|
|
||||||
milliseconds_elapsed, &tvnow);
|
|
||||||
control_event_tb_empty(bucket, conn_read_empty_time,
|
|
||||||
conn_write_empty_time,
|
|
||||||
milliseconds_elapsed);
|
|
||||||
tor_free(bucket);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conn->read_blocked_on_bw == 1 /* marked to turn reading back on now */
|
if (conn->read_blocked_on_bw == 1 /* marked to turn reading back on now */
|
||||||
|
|
|
@ -272,13 +272,6 @@ void connection_check_oos(int n_socks, int failed);
|
||||||
STATIC void connection_free_minimal(connection_t *conn);
|
STATIC void connection_free_minimal(connection_t *conn);
|
||||||
|
|
||||||
/* Used only by connection.c and test*.c */
|
/* Used only by connection.c and test*.c */
|
||||||
uint32_t bucket_millis_empty(int tokens_before, uint32_t last_empty_time,
|
|
||||||
int tokens_after, int milliseconds_elapsed,
|
|
||||||
const struct timeval *tvnow);
|
|
||||||
void connection_buckets_note_empty_ts(uint32_t *timestamp_var,
|
|
||||||
int tokens_before,
|
|
||||||
size_t tokens_removed,
|
|
||||||
const struct timeval *tvnow);
|
|
||||||
MOCK_DECL(STATIC int,connection_connect_sockaddr,
|
MOCK_DECL(STATIC int,connection_connect_sockaddr,
|
||||||
(connection_t *conn,
|
(connection_t *conn,
|
||||||
const struct sockaddr *sa,
|
const struct sockaddr *sa,
|
||||||
|
|
|
@ -1214,7 +1214,6 @@ static const struct control_event_t control_event_table[] = {
|
||||||
{ EVENT_CONF_CHANGED, "CONF_CHANGED"},
|
{ EVENT_CONF_CHANGED, "CONF_CHANGED"},
|
||||||
{ EVENT_CONN_BW, "CONN_BW" },
|
{ EVENT_CONN_BW, "CONN_BW" },
|
||||||
{ EVENT_CELL_STATS, "CELL_STATS" },
|
{ EVENT_CELL_STATS, "CELL_STATS" },
|
||||||
{ EVENT_TB_EMPTY, "TB_EMPTY" },
|
|
||||||
{ EVENT_CIRC_BANDWIDTH_USED, "CIRC_BW" },
|
{ EVENT_CIRC_BANDWIDTH_USED, "CIRC_BW" },
|
||||||
{ EVENT_TRANSPORT_LAUNCHED, "TRANSPORT_LAUNCHED" },
|
{ EVENT_TRANSPORT_LAUNCHED, "TRANSPORT_LAUNCHED" },
|
||||||
{ EVENT_HS_DESC, "HS_DESC" },
|
{ EVENT_HS_DESC, "HS_DESC" },
|
||||||
|
@ -6077,28 +6076,6 @@ control_event_circuit_cell_stats(void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Tokens in <b>bucket</b> have been refilled: the read bucket was empty
|
|
||||||
* for <b>read_empty_time</b> millis, the write bucket was empty for
|
|
||||||
* <b>write_empty_time</b> millis, and buckets were last refilled
|
|
||||||
* <b>milliseconds_elapsed</b> millis ago. Only emit TB_EMPTY event if
|
|
||||||
* either read or write bucket have been empty before. */
|
|
||||||
int
|
|
||||||
control_event_tb_empty(const char *bucket, uint32_t read_empty_time,
|
|
||||||
uint32_t write_empty_time,
|
|
||||||
int milliseconds_elapsed)
|
|
||||||
{
|
|
||||||
if (get_options()->TestingEnableTbEmptyEvent &&
|
|
||||||
EVENT_IS_INTERESTING(EVENT_TB_EMPTY) &&
|
|
||||||
(read_empty_time > 0 || write_empty_time > 0)) {
|
|
||||||
send_control_event(EVENT_TB_EMPTY,
|
|
||||||
"650 TB_EMPTY %s READ=%d WRITTEN=%d "
|
|
||||||
"LAST=%d\r\n",
|
|
||||||
bucket, read_empty_time, write_empty_time,
|
|
||||||
milliseconds_elapsed);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* about 5 minutes worth. */
|
/* about 5 minutes worth. */
|
||||||
#define N_BW_EVENTS_TO_CACHE 300
|
#define N_BW_EVENTS_TO_CACHE 300
|
||||||
/* Index into cached_bw_events to next write. */
|
/* Index into cached_bw_events to next write. */
|
||||||
|
|
|
@ -59,9 +59,6 @@ int control_event_circ_bandwidth_used(void);
|
||||||
int control_event_conn_bandwidth(connection_t *conn);
|
int control_event_conn_bandwidth(connection_t *conn);
|
||||||
int control_event_conn_bandwidth_used(void);
|
int control_event_conn_bandwidth_used(void);
|
||||||
int control_event_circuit_cell_stats(void);
|
int control_event_circuit_cell_stats(void);
|
||||||
int control_event_tb_empty(const char *bucket, uint32_t read_empty_time,
|
|
||||||
uint32_t write_empty_time,
|
|
||||||
int milliseconds_elapsed);
|
|
||||||
void control_event_logmsg(int severity, uint32_t domain, const char *msg);
|
void control_event_logmsg(int severity, uint32_t domain, const char *msg);
|
||||||
int control_event_descriptors_changed(smartlist_t *routers);
|
int control_event_descriptors_changed(smartlist_t *routers);
|
||||||
int control_event_address_mapped(const char *from, const char *to,
|
int control_event_address_mapped(const char *from, const char *to,
|
||||||
|
@ -194,7 +191,7 @@ void control_free_all(void);
|
||||||
#define EVENT_CONF_CHANGED 0x0019
|
#define EVENT_CONF_CHANGED 0x0019
|
||||||
#define EVENT_CONN_BW 0x001A
|
#define EVENT_CONN_BW 0x001A
|
||||||
#define EVENT_CELL_STATS 0x001B
|
#define EVENT_CELL_STATS 0x001B
|
||||||
#define EVENT_TB_EMPTY 0x001C
|
/* UNUSED : 0x001C */
|
||||||
#define EVENT_CIRC_BANDWIDTH_USED 0x001D
|
#define EVENT_CIRC_BANDWIDTH_USED 0x001D
|
||||||
#define EVENT_TRANSPORT_LAUNCHED 0x0020
|
#define EVENT_TRANSPORT_LAUNCHED 0x0020
|
||||||
#define EVENT_HS_DESC 0x0021
|
#define EVENT_HS_DESC 0x0021
|
||||||
|
|
10
src/or/or.h
10
src/or/or.h
|
@ -1660,13 +1660,6 @@ typedef struct or_connection_t {
|
||||||
* bandwidthburst. (OPEN ORs only) */
|
* bandwidthburst. (OPEN ORs only) */
|
||||||
int write_bucket; /**< When this hits 0, stop writing. Like read_bucket. */
|
int write_bucket; /**< When this hits 0, stop writing. Like read_bucket. */
|
||||||
|
|
||||||
/** Last emptied read token bucket in msec since midnight; only used if
|
|
||||||
* TB_EMPTY events are enabled. */
|
|
||||||
uint32_t read_emptied_time;
|
|
||||||
/** Last emptied write token bucket in msec since midnight; only used if
|
|
||||||
* TB_EMPTY events are enabled. */
|
|
||||||
uint32_t write_emptied_time;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Count the number of bytes flushed out on this orconn, and the number of
|
* Count the number of bytes flushed out on this orconn, and the number of
|
||||||
* bytes TLS actually sent - used for overhead estimation for scheduling.
|
* bytes TLS actually sent - used for overhead estimation for scheduling.
|
||||||
|
@ -4427,9 +4420,6 @@ typedef struct {
|
||||||
/** Enable CELL_STATS events. Only altered on testing networks. */
|
/** Enable CELL_STATS events. Only altered on testing networks. */
|
||||||
int TestingEnableCellStatsEvent;
|
int TestingEnableCellStatsEvent;
|
||||||
|
|
||||||
/** Enable TB_EMPTY events. Only altered on testing networks. */
|
|
||||||
int TestingEnableTbEmptyEvent;
|
|
||||||
|
|
||||||
/** If true, and we have GeoIP data, and we're a bridge, keep a per-country
|
/** If true, and we have GeoIP data, and we're a bridge, keep a per-country
|
||||||
* count of how many client addresses have contacted us so that we can help
|
* count of how many client addresses have contacted us so that we can help
|
||||||
* the bridge authority guess which countries have blocked access to us. */
|
* the bridge authority guess which countries have blocked access to us. */
|
||||||
|
|
|
@ -11,79 +11,6 @@
|
||||||
#include "control.h"
|
#include "control.h"
|
||||||
#include "test.h"
|
#include "test.h"
|
||||||
|
|
||||||
static void
|
|
||||||
help_test_bucket_note_empty(uint32_t expected_msec_since_midnight,
|
|
||||||
int tokens_before, size_t tokens_removed,
|
|
||||||
uint32_t msec_since_epoch)
|
|
||||||
{
|
|
||||||
uint32_t timestamp_var = 0;
|
|
||||||
struct timeval tvnow;
|
|
||||||
tvnow.tv_sec = msec_since_epoch / 1000;
|
|
||||||
tvnow.tv_usec = (msec_since_epoch % 1000) * 1000;
|
|
||||||
connection_buckets_note_empty_ts(×tamp_var, tokens_before,
|
|
||||||
tokens_removed, &tvnow);
|
|
||||||
tt_int_op(expected_msec_since_midnight, OP_EQ, timestamp_var);
|
|
||||||
|
|
||||||
done:
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
test_cntev_bucket_note_empty(void *arg)
|
|
||||||
{
|
|
||||||
(void)arg;
|
|
||||||
|
|
||||||
/* Two cases with nothing to note, because bucket was empty before;
|
|
||||||
* 86442200 == 1970-01-02 00:00:42.200000 */
|
|
||||||
help_test_bucket_note_empty(0, 0, 0, 86442200);
|
|
||||||
help_test_bucket_note_empty(0, -100, 100, 86442200);
|
|
||||||
|
|
||||||
/* Nothing to note, because bucket has not been emptied. */
|
|
||||||
help_test_bucket_note_empty(0, 101, 100, 86442200);
|
|
||||||
|
|
||||||
/* Bucket was emptied, note 42200 msec since midnight. */
|
|
||||||
help_test_bucket_note_empty(42200, 101, 101, 86442200);
|
|
||||||
help_test_bucket_note_empty(42200, 101, 102, 86442200);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
test_cntev_bucket_millis_empty(void *arg)
|
|
||||||
{
|
|
||||||
struct timeval tvnow;
|
|
||||||
(void)arg;
|
|
||||||
|
|
||||||
/* 1970-01-02 00:00:42.200000 */
|
|
||||||
tvnow.tv_sec = 86400 + 42;
|
|
||||||
tvnow.tv_usec = 200000;
|
|
||||||
|
|
||||||
/* Bucket has not been refilled. */
|
|
||||||
tt_int_op(0, OP_EQ, bucket_millis_empty(0, 42120, 0, 100, &tvnow));
|
|
||||||
tt_int_op(0, OP_EQ, bucket_millis_empty(-10, 42120, -10, 100, &tvnow));
|
|
||||||
|
|
||||||
/* Bucket was not empty. */
|
|
||||||
tt_int_op(0, OP_EQ, bucket_millis_empty(10, 42120, 20, 100, &tvnow));
|
|
||||||
|
|
||||||
/* Bucket has been emptied 80 msec ago and has just been refilled. */
|
|
||||||
tt_int_op(80, OP_EQ, bucket_millis_empty(-20, 42120, -10, 100, &tvnow));
|
|
||||||
tt_int_op(80, OP_EQ, bucket_millis_empty(-10, 42120, 0, 100, &tvnow));
|
|
||||||
tt_int_op(80, OP_EQ, bucket_millis_empty(0, 42120, 10, 100, &tvnow));
|
|
||||||
|
|
||||||
/* Bucket has been emptied 180 msec ago, last refill was 100 msec ago
|
|
||||||
* which was insufficient to make it positive, so cap msec at 100. */
|
|
||||||
tt_int_op(100, OP_EQ, bucket_millis_empty(0, 42020, 1, 100, &tvnow));
|
|
||||||
|
|
||||||
/* 1970-01-02 00:00:00:050000 */
|
|
||||||
tvnow.tv_sec = 86400;
|
|
||||||
tvnow.tv_usec = 50000;
|
|
||||||
|
|
||||||
/* Last emptied 30 msec before midnight, tvnow is 50 msec after
|
|
||||||
* midnight, that's 80 msec in total. */
|
|
||||||
tt_int_op(80, OP_EQ, bucket_millis_empty(0, 86400000 - 30, 1, 100, &tvnow));
|
|
||||||
|
|
||||||
done:
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
add_testing_cell_stats_entry(circuit_t *circ, uint8_t command,
|
add_testing_cell_stats_entry(circuit_t *circ, uint8_t command,
|
||||||
unsigned int waiting_time,
|
unsigned int waiting_time,
|
||||||
|
@ -395,8 +322,6 @@ test_cntev_event_mask(void *arg)
|
||||||
{ #name, test_cntev_ ## name, flags, 0, NULL }
|
{ #name, test_cntev_ ## name, flags, 0, NULL }
|
||||||
|
|
||||||
struct testcase_t controller_event_tests[] = {
|
struct testcase_t controller_event_tests[] = {
|
||||||
TEST(bucket_note_empty, TT_FORK),
|
|
||||||
TEST(bucket_millis_empty, TT_FORK),
|
|
||||||
TEST(sum_up_cell_stats, TT_FORK),
|
TEST(sum_up_cell_stats, TT_FORK),
|
||||||
TEST(append_cell_stats, TT_FORK),
|
TEST(append_cell_stats, TT_FORK),
|
||||||
TEST(format_cell_stats, TT_FORK),
|
TEST(format_cell_stats, TT_FORK),
|
||||||
|
|
|
@ -4132,16 +4132,6 @@ test_options_validate__testing_options(void *ignored)
|
||||||
tt_assert(!msg);
|
tt_assert(!msg);
|
||||||
tor_free(msg);
|
tor_free(msg);
|
||||||
|
|
||||||
free_options_test_data(tdata);
|
|
||||||
tdata = get_options_test_data(TEST_OPTIONS_DEFAULT_VALUES
|
|
||||||
"TestingEnableTbEmptyEvent 1\n"
|
|
||||||
);
|
|
||||||
ret = options_validate(tdata->old_opt, tdata->opt, tdata->def_opt, 0, &msg);
|
|
||||||
tt_int_op(ret, OP_EQ, -1);
|
|
||||||
tt_str_op(msg, OP_EQ, "TestingEnableTbEmptyEvent may only be changed "
|
|
||||||
"in testing Tor networks!");
|
|
||||||
tor_free(msg);
|
|
||||||
|
|
||||||
free_options_test_data(tdata);
|
free_options_test_data(tdata);
|
||||||
tdata = get_options_test_data(TEST_OPTIONS_DEFAULT_VALUES
|
tdata = get_options_test_data(TEST_OPTIONS_DEFAULT_VALUES
|
||||||
"TestingEnableTbEmptyEvent 1\n"
|
"TestingEnableTbEmptyEvent 1\n"
|
||||||
|
|
Loading…
Reference in New Issue