Browse Source

more log uncluttering

svn:r5254
Roger Dingledine 20 years ago
parent
commit
ae92a91d96
5 changed files with 28 additions and 17 deletions
  1. 7 5
      src/or/circuitbuild.c
  2. 7 1
      src/or/connection.c
  3. 3 4
      src/or/connection_or.c
  4. 1 1
      src/or/main.c
  5. 10 6
      src/or/relay.c

+ 7 - 5
src/or/circuitbuild.c

@@ -599,8 +599,9 @@ circuit_note_clock_jumped(int seconds_elapsed)
 }
 }
 
 
 /** Take the 'extend' cell, pull out addr/port plus the onion skin. Make
 /** Take the 'extend' cell, pull out addr/port plus the onion skin. Make
- * sure we're connected to the next hop, and pass it the onion skin in
- * a create cell.
+ * sure we're connected to the next hop, and pass it the onion skin using
+ * a create cell. Return -1 if we want to warn and tear down the circuit,
+ * else return 0.
  */
  */
 int
 int
 circuit_extend(cell_t *cell, circuit_t *circ)
 circuit_extend(cell_t *cell, circuit_t *circ)
@@ -611,14 +612,14 @@ circuit_extend(cell_t *cell, circuit_t *circ)
   char *id_digest=NULL;
   char *id_digest=NULL;
 
 
   if (circ->n_conn) {
   if (circ->n_conn) {
-    log_fn(LOG_WARN,"n_conn already set. Bug/attack. Closing.");
+    log_fn(LOG_PROTOCOL_WARN,"n_conn already set. Bug/attack. Closing.");
     return -1;
     return -1;
   }
   }
 
 
   relay_header_unpack(&rh, cell->payload);
   relay_header_unpack(&rh, cell->payload);
 
 
   if (rh.length < 4+2+ONIONSKIN_CHALLENGE_LEN+DIGEST_LEN) {
   if (rh.length < 4+2+ONIONSKIN_CHALLENGE_LEN+DIGEST_LEN) {
-    log_fn(LOG_WARN, "Wrong length %d on extend cell. Closing circuit.", rh.length);
+    log_fn(LOG_PROTOCOL_WARN, "Wrong length %d on extend cell. Closing circuit.", rh.length);
     return -1;
     return -1;
   }
   }
 
 
@@ -654,7 +655,8 @@ circuit_extend(cell_t *cell, circuit_t *circ)
       n_conn = connection_or_connect(circ->n_addr, circ->n_port, id_digest);
       n_conn = connection_or_connect(circ->n_addr, circ->n_port, id_digest);
       if (!n_conn) {
       if (!n_conn) {
         log_fn(LOG_INFO,"Launching n_conn failed. Closing.");
         log_fn(LOG_INFO,"Launching n_conn failed. Closing.");
-        return -1;
+        circuit_mark_for_close(circ);
+        return 0;
       }
       }
       log_fn(LOG_DEBUG,"connecting in progress (or finished). Good.");
       log_fn(LOG_DEBUG,"connecting in progress (or finished). Good.");
     }
     }

+ 7 - 1
src/or/connection.c

@@ -458,7 +458,13 @@ connection_expire_held_open(void)
     if (conn->hold_open_until_flushed) {
     if (conn->hold_open_until_flushed) {
       tor_assert(conn->marked_for_close);
       tor_assert(conn->marked_for_close);
       if (now - conn->timestamp_lastwritten >= 15) {
       if (now - conn->timestamp_lastwritten >= 15) {
-        log_fn(LOG_NOTICE,"Giving up on marked_for_close conn that's been flushing for 15s (fd %d, type %s, state %s).",
+        int severity;
+        if (conn->type == CONN_TYPE_EXIT ||
+            (conn->type == CONN_TYPE_DIR && conn->purpose == DIR_PURPOSE_SERVER))
+          severity = LOG_INFO;
+        else
+          severity = LOG_NOTICE;
+        log_fn(severity, "Giving up on marked_for_close conn that's been flushing for 15s (fd %d, type %s, state %s).",
                conn->s, conn_type_to_string(conn->type),
                conn->s, conn_type_to_string(conn->type),
                conn_state_to_string(conn->type, conn->state));
                conn_state_to_string(conn->type, conn->state));
         conn->hold_open_until_flushed = 0;
         conn->hold_open_until_flushed = 0;

+ 3 - 4
src/or/connection_or.c

@@ -463,8 +463,7 @@ connection_or_check_valid_handshake(connection_t *conn, char *digest_rcvd)
   crypto_pk_env_t *identity_rcvd=NULL;
   crypto_pk_env_t *identity_rcvd=NULL;
   char nickname[MAX_NICKNAME_LEN+1];
   char nickname[MAX_NICKNAME_LEN+1];
   or_options_t *options = get_options();
   or_options_t *options = get_options();
-  int severity = (authdir_mode(options) || !server_mode(options))
-                 ? LOG_WARN : LOG_INFO;
+  int severity = server_mode(options) ? LOG_PROTOCOL_WARN : LOG_WARN;
 
 
   check_no_tls_errors();
   check_no_tls_errors();
   if (! tor_tls_peer_has_cert(conn->tls)) {
   if (! tor_tls_peer_has_cert(conn->tls)) {
@@ -473,7 +472,7 @@ connection_or_check_valid_handshake(connection_t *conn, char *digest_rcvd)
   }
   }
   check_no_tls_errors();
   check_no_tls_errors();
   if (tor_tls_get_peer_cert_nickname(conn->tls, nickname, sizeof(nickname))) {
   if (tor_tls_get_peer_cert_nickname(conn->tls, nickname, sizeof(nickname))) {
-    log_fn(LOG_WARN,"Other side (%s:%d) has a cert without a valid nickname. Closing.",
+    log_fn(severity,"Other side (%s:%d) has a cert without a valid nickname. Closing.",
            conn->address, conn->port);
            conn->address, conn->port);
     return -1;
     return -1;
   }
   }
@@ -482,7 +481,7 @@ connection_or_check_valid_handshake(connection_t *conn, char *digest_rcvd)
          conn->address, conn->port, nickname);
          conn->address, conn->port, nickname);
 
 
   if (tor_tls_verify(severity, conn->tls, &identity_rcvd) < 0) {
   if (tor_tls_verify(severity, conn->tls, &identity_rcvd) < 0) {
-    log_fn(LOG_WARN,"Other side, which claims to be router '%s' (%s:%d), has a cert but it's invalid. Closing.",
+    log_fn(severity,"Other side, which claims to be router '%s' (%s:%d), has a cert but it's invalid. Closing.",
            nickname, conn->address, conn->port);
            nickname, conn->address, conn->port);
     return -1;
     return -1;
   }
   }

+ 1 - 1
src/or/main.c

@@ -619,7 +619,7 @@ run_connection_housekeeping(int i, time_t now)
     } else if (
     } else if (
          now >= conn->timestamp_lastempty + options->KeepalivePeriod*10 &&
          now >= conn->timestamp_lastempty + options->KeepalivePeriod*10 &&
          now >= conn->timestamp_lastwritten + options->KeepalivePeriod*10) {
          now >= conn->timestamp_lastwritten + options->KeepalivePeriod*10) {
-      log_fn(LOG_NOTICE,"Expiring stuck OR connection to fd %d (%s:%d). (%d bytes to flush; %d seconds since last write)",
+      log_fn(LOG_PROTOCOL_WARN,"Expiring stuck OR connection to fd %d (%s:%d). (%d bytes to flush; %d seconds since last write)",
              conn->s, conn->address, conn->port,
              conn->s, conn->address, conn->port,
              (int)buf_datalen(conn->outbuf),
              (int)buf_datalen(conn->outbuf),
              (int)(now-conn->timestamp_lastwritten));
              (int)(now-conn->timestamp_lastwritten));

+ 10 - 6
src/or/relay.c

@@ -157,7 +157,7 @@ circuit_receive_relay_cell(cell_t *cell, circuit_t *circ, int cell_direction)
       ++stats_n_relay_cells_delivered;
       ++stats_n_relay_cells_delivered;
       log_fn(LOG_DEBUG,"Sending away from origin.");
       log_fn(LOG_DEBUG,"Sending away from origin.");
       if (connection_edge_process_relay_cell(cell, circ, conn, NULL) < 0) {
       if (connection_edge_process_relay_cell(cell, circ, conn, NULL) < 0) {
-        log_fn(LOG_WARN,"connection_edge_process_relay_cell (away from origin) failed.");
+        log_fn(LOG_PROTOCOL_WARN,"connection_edge_process_relay_cell (away from origin) failed.");
         return -1;
         return -1;
       }
       }
     }
     }
@@ -808,7 +808,7 @@ connection_edge_process_relay_cell_not_open(
  * If <b>layer_hint</b> is defined, then we're the origin of the
  * If <b>layer_hint</b> is defined, then we're the origin of the
  * circuit, and it specifies the hop that packaged <b>cell</b>.
  * circuit, and it specifies the hop that packaged <b>cell</b>.
  *
  *
- * Return -1 if you want to tear down the circuit, else 0.
+ * Return -1 if you want to warn and tear down the circuit, else 0.
  */
  */
 static int
 static int
 connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ,
 connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ,
@@ -858,8 +858,10 @@ connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ,
       ++stats_n_data_cells_received;
       ++stats_n_data_cells_received;
       if (( layer_hint && --layer_hint->deliver_window < 0) ||
       if (( layer_hint && --layer_hint->deliver_window < 0) ||
           (!layer_hint && --circ->deliver_window < 0)) {
           (!layer_hint && --circ->deliver_window < 0)) {
-        log_fn(LOG_WARN,"(relay data) circ deliver_window below 0. Killing.");
-        connection_edge_end(conn, END_STREAM_REASON_TORPROTOCOL, conn->cpath_layer);
+        log_fn(LOG_PROTOCOL_WARN,
+               "(relay data) circ deliver_window below 0. Killing.");
+        connection_edge_end(conn, END_STREAM_REASON_TORPROTOCOL,
+                            conn->cpath_layer);
         connection_mark_for_close(conn);
         connection_mark_for_close(conn);
         return -1;
         return -1;
       }
       }
@@ -874,7 +876,8 @@ connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ,
       }
       }
 
 
       if (--conn->deliver_window < 0) { /* is it below 0 after decrement? */
       if (--conn->deliver_window < 0) { /* is it below 0 after decrement? */
-        log_fn(LOG_WARN,"(relay data) conn deliver_window below 0. Killing.");
+        log_fn(LOG_PROTOCOL_WARN,
+               "(relay data) conn deliver_window below 0. Killing.");
         return -1; /* somebody's breaking protocol. kill the whole circuit. */
         return -1; /* somebody's breaking protocol. kill the whole circuit. */
       }
       }
 
 
@@ -962,7 +965,8 @@ connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ,
       return 0;
       return 0;
     case RELAY_COMMAND_CONNECTED:
     case RELAY_COMMAND_CONNECTED:
       if (conn) {
       if (conn) {
-        log_fn(LOG_WARN,"'connected' unsupported while open. Closing circ.");
+        log_fn(LOG_PROTOCOL_WARN,
+               "'connected' unsupported while open. Closing circ.");
         return -1;
         return -1;
       }
       }
       log_fn(LOG_INFO,"'connected' received, no conn attached anymore. Ignoring.");
       log_fn(LOG_INFO,"'connected' received, no conn attached anymore. Ignoring.");