[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Hook up circuit padding to circuit_t.
commit 2f7b5a2d4468532251dd7b177c02a9c192690174
Author: Mike Perry <mikeperry-git@xxxxxxxxxxxxxx>
Date: Tue Oct 23 19:51:22 2018 +0000
Hook up circuit padding to circuit_t.
Co-authored-by: George Kadianakis <desnacked@xxxxxxxxxx>
---
src/core/or/circuit_st.h | 24 ++++++++++++++++++++++++
src/core/or/circuitlist.c | 4 ++++
src/core/or/origin_circuit_st.h | 4 ++++
3 files changed, 32 insertions(+)
diff --git a/src/core/or/circuit_st.h b/src/core/or/circuit_st.h
index 2e33b37b0..0d9ad3cdd 100644
--- a/src/core/or/circuit_st.h
+++ b/src/core/or/circuit_st.h
@@ -12,6 +12,11 @@
#include "core/or/cell_queue_st.h"
struct hs_token_t;
+typedef struct circpad_machine_t circpad_machine_t;
+typedef struct circpad_machineinfo_t circpad_machineinfo_t;
+
+/** Number of padding state machines on a circuit. */
+#define CIRCPAD_MAX_MACHINES (2)
/** "magic" value for an origin_circuit_t */
#define ORIGIN_CIRCUIT_MAGIC 0x35315243u
@@ -177,6 +182,25 @@ struct circuit_t {
/** Hashtable node: used to look up the circuit by its HS token using the HS
circuitmap. */
HT_ENTRY(circuit_t) hs_circuitmap_node;
+
+ /** Adaptive Padding state machines: these are immutable. The state machines
+ * that come from the consensus are saved to a global structure, to avoid
+ * per-circuit allocations. This merely points to the global copy.
+ *
+ * Each element of this array corresponds to a different padding machine,
+ * and we can have up to CIRCPAD_MAX_MACHINES such machines. */
+ const circpad_machine_t *padding_machine[CIRCPAD_MAX_MACHINES];
+
+ /** Adaptive Padding machine info for above machines. This is the
+ * per-circuit mutable information, such as the current state and
+ * histogram token counts. Some of it is optional (aka NULL).
+ * If a machine is being shut down, these indexes can be NULL
+ * without the corresponding padding_machine being NULL, while we
+ * wait for the other end to respond to our shutdown request.
+ *
+ * Each element of this array corresponds to a different padding machine,
+ * and we can have up to CIRCPAD_MAX_MACHINES such machines. */
+ circpad_machineinfo_t *padding_info[CIRCPAD_MAX_MACHINES];
};
#endif
diff --git a/src/core/or/circuitlist.c b/src/core/or/circuitlist.c
index c4b5f7ee3..71f8becdd 100644
--- a/src/core/or/circuitlist.c
+++ b/src/core/or/circuitlist.c
@@ -62,6 +62,7 @@
#include "core/or/circuitlist.h"
#include "core/or/circuituse.h"
#include "core/or/circuitstats.h"
+#include "core/or/circuitpadding.h"
#include "core/mainloop/connection.h"
#include "app/config/config.h"
#include "core/or/connection_edge.h"
@@ -1231,6 +1232,9 @@ circuit_free_(circuit_t *circ)
CIRCUIT_IS_ORIGIN(circ) ?
TO_ORIGIN_CIRCUIT(circ)->global_identifier : 0);
+ /* Free any circuit padding structures */
+ circpad_circuit_free_all_machineinfos(circ);
+
if (should_free) {
memwipe(mem, 0xAA, memlen); /* poison memory */
tor_free(mem);
diff --git a/src/core/or/origin_circuit_st.h b/src/core/or/origin_circuit_st.h
index 26cdf590f..921076c1b 100644
--- a/src/core/or/origin_circuit_st.h
+++ b/src/core/or/origin_circuit_st.h
@@ -161,6 +161,10 @@ struct origin_circuit_t {
* connections to this circuit. */
unsigned int unusable_for_new_conns : 1;
+ /* If this flag is set (due to padding negotiation failure), we should
+ * not try to negotiate further circuit padding. */
+ unsigned padding_negotiation_failed : 1;
+
/**
* Tristate variable to guard against pathbias miscounting
* due to circuit purpose transitions changing the decision
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits