]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Send NETINFO on receiving a NETINFO if we have not yet sent one.
authorNick Mathewson <nickm@torproject.org>
Tue, 20 Aug 2013 18:52:56 +0000 (14:52 -0400)
committerNick Mathewson <nickm@torproject.org>
Wed, 21 Aug 2013 15:28:57 +0000 (11:28 -0400)
(Backport to Tor 0.2.3)

Relays previously, when initiating a connection, would only send a
NETINFO after sending an AUTHENTICATE.  But bridges, when receiving a
connection, would never send AUTH_CHALLENGE.  So relays wouldn't
AUTHENTICATE, and wouldn't NETINFO, and then bridges would be
surprised to be receiving CREATE cells on a non-open circuit.

Fixes bug 9546.

bug9546 [new file with mode: 0644]
src/or/command.c
src/or/connection_or.c
src/or/or.h

diff --git a/bug9546 b/bug9546
new file mode 100644 (file)
index 0000000..8596eac
--- /dev/null
+++ b/bug9546
@@ -0,0 +1,5 @@
+  o Major bugfixes:
+
+    - When a relay is extending a circuit to a bridge, it needs to send a
+      NETINFO cell, even when the bridge hasn't sent an AUTH_CHALLENGE
+      cell. Fixes bug 9546; bugfix on ????.
index 8321e261e03c2cae6bf7b37d9e730ff97a0944fd..26e4e6897f6b3f0a196bed2b2ad9a9e70b0b5e04 100644 (file)
@@ -941,6 +941,16 @@ command_process_netinfo_cell(cell_t *cell, or_connection_t *conn)
    * trustworthy. */
   (void)my_apparent_addr;
 
+  if (! conn->handshake_state->sent_netinfo) {
+    /* If we were prepared to authenticate, but we never got an AUTH_CHALLENGE
+     * cell, then we would not previously have sent a NETINFO cell. Do so
+     * now. */
+    if (connection_or_send_netinfo(conn) < 0) {
+      connection_mark_for_close(TO_CONN(conn));
+      return;
+    }
+  }
+
   if (connection_or_set_state_open(conn)<0) {
     log_fn(LOG_PROTOCOL_WARN, LD_OR, "Got good NETINFO cell from %s:%d; but "
            "was unable to make the OR connection become open.",
index 5eecee07403e7a87daab2c119bf9d61f605599dd..56c6ed520aea0359cf69c7b8512af86ad7660d74 100644 (file)
@@ -1975,6 +1975,12 @@ connection_or_send_netinfo(or_connection_t *conn)
 
   tor_assert(conn->handshake_state);
 
+  if (conn->handshake_state->sent_netinfo) {
+    log_warn(LD_BUG, "Attempted to send an extra netinfo cell on a connection "
+             "where we already sent one.");
+    return 0;
+  }
+
   memset(&cell, 0, sizeof(cell_t));
   cell.command = CELL_NETINFO;
 
@@ -2009,6 +2015,7 @@ connection_or_send_netinfo(or_connection_t *conn)
   }
 
   conn->handshake_state->digest_sent_data = 0;
+  conn->handshake_state->sent_netinfo = 1;
   connection_or_write_cell_to_buf(&cell, conn);
 
   return 0;
index dd95c349c08e119d2e394d840d2498c132582dac..b8f334ece2cd352c5034525e3db083adcc712ed3 100644 (file)
@@ -1161,6 +1161,9 @@ typedef struct or_handshake_state_t {
   /* True iff we've received valid authentication to some identity. */
   unsigned int authenticated : 1;
 
+  /* True iff we have sent a netinfo cell */
+  unsigned int sent_netinfo : 1;
+
   /** True iff we should feed outgoing cells into digest_sent and
    * digest_received respectively.
    *