gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [gnunet] branch master updated: misc log fixes, plus preven


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated: misc log fixes, plus prevent multiple TCP connections from wrecking havoc by creating a missunderstanding about which one is active
Date: Sun, 19 Feb 2017 23:26:59 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new c2d896668 misc log fixes, plus prevent multiple TCP connections from 
wrecking havoc by creating a missunderstanding about which one is active
c2d896668 is described below

commit c2d8966687f4c1b88c9fee8ce8913a51c4bb0f83
Author: Christian Grothoff <address@hidden>
AuthorDate: Sun Feb 19 23:26:57 2017 +0100

    misc log fixes, plus prevent multiple TCP connections from wrecking havoc 
by creating a missunderstanding about which one is active
---
 src/scalarproduct/test_scalarproduct.conf |  3 -
 src/transport/gnunet-service-transport.c  | 41 +++++++-------
 src/transport/plugin_transport_tcp.c      | 92 ++++++++++++++++++++-----------
 3 files changed, 81 insertions(+), 55 deletions(-)

diff --git a/src/scalarproduct/test_scalarproduct.conf 
b/src/scalarproduct/test_scalarproduct.conf
index 3ab47cfeb..73dbadbce 100644
--- a/src/scalarproduct/test_scalarproduct.conf
+++ b/src/scalarproduct/test_scalarproduct.conf
@@ -21,6 +21,3 @@ WAN_QUOTA_OUT = unlimited
 
 [peerinfo]
 USE_INCLUDED_HELLOS = NO
-
-[nat]
-RETURN_LOCAL_ADDRESSES = YES
diff --git a/src/transport/gnunet-service-transport.c 
b/src/transport/gnunet-service-transport.c
index e7b221344..ec4d82164 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -150,11 +150,11 @@ struct TransportClient
 
   /**
    * What type of client is this?
-   */ 
+   */
   enum ClientType type;
 
   union {
-  
+
     /**
      * Peer identity to monitor the addresses of.
      * Zero to monitor all neighbours.  Valid if
@@ -172,21 +172,21 @@ struct TransportClient
        * if we're performing one that has been cancelled).
        */
       struct GST_BlacklistCheck *bc;
-      
+
       /**
        * Set to #GNUNET_YES if we're currently waiting for a reply.
        */
       int waiting_for_reply;
-      
+
       /**
        * #GNUNET_YES if we have to call receive_done for this client
        */
       int call_receive_done;
-            
+
     } blacklist;
-    
+
   } details;
-  
+
 };
 
 
@@ -272,7 +272,7 @@ struct AddressToStringContext
  */
 struct SendTransmitContinuationContext
 {
-  
+
   /**
    * Client that made the request.
    */
@@ -563,7 +563,7 @@ client_disconnect_cb (void *cls,
                                             bc);
     }
     break;
-  }               
+  }
   GNUNET_free (tc);
 }
 
@@ -793,7 +793,7 @@ handle_client_send (void *cls,
                    const struct OutboundMessage *obm)
 {
   static unsigned long long uuid_gen;
-  struct TransportClient *tc = cls;  
+  struct TransportClient *tc = cls;
   const struct GNUNET_MessageHeader *obmm;
   struct SendTransmitContinuationContext *stcc;
 
@@ -937,7 +937,7 @@ check_client_address_to_string (void *cls,
     return GNUNET_SYSERR;
   }
   return GNUNET_OK;
-}    
+}
 
 
 /**
@@ -950,7 +950,7 @@ static void
 handle_client_address_to_string (void *cls,
                                 const struct AddressLookupMessage *alum)
 {
-  struct TransportClient *tc = cls;  
+  struct TransportClient *tc = cls;
   struct GNUNET_TRANSPORT_PluginFunctions *papi;
   const char *plugin_name;
   const char *address;
@@ -1308,7 +1308,7 @@ handle_client_monitor_plugins (void *cls,
                               const struct GNUNET_MessageHeader *message)
 {
   struct TransportClient *tc = cls;
-  
+
   GNUNET_SERVICE_client_mark_monitor (tc->client);
   GNUNET_SERVICE_client_disable_continue_warning (tc->client);
   GNUNET_notification_context_add (plugin_nc,
@@ -1690,9 +1690,10 @@ GST_receive_callback (void *cls,
     goto end;
   type = ntohs (message->type);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Received message with type %u from peer `%s'\n",
+              "Received message with type %u from peer `%s' at %s\n",
               type,
-              GNUNET_i2s (&address->peer));
+              GNUNET_i2s (&address->peer),
+              GST_plugins_a2s (address));
 
   GNUNET_STATISTICS_update (GST_stats,
                             gettext_noop ("# bytes total received"),
@@ -2226,7 +2227,7 @@ handle_client_set_metric (void *cls,
                          const struct TrafficMetricMessage *tm)
 {
   struct TransportClient *tc = cls;
-  
+
   GST_manipulation_set_metric (tm);
   GNUNET_SERVICE_client_continue (tc->client);
 }
@@ -2375,7 +2376,7 @@ handle_client_blacklist_reply (void *cls,
   bc = tc->details.blacklist.bc;
   tc->details.blacklist.bc = NULL;
   tc->details.blacklist.waiting_for_reply = GNUNET_NO;
-  tc->details.blacklist.call_receive_done = GNUNET_YES; 
+  tc->details.blacklist.call_receive_done = GNUNET_YES;
   if (NULL != bc)
   {
     /* only run this if the blacklist check has not been
@@ -2808,7 +2809,7 @@ run (void *cls,
 #if HAVE_GETRLIMIT
   {
     struct rlimit r_file;
-  
+
     if (0 == getrlimit (RLIMIT_NOFILE,
                        &r_file))
     {
@@ -2893,7 +2894,7 @@ GNUNET_SERVICE_MAIN
                        GNUNET_MESSAGE_TYPE_TRANSPORT_SEND,
                        struct OutboundMessage,
                        NULL),
- GNUNET_MQ_hd_var_size (client_address_to_string,                      
+ GNUNET_MQ_hd_var_size (client_address_to_string,
                        GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING,
                        struct AddressLookupMessage,
                        NULL),
@@ -2913,7 +2914,7 @@ GNUNET_SERVICE_MAIN
                          GNUNET_MESSAGE_TYPE_TRANSPORT_TRAFFIC_METRIC,
                          struct TrafficMetricMessage,
                          NULL),
- GNUNET_MQ_hd_fixed_size (client_monitor_plugins, 
+ GNUNET_MQ_hd_fixed_size (client_monitor_plugins,
                          GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PLUGIN_START,
                          struct GNUNET_MessageHeader,
                          NULL),
diff --git a/src/transport/plugin_transport_tcp.c 
b/src/transport/plugin_transport_tcp.c
index eca62a8ca..4ed5b38f7 100644
--- a/src/transport/plugin_transport_tcp.c
+++ b/src/transport/plugin_transport_tcp.c
@@ -1418,7 +1418,7 @@ create_session (struct Plugin *plugin,
     GNUNET_assert (NULL == client);
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Creating new session for peer `%4s' at address %s\n",
+       "Creating new session for peer `%s' at address %s\n",
        GNUNET_i2s (&address->peer),
        tcp_plugin_address_to_string (plugin,
                                      address->address,
@@ -1522,7 +1522,7 @@ do_transmit (void *cls,
   if (NULL == buf)
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
-         "Timeout trying to transmit to peer `%4s', discarding message 
queue.\n",
+         "Timeout trying to transmit to peer `%s', discarding message 
queue.\n",
          GNUNET_i2s (&session->target));
     /* timeout; cancel all messages that have already expired */
     hd = NULL;
@@ -1540,7 +1540,7 @@ do_transmit (void *cls,
       GNUNET_assert (pos->message_size <= session->bytes_in_queue);
       session->bytes_in_queue -= pos->message_size;
       LOG (GNUNET_ERROR_TYPE_DEBUG,
-           "Failed to transmit %u byte message to `%4s'.\n",
+           "Failed to transmit %u byte message to `%s'.\n",
            pos->message_size,
            GNUNET_i2s (&session->target));
       ret += pos->message_size;
@@ -1729,10 +1729,10 @@ tcp_plugin_send (void *cls,
   pm->transmit_cont = cont;
   pm->transmit_cont_cls = cont_cls;
 
-  LOG(GNUNET_ERROR_TYPE_DEBUG,
-      "Asked to transmit %u bytes to `%s', added message to list.\n",
-      msgbuf_size,
-      GNUNET_i2s (&session->target));
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Asked to transmit %u bytes to `%s', added message to list.\n",
+       msgbuf_size,
+       GNUNET_i2s (&session->target));
 
   if (GNUNET_YES ==
       GNUNET_CONTAINER_multipeermap_contains_value (plugin->sessionmap,
@@ -1997,6 +1997,13 @@ tcp_plugin_get_session (void *cls,
                                          address->address_length));
       return session;
     }
+    /* This is a bit of a hack, limiting TCP to never allow more than
+       one TCP connection to any given peer at the same time.
+       Without this, peers sometimes disagree about which of the TCP
+       connections they should use, causing one side to believe that
+       they transmit successfully, while the other receives nothing. */
+    return NULL; /* Refuse to have more than one TCP connection per
+                    peer pair at the same time. */
   }
 
   if (addrlen == sizeof(struct IPv6TcpAddress))
@@ -2078,7 +2085,7 @@ tcp_plugin_get_session (void *cls,
                                                 &address->peer)))
   {
     struct sockaddr_in local_sa;
-    
+
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Found valid IPv4 NAT address (creating session)!\n");
     session = create_session (plugin,
@@ -2168,13 +2175,13 @@ tcp_plugin_get_session (void *cls,
   if (NULL == sa)
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
-         "Failed to create connection to `%4s' at `%s'\n",
+         "Failed to create connection to `%s' at `%s'\n",
          GNUNET_i2s (&address->peer),
          GNUNET_a2s (sb, sbs));
     return NULL;
   }
   LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Asked to transmit to `%4s', creating fresh session using address 
`%s'.\n",
+       "Asked to transmit to `%s', creating fresh session using address 
`%s'.\n",
        GNUNET_i2s (&address->peer),
        GNUNET_a2s (sb, sbs));
 
@@ -2246,7 +2253,7 @@ tcp_plugin_disconnect (void *cls,
   struct Plugin *plugin = cls;
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Disconnecting peer `%4s'\n",
+       "Disconnecting peer `%s'\n",
        GNUNET_i2s (target));
   GNUNET_CONTAINER_multipeermap_get_multiple (plugin->sessionmap,
                                               target,
@@ -2446,7 +2453,7 @@ tcp_plugin_check_address (void *cls,
   if (addrlen == sizeof(struct IPv4TcpAddress))
   {
     struct sockaddr_in s4;
-    
+
     v4 = (const struct IPv4TcpAddress *) addr;
     if (0 != memcmp (&v4->options,
                      &plugin->myoptions,
@@ -2462,7 +2469,7 @@ tcp_plugin_check_address (void *cls,
 #endif
     s4.sin_port = v4->t4_port;
     s4.sin_addr.s_addr = v4->ipv4_addr;
-    
+
     if (GNUNET_OK !=
        GNUNET_NAT_test_address (plugin->nat,
                                 &s4,
@@ -2472,7 +2479,7 @@ tcp_plugin_check_address (void *cls,
   else
   {
     struct sockaddr_in6 s6;
-    
+
     v6 = (const struct IPv6TcpAddress *) addr;
     if (IN6_IS_ADDR_LINKLOCAL (&v6->ipv6_addr))
     {
@@ -2686,27 +2693,37 @@ handle_tcp_welcome (void *cls,
                                           &alen))
     {
       LOG (GNUNET_ERROR_TYPE_INFO,
-           "Received WELCOME message from my own identity `%4s' on address 
`%s'\n",
+           "Received WELCOME message from my own identity `%s' on address 
`%s'\n",
            GNUNET_i2s (&wm->clientIdentity),
            GNUNET_a2s (vaddr, alen));
-      GNUNET_free(vaddr);
+      GNUNET_free (vaddr);
     }
     return;
   }
 
-  LOG(GNUNET_ERROR_TYPE_DEBUG,
-      "Received WELCOME message from `%4s' %p\n",
-      GNUNET_i2s (&wm->clientIdentity),
-      client);
+  if (GNUNET_OK ==
+      GNUNET_SERVER_client_get_address (client,
+                                        &vaddr,
+                                        &alen))
+  {
+    LOG(GNUNET_ERROR_TYPE_DEBUG,
+        "Received WELCOME message from `%s' on address `%s'\n",
+        GNUNET_i2s (&wm->clientIdentity),
+        GNUNET_a2s (vaddr, alen));
+    GNUNET_free (vaddr);
+  }
   GNUNET_STATISTICS_update (plugin->env->stats,
                             gettext_noop ("# TCP WELCOME messages received"),
                             1,
                             GNUNET_NO);
-  session = lookup_session_by_client (plugin, client);
+  session = lookup_session_by_client (plugin,
+                                      client);
   if (NULL != session)
   {
     if (GNUNET_OK ==
-        GNUNET_SERVER_client_get_address (client, &vaddr, &alen))
+        GNUNET_SERVER_client_get_address (client,
+                                          &vaddr,
+                                          &alen))
     {
       LOG (GNUNET_ERROR_TYPE_DEBUG,
            "Found existing session %p for peer `%s'\n",
@@ -2795,12 +2812,11 @@ handle_tcp_welcome (void *cls,
     }
   }
 
-  if (session->expecting_welcome != GNUNET_YES)
+  if (GNUNET_YES != session->expecting_welcome)
   {
-    GNUNET_break_op(0);
+    GNUNET_break_op (0);
     GNUNET_SERVER_receive_done (client,
                                 GNUNET_SYSERR);
-    GNUNET_break(0);
     return;
   }
   session->last_activity = GNUNET_TIME_absolute_get ();
@@ -2869,7 +2885,9 @@ handle_tcp_data (void *cls,
     void *vaddr;
     size_t alen;
 
-    GNUNET_SERVER_client_get_address (client, &vaddr, &alen);
+    GNUNET_SERVER_client_get_address (client,
+                                      &vaddr,
+                                      &alen);
     LOG (GNUNET_ERROR_TYPE_ERROR,
          "Received unexpected %u bytes of type %u from `%s'\n",
          (unsigned int) ntohs (message->size),
@@ -2883,11 +2901,21 @@ handle_tcp_data (void *cls,
   }
 
   session->last_activity = GNUNET_TIME_absolute_get ();
-  LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Passing %u bytes of type %u from `%4s' to transport service.\n",
-       (unsigned int) ntohs (message->size),
-       (unsigned int) ntohs (message->type),
-       GNUNET_i2s (&session->target));
+  {
+    void *vaddr;
+    size_t alen;
+
+    GNUNET_SERVER_client_get_address (client,
+                                      &vaddr,
+                                      &alen);
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "Passing %u bytes of type %u from `%s' at %s to transport service.\n",
+         (unsigned int) ntohs (message->size),
+         (unsigned int) ntohs (message->type),
+         GNUNET_i2s (&session->target),
+         GNUNET_a2s (vaddr, alen));
+    GNUNET_free_non_null (vaddr);
+  }
 
   GNUNET_STATISTICS_update (plugin->env->stats,
                             gettext_noop ("# bytes received via TCP"),
@@ -2984,7 +3012,7 @@ disconnect_notify (void *cls,
   if (NULL == session)
     return; /* unknown, nothing to do */
   LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Destroying session of `%4s' with %s due to network-level 
disconnect.\n",
+       "Destroying session of `%s' with %s due to network-level disconnect.\n",
        GNUNET_i2s (&session->target),
        tcp_plugin_address_to_string (session->plugin,
                                      session->address->address,

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]