aboutsummaryrefslogtreecommitdiff
path: root/src/cadet
diff options
context:
space:
mode:
authorDavid Barksdale <amatus@amat.us>2017-12-23 09:54:23 -0600
committerDavid Barksdale <amatus@amat.us>2017-12-23 09:54:23 -0600
commit9def71212263b1fcaaa54795a07c97c5b9118a75 (patch)
tree52fa2dd258b0ea6dcba324d2ee07f52c260c15d7 /src/cadet
parent517cf93fbd1c97a9909c6643601c8592553966bd (diff)
downloadgnunet-9def71212263b1fcaaa54795a07c97c5b9118a75.tar.gz
gnunet-9def71212263b1fcaaa54795a07c97c5b9118a75.zip
Check for cycles in cadet paths
I believe this is the underlying issue from commit 012ff13acc0cb2f5d7210aa48819395fecf12a3d. I tested out this change and saw that cyclic paths were dropped and GCP_set_mq() no longer had to deal with multiple removals. After this commit I'll revert that one.
Diffstat (limited to 'src/cadet')
-rw-r--r--src/cadet/gnunet-service-cadet_core.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/cadet/gnunet-service-cadet_core.c b/src/cadet/gnunet-service-cadet_core.c
index a67bbf445..cb213fc54 100644
--- a/src/cadet/gnunet-service-cadet_core.c
+++ b/src/cadet/gnunet-service-cadet_core.c
@@ -773,10 +773,31 @@ handle_connection_create (void *cls,
773 path_length = size / sizeof (struct GNUNET_PeerIdentity); 773 path_length = size / sizeof (struct GNUNET_PeerIdentity);
774 if (0 == path_length) 774 if (0 == path_length)
775 { 775 {
776 /* bogus request */ 776 LOG (GNUNET_ERROR_TYPE_DEBUG,
777 "Dropping CADET_CONNECTION_CREATE with empty path\n");
777 GNUNET_break_op (0); 778 GNUNET_break_op (0);
778 return; 779 return;
779 } 780 }
781 /* Check for loops */
782 struct GNUNET_CONTAINER_MultiPeerMap *map;
783 map = GNUNET_CONTAINER_multipeermap_create (path_length,
784 GNUNET_YES);
785 GNUNET_assert (NULL != map);
786 for (off = 0; off < path_length; off++) {
787 if (GNUNET_SYSERR ==
788 GNUNET_CONTAINER_multipeermap_put (map,
789 &pids[off],
790 NULL,
791 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) {
792 /* bogus request */
793 GNUNET_CONTAINER_multipeermap_destroy (map);
794 LOG (GNUNET_ERROR_TYPE_DEBUG,
795 "Dropping CADET_CONNECTION_CREATE with cyclic path\n");
796 GNUNET_break_op (0);
797 return;
798 }
799 }
800 GNUNET_CONTAINER_multipeermap_destroy (map);
780 /* Initiator is at offset 0. */ 801 /* Initiator is at offset 0. */
781 for (off=1;off<path_length;off++) 802 for (off=1;off<path_length;off++)
782 if (0 == memcmp (&my_full_id, 803 if (0 == memcmp (&my_full_id,
@@ -785,7 +806,8 @@ handle_connection_create (void *cls,
785 break; 806 break;
786 if (off == path_length) 807 if (off == path_length)
787 { 808 {
788 /* We are not on the path, bogus request */ 809 LOG (GNUNET_ERROR_TYPE_DEBUG,
810 "Dropping CADET_CONNECTION_CREATE without us in the path\n");
789 GNUNET_break_op (0); 811 GNUNET_break_op (0);
790 return; 812 return;
791 } 813 }
@@ -793,7 +815,8 @@ handle_connection_create (void *cls,
793 if (sender != GCP_get (&pids[off - 1], 815 if (sender != GCP_get (&pids[off - 1],
794 GNUNET_NO)) 816 GNUNET_NO))
795 { 817 {
796 /* sender is not on the path, not allowed */ 818 LOG (GNUNET_ERROR_TYPE_DEBUG,
819 "Dropping CADET_CONNECTION_CREATE without sender in the path\n");
797 GNUNET_break_op (0); 820 GNUNET_break_op (0);
798 return; 821 return;
799 } 822 }