diff options
author | David Goulet <dgoulet@torproject.org> | 2022-11-08 15:26:44 -0500 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2022-11-08 15:26:44 -0500 |
commit | 8b8873b759183d2f6d3a92cff2773ca74d1a4ce8 (patch) | |
tree | 82a6d5ece9d7bc3f3ce4d1f250243d97d5e9788e /src/feature/relay | |
parent | 56ee2131f19c462e2e4be294b61128a10b8ce374 (diff) | |
parent | 5b0103cfb4a8e3c9807eab8d381cff0cf65d7ab8 (diff) | |
download | tor-8b8873b759183d2f6d3a92cff2773ca74d1a4ce8.tar.gz tor-8b8873b759183d2f6d3a92cff2773ca74d1a4ce8.zip |
Merge branch 'maint-0.4.7'
Diffstat (limited to 'src/feature/relay')
-rw-r--r-- | src/feature/relay/relay_metrics.c | 60 |
1 files changed, 50 insertions, 10 deletions
diff --git a/src/feature/relay/relay_metrics.c b/src/feature/relay/relay_metrics.c index cd80c5e95e..02e38d7699 100644 --- a/src/feature/relay/relay_metrics.c +++ b/src/feature/relay/relay_metrics.c @@ -184,6 +184,22 @@ handshake_type_to_str(const uint16_t type) } } +/** Helper function to convert a socket family type into a string. */ +static inline const char * +af_to_string(const int af) +{ + switch (af) { + case AF_INET: + return "ipv4"; + case AF_INET6: + return "ipv6"; + case AF_UNIX: + return "unix"; + default: + return "<unknown>"; + } +} + /** Fill function for the RELAY_METRICS_NUM_CIRCUITS metric. */ static void fill_circuits_values(void) @@ -515,6 +531,7 @@ fill_single_connection_value(metrics_store_entry_t *sentry, unsigned int conn_type, const char* direction, const char* state, + int socket_family, uint64_t value) { metrics_store_entry_add_label(sentry, @@ -523,6 +540,8 @@ fill_single_connection_value(metrics_store_entry_t *sentry, metrics_format_label("direction", direction)); metrics_store_entry_add_label(sentry, metrics_format_label("state", state)); + metrics_store_entry_add_label(sentry, + metrics_format_label("family", af_to_string(socket_family))); metrics_store_entry_update(sentry, value); } @@ -540,28 +559,49 @@ fill_connections_values(void) } metrics_store_entry_t *sentry = metrics_store_add(the_store, rentry->type, rentry->name, rentry->help); - fill_single_connection_value(sentry, i, "initiated", "created", - rep_hist_get_conn_created(false, i)); + fill_single_connection_value(sentry, i, "initiated", "created", AF_INET, + rep_hist_get_conn_created(false, i, AF_INET)); + sentry = metrics_store_add(the_store, rentry->type, rentry->name, + rentry->help); + fill_single_connection_value(sentry, i, "initiated", "created", AF_INET6, + rep_hist_get_conn_created(false, i, + AF_INET6)); sentry = metrics_store_add(the_store, rentry->type, rentry->name, rentry->help); - fill_single_connection_value(sentry, i, "received", "created", - rep_hist_get_conn_created(true, i)); + fill_single_connection_value(sentry, i, "received", "created", AF_INET, + rep_hist_get_conn_created(true, i, AF_INET)); + sentry = metrics_store_add(the_store, rentry->type, rentry->name, + rentry->help); + fill_single_connection_value(sentry, i, "received", "created", AF_INET6, + rep_hist_get_conn_created(true, i, AF_INET6)); sentry = metrics_store_add(the_store, rentry->type, rentry->name, rentry->help); - fill_single_connection_value(sentry, i, "initiated", "opened", - rep_hist_get_conn_opened(false, i)); + fill_single_connection_value(sentry, i, "initiated", "opened", AF_INET, + rep_hist_get_conn_opened(false, i, AF_INET)); + sentry = metrics_store_add(the_store, rentry->type, rentry->name, + rentry->help); + fill_single_connection_value(sentry, i, "initiated", "opened", AF_INET6, + rep_hist_get_conn_opened(false, i, AF_INET6)); sentry = metrics_store_add(the_store, rentry->type, rentry->name, rentry->help); - fill_single_connection_value(sentry, i, "received", "opened", - rep_hist_get_conn_opened(true, i)); + fill_single_connection_value(sentry, i, "received", "opened", AF_INET, + rep_hist_get_conn_opened(true, i, AF_INET)); + sentry = metrics_store_add(the_store, rentry->type, rentry->name, + rentry->help); + fill_single_connection_value(sentry, i, "received", "opened", AF_INET6, + rep_hist_get_conn_opened(true, i, AF_INET6)); sentry = metrics_store_add(the_store, rentry->type, rentry->name, rentry->help); - fill_single_connection_value(sentry, i, "received", "rejected", - rep_hist_get_conn_rejected(i)); + fill_single_connection_value(sentry, i, "received", "rejected", AF_INET, + rep_hist_get_conn_rejected(i, AF_INET)); + sentry = metrics_store_add(the_store, rentry->type, rentry->name, + rentry->help); + fill_single_connection_value(sentry, i, "received", "rejected", AF_INET6, + rep_hist_get_conn_rejected(i, AF_INET6)); } } |