gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet] branch master updated (005f21871 -> a3b9d9876)


From: gnunet
Subject: [gnunet] branch master updated (005f21871 -> a3b9d9876)
Date: Mon, 05 Feb 2024 14:47:41 +0100

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

t3sserakt pushed a change to branch master
in repository gnunet.

    from 005f21871 README: MD link
     new 3ff5ca260 Core: Reverted code for complex ephemeral handling.
     new 67c90f846 Core: Fixed bug to stop keepalive after handling ping.
     new 3336f8c25 Core: Optimized code.
     new a3b9d9876 Core: Fixed fragmentation logic.

The 4 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/service/core/gnunet-service-core_kx.c        | 130 +++++++++--------------
 src/service/transport/gnunet-service-transport.c |  41 +++++--
 2 files changed, 82 insertions(+), 89 deletions(-)

diff --git a/src/service/core/gnunet-service-core_kx.c 
b/src/service/core/gnunet-service-core_kx.c
index fc9bfd7b9..4d970abbe 100644
--- a/src/service/core/gnunet-service-core_kx.c
+++ b/src/service/core/gnunet-service-core_kx.c
@@ -693,14 +693,6 @@ deliver_message (void *cls, const struct 
GNUNET_MessageHeader *m)
 }
 
 
-static void
-do_rekey (void *cls);
-
-
-static void
-sign_ephemeral_key ();
-
-
 /**
  * Function called by transport to notify us that
  * a peer connected to us (on the network level).
@@ -726,66 +718,34 @@ handle_transport_notify_connect (void *cls,
                             gettext_noop ("# key exchanges initiated"),
                             1,
                             GNUNET_NO);
-  for (kx = kx_head; NULL != kx; kx = kx->next)
-  {
-    if (0 == memcmp (pid, kx->peer, sizeof(struct GNUNET_PeerIdentity)))
-      break;
-  }
-  if (NULL == kx)
+  
+  kx = GNUNET_new (struct GSC_KeyExchangeInfo);
+  kx->mst = GNUNET_MST_create (&deliver_message, kx);
+  kx->mq = mq;
+  kx->peer = pid;
+  kx->set_key_retry_frequency = INITIAL_SET_KEY_RETRY_FREQUENCY;
+  GNUNET_CONTAINER_DLL_insert (kx_head, kx_tail, kx);
+  kx->status = GNUNET_CORE_KX_STATE_KEY_SENT;
+  monitor_notify_all (kx);
+  GNUNET_CRYPTO_hash (pid, sizeof(struct GNUNET_PeerIdentity), &h1);
+  GNUNET_CRYPTO_hash (&GSC_my_identity,
+                      sizeof(struct GNUNET_PeerIdentity),
+                      &h2);
+  if (0 < GNUNET_CRYPTO_hash_cmp (&h1, &h2))
   {
-    GNUNET_CRYPTO_ecdhe_key_create (&my_ephemeral_key);
-    sign_ephemeral_key ();
-    {
-      struct GNUNET_HashCode eh;
-
-      GNUNET_CRYPTO_hash (&current_ekm.ephemeral_key,
-                          sizeof(current_ekm.ephemeral_key),
-                          &eh);
-      GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                  "Starting with ephemeral key %s\n",
-                  GNUNET_h2s (&eh));
-    }
-    kx = GNUNET_new (struct GSC_KeyExchangeInfo);
-    kx->mst = GNUNET_MST_create (&deliver_message, kx);
-    kx->mq = mq;
-    kx->peer = pid;
-    kx->set_key_retry_frequency = INITIAL_SET_KEY_RETRY_FREQUENCY;
-    GNUNET_CONTAINER_DLL_insert (kx_head, kx_tail, kx);
-    kx->status = GNUNET_CORE_KX_STATE_KEY_SENT;
-    monitor_notify_all (kx);
-    GNUNET_CRYPTO_hash (pid, sizeof(struct GNUNET_PeerIdentity), &h1);
-    GNUNET_CRYPTO_hash (&GSC_my_identity,
-                        sizeof(struct GNUNET_PeerIdentity),
-                        &h2);
-    if (0 < GNUNET_CRYPTO_hash_cmp (&h1, &h2))
-      {
-        /* peer with "lower" identity starts KX, otherwise we typically end up
-           with both peers starting the exchange and transmit the 'set key'
-           message twice */
-        send_key (kx);
-      }
-    else
-      {
-        /* peer with "higher" identity starts a delayed KX, if the "lower" peer
-         * does not start a KX since it sees no reasons to do so  */
-        kx->retry_set_key_task =
-          GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
-                                        &set_key_retry_task,
-                                        kx);
-      }
+    /* peer with "lower" identity starts KX, otherwise we typically end up
+       with both peers starting the exchange and transmit the 'set key'
+       message twice */
+    send_key (kx);
   }
   else
   {
-    struct GNUNET_TIME_Relative left;
-
-    left = GNUNET_TIME_absolute_get_remaining (kx->timeout);
-    if (0 == left.rel_value_us)
-    {
-      kx->status = GNUNET_CORE_KX_STATE_DOWN;
-    }
-    else
-      kx->status = GNUNET_CORE_KX_STATE_REKEY_SENT;
-    do_rekey (NULL);
+    /* peer with "higher" identity starts a delayed KX, if the "lower" peer
+     * does not start a KX since it sees no reasons to do so  */
+    kx->retry_set_key_task =
+      GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+                                    &set_key_retry_task,
+                                    kx);
   }
   return kx;
 }
@@ -895,6 +855,7 @@ handle_ephemeral_key (void *cls, const struct 
EphemeralKeyMessage *m)
   struct GNUNET_TIME_Absolute end_t;
   struct GNUNET_TIME_Absolute now;
   enum GNUNET_CORE_KxState sender_status;
+  enum GNUNET_GenericReturnValue do_verify = GNUNET_YES;
 
   end_t = GNUNET_TIME_absolute_ntoh (m->expiration_time);
   if (((GNUNET_CORE_KX_STATE_KEY_RECEIVED == kx->status) ||
@@ -918,14 +879,14 @@ handle_ephemeral_key (void *cls, const struct 
EphemeralKeyMessage *m)
   {
     GNUNET_STATISTICS_update (GSC_stats,
                               gettext_noop (
-                                "# duplicate ephemeral keys ignored"),
+                                "# duplicate ephemeral keys. Not verifying."),
                               1,
                               GNUNET_NO);
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                "Ignoring duplicate EPHEMERAL_KEY from %s\n",
+                "Duplicate EPHEMERAL_KEY from %s, do not verify\n",
                 GNUNET_i2s (&m->origin_identity));
     GNUNET_TRANSPORT_core_receive_continue (transport, kx->peer);
-    return;
+    do_verify = GNUNET_NO;
   }
   if (0 != memcmp (&m->origin_identity,
                    kx->peer,
@@ -939,7 +900,7 @@ handle_ephemeral_key (void *cls, const struct 
EphemeralKeyMessage *m)
     GNUNET_TRANSPORT_core_receive_continue (transport, kx->peer);
     return;
   }
-  if ((ntohl (m->purpose.size) !=
+  if (do_verify && ((ntohl (m->purpose.size) !=
        sizeof(struct GNUNET_CRYPTO_EccSignaturePurpose)
        + sizeof(struct GNUNET_TIME_AbsoluteNBO)
        + sizeof(struct GNUNET_TIME_AbsoluteNBO)
@@ -949,7 +910,7 @@ handle_ephemeral_key (void *cls, const struct 
EphemeralKeyMessage *m)
        GNUNET_CRYPTO_eddsa_verify_ (GNUNET_SIGNATURE_PURPOSE_SET_ECC_KEY,
                                     &m->purpose,
                                     &m->signature,
-                                    &m->origin_identity.public_key)))
+                                    &m->origin_identity.public_key))))
   {
     /* invalid signature */
     GNUNET_break_op (0);
@@ -1092,6 +1053,10 @@ handle_ephemeral_key (void *cls, const struct 
EphemeralKeyMessage *m)
 }
 
 
+static void
+send_keep_alive (void *cls);
+
+
 /**
  * We received a PING message.  Validate and transmit
  * a PONG message.
@@ -1176,6 +1141,11 @@ handle_ping (void *cls, const struct PingMessage *m)
                             1,
                             GNUNET_NO);
   GNUNET_MQ_send (kx->mq, env);
+  if (NULL != kx->keep_alive_task)
+  {
+    GNUNET_SCHEDULER_cancel (kx->keep_alive_task);
+    kx->keep_alive_task = GNUNET_SCHEDULER_add_delayed (MIN_PING_FREQUENCY, 
&send_keep_alive, kx);
+  }
   GNUNET_TRANSPORT_core_receive_continue (transport, kx->peer);
 }
 
@@ -1798,11 +1768,6 @@ do_rekey (void *cls)
   struct GSC_KeyExchangeInfo *pos;
 
   (void) cls;
-  if (NULL != rekey_task)
-  {
-    GNUNET_SCHEDULER_cancel (rekey_task);
-    rekey_task = NULL;
-  }
   rekey_task = GNUNET_SCHEDULER_add_delayed (REKEY_FREQUENCY, &do_rekey, NULL);
   GNUNET_CRYPTO_ecdhe_key_create (&my_ephemeral_key);
   sign_ephemeral_key ();
@@ -1819,13 +1784,11 @@ do_rekey (void *cls)
     if (GNUNET_CORE_KX_STATE_UP == pos->status)
     {
       pos->status = GNUNET_CORE_KX_STATE_REKEY_SENT;
-      monitor_notify_all (pos);
       derive_session_keys (pos);
     }
-    if (GNUNET_CORE_KX_STATE_DOWN == pos->status)
+    else if (GNUNET_CORE_KX_STATE_DOWN == pos->status)
     {
       pos->status = GNUNET_CORE_KX_STATE_KEY_SENT;
-      monitor_notify_all (pos);
     }
     monitor_notify_all (pos);
     send_key (pos);
@@ -1865,7 +1828,18 @@ GSC_KX_init (struct GNUNET_CRYPTO_EddsaPrivateKey *pk)
   my_private_key = *pk;
   GNUNET_CRYPTO_eddsa_key_get_public (&my_private_key,
                                       &GSC_my_identity.public_key);
-  
+  GNUNET_CRYPTO_ecdhe_key_create (&my_ephemeral_key);
+  sign_ephemeral_key ();
+  {
+    struct GNUNET_HashCode eh;
+
+    GNUNET_CRYPTO_hash (&current_ekm.ephemeral_key,
+                        sizeof(current_ekm.ephemeral_key),
+                        &eh);
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                "Starting with ephemeral key %s\n",
+                GNUNET_h2s (&eh));
+  }
 
   nc = GNUNET_notification_context_create (1);
   rekey_task = GNUNET_SCHEDULER_add_delayed (REKEY_FREQUENCY, &do_rekey, NULL);
diff --git a/src/service/transport/gnunet-service-transport.c 
b/src/service/transport/gnunet-service-transport.c
index d61755890..8c5de96ec 100644
--- a/src/service/transport/gnunet-service-transport.c
+++ b/src/service/transport/gnunet-service-transport.c
@@ -3105,7 +3105,7 @@ free_pending_message (struct PendingMessage *pm)
                                   vl->pending_msg_tail,
                                   pm);
   }
-  else if (NULL != pm->frag_parent)
+  else if (NULL != pm->frag_parent && PMT_DV_BOX != pm->pmt)
   {
     struct PendingMessage *root = pm->frag_parent;
 
@@ -9902,23 +9902,41 @@ reorder_root_pm (struct PendingMessage *pm,
 
 
 static unsigned int
-check_next_attempt_tree (struct PendingMessage *pm)
+check_next_attempt_tree (struct PendingMessage *pm, struct PendingMessage 
*root)
 {
   struct PendingMessage *pos;
-  enum GNUNET_GenericReturnValue frags_in_flight_round;
+  enum GNUNET_GenericReturnValue frags_in_flight;
 
   pos = pm->head_frag;
   while (NULL != pos)
   {
     if (pos->frags_in_flight_round == pm->frags_in_flight_round ||
-        GNUNET_YES == check_next_attempt_tree (pos))
-      frags_in_flight_round = GNUNET_NO;
+        GNUNET_NO == check_next_attempt_tree (pos, root))
+      frags_in_flight = GNUNET_NO;
     else
-      frags_in_flight_round = GNUNET_YES;
+    {
+      frags_in_flight = GNUNET_YES;
+      break;
+    }
     pos = pos->next_frag;
   }
 
-  return frags_in_flight_round;
+  return frags_in_flight;
+}
+
+
+static void
+harmonize_flight_round (struct PendingMessage *pm)
+{
+  struct PendingMessage *pos;
+
+  pos = pm->head_frag;
+  while (NULL != pos)
+  {
+    pos->frags_in_flight_round = pm->frags_in_flight_round;
+    harmonize_flight_round (pos);
+    pos = pos->next_frag;
+  }
 }
 
 
@@ -9964,12 +9982,13 @@ update_pm_next_attempt (struct PendingMessage *pm,
       root = root->frag_parent;
 
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "frag_count %u\n",
+                "frag_count next atempt %u\n",
                 root->frag_count);
 
     if (GNUNET_NO == root->frags_in_flight)
     {
       root->next_attempt = next_attempt;
+      harmonize_flight_round (root);
       root->frags_in_flight_round++;
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                   "Next attempt for fragmented message <%" PRIu64 "> (<%" 
PRIu64
@@ -9981,9 +10000,10 @@ update_pm_next_attempt (struct PendingMessage *pm,
 
     pm->next_attempt = root->next_attempt;
     pm->frags_in_flight_round = root->frags_in_flight_round;
+    harmonize_flight_round (pm);
 
     if (root->bytes_msg == root->frag_off)
-      root->frags_in_flight = check_next_attempt_tree (root);
+      root->frags_in_flight = check_next_attempt_tree (root, root);
     else
       root->frags_in_flight = GNUNET_YES;
 
@@ -9997,8 +10017,7 @@ update_pm_next_attempt (struct PendingMessage *pm,
       if (PMT_DV_BOX == root->pmt)
         root = root->frag_parent;
       reorder_root_pm (root, root->next_attempt);
-      root->frag_count = 0;
-      root->next_attempt = GNUNET_TIME_UNIT_ZERO_ABS;
+      //root->next_attempt = GNUNET_TIME_UNIT_ZERO_ABS;
     }
     else
     {

-- 
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]