Commit bdc94118 authored by Mike Perry's avatar Mike Perry
Browse files

fixup! Handle ntorv3 handshake type in various codepaths

Note more cases
parent 2b723f4e
......@@ -396,6 +396,7 @@ dumpstats(int severity)
100*(((double)stats_n_data_bytes_received) /
((double)stats_n_data_cells_received*RELAY_PAYLOAD_SIZE)) );
// XXX TODO-324 ntorv3?? or combine with ntor?
cpuworker_log_onionskin_overhead(severity, ONION_HANDSHAKE_TYPE_TAP, "TAP");
cpuworker_log_onionskin_overhead(severity, ONION_HANDSHAKE_TYPE_NTOR,"ntor");
......
......@@ -90,7 +90,8 @@ check_create_cell(const create_cell_t *cell, int unknown_ok)
return -1;
break;
case ONION_HANDSHAKE_TYPE_NTOR_V3:
// TODO-324: can we check this?
// XXX TODO-324: Do we need check this, or is this
// an old codepath because CREATE vs CREATE2?
break;
default:
if (! unknown_ok)
......@@ -160,6 +161,7 @@ create_cell_parse(create_cell_t *cell_out, const cell_t *cell_in)
{
switch (cell_in->command) {
case CELL_CREATE:
// XXX TODO-324 ntorv3?
if (tor_memeq(cell_in->payload, NTOR_CREATE_MAGIC, 16)) {
create_cell_init(cell_out, CELL_CREATE, ONION_HANDSHAKE_TYPE_NTOR,
NTOR_ONIONSKIN_LEN, cell_in->payload+16);
......@@ -173,6 +175,7 @@ create_cell_parse(create_cell_t *cell_out, const cell_t *cell_in)
CREATE_FAST_LEN, cell_in->payload);
break;
case CELL_CREATE2:
// XXX TODO-324 ntorv3?
if (parse_create2_payload(cell_out, cell_in->payload,
CELL_PAYLOAD_SIZE) < 0)
return -1;
......@@ -289,6 +292,7 @@ extend_cell_from_extend1_cell_body(extend_cell_t *cell_out,
cell_out->cell_type = RELAY_COMMAND_EXTEND;
tor_addr_from_ipv4h(&cell_out->orport_ipv4.addr, cell->ipv4addr);
cell_out->orport_ipv4.port = cell->port;
// XXX TODO-324 ntorv3??
if (tor_memeq(cell->onionskin, NTOR_CREATE_MAGIC, 16)) {
cell_out->create_cell.cell_type = CELL_CREATE2;
cell_out->create_cell.handshake_type = ONION_HANDSHAKE_TYPE_NTOR;
......@@ -525,6 +529,7 @@ create_cell_format_impl(cell_t *cell_out, const create_cell_t *cell_in,
switch (cell_in->cell_type) {
case CELL_CREATE:
// XXX TODO-324 ntorv3??
if (cell_in->handshake_type == ONION_HANDSHAKE_TYPE_NTOR) {
memcpy(p, NTOR_CREATE_MAGIC, 16);
p += 16;
......@@ -627,6 +632,7 @@ extend_cell_format(uint8_t *command_out, uint16_t *len_out,
*len_out = 6 + TAP_ONIONSKIN_CHALLENGE_LEN + DIGEST_LEN;
set_uint32(p, tor_addr_to_ipv4n(&cell_in->orport_ipv4.addr));
set_uint16(p+4, htons(cell_in->orport_ipv4.port));
// XXX TODO-324 ntorv3??
if (cell_in->create_cell.handshake_type == ONION_HANDSHAKE_TYPE_NTOR) {
memcpy(p+6, NTOR_CREATE_MAGIC, 16);
memcpy(p+22, cell_in->create_cell.onionskin, NTOR_ONIONSKIN_LEN);
......@@ -661,6 +667,7 @@ extend_cell_format(uint8_t *command_out, uint16_t *len_out,
ls->ls_len = DIGEST_LEN;
memcpy(ls->un_legacy_id, cell_in->node_id, DIGEST_LEN);
}
// XXX TODO-324 ntorv3??
if (should_include_ed25519_id_extend_cells(NULL, get_options()) &&
!ed25519_public_key_is_zero(&cell_in->ed_pubkey)) {
/* Then, maybe, the ed25519 id! */
......
......@@ -1426,6 +1426,8 @@ getinfo_helper_rephist(control_connection_t *control_conn,
(void) errmsg;
int result;
// XXX TODO-324 ntorv3?? combine them? changing rephist will change
// metrics too... maybe just combine is best?
if (!strcmp(question, "stats/ntor/assigned")) {
result =
rep_hist_get_circuit_handshake_assigned(ONION_HANDSHAKE_TYPE_NTOR);
......
......@@ -110,6 +110,7 @@ have_room_for_onionskin(uint16_t type)
/* How long would it take to process the ntor cells that we expect to
* process while draining the tap queue? */
// XXX TODO-324 ntorv3??
ntor_during_tap_usec = estimated_usec_for_onionskins(
MIN(ol_entries[ONION_HANDSHAKE_TYPE_NTOR],
ol_entries[ONION_HANDSHAKE_TYPE_TAP] * num_ntors_per_tap()),
......@@ -165,6 +166,7 @@ onion_pending_add(or_circuit_t *circ, create_cell_t *onionskin)
static ratelim_t last_warned =
RATELIM_INIT(WARN_TOO_MANY_CIRC_CREATIONS_INTERVAL);
rep_hist_note_circuit_handshake_dropped(onionskin->handshake_type);
// XXX TODO-324 ntorv3??
if (onionskin->handshake_type == ONION_HANDSHAKE_TYPE_NTOR) {
char *m;
/* Note this ntor onionskin drop as an overload */
......@@ -184,6 +186,7 @@ onion_pending_add(or_circuit_t *circ, create_cell_t *onionskin)
}
++ol_entries[onionskin->handshake_type];
// XXX TODO-324 ntorv3??
log_info(LD_OR, "New create (%s). Queues now ntor=%d and tap=%d.",
onionskin->handshake_type == ONION_HANDSHAKE_TYPE_NTOR ? "ntor" : "tap",
ol_entries[ONION_HANDSHAKE_TYPE_NTOR],
......@@ -237,6 +240,7 @@ decide_next_handshake_type(void)
/* The number of times we've chosen ntor lately when both were available. */
static int recently_chosen_ntors = 0;
// XXX TODO-324 ntorv3??
if (!ol_entries[ONION_HANDSHAKE_TYPE_NTOR])
return ONION_HANDSHAKE_TYPE_TAP; /* no ntors? try tap */
......@@ -289,6 +293,7 @@ onion_next_task(create_cell_t **onionskin_out)
circ = head->circ;
if (head->onionskin)
--ol_entries[head->handshake_type];
// XXX TODO-324 ntorv3??
log_info(LD_OR, "Processing create (%s). Queues now ntor=%d and tap=%d.",
head->handshake_type == ONION_HANDSHAKE_TYPE_NTOR ? "ntor" : "tap",
ol_entries[ONION_HANDSHAKE_TYPE_NTOR],
......@@ -342,6 +347,7 @@ onion_queue_entry_remove(onion_queue_t *victim)
/* LCOV_EXCL_STOP */
}
// XXX TODO-324: ntorv3?? are we sure we want separate queues?
TOR_TAILQ_REMOVE(&ol_list[victim->handshake_type], victim, next);
if (victim->circ)
......
......@@ -2230,6 +2230,7 @@ void
rep_hist_log_circuit_handshake_stats(time_t now)
{
(void)now;
// XXX TODO-324 ntorv3??
log_notice(LD_HEARTBEAT, "Circuit handshake stats since last time: "
"%d/%d TAP, %d/%d NTor.",
onion_handshakes_assigned[ONION_HANDSHAKE_TYPE_TAP],
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment