gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet] branch master updated (577ad2f7d -> 29213833f)


From: gnunet
Subject: [gnunet] branch master updated (577ad2f7d -> 29213833f)
Date: Wed, 10 Jan 2024 11:59:57 +0100

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

t3sserakt pushed a change to branch master
in repository gnunet.

    from 577ad2f7d bump lib version due to exported symbol change
     new a54d28cd8 Changed creation of key for kx to be for every notification 
of transport about a new connected peer.
     new 894754f92 Added missing GNUNET_TRANSPORT_core_receive_continue.
     new b9cd040cb Fixed bug in logic getting root parent of fragment which is 
a DV box.
     new 84b76e31d Resuming communicators in case of core restarting.
     new 78b0a9aeb Fixed bug in logic freeing timedout QueueEntry.
     new 0d9df1c01 Fixed bug calculating next resend of fragments.
     new c69a0e9f5 first_challenge_use has to be reset in case of revalidation.
     new 01b7a5d0a When to resend a validation challenge and when to start 
revalidation needs to be seperate logic.
     new 29213833f Merge branch 'master' of ssh://git.gnunet.org/gnunet

The 9 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        | 108 ++++++++-----
 src/service/transport/gnunet-service-transport.c | 191 +++++++++++++++++++++--
 2 files changed, 253 insertions(+), 46 deletions(-)

diff --git a/src/service/core/gnunet-service-core_kx.c 
b/src/service/core/gnunet-service-core_kx.c
index ca7bccbd9..57f578151 100644
--- a/src/service/core/gnunet-service-core_kx.c
+++ b/src/service/core/gnunet-service-core_kx.c
@@ -693,6 +693,14 @@ 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).
@@ -718,33 +726,66 @@ handle_transport_notify_connect (void *cls,
                             gettext_noop ("# key exchanges initiated"),
                             1,
                             GNUNET_NO);
-  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))
+  for (kx = kx_head; NULL != kx; kx = kx->next)
   {
-    /* 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);
+    if (0 == memcmp (pid, kx->peer, sizeof(struct GNUNET_PeerIdentity)))
+      break;
+  }
+  if (NULL == kx)
+  {
+    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);
+      }
   }
   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);
+    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);
   }
   return kx;
 }
@@ -1135,6 +1176,7 @@ handle_ping (void *cls, const struct PingMessage *m)
                             1,
                             GNUNET_NO);
   GNUNET_MQ_send (kx->mq, env);
+  GNUNET_TRANSPORT_core_receive_continue (transport, kx->peer);
 }
 
 
@@ -1361,6 +1403,7 @@ handle_pong (void *cls, const struct PongMessage *m)
     GNUNET_break (0);
     break;
   }
+  GNUNET_TRANSPORT_core_receive_continue (transport, kx->peer);
 }
 
 
@@ -1754,6 +1797,12 @@ 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 ();
@@ -1816,18 +1865,7 @@ 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 f48455868..0c23decdb 100644
--- a/src/service/transport/gnunet-service-transport.c
+++ b/src/service/transport/gnunet-service-transport.c
@@ -2659,6 +2659,16 @@ struct ValidationState
    */
   struct GNUNET_CRYPTO_ChallengeNonceP challenge;
 
+  /**
+   * Hascode key to store state in a map.
+   */
+  struct GNUNET_HashCode hc;
+
+  /**
+   * Task to revalidate this address.
+   */
+  struct GNUNET_SCHEDULER_Task *revalidation_task;
+
   /**
    * Claimed address of the peer.
    */
@@ -2852,6 +2862,12 @@ static struct GNUNET_CONTAINER_MultiPeerMap *dv_routes;
  */
 static struct GNUNET_CONTAINER_MultiPeerMap *validation_map;
 
+/**
+ * Map from addresses to `struct ValidationState` entries describing
+ * addresses we are aware of and their validity state.
+ */
+static struct GNUNET_CONTAINER_MultiHashMap *revalidation_map;
+
 /**
  * Map from PIDs to `struct VirtualLink` entries describing
  * links CORE knows to exist.
@@ -3093,7 +3109,7 @@ free_pending_message (struct PendingMessage *pm)
   {
     struct PendingMessage *root = pm->frag_parent;
 
-    while (NULL != root->frag_parent)
+    while (NULL != root->frag_parent && PMT_DV_BOX != root->pmt)
       root = root->frag_parent;
 
     root->frag_count--;
@@ -3275,6 +3291,25 @@ free_virtual_link (struct VirtualLink *vl)
 static void
 free_validation_state (struct ValidationState *vs)
 {
+  struct GNUNET_HashCode hkey;
+  struct GNUNET_HashCode hc;
+
+  if (NULL != vs->revalidation_task)
+  {
+    GNUNET_SCHEDULER_cancel (vs->revalidation_task);
+    vs->revalidation_task = NULL;
+  }
+  /*memcpy (&hkey,
+          &hc,
+          sizeof (hkey));*/
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Remove key %s for address %s map size %u contains %u during 
freeing state\n",
+              GNUNET_h2s (&vs->hc),
+              vs->address,
+              GNUNET_CONTAINER_multihashmap_size (revalidation_map),
+              GNUNET_CONTAINER_multihashmap_contains (revalidation_map,
+                                                      &vs->hc));
+  GNUNET_CONTAINER_multihashmap_remove (revalidation_map, &vs->hc, vs);
   GNUNET_assert (
     GNUNET_YES ==
     GNUNET_CONTAINER_multipeermap_remove (validation_map, &vs->pid, vs));
@@ -4101,6 +4136,34 @@ notify_client_connect_info (void *cls,
 }
 
 
+/**
+ * Send ACK to communicator (if requested) and free @a cmc.
+ *
+ * @param cmc context for which we are done handling the message
+ */
+static void
+finish_cmc_handling_with_continue (struct CommunicatorMessageContext *cmc,
+                                   unsigned
+                                   int continue_client);
+
+static enum GNUNET_GenericReturnValue
+resume_communicators(void *cls,
+                     const struct GNUNET_PeerIdentity *pid,
+                     void *value)
+{
+  struct VirtualLink *vl = value;
+  struct CommunicatorMessageContext *cmc;
+
+  /* resume communicators */
+  while (NULL != (cmc = vl->cmc_tail))
+  {
+    GNUNET_CONTAINER_DLL_remove (vl->cmc_head, vl->cmc_tail, cmc);
+    finish_cmc_handling_with_continue (cmc, GNUNET_YES == cmc->continue_send ? 
GNUNET_NO : GNUNET_YES);
+  }
+  return GNUNET_OK;
+}
+
+
 /**
  * Initialize a "CORE" client.  We got a start message from this
  * client, so add it to the list of clients for broadcasting of
@@ -4137,6 +4200,9 @@ handle_client_start (void *cls, const struct StartMessage 
*start)
   GNUNET_CONTAINER_multipeermap_iterate (neighbours,
                                          &notify_client_connect_info,
                                          tc);
+  GNUNET_CONTAINER_multipeermap_iterate (links,
+                                         &resume_communicators,
+                                         NULL);
   GNUNET_SERVICE_client_continue (tc->client);
 }
 
@@ -4511,21 +4577,36 @@ free_timedout_queue_entry (void *cls)
   struct TransportClient *tc = cls;
   struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
 
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "freeing timedout queue entries\n");
+
+  tc->details.communicator.free_queue_entry_task = NULL;
   for (struct Queue *queue = tc->details.communicator.queue_head; NULL != 
queue;
        queue = queue->next_client)
   {
-    for (struct QueueEntry *qep = queue->queue_head; NULL != qep;
-      qep = qep->next)
+    struct QueueEntry *qep = queue->queue_head;
+
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "checking QID %u for timedout queue entries\n",
+                queue->qid);
+    while (NULL != qep)
     {
-      struct GNUNET_TIME_Relative diff = GNUNET_TIME_absolute_get_difference 
(qep->creation_timestamp, now);
+      struct QueueEntry *pos = qep;
+      
+      qep = qep->next;
+      struct GNUNET_TIME_Relative diff = GNUNET_TIME_absolute_get_difference 
(pos->creation_timestamp, now);
+
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "diff to now %s \n",
+                  GNUNET_TIME_relative2s (diff, GNUNET_NO));
       if (GNUNET_TIME_relative_cmp (QUEUE_ENTRY_TIMEOUT, < , diff))
       {
         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Freeing timed out QueueEntry with MID %" PRIu64
                 " and QID %u\n",
-                qep->mid,
+                pos->mid,
                 queue->qid);
-        free_queue_entry(qep, tc);
+        free_queue_entry(pos, tc);
       }
     }
   }
@@ -8727,6 +8808,7 @@ start_address_validation (const struct 
GNUNET_PeerIdentity *pid,
                               &vs->challenge,
                               sizeof(vs->challenge));
   vs->address = GNUNET_strdup (address);
+  GNUNET_CRYPTO_hash (vs->address, strlen(vs->address), &vs->hc);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Starting address validation `%s' of peer %s using challenge 
%s\n",
               address,
@@ -9014,6 +9096,43 @@ find_queue (const struct GNUNET_PeerIdentity *pid, const 
char *address)
   return NULL;
 }
 
+static void
+validation_transmit_on_queue (struct Queue *q, struct ValidationState *vs);
+
+static void
+revalidation_start_cb (void *cls)
+{
+  struct ValidationState *vs = cls;
+  struct Queue *q;
+  struct GNUNET_TIME_Absolute now;
+
+  vs->revalidation_task = NULL;
+  q = find_queue (&vs->pid, vs->address);
+  if (NULL == q)
+  {
+    now = GNUNET_TIME_absolute_get ();
+    vs->awaiting_queue = GNUNET_YES;
+    suggest_to_connect (&vs->pid, vs->address);
+    update_next_challenge_time (vs, now);
+  }
+  else
+    validation_transmit_on_queue (q, vs);
+}
+
+
+static enum GNUNET_GenericReturnValue
+revalidate_map_it (
+  void *cls,
+  const struct GNUNET_HashCode *key,
+  void *value)
+{
+  (void *) cls;
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Key in revalidate map  %s \n",
+                GNUNET_h2s (key));
+  return GNUNET_YES;
+}
+
 
 /**
  * Communicator gave us a transport address validation response.  Process the
@@ -9135,6 +9254,29 @@ handle_validation_response (
               GNUNET_sh2s (&tvr->challenge.value),
               GNUNET_i2s (&cmc->im.sender),
               GNUNET_STRINGS_absolute_time_to_string (vs->valid_until));
+  /*memcpy (&hkey,
+          &hc,
+          sizeof (hkey));*/
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Key %s for address %s map size %u contains %u\n",
+              GNUNET_h2s (&vs->hc),
+              vs->address,
+              GNUNET_CONTAINER_multihashmap_size (revalidation_map),
+              GNUNET_CONTAINER_multihashmap_contains (revalidation_map,
+                                                      &vs->hc));
+  GNUNET_assert (GNUNET_YES ==
+                 GNUNET_CONTAINER_multihashmap_put (
+                   revalidation_map,
+                   &vs->hc,
+                   vs,
+                   GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
+  GNUNET_CONTAINER_multihashmap_iterate (revalidation_map,
+                                         revalidate_map_it,
+                                         NULL);
+  vs->revalidation_task =
+    GNUNET_SCHEDULER_add_at (GNUNET_TIME_absolute_subtract (vs->next_challenge,
+                                                            
GNUNET_TIME_UNIT_MINUTES),
+                                                            
&revalidation_start_cb, vs);
   vs->sc = GNUNET_PEERSTORE_store (peerstore,
                                    "transport",
                                    &cmc->im.sender,
@@ -9809,7 +9951,7 @@ update_pm_next_attempt (struct PendingMessage *pm,
   {
     struct PendingMessage *root = pm->frag_parent;
 
-    while (NULL != root->frag_parent)
+    while (NULL != root->frag_parent && PMT_DV_BOX != root->pmt)
       root = root->frag_parent;
 
     if (GNUNET_NO == root->frags_in_flight)
@@ -9852,8 +9994,7 @@ update_pm_next_attempt (struct PendingMessage *pm,
         GNUNET_TIME_absolute_get_remaining (root->next_attempt);
       struct GNUNET_TIME_Relative plus = GNUNET_TIME_absolute_get_remaining (
         next_attempt);
-
-      s1 = GNUNET_TIME_relative_multiply (plus_mean,
+      s1 = GNUNET_TIME_relative_multiply_double (plus_mean,
                                           factor);
       s2 = GNUNET_TIME_relative_divide (plus,
                                         root->frag_count);
@@ -10345,7 +10486,7 @@ transmit_on_queue (void *cls)
       struct PendingMessage *root;
 
       root = pm->frag_parent;
-      while (NULL != root->frag_parent)
+      while (NULL != root->frag_parent && PMT_DV_BOX != root->pmt)
         root = root->frag_parent;
 
       wait_multiplier =  (unsigned int) ceil ((double) root->bytes_msg
@@ -10761,8 +10902,33 @@ static void
 validation_transmit_on_queue (struct Queue *q, struct ValidationState *vs)
 {
   struct TransportValidationChallengeMessage tvc;
+  struct GNUNET_HashCode hkey;
+  struct GNUNET_HashCode hc;
+  struct GNUNET_TIME_Absolute monotonic_time;
 
-  vs->last_challenge_use = GNUNET_TIME_absolute_get_monotonic (GST_cfg);
+  if (NULL != vs->revalidation_task)
+  {
+    GNUNET_SCHEDULER_cancel (vs->revalidation_task);
+    vs->revalidation_task = NULL;
+  }
+  /*memcpy (&hkey,
+          &hc,
+          sizeof (hkey));*/
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Remove key %s for address %s map size %u contains %u\n",
+              GNUNET_h2s (&vs->hc),
+              vs->address,
+              GNUNET_CONTAINER_multihashmap_size (revalidation_map),
+              GNUNET_CONTAINER_multihashmap_contains (revalidation_map,
+                                                      &vs->hc));
+  GNUNET_CONTAINER_multihashmap_remove (revalidation_map, &vs->hc, vs);
+
+  monotonic_time  = GNUNET_TIME_absolute_get_monotonic (GST_cfg);
+  if (GNUNET_TIME_UNIT_ZERO_ABS.abs_value_us == 
vs->last_challenge_use.abs_value_us)
+  {
+    vs->first_challenge_use = monotonic_time;
+  }
+  vs->last_challenge_use = monotonic_time;
   tvc.header.type =
     htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_CHALLENGE);
   tvc.header.size = htons (sizeof(tvc));
@@ -11750,6 +11916,8 @@ do_shutdown (void *cls)
                                          NULL);
   GNUNET_CONTAINER_multipeermap_destroy (validation_map);
   validation_map = NULL;
+  GNUNET_CONTAINER_multihashmap_destroy (revalidation_map);
+  revalidation_map = NULL;
   while (NULL != ir_head)
     free_incoming_request (ir_head);
   GNUNET_assert (0 == ir_total);
@@ -11825,6 +11993,7 @@ run (void *cls,
   dvlearn_map = GNUNET_CONTAINER_multishortmap_create (2 * 
MAX_DV_LEARN_PENDING,
                                                        GNUNET_YES);
   validation_map = GNUNET_CONTAINER_multipeermap_create (1024, GNUNET_YES);
+  revalidation_map = GNUNET_CONTAINER_multihashmap_create (1024, GNUNET_YES);
   validation_heap =
     GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
   GST_my_private_key =

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