mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-02 16:43:32 +01:00
Compare commits
No commits in common. "f72d508ecca5ead5fc7b82fa63025caa8182bef6" and "ec5eb9470f81b573bf67bc751e3331a180b0069f" have entirely different histories.
f72d508ecc
...
ec5eb9470f
@ -3640,13 +3640,9 @@ record_num_bytes_transferred_impl(connection_t *conn,
|
||||
{
|
||||
/* Count bytes of answering direct and tunneled directory requests */
|
||||
if (conn->type == CONN_TYPE_DIR && conn->purpose == DIR_PURPOSE_SERVER) {
|
||||
if (num_read > 0)
|
||||
bwhist_note_dir_bytes_read(num_read, now);
|
||||
if (num_written > 0)
|
||||
bwhist_note_dir_bytes_written(num_written, now);
|
||||
dir_connection_t *dir_conn = TO_DIR_CONN(conn);
|
||||
stats_increment_dir_bytes_read_and_written(num_read,
|
||||
num_written, dir_conn->hs_request);
|
||||
dir_conn->num_read += num_read;
|
||||
dir_conn->num_written += num_written;
|
||||
}
|
||||
|
||||
/* Linked connections and internal IPs aren't counted for statistics or
|
||||
|
@ -139,11 +139,14 @@ static uint64_t stats_n_bytes_read = 0;
|
||||
/** How many bytes have we written since we started the process? */
|
||||
static uint64_t stats_n_bytes_written = 0;
|
||||
/** How many bytes have we read for directory purpose since we started the
|
||||
* process? Includes hsdir connections */
|
||||
* process? */
|
||||
static uint64_t stats_n_dir_bytes_read = 0;
|
||||
/** How many bytes have we written for directory purpose since we started the
|
||||
* process? Does not include hsdir connections */
|
||||
* process? */
|
||||
static uint64_t stats_n_dir_bytes_written = 0;
|
||||
/** How many bytes have we read for hs directory purpose since we started the
|
||||
* process? */
|
||||
static uint64_t stats_n_hsdir_bytes_read = 0;
|
||||
/** How many bytes have we written for hs directory purpose since we started
|
||||
* the process? */
|
||||
static uint64_t stats_n_hsdir_bytes_written = 0;
|
||||
@ -488,21 +491,24 @@ stats_increment_bytes_read_and_written(uint64_t r, uint64_t w)
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the amount of directory traffic read, in bytes, over the life of this
|
||||
* Return the amount of directory raffic read, in bytes, over the life of this
|
||||
* process.
|
||||
*/
|
||||
uint64_t
|
||||
get_dir_bytes_read(void)
|
||||
MOCK_IMPL(uint64_t,
|
||||
get_dir_bytes_read,(bool hs))
|
||||
{
|
||||
return stats_n_dir_bytes_read;
|
||||
if (hs)
|
||||
return stats_n_hsdir_bytes_read;
|
||||
else
|
||||
return stats_n_dir_bytes_read;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the amount of directory traffic read, in bytes, over the life of this
|
||||
* process.
|
||||
*/
|
||||
uint64_t
|
||||
get_dir_bytes_written(bool hs)
|
||||
MOCK_IMPL(uint64_t,
|
||||
get_dir_bytes_written,(bool hs))
|
||||
{
|
||||
if (hs)
|
||||
return stats_n_hsdir_bytes_written;
|
||||
@ -517,10 +523,11 @@ get_dir_bytes_written(bool hs)
|
||||
void
|
||||
stats_increment_dir_bytes_read_and_written(uint64_t r, uint64_t w, bool hs)
|
||||
{
|
||||
stats_n_dir_bytes_read += r;
|
||||
if (hs) {
|
||||
stats_n_hsdir_bytes_read += r;
|
||||
stats_n_hsdir_bytes_written += w;
|
||||
} else {
|
||||
stats_n_dir_bytes_read += r;
|
||||
stats_n_dir_bytes_written += w;
|
||||
}
|
||||
}
|
||||
|
@ -28,8 +28,8 @@ int connection_is_on_closeable_list(connection_t *conn);
|
||||
MOCK_DECL(smartlist_t *, get_connection_array, (void));
|
||||
MOCK_DECL(uint64_t,get_bytes_read,(void));
|
||||
MOCK_DECL(uint64_t,get_bytes_written,(void));
|
||||
uint64_t get_dir_bytes_read(void);
|
||||
uint64_t get_dir_bytes_written(bool hs);
|
||||
MOCK_DECL(uint64_t,get_dir_bytes_read,(bool hs));
|
||||
MOCK_DECL(uint64_t,get_dir_bytes_written,(bool hs));
|
||||
void stats_increment_bytes_read_and_written(uint64_t r, uint64_t w);
|
||||
void stats_increment_dir_bytes_read_and_written(uint64_t r,
|
||||
uint64_t w, bool hs);
|
||||
|
@ -62,6 +62,17 @@ struct dir_connection_t {
|
||||
* needs this for the incoming side, so it's moved here. */
|
||||
uint64_t dirreq_id;
|
||||
|
||||
/** Number of bytes read on this connection. We track this here, and update
|
||||
* global statistics on connection tear down so that we can differentiate
|
||||
* between normal directory and hidden-service related request.
|
||||
**/
|
||||
size_t num_read;
|
||||
/** Number of bytes written on this connection. We track this here, and
|
||||
* update global statistics on connection tear down so that we can
|
||||
* differentiate between normal directory and hidden-service related request.
|
||||
**/
|
||||
size_t num_written;
|
||||
|
||||
#ifdef MEASUREMENTS_21206
|
||||
/** Number of RELAY_DATA cells received. */
|
||||
uint32_t data_cells_received;
|
||||
|
@ -11,11 +11,13 @@
|
||||
#include "core/or/connection_edge.h"
|
||||
#include "core/or/connection_or.h"
|
||||
#include "core/or/channeltls.h"
|
||||
#include "core/mainloop/mainloop.h"
|
||||
#include "feature/dircache/dircache.h"
|
||||
#include "feature/dircache/dirserv.h"
|
||||
#include "feature/dirclient/dirclient.h"
|
||||
#include "feature/dircommon/directory.h"
|
||||
#include "feature/dircommon/fp_pair.h"
|
||||
#include "feature/stats/bwhist.h"
|
||||
#include "feature/stats/geoip_stats.h"
|
||||
#include "lib/compress/compress.h"
|
||||
|
||||
@ -492,6 +494,16 @@ connection_dir_about_to_close(dir_connection_t *dir_conn)
|
||||
connection_dir_client_request_failed(dir_conn);
|
||||
}
|
||||
|
||||
if (!dir_conn->hs_request) {
|
||||
const time_t now = approx_time();
|
||||
if (dir_conn->num_read > 0)
|
||||
bwhist_note_dir_bytes_read(dir_conn->num_read, now);
|
||||
if (dir_conn->num_written > 0)
|
||||
bwhist_note_dir_bytes_written(dir_conn->num_written, now);
|
||||
}
|
||||
stats_increment_dir_bytes_read_and_written(dir_conn->num_read,
|
||||
dir_conn->num_written, dir_conn->hs_request);
|
||||
|
||||
connection_dir_client_refetch_hsdesc_if_needed(dir_conn);
|
||||
}
|
||||
|
||||
|
@ -419,7 +419,9 @@ fill_traffic_directory_values(void)
|
||||
the_store, rentry->type, rentry->name, rentry->help, 0, NULL);
|
||||
metrics_store_entry_add_label(sentry,
|
||||
metrics_format_label("direction", "read"));
|
||||
metrics_store_entry_update(sentry, get_dir_bytes_read());
|
||||
metrics_store_entry_add_label(sentry,
|
||||
metrics_format_label("kind", "directory"));
|
||||
metrics_store_entry_update(sentry, get_dir_bytes_read(false));
|
||||
|
||||
sentry = metrics_store_add(the_store, rentry->type, rentry->name,
|
||||
rentry->help, 0, NULL);
|
||||
@ -429,6 +431,14 @@ fill_traffic_directory_values(void)
|
||||
metrics_format_label("kind", "directory"));
|
||||
metrics_store_entry_update(sentry, get_dir_bytes_written(false));
|
||||
|
||||
sentry = metrics_store_add(
|
||||
the_store, rentry->type, rentry->name, rentry->help, 0, NULL);
|
||||
metrics_store_entry_add_label(sentry,
|
||||
metrics_format_label("direction", "read"));
|
||||
metrics_store_entry_add_label(sentry,
|
||||
metrics_format_label("kind", "hsdir"));
|
||||
metrics_store_entry_update(sentry, get_dir_bytes_read(true));
|
||||
|
||||
sentry = metrics_store_add(the_store, rentry->type, rentry->name,
|
||||
rentry->help, 0, NULL);
|
||||
metrics_store_entry_add_label(sentry,
|
||||
|
Loading…
Reference in New Issue
Block a user