gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet] branch master updated (e91dbda4f -> 2c734ad63)


From: gnunet
Subject: [gnunet] branch master updated (e91dbda4f -> 2c734ad63)
Date: Sat, 05 Aug 2023 10:53:04 +0200

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

martin-schanzenbach pushed a change to branch master
in repository gnunet.

    from e91dbda4f quic communicator: add nat handler
     new 75009e70c TNG: TCP rekey from 4GB to 400MB
     new 2c734ad63 TNG: TCP communicator code KX needs to be checked per 
connection, not globally

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/transport/gnunet-communicator-tcp.c | 49 +++++++++++++++++++--------------
 1 file changed, 29 insertions(+), 20 deletions(-)

diff --git a/src/transport/gnunet-communicator-tcp.c 
b/src/transport/gnunet-communicator-tcp.c
index 20d052dce..85c3eb422 100644
--- a/src/transport/gnunet-communicator-tcp.c
+++ b/src/transport/gnunet-communicator-tcp.c
@@ -82,9 +82,9 @@
 
 /**
  * How often do we rekey based on number of bytes transmitted?
- * (additionally randomized).
+ * (additionally randomized). Currently 400 MB
  */
-#define REKEY_MAX_BYTES (1024LLU * 1024 * 1024 * 4LLU)
+#define REKEY_MAX_BYTES (1024LLU * 1024 * 400)
 
 /**
  * Size of the initial key exchange message sent first in both
@@ -661,6 +661,17 @@ struct Queue
    * Store Context for retrieving the monotonic time send with the handshake 
ack.
    */
   struct GNUNET_PEERSTORE_StoreContext *handshake_ack_monotime_sc;
+
+  /**
+   * Size of data received without KX challenge played back.
+   */
+  // TODO remove?
+  size_t unverified_size;
+
+  /**
+   * Has the initial (core) handshake already happened?
+   */
+  int initial_core_kx_done;
 };
 
 
@@ -887,11 +898,6 @@ struct ListenTask *lts_tail;
  */
 int addrs_lens;
 
-/**
- * Size of data received without KX challenge played back.
- */
-// TODO remove?
-size_t unverified_size;
 
 /**
  * Database for peer's HELLOs.
@@ -1860,24 +1866,23 @@ queue_write (void *cls)
 static size_t
 try_handle_plaintext (struct Queue *queue)
 {
-  const struct GNUNET_MessageHeader *hdr =
-    (const struct GNUNET_MessageHeader *) queue->pread_buf;
-  const struct TCPConfirmationAck *tca = (const struct
-                                          TCPConfirmationAck *) 
queue->pread_buf;
-  const struct TCPBox *box = (const struct TCPBox *) queue->pread_buf;
-  const struct TCPRekey *rekey = (const struct TCPRekey *) queue->pread_buf;
-  const struct TCPFinish *fin = (const struct TCPFinish *) queue->pread_buf;
+  const struct GNUNET_MessageHeader *hdr;
+  const struct TCPConfirmationAck *tca;
+  const struct TCPBox *box;
+  const struct TCPRekey *rekey;
+  const struct TCPFinish *fin;
   struct TCPRekey rekeyz;
   struct TCPFinish finz;
   struct GNUNET_ShortHashCode tmac;
   uint16_t type;
-  size_t size = 0; /* make compiler happy */
+  size_t size = 0;
   struct TcpHandshakeAckSignature thas;
   const struct GNUNET_CRYPTO_ChallengeNonceP challenge = queue->challenge;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "try handle plaintext!\n");
 
+  hdr = (const struct GNUNET_MessageHeader *) queue->pread_buf;
   if ((sizeof(*hdr) > queue->pread_off))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1885,11 +1890,11 @@ try_handle_plaintext (struct Queue *queue)
     return 0; /* not even a header */
   }
 
-  if ((-1 != unverified_size) && (unverified_size > INITIAL_CORE_KX_SIZE))
+  if ((GNUNET_YES != queue->initial_core_kx_done) && (queue->unverified_size > 
INITIAL_CORE_KX_SIZE))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "Already received data of size %lu bigger than KX size %lu!\n",
-                unverified_size,
+                queue->unverified_size,
                 INITIAL_CORE_KX_SIZE);
     GNUNET_break_op (0);
     queue_finish (queue);
@@ -1900,6 +1905,7 @@ try_handle_plaintext (struct Queue *queue)
   switch (type)
   {
   case GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_CONFIRMATION_ACK:
+  tca = (const struct TCPConfirmationAck *) queue->pread_buf;
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "start processing ack\n");
     if (sizeof(*tca) > queue->pread_off)
@@ -1972,7 +1978,7 @@ try_handle_plaintext (struct Queue *queue)
                                          queue->address->sa_family, NULL);
     }
 
-    unverified_size = -1;
+    queue->unverified_size = -1;
 
     char *foreign_addr;
 
@@ -2012,6 +2018,7 @@ try_handle_plaintext (struct Queue *queue)
     break;
   case GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_BOX:
     /* Special case: header size excludes box itself! */
+    box = (const struct TCPBox *) queue->pread_buf;
     if (ntohs (hdr->size) + sizeof(struct TCPBox) > queue->pread_off)
       return 0;
     calculate_hmac (&queue->in_hmac, &box[1], ntohs (hdr->size), &tmac);
@@ -2028,6 +2035,7 @@ try_handle_plaintext (struct Queue *queue)
     break;
 
   case GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_REKEY:
+    rekey = (const struct TCPRekey *) queue->pread_buf;
     if (sizeof(*rekey) > queue->pread_off)
       return 0;
     if (ntohs (hdr->size) != sizeof(*rekey))
@@ -2052,6 +2060,7 @@ try_handle_plaintext (struct Queue *queue)
     break;
 
   case GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_FINISH:
+    fin = (const struct TCPFinish *) queue->pread_buf;
     if (sizeof(*fin) > queue->pread_off)
       return 0;
     if (ntohs (hdr->size) != sizeof(*fin))
@@ -2083,8 +2092,8 @@ try_handle_plaintext (struct Queue *queue)
     return 0;
   }
   GNUNET_assert (0 != size);
-  if (-1 != unverified_size)
-    unverified_size += size;
+  if (-1 != queue->unverified_size)
+    queue->unverified_size += size;
   return size;
 }
 

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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