From: Nick Mathewson Date: Thu, 20 Sep 2018 18:41:44 +0000 (-0400) Subject: Merge branch 'bug23512-v4-029-fixes' X-Git-Tag: tor-0.3.5.2-alpha~7 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=813019cc57844876fcc63d87510b8efbcbf80563;p=thirdparty%2Ftor.git Merge branch 'bug23512-v4-029-fixes' --- 813019cc57844876fcc63d87510b8efbcbf80563 diff --cc src/feature/stats/rephist.c index 2588bb4c00,20f9148f03..a2dbb0ff16 --- a/src/feature/stats/rephist.c +++ b/src/feature/stats/rephist.c @@@ -74,43 -74,25 +74,39 @@@ * (The "rephist" name originally stood for "reputation and history". ) **/ -#include "or.h" -#include "circuitlist.h" -#include "circuituse.h" -#include "config.h" -#include "networkstatus.h" -#include "nodelist.h" -#include "rephist.h" -#include "router.h" -#include "routerlist.h" ++#define REPHIST_PRIVATE +#include "core/or/or.h" +#include "core/or/circuitlist.h" +#include "core/or/circuituse.h" +#include "app/config/config.h" +#include "lib/crypt_ops/crypto_rand.h" +#include "feature/nodelist/networkstatus.h" +#include "feature/nodelist/nodelist.h" +#include "feature/stats/rephist.h" +#include "feature/relay/router.h" +#include "feature/nodelist/routerlist.h" #include "ht.h" +#include "core/or/channelpadding.h" +#include "core/or/connection_or.h" +#include "app/config/statefile.h" -static void bw_arrays_init(void); -static void predicted_ports_init(void); +#include "feature/nodelist/networkstatus_st.h" +#include "core/or/or_circuit_st.h" +#include "app/config/or_state_st.h" + +#include "lib/container/bloomfilt.h" +#include "lib/container/order.h" +#include "lib/math/fp.h" +#include "lib/math/laplace.h" +#include "lib/time/tvdiff.h" -typedef struct bw_array_t bw_array_t; -STATIC uint64_t find_largest_max(bw_array_t *b); -STATIC void commit_max(bw_array_t *b); -STATIC void advance_obs(bw_array_t *b); +#ifdef HAVE_FCNTL_H +#include +#endif + +static void bw_arrays_init(void); +static void predicted_ports_alloc(void); - typedef struct bw_array_t bw_array_t; - STATIC uint64_t find_largest_max(bw_array_t *b); - STATIC void commit_max(bw_array_t *b); - STATIC void advance_obs(bw_array_t *b); - /** Total number of bytes currently allocated in fields used by rephist.c. */ uint64_t rephist_total_alloc=0; /** Number of or_history_t objects currently allocated. */ diff --cc src/feature/stats/rephist.h index e17a722489,f4bcd8ea09..842184f815 --- a/src/feature/stats/rephist.h +++ b/src/feature/stats/rephist.h @@@ -109,34 -117,7 +109,39 @@@ extern uint32_t rephist_total_num #ifdef TOR_UNIT_TESTS extern int onion_handshakes_requested[MAX_ONION_HANDSHAKE_TYPE+1]; extern int onion_handshakes_assigned[MAX_ONION_HANDSHAKE_TYPE+1]; -extern bw_array_t *write_array; ++extern struct bw_array_t *write_array; + #endif + ++#ifdef REPHIST_PRIVATE +typedef struct bw_array_t bw_array_t; - extern bw_array_t *write_array; ++STATIC uint64_t find_largest_max(bw_array_t *b); ++STATIC void commit_max(bw_array_t *b); ++STATIC void advance_obs(bw_array_t *b); #endif + +/** + * Represents the type of a cell for padding accounting + */ +typedef enum padding_type_t { + /** A RELAY_DROP cell */ + PADDING_TYPE_DROP, + /** A CELL_PADDING cell */ + PADDING_TYPE_CELL, + /** Total counts of padding and non-padding together */ + PADDING_TYPE_TOTAL, + /** Total cell counts for all padding-enabled channels */ + PADDING_TYPE_ENABLED_TOTAL, + /** CELL_PADDING counts for all padding-enabled channels */ + PADDING_TYPE_ENABLED_CELL +} padding_type_t; + +/** The amount of time over which the padding cell counts were counted */ +#define REPHIST_CELL_PADDING_COUNTS_INTERVAL (24*60*60) +void rep_hist_padding_count_read(padding_type_t type); +void rep_hist_padding_count_write(padding_type_t type); +char *rep_hist_get_padding_count_lines(void); +void rep_hist_reset_padding_counts(void); +void rep_hist_prep_published_padding_counts(time_t now); +void rep_hist_padding_count_timers(uint64_t num_timers); + +#endif /* !defined(TOR_REPHIST_H) */ - diff --cc src/test/test_relay.c index c3fd6578e1,57dcb2406a..4311392be8 --- a/src/test/test_relay.c +++ b/src/test/test_relay.c @@@ -1,30 -1,27 +1,30 @@@ -/* Copyright (c) 2014-2016, The Tor Project, Inc. */ +/* Copyright (c) 2014-2018, The Tor Project, Inc. */ /* See LICENSE for licensing information */ - #include "core/or/or.h" -#include "or.h" #define CIRCUITBUILD_PRIVATE -#include "circuitbuild.h" -#include "circuitlist.h" -#include "rephist.h" -#include "channeltls.h" + #define RELAY_PRIVATE -#include "relay.h" ++#define REPHIST_PRIVATE ++#include "core/or/or.h" +#include "core/or/circuitbuild.h" +#include "core/or/circuitlist.h" +#include "core/or/channeltls.h" +#include "feature/stats/rephist.h" - #define RELAY_PRIVATE +#include "core/or/relay.h" ++#include "feature/stats/rephist.h" ++#include "lib/container/order.h" /* For init/free stuff */ -#include "scheduler.h" +#include "core/or/scheduler.h" + +#include "core/or/cell_st.h" +#include "core/or/or_circuit_st.h" /* Test suite stuff */ -#include "test.h" -#include "fakechans.h" +#include "test/test.h" +#include "test/fakechans.h" static or_circuit_t * new_fake_orcirc(channel_t *nchan, channel_t *pchan); static void test_relay_append_cell_to_circuit_queue(void *arg); --uint64_t find_largest_max(bw_array_t *b); --void commit_max(bw_array_t *b); --void advance_obs(bw_array_t *b); static or_circuit_t * new_fake_orcirc(channel_t *nchan, channel_t *pchan)