[tor-commits] [tor/master] Merge remote-tracking branch 'public/wide_circ_ids'
nickm at torproject.org
nickm at torproject.org
Fri Feb 15 21:23:51 UTC 2013
commit d6634001c9063323643e3ddfe8905c250a6d60d7
Merge: 5fcc5df 076654c
Author: Nick Mathewson <nickm at torproject.org>
Date: Fri Feb 15 16:23:43 2013 -0500
Merge remote-tracking branch 'public/wide_circ_ids'
Conflicts:
src/or/channel.h
src/or/connection_or.c
src/or/cpuworker.c
src/or/buffers.c | 42 ++++++++++++-------
src/or/channel.c | 14 +++++-
src/or/channel.h | 5 ++-
src/or/channeltls.c | 29 ++++++++++----
src/or/circuitbuild.c | 12 +++---
src/or/circuitlist.c | 2 +-
src/or/command.c | 5 ++-
src/or/connection.c | 8 ++--
src/or/connection_or.c | 105 +++++++++++++++++++++++++++++++----------------
src/or/connection_or.h | 14 +++++--
src/or/cpuworker.c | 6 +-
src/or/or.h | 33 ++++++++++++---
src/or/relay.c | 11 +++--
src/or/relay.h | 3 +-
src/or/router.c | 3 +-
15 files changed, 197 insertions(+), 95 deletions(-)
diff --cc src/or/channel.h
index ec79888,a21271c..0933ec8
--- a/src/or/channel.h
+++ b/src/or/channel.h
@@@ -142,7 -142,9 +142,9 @@@ struct channel_s
* When we send CREATE cells along this connection, which half of the
* space should we use?
*/
- circ_id_type_t circ_id_type:2;
+ ENUM_BF(circ_id_type_t) circ_id_type:2;
+ /** DOCDOC*/
+ unsigned wide_circ_ids:1;
/*
* Which circ_id do we try to use next on this connection? This is
* always in the range 0..1<<15-1.
diff --cc src/or/command.c
index 09313b4,4007cd6..dfe4f65
--- a/src/or/command.c
+++ b/src/or/command.c
@@@ -221,17 -218,12 +221,20 @@@ command_process_create_cell(cell_t *cel
return;
}
+ if (cell->circ_id == 0) {
+ log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
+ "Received a create cell (type %d) from %s with zero circID; "
+ " ignoring.", (int)cell->command,
+ channel_get_actual_remote_descr(chan));
+ return;
+ }
+
/* If the high bit of the circuit ID is not as expected, close the
* circ. */
- id_is_high = cell->circ_id & (1<<15);
+ if (chan->wide_circ_ids)
+ id_is_high = cell->circ_id & (1u<<31);
+ else
+ id_is_high = cell->circ_id & (1u<<15);
if ((id_is_high &&
chan->circ_id_type == CIRC_ID_TYPE_HIGHER) ||
(!id_is_high &&
diff --cc src/or/connection_or.c
index 5ec32d6,4da4367..c4415c5
--- a/src/or/connection_or.c
+++ b/src/or/connection_or.c
@@@ -1764,9 -1785,9 +1791,9 @@@ or_handshake_state_record_cell(or_conne
d = *dptr;
/* Re-packing like this is a little inefficient, but we don't have to do
this very often at all. */
- cell_pack(&packed, cell);
- crypto_digest_add_bytes(d, packed.body, sizeof(packed.body));
+ cell_pack(&packed, cell, conn->wide_circ_ids);
+ crypto_digest_add_bytes(d, packed.body, cell_network_size);
- memset(&packed, 0, sizeof(packed));
+ memwipe(&packed, 0, sizeof(packed));
}
/** Remember that a variable-length <b>cell</b> has been transmitted (if
@@@ -1797,11 -1820,11 +1826,11 @@@ or_handshake_state_record_var_cell(or_c
d = *dptr;
- var_cell_pack_header(cell, buf);
- crypto_digest_add_bytes(d, buf, sizeof(buf));
+ n = var_cell_pack_header(cell, buf, conn->wide_circ_ids);
+ crypto_digest_add_bytes(d, buf, n);
crypto_digest_add_bytes(d, (const char *)cell->payload, cell->payload_len);
- memset(buf, 0, sizeof(buf));
+ memwipe(buf, 0, sizeof(buf));
}
/** Set <b>conn</b>'s state to OR_CONN_STATE_OPEN, and tell other subsystems
diff --cc src/or/cpuworker.c
index 444f17c,a25a8a7..af5f91a
--- a/src/or/cpuworker.c
+++ b/src/or/cpuworker.c
@@@ -31,7 -31,10 +31,7 @@@
#define MIN_CPUWORKERS 1
/** The tag specifies which circuit this onionskin was from. */
- #define TAG_LEN 10
+ #define TAG_LEN 12
-/** How many bytes are sent from the cpuworker back to tor? */
-#define LEN_ONION_RESPONSE \
- (1+TAG_LEN+ONIONSKIN_REPLY_LEN+CPATH_KEY_MATERIAL_LEN)
/** How many cpuworkers we have running right now. */
static int num_cpuworkers=0;
@@@ -78,69 -81,12 +78,69 @@@ tag_pack(uint8_t *tag, uint64_t chan_id
/** Unpack <b>tag</b> into addr, port, and circ_id.
*/
static void
-tag_unpack(const char *tag, uint64_t *chan_id, circid_t *circ_id)
+tag_unpack(const uint8_t *tag, uint64_t *chan_id, circid_t *circ_id)
{
*chan_id = get_uint64(tag);
- *circ_id = get_uint16(tag+8);
+ *circ_id = get_uint32(tag+8);
}
+/** Magic numbers to make sure our cpuworker_requests don't grow any
+ * mis-framing bugs. */
+#define CPUWORKER_REQUEST_MAGIC 0xda4afeed
+#define CPUWORKER_REPLY_MAGIC 0x5eedf00d
+
+/** A request sent to a cpuworker. */
+typedef struct cpuworker_request_t {
+ /** Magic number; must be CPUWORKER_REQUEST_MAGIC. */
+ uint32_t magic;
+ /** Opaque tag to identify the job */
+ uint8_t tag[TAG_LEN];
+ /** Task code. Must be one of CPUWORKER_TASK_* */
+ uint8_t task;
+
+ /** Flag: Are we timing this request? */
+ unsigned timed : 1;
+ /** If we're timing this request, when was it sent to the cpuworker? */
+ struct timeval started_at;
+
+ /** A create cell for the cpuworker to process. */
+ create_cell_t create_cell;
+
+ /* Turn the above into a tagged union if needed. */
+} cpuworker_request_t;
+
+/** A reply sent by a cpuworker. */
+typedef struct cpuworker_reply_t {
+ /** Magic number; must be CPUWORKER_REPLY_MAGIC. */
+ uint32_t magic;
+ /** Opaque tag to identify the job; matches the request's tag.*/
+ uint8_t tag[TAG_LEN];
+ /** True iff we got a successful request. */
+ uint8_t success;
+
+ /** Are we timing this request? */
+ unsigned int timed : 1;
+ /** What handshake type was the request? (Used for timing) */
+ uint16_t handshake_type;
+ /** When did we send the request to the cpuworker? */
+ struct timeval started_at;
+ /** Once the cpuworker received the request, how many microseconds did it
+ * take? (This shouldn't overflow; 4 billion micoseconds is over an hour,
+ * and we'll never have an onion handshake that takes so long.) */
+ uint32_t n_usec;
+
+ /** Output of processing a create cell
+ *
+ * @{
+ */
+ /** The created cell to send back. */
+ created_cell_t created_cell;
+ /** The keys to use on this circuit. */
+ uint8_t keys[CPATH_KEY_MATERIAL_LEN];
+ /** Input to use for authenticating introduce1 cells. */
+ uint8_t rend_auth_material[DIGEST_LEN];
+} cpuworker_reply_t;
+
/** Called when the onion key has changed and we need to spawn new
* cpuworkers. Close all currently idle cpuworkers, and mark the last
* rotation time as now.
More information about the tor-commits
mailing list