[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Add IPv6 read and write history to bwhist, state, and extrainfo.



commit c5db7667d6964344e87fb7ee71df3f2ebe8131e6
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Fri Jul 10 08:29:24 2020 -0400

    Add IPv6 read and write history to bwhist, state, and extrainfo.
    
    These values are stored, persisted, and published.  They are not yet
    actually filled with anything.
---
 src/app/config/or_state_st.h |  8 ++++++++
 src/app/config/statefile.c   |  8 ++++++++
 src/feature/stats/bwhist.c   | 21 +++++++++++++++++++--
 3 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/src/app/config/or_state_st.h b/src/app/config/or_state_st.h
index 8c4e9d5e6..31b7f8a98 100644
--- a/src/app/config/or_state_st.h
+++ b/src/app/config/or_state_st.h
@@ -65,6 +65,14 @@ struct or_state_t {
   int         BWHistoryWriteInterval;
   struct smartlist_t *BWHistoryWriteValues;
   struct smartlist_t *BWHistoryWriteMaxima;
+  time_t      BWHistoryIPv6ReadEnds;
+  int         BWHistoryIPv6ReadInterval;
+  struct smartlist_t *BWHistoryIPv6ReadValues;
+  struct smartlist_t *BWHistoryIPv6ReadMaxima;
+  time_t      BWHistoryIPv6WriteEnds;
+  int         BWHistoryIPv6WriteInterval;
+  struct smartlist_t *BWHistoryIPv6WriteValues;
+  struct smartlist_t *BWHistoryIPv6WriteMaxima;
   time_t      BWHistoryDirReadEnds;
   int         BWHistoryDirReadInterval;
   struct smartlist_t *BWHistoryDirReadValues;
diff --git a/src/app/config/statefile.c b/src/app/config/statefile.c
index 4198c8a38..b25167d2e 100644
--- a/src/app/config/statefile.c
+++ b/src/app/config/statefile.c
@@ -112,6 +112,14 @@ static const config_var_t state_vars_[] = {
   V(BWHistoryWriteInterval,           POSINT,     "900"),
   V(BWHistoryWriteValues,             CSV,      ""),
   V(BWHistoryWriteMaxima,             CSV,      ""),
+  V(BWHistoryIPv6ReadEnds,                ISOTIME,  NULL),
+  V(BWHistoryIPv6ReadInterval,            POSINT,     "900"),
+  V(BWHistoryIPv6ReadValues,              CSV,      ""),
+  V(BWHistoryIPv6ReadMaxima,              CSV,      ""),
+  V(BWHistoryIPv6WriteEnds,               ISOTIME,  NULL),
+  V(BWHistoryIPv6WriteInterval,           POSINT,     "900"),
+  V(BWHistoryIPv6WriteValues,             CSV,      ""),
+  V(BWHistoryIPv6WriteMaxima,             CSV,      ""),
   V(BWHistoryDirReadEnds,             ISOTIME,  NULL),
   V(BWHistoryDirReadInterval,         POSINT,     "900"),
   V(BWHistoryDirReadValues,           CSV,      ""),
diff --git a/src/feature/stats/bwhist.c b/src/feature/stats/bwhist.c
index fef8a3b2d..44717f33b 100644
--- a/src/feature/stats/bwhist.c
+++ b/src/feature/stats/bwhist.c
@@ -162,10 +162,14 @@ bw_array_free_(bw_array_t *b)
   tor_free(b);
 }
 
-/** Recent history of bandwidth observations for read operations. */
+/** Recent history of bandwidth observations for (all) read operations. */
 static bw_array_t *read_array = NULL;
-/** Recent history of bandwidth observations for write operations. */
+/** Recent history of bandwidth observations for IPv6 read operations. */
+static bw_array_t *read_array_ipv6 = NULL;
+/** Recent history of bandwidth observations for (all) write operations. */
 STATIC bw_array_t *write_array = NULL;
+/** Recent history of bandwidth observations for IPv6 write operations. */
+static bw_array_t *write_array_ipv6 = NULL;
 /** Recent history of bandwidth observations for read operations for the
     directory protocol. */
 static bw_array_t *dir_read_array = NULL;
@@ -179,12 +183,16 @@ void
 bwhist_init(void)
 {
   bw_array_free(read_array);
+  bw_array_free(read_array_ipv6);
   bw_array_free(write_array);
+  bw_array_free(write_array_ipv6);
   bw_array_free(dir_read_array);
   bw_array_free(dir_write_array);
 
   read_array = bw_array_new();
+  read_array_ipv6 = bw_array_new();
   write_array = bw_array_new();
+  write_array_ipv6 = bw_array_new();
   dir_read_array = bw_array_new();
   dir_write_array = bw_array_new();
 }
@@ -358,6 +366,8 @@ bwhist_get_bandwidth_lines(void)
 
   bwhist_get_one_bandwidth_line(buf, "write-history", write_array);
   bwhist_get_one_bandwidth_line(buf, "read-history", read_array);
+  bwhist_get_one_bandwidth_line(buf, "ipv6-write-history", write_array_ipv6);
+  bwhist_get_one_bandwidth_line(buf, "ipv6-read-history", read_array_ipv6);
   bwhist_get_one_bandwidth_line(buf, "dirreq-write-history", dir_write_array);
   bwhist_get_one_bandwidth_line(buf, "dirreq-read-history", dir_read_array);
 
@@ -441,6 +451,8 @@ bwhist_update_state(or_state_t *state)
 
   UPDATE(write_array, Write);
   UPDATE(read_array, Read);
+  UPDATE(write_array_ipv6, IPv6Write);
+  UPDATE(read_array_ipv6, IPv6Read);
   UPDATE(dir_write_array, DirWrite);
   UPDATE(dir_read_array, DirRead);
 
@@ -535,6 +547,7 @@ bwhist_load_state(or_state_t *state, char **err)
 
   /* Assert they already have been malloced */
   tor_assert(read_array && write_array);
+  tor_assert(read_array_ipv6 && write_array_ipv6);
   tor_assert(dir_read_array && dir_write_array);
 
 #define LOAD(arrname,st)                                                \
@@ -548,6 +561,8 @@ bwhist_load_state(or_state_t *state, char **err)
 
   LOAD(write_array, Write);
   LOAD(read_array, Read);
+  LOAD(write_array_ipv6, IPv6Write);
+  LOAD(read_array_ipv6, IPv6Read);
   LOAD(dir_write_array, DirWrite);
   LOAD(dir_read_array, DirRead);
 
@@ -565,7 +580,9 @@ void
 bwhist_free_all(void)
 {
   bw_array_free(read_array);
+  bw_array_free(read_array_ipv6);
   bw_array_free(write_array);
+  bw_array_free(write_array_ipv6);
   bw_array_free(dir_read_array);
   bw_array_free(dir_write_array);
 }



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits