gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [gnunet] 01/04: abort union if we receive too little fresh


From: gnunet
Subject: [GNUnet-SVN] [gnunet] 01/04: abort union if we receive too little fresh elements
Date: Thu, 23 Feb 2017 17:47:45 +0100

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

dold pushed a commit to branch master
in repository gnunet.

commit 5a2d590a6f4b4f2c35d1240e65cc43aff111eb8b
Author: Florian Dold <address@hidden>
AuthorDate: Thu Feb 23 14:18:21 2017 +0100

    abort union if we receive too little fresh elements
---
 src/set/gnunet-service-set_union.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/src/set/gnunet-service-set_union.c 
b/src/set/gnunet-service-set_union.c
index acaabd94a..832018723 100644
--- a/src/set/gnunet-service-set_union.c
+++ b/src/set/gnunet-service-set_union.c
@@ -183,6 +183,17 @@ struct OperationState
    * Salt for the IBF we've received and that we're currently decoding.
    */
   uint32_t salt_receive;
+
+  /**
+   * Number of elements we received from the other peer
+   * that were not in the local set yet.
+   */
+  uint32_t received_fresh;
+
+  /**
+   * Total number of elements received from the other peer.
+   */
+  uint32_t received_total;
 };
 
 
@@ -1210,6 +1221,8 @@ maybe_finish (struct Operation *op)
 
 /**
  * Handle an element message from a remote peer.
+ * Sent by the other peer either because we decoded an IBF and placed a demand,
+ * or because the other peer switched to full set transmission.
  *
  * @param cls the union operation
  * @param mh the message
@@ -1273,6 +1286,8 @@ handle_p2p_elements (void *cls,
                             1,
                             GNUNET_NO);
 
+  op->state->received_total += 1;
+
   if (GNUNET_YES == op_has_element (op, &ee->element_hash))
   {
     /* Got repeated element.  Should not happen since
@@ -1287,6 +1302,7 @@ handle_p2p_elements (void *cls,
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "Registering new element from remote peer\n");
+    op->state->received_fresh += 1;
     op_register_element (op, ee);
     /* only send results immediately if the client wants it */
     switch (op->spec->result_mode)
@@ -1304,6 +1320,14 @@ handle_p2p_elements (void *cls,
     }
   }
 
+  if (op->state->received_total > 8 && op->state->received_fresh < 
op->state->received_total / 3)
+  {
+    /* The other peer gave us lots of old elements, there's something wrong. */
+    GNUNET_break_op (0);
+    fail_union_operation (op);
+    return;
+  }
+
   maybe_finish (op);
 }
 

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



reply via email to

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