aboutsummaryrefslogtreecommitdiff
path: root/src/rps
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-02-23 10:48:08 +0100
committerChristian Grothoff <christian@grothoff.org>2019-02-23 10:48:08 +0100
commitf1e8076ed474a429aff32839ed5f8fc20371839c (patch)
treebb38cb99b0e9cb7b937d33b539e74b9eb9fe4d32 /src/rps
parent3d0f1dd3805bfef30ff7a7f8e246a926b7fa7838 (diff)
parent7b01b7b1760cc973719c9a20123f99e4a7e1b5a6 (diff)
downloadgnunet-f1e8076ed474a429aff32839ed5f8fc20371839c.tar.gz
gnunet-f1e8076ed474a429aff32839ed5f8fc20371839c.zip
merge
Diffstat (limited to 'src/rps')
-rw-r--r--src/rps/gnunet-rps-profiler.c16
-rw-r--r--src/rps/gnunet-service-rps.c173
-rw-r--r--src/rps/gnunet-service-rps_custommap.c39
-rw-r--r--src/rps/profiler_rps.conf3
-rw-r--r--src/rps/rps-test_util.c55
-rw-r--r--src/rps/rps-test_util.h4
-rw-r--r--src/rps/rps.h2
-rw-r--r--src/rps/rps_api.c2
-rw-r--r--src/rps/test_rps.c4
-rw-r--r--src/rps/test_rps.conf2
10 files changed, 176 insertions, 124 deletions
diff --git a/src/rps/gnunet-rps-profiler.c b/src/rps/gnunet-rps-profiler.c
index 36a167203..98fc8dccb 100644
--- a/src/rps/gnunet-rps-profiler.c
+++ b/src/rps/gnunet-rps-profiler.c
@@ -1574,7 +1574,7 @@ static void mal_init_peer (struct RPSPeer *rps_peer)
1574static void 1574static void
1575mal_pre (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h) 1575mal_pre (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h)
1576{ 1576{
1577 #ifdef ENABLE_MALICIOUS 1577 #if ENABLE_MALICIOUS
1578 uint32_t num_mal_peers; 1578 uint32_t num_mal_peers;
1579 1579
1580 GNUNET_assert ( (1 >= portion) && 1580 GNUNET_assert ( (1 >= portion) &&
@@ -1605,7 +1605,7 @@ mal_cb (struct RPSPeer *rps_peer)
1605 return; 1605 return;
1606 } 1606 }
1607 1607
1608 #ifdef ENABLE_MALICIOUS 1608 #if ENABLE_MALICIOUS
1609 GNUNET_assert ( (1 >= portion) && 1609 GNUNET_assert ( (1 >= portion) &&
1610 (0 < portion) ); 1610 (0 < portion) );
1611 num_mal_peers = round (portion * num_peers); 1611 num_mal_peers = round (portion * num_peers);
@@ -2636,9 +2636,11 @@ stat_iterator (void *cls,
2636 (void) subsystem; 2636 (void) subsystem;
2637 (void) is_persistent; 2637 (void) is_persistent;
2638 2638
2639 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got stat value: %s - %" PRIu64 "\n", 2639 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2640 name, 2640 "Got stat value: %s - %" PRIu64 " (%u)\n",
2641 value); 2641 name,
2642 value,
2643 rps_peer->index);
2642 to_file (rps_peer->file_name_stats, 2644 to_file (rps_peer->file_name_stats,
2643 "%s: %" PRIu64 "\n", 2645 "%s: %" PRIu64 "\n",
2644 name, 2646 name,
@@ -2650,7 +2652,9 @@ stat_iterator (void *cls,
2650 return GNUNET_OK; 2652 return GNUNET_OK;
2651} 2653}
2652 2654
2653void post_profiler (struct RPSPeer *rps_peer) 2655
2656void
2657post_profiler (struct RPSPeer *rps_peer)
2654{ 2658{
2655 if (COLLECT_STATISTICS != cur_test_run.have_collect_statistics) 2659 if (COLLECT_STATISTICS != cur_test_run.have_collect_statistics)
2656 { 2660 {
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index 08f2450f5..05d5c91c3 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -11,7 +11,7 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
@@ -261,7 +261,7 @@ struct ChannelCtx
261}; 261};
262 262
263 263
264#ifdef ENABLE_MALICIOUS 264#if ENABLE_MALICIOUS
265 265
266/** 266/**
267 * If type is 2 This struct is used to store the attacked peers in a DLL 267 * If type is 2 This struct is used to store the attacked peers in a DLL
@@ -492,7 +492,7 @@ static struct GNUNET_PEERINFO_Handle *peerinfo_handle;
492static struct GNUNET_PEERINFO_NotifyContext *peerinfo_notify_handle; 492static struct GNUNET_PEERINFO_NotifyContext *peerinfo_notify_handle;
493 493
494 494
495#ifdef ENABLE_MALICIOUS 495#if ENABLE_MALICIOUS
496/** 496/**
497 * Type of malicious peer 497 * Type of malicious peer
498 * 498 *
@@ -1379,6 +1379,7 @@ mq_notify_sent_cb (void *cls)
1379 if (0 == strncmp ("PUSH", pending_msg->type, 4)) 1379 if (0 == strncmp ("PUSH", pending_msg->type, 4))
1380 GNUNET_STATISTICS_update(stats, "# pushes sent", 1, GNUNET_NO); 1380 GNUNET_STATISTICS_update(stats, "# pushes sent", 1, GNUNET_NO);
1381 if (0 == strncmp ("PULL REQUEST", pending_msg->type, 12) && 1381 if (0 == strncmp ("PULL REQUEST", pending_msg->type, 12) &&
1382 NULL != map_single_hop &&
1382 GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (map_single_hop, 1383 GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (map_single_hop,
1383 &pending_msg->peer_ctx->peer_id)) 1384 &pending_msg->peer_ctx->peer_id))
1384 GNUNET_STATISTICS_update(stats, 1385 GNUNET_STATISTICS_update(stats,
@@ -2576,7 +2577,7 @@ insert_in_sampler (void *cls,
2576 * messages to it */ 2577 * messages to it */
2577 //indicate_sending_intention (peer); 2578 //indicate_sending_intention (peer);
2578 } 2579 }
2579 #ifdef TO_FILE 2580#ifdef TO_FILE
2580 sub->num_observed_peers++; 2581 sub->num_observed_peers++;
2581 GNUNET_CONTAINER_multipeermap_put 2582 GNUNET_CONTAINER_multipeermap_put
2582 (sub->observed_unique_peers, 2583 (sub->observed_unique_peers,
@@ -2590,7 +2591,7 @@ insert_in_sampler (void *cls,
2590 sub->num_observed_peers, 2591 sub->num_observed_peers,
2591 num_observed_unique_peers, 2592 num_observed_unique_peers,
2592 1.0*num_observed_unique_peers/sub->num_observed_peers) 2593 1.0*num_observed_unique_peers/sub->num_observed_peers)
2593 #endif /* TO_FILE */ 2594#endif /* TO_FILE */
2594} 2595}
2595 2596
2596 2597
@@ -2675,11 +2676,23 @@ static void
2675remove_peer (struct Sub *sub, 2676remove_peer (struct Sub *sub,
2676 const struct GNUNET_PeerIdentity *peer) 2677 const struct GNUNET_PeerIdentity *peer)
2677{ 2678{
2678 (void) View_remove_peer (sub->view, peer); 2679 (void) View_remove_peer (sub->view,
2679 CustomPeerMap_remove_peer (sub->pull_map, peer); 2680 peer);
2680 CustomPeerMap_remove_peer (sub->push_map, peer); 2681 CustomPeerMap_remove_peer (sub->pull_map,
2681 RPS_sampler_reinitialise_by_value (sub->sampler, peer); 2682 peer);
2682 destroy_peer (get_peer_ctx (sub->peer_map, peer)); 2683 CustomPeerMap_remove_peer (sub->push_map,
2684 peer);
2685 RPS_sampler_reinitialise_by_value (sub->sampler,
2686 peer);
2687 /* We want to destroy the peer now.
2688 * Sometimes, it just seems that it's already been removed from the peer_map,
2689 * so check the peer_map first. */
2690 if (GNUNET_YES == check_peer_known (sub->peer_map,
2691 peer))
2692 {
2693 destroy_peer (get_peer_ctx (sub->peer_map,
2694 peer));
2695 }
2683} 2696}
2684 2697
2685 2698
@@ -2701,15 +2714,19 @@ clean_peer (struct Sub *sub,
2701 LOG (GNUNET_ERROR_TYPE_DEBUG, 2714 LOG (GNUNET_ERROR_TYPE_DEBUG,
2702 "Going to remove send channel to peer %s\n", 2715 "Going to remove send channel to peer %s\n",
2703 GNUNET_i2s (peer)); 2716 GNUNET_i2s (peer));
2704 #ifdef ENABLE_MALICIOUS 2717 #if ENABLE_MALICIOUS
2705 if (0 != GNUNET_CRYPTO_cmp_peer_identity (&attacked_peer, peer)) 2718 if (0 != GNUNET_CRYPTO_cmp_peer_identity (&attacked_peer,
2706 (void) destroy_sending_channel (get_peer_ctx (sub->peer_map, peer)); 2719 peer))
2720 (void) destroy_sending_channel (get_peer_ctx (sub->peer_map,
2721 peer));
2707 #else /* ENABLE_MALICIOUS */ 2722 #else /* ENABLE_MALICIOUS */
2708 (void) destroy_sending_channel (get_peer_ctx (sub->peer_map, peer)); 2723 (void) destroy_sending_channel (get_peer_ctx (sub->peer_map,
2724 peer));
2709 #endif /* ENABLE_MALICIOUS */ 2725 #endif /* ENABLE_MALICIOUS */
2710 } 2726 }
2711 2727
2712 if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (sub->peer_map, peer)) 2728 if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (sub->peer_map,
2729 peer))
2713 { 2730 {
2714 /* Peer was already removed by callback on destroyed channel */ 2731 /* Peer was already removed by callback on destroyed channel */
2715 LOG (GNUNET_ERROR_TYPE_WARNING, 2732 LOG (GNUNET_ERROR_TYPE_WARNING,
@@ -2846,19 +2863,15 @@ new_sub (const struct GNUNET_HashCode *hash,
2846 { 2863 {
2847 char *tmp_filename_valid_peers; 2864 char *tmp_filename_valid_peers;
2848 char str_hash[105]; 2865 char str_hash[105];
2849 uint32_t len_filename_valid_peers; 2866
2850 2867 GNUNET_snprintf (str_hash,
2851 (void) GNUNET_snprintf (str_hash, 105, GNUNET_h2s_full (hash)); 2868 sizeof (str_hash),
2852 tmp_filename_valid_peers = GNUNET_strdup (sub->filename_valid_peers); 2869 GNUNET_h2s_full (hash));
2853 GNUNET_free (sub->filename_valid_peers); 2870 tmp_filename_valid_peers = sub->filename_valid_peers;
2854 len_filename_valid_peers = strlen (tmp_filename_valid_peers) + 105; /* Len of full hash + 1 */ 2871 GNUNET_asprintf (&sub->filename_valid_peers,
2855 sub->filename_valid_peers = GNUNET_malloc (len_filename_valid_peers); 2872 "%s%s",
2856 strncat (sub->filename_valid_peers, 2873 tmp_filename_valid_peers,
2857 tmp_filename_valid_peers, 2874 str_hash);
2858 len_filename_valid_peers);
2859 strncat (sub->filename_valid_peers,
2860 str_hash,
2861 len_filename_valid_peers);
2862 GNUNET_free (tmp_filename_valid_peers); 2875 GNUNET_free (tmp_filename_valid_peers);
2863 } 2876 }
2864 sub->peer_map = GNUNET_CONTAINER_multipeermap_create (4, GNUNET_NO); 2877 sub->peer_map = GNUNET_CONTAINER_multipeermap_create (4, GNUNET_NO);
@@ -2874,7 +2887,7 @@ new_sub (const struct GNUNET_HashCode *hash,
2874 2887
2875 /* Logging of internals */ 2888 /* Logging of internals */
2876 sub->file_name_view_log = store_prefix_file_name (&own_identity, "view"); 2889 sub->file_name_view_log = store_prefix_file_name (&own_identity, "view");
2877 #ifdef TO_FILE 2890#ifdef TO_FILE
2878 sub->file_name_observed_log = store_prefix_file_name (&own_identity, 2891 sub->file_name_observed_log = store_prefix_file_name (&own_identity,
2879 "observed"); 2892 "observed");
2880 sub->file_name_push_recv = store_prefix_file_name (&own_identity, 2893 sub->file_name_push_recv = store_prefix_file_name (&own_identity,
@@ -2884,7 +2897,7 @@ new_sub (const struct GNUNET_HashCode *hash,
2884 sub->num_observed_peers = 0; 2897 sub->num_observed_peers = 0;
2885 sub->observed_unique_peers = GNUNET_CONTAINER_multipeermap_create (1, 2898 sub->observed_unique_peers = GNUNET_CONTAINER_multipeermap_create (1,
2886 GNUNET_NO); 2899 GNUNET_NO);
2887 #endif /* TO_FILE */ 2900#endif /* TO_FILE */
2888 2901
2889 /* Set up data structures for gossip */ 2902 /* Set up data structures for gossip */
2890 sub->push_map = CustomPeerMap_create (4); 2903 sub->push_map = CustomPeerMap_create (4);
@@ -2915,8 +2928,10 @@ static void
2915destroy_sub (struct Sub *sub) 2928destroy_sub (struct Sub *sub)
2916{ 2929{
2917#ifdef TO_FILE 2930#ifdef TO_FILE
2918 char push_recv_str[1536] = ""; /* 256 * 6 (1 whitespace, 1 comma, up to 4 chars) */ 2931#define SIZE_DUMP_FILE 1536 /* 256 * 6 (1 whitespace, 1 comma, up to 4 chars) */
2919 char pull_delays_str[1536] = ""; /* 256 * 6 (1 whitespace, 1 comma, up to 4 chars) */ 2932 char push_recv_str[SIZE_DUMP_FILE + 1] = "";
2933 char pull_delays_str[SIZE_DUMP_FILE + 1] = "";
2934 char *recv_str_iter;
2920#endif /* TO_FILE */ 2935#endif /* TO_FILE */
2921 GNUNET_assert (NULL != sub); 2936 GNUNET_assert (NULL != sub);
2922 GNUNET_assert (NULL != sub->do_round_task); 2937 GNUNET_assert (NULL != sub->do_round_task);
@@ -2945,36 +2960,49 @@ destroy_sub (struct Sub *sub)
2945 sub->file_name_observed_log = NULL; 2960 sub->file_name_observed_log = NULL;
2946 2961
2947 /* Write push frequencies to disk */ 2962 /* Write push frequencies to disk */
2963 recv_str_iter = push_recv_str;
2948 for (uint32_t i = 0; i < 256; i++) 2964 for (uint32_t i = 0; i < 256; i++)
2949 { 2965 {
2950 char push_recv_str_tmp[8]; 2966 char push_recv_str_tmp[8];
2951 (void) snprintf (push_recv_str_tmp, 8, "%" PRIu32 "\n", sub->push_recv[i]); 2967
2952 (void) strncat (push_recv_str, 2968 GNUNET_snprintf (push_recv_str_tmp,
2953 push_recv_str_tmp, 2969 sizeof (push_recv_str_tmp),
2954 1535 - strnlen (push_recv_str, 1536)); 2970 "%" PRIu32 "\n",
2955 } 2971 sub->push_recv[i]);
2956 (void) strncat (push_recv_str, 2972 recv_str_iter = stpncpy (recv_str_iter,
2957 "\n", 2973 push_recv_str_tmp,
2958 1535 - strnlen (push_recv_str, 1536)); 2974 6);
2959 LOG (GNUNET_ERROR_TYPE_DEBUG, "Writing push stats to disk\n"); 2975 }
2960 to_file_w_len (sub->file_name_push_recv, 1535, push_recv_str); 2976 (void) stpcpy (recv_str_iter,
2977 "\n");
2978 LOG (GNUNET_ERROR_TYPE_DEBUG,
2979 "Writing push stats to disk\n");
2980 to_file_w_len (sub->file_name_push_recv,
2981 SIZE_DUMP_FILE,
2982 push_recv_str);
2961 GNUNET_free (sub->file_name_push_recv); 2983 GNUNET_free (sub->file_name_push_recv);
2962 sub->file_name_push_recv = NULL; 2984 sub->file_name_push_recv = NULL;
2963 2985
2964 /* Write pull delays to disk */ 2986 /* Write pull delays to disk */
2987 recv_str_iter = pull_delays_str;
2965 for (uint32_t i = 0; i < 256; i++) 2988 for (uint32_t i = 0; i < 256; i++)
2966 { 2989 {
2967 char pull_delays_str_tmp[8]; 2990 char pull_delays_str_tmp[8];
2968 (void) snprintf (pull_delays_str_tmp, 8, "%" PRIu32 "\n", sub->pull_delays[i]); 2991
2969 (void) strncat (pull_delays_str, 2992 GNUNET_snprintf (pull_delays_str_tmp,
2970 pull_delays_str_tmp, 2993 sizeof (pull_delays_str_tmp),
2971 1535 - strnlen (pull_delays_str, 1536)); 2994 "%" PRIu32 "\n",
2972 } 2995 sub->pull_delays[i]);
2973 (void) strncat (pull_delays_str, 2996 recv_str_iter = stpncpy (recv_str_iter,
2974 "\n", 2997 pull_delays_str_tmp,
2975 1535 - strnlen (pull_delays_str, 1536)); 2998 6);
2999 }
3000 (void) stpcpy (recv_str_iter,
3001 "\n");
2976 LOG (GNUNET_ERROR_TYPE_DEBUG, "Writing pull delays to disk\n"); 3002 LOG (GNUNET_ERROR_TYPE_DEBUG, "Writing pull delays to disk\n");
2977 to_file_w_len (sub->file_name_pull_delays, 1535, pull_delays_str); 3003 to_file_w_len (sub->file_name_pull_delays,
3004 SIZE_DUMP_FILE,
3005 pull_delays_str);
2978 GNUNET_free (sub->file_name_pull_delays); 3006 GNUNET_free (sub->file_name_pull_delays);
2979 sub->file_name_pull_delays = NULL; 3007 sub->file_name_pull_delays = NULL;
2980 3008
@@ -3028,8 +3056,11 @@ core_connects (void *cls,
3028 (void) cls; 3056 (void) cls;
3029 (void) mq; 3057 (void) mq;
3030 3058
3031 GNUNET_CONTAINER_multipeermap_put (map_single_hop, peer, NULL, 3059 GNUNET_assert (GNUNET_YES ==
3032 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); 3060 GNUNET_CONTAINER_multipeermap_put (map_single_hop,
3061 peer,
3062 NULL,
3063 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
3033 return NULL; 3064 return NULL;
3034} 3065}
3035 3066
@@ -3436,7 +3467,7 @@ handle_peer_push (void *cls,
3436 GNUNET_STATISTICS_update(stats, "# push message received", 1, GNUNET_NO); 3467 GNUNET_STATISTICS_update(stats, "# push message received", 1, GNUNET_NO);
3437 } 3468 }
3438 3469
3439 #ifdef ENABLE_MALICIOUS 3470 #if ENABLE_MALICIOUS
3440 struct AttackedPeer *tmp_att_peer; 3471 struct AttackedPeer *tmp_att_peer;
3441 3472
3442 if ( (1 == mal_type) || 3473 if ( (1 == mal_type) ||
@@ -3512,7 +3543,7 @@ handle_peer_pull_request (void *cls,
3512 } 3543 }
3513 } 3544 }
3514 3545
3515 #ifdef ENABLE_MALICIOUS 3546 #if ENABLE_MALICIOUS
3516 if (1 == mal_type 3547 if (1 == mal_type
3517 || 3 == mal_type) 3548 || 3 == mal_type)
3518 { /* Try to maximise representation */ 3549 { /* Try to maximise representation */
@@ -3606,7 +3637,7 @@ handle_peer_pull_reply (void *cls,
3606 const struct GNUNET_PeerIdentity *peers; 3637 const struct GNUNET_PeerIdentity *peers;
3607 struct Sub *sub = channel_ctx->peer_ctx->sub; 3638 struct Sub *sub = channel_ctx->peer_ctx->sub;
3608 uint32_t i; 3639 uint32_t i;
3609#ifdef ENABLE_MALICIOUS 3640#if ENABLE_MALICIOUS
3610 struct AttackedPeer *tmp_att_peer; 3641 struct AttackedPeer *tmp_att_peer;
3611#endif /* ENABLE_MALICIOUS */ 3642#endif /* ENABLE_MALICIOUS */
3612 3643
@@ -3618,7 +3649,8 @@ handle_peer_pull_reply (void *cls,
3618 "# pull reply messages received", 3649 "# pull reply messages received",
3619 1, 3650 1,
3620 GNUNET_NO); 3651 GNUNET_NO);
3621 if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (map_single_hop, 3652 if (NULL != map_single_hop &&
3653 GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (map_single_hop,
3622 &channel_ctx->peer_ctx->peer_id)) 3654 &channel_ctx->peer_ctx->peer_id))
3623 { 3655 {
3624 GNUNET_STATISTICS_update (stats, 3656 GNUNET_STATISTICS_update (stats,
@@ -3628,7 +3660,7 @@ handle_peer_pull_reply (void *cls,
3628 } 3660 }
3629 } 3661 }
3630 3662
3631 #ifdef ENABLE_MALICIOUS 3663 #if ENABLE_MALICIOUS
3632 // We shouldn't even receive pull replies as we're not sending 3664 // We shouldn't even receive pull replies as we're not sending
3633 if (2 == mal_type) 3665 if (2 == mal_type)
3634 { 3666 {
@@ -3649,7 +3681,7 @@ handle_peer_pull_reply (void *cls,
3649 i, 3681 i,
3650 GNUNET_i2s (&peers[i])); 3682 GNUNET_i2s (&peers[i]));
3651 3683
3652 #ifdef ENABLE_MALICIOUS 3684 #if ENABLE_MALICIOUS
3653 if ((NULL != att_peer_set) && 3685 if ((NULL != att_peer_set) &&
3654 (1 == mal_type || 3 == mal_type)) 3686 (1 == mal_type || 3 == mal_type))
3655 { /* Add attacked peer to local list */ 3687 { /* Add attacked peer to local list */
@@ -3670,25 +3702,30 @@ handle_peer_pull_reply (void *cls,
3670 } 3702 }
3671 #endif /* ENABLE_MALICIOUS */ 3703 #endif /* ENABLE_MALICIOUS */
3672 /* Make sure we 'know' about this peer */ 3704 /* Make sure we 'know' about this peer */
3673 (void) insert_peer (channel_ctx->peer_ctx->sub, &peers[i]); 3705 (void) insert_peer (channel_ctx->peer_ctx->sub,
3706 &peers[i]);
3674 3707
3675 if (GNUNET_YES == check_peer_valid (channel_ctx->peer_ctx->sub->valid_peers, 3708 if (GNUNET_YES == check_peer_valid (channel_ctx->peer_ctx->sub->valid_peers,
3676 &peers[i])) 3709 &peers[i]))
3677 { 3710 {
3678 CustomPeerMap_put (channel_ctx->peer_ctx->sub->pull_map, &peers[i]); 3711 CustomPeerMap_put (channel_ctx->peer_ctx->sub->pull_map,
3712 &peers[i]);
3679 } 3713 }
3680 else 3714 else
3681 { 3715 {
3682 schedule_operation (channel_ctx->peer_ctx, 3716 schedule_operation (channel_ctx->peer_ctx,
3683 insert_in_pull_map, 3717 insert_in_pull_map,
3684 channel_ctx->peer_ctx->sub); /* cls */ 3718 channel_ctx->peer_ctx->sub); /* cls */
3685 (void) issue_peer_online_check (channel_ctx->peer_ctx->sub, &peers[i]); 3719 (void) issue_peer_online_check (channel_ctx->peer_ctx->sub,
3720 &peers[i]);
3686 } 3721 }
3687 } 3722 }
3688 3723
3689 UNSET_PEER_FLAG (get_peer_ctx (channel_ctx->peer_ctx->sub->peer_map, sender), 3724 UNSET_PEER_FLAG (get_peer_ctx (channel_ctx->peer_ctx->sub->peer_map,
3725 sender),
3690 Peers_PULL_REPLY_PENDING); 3726 Peers_PULL_REPLY_PENDING);
3691 clean_peer (channel_ctx->peer_ctx->sub, sender); 3727 clean_peer (channel_ctx->peer_ctx->sub,
3728 sender);
3692 3729
3693 GNUNET_break_op (check_peer_known (channel_ctx->peer_ctx->sub->peer_map, 3730 GNUNET_break_op (check_peer_known (channel_ctx->peer_ctx->sub->peer_map,
3694 sender)); 3731 sender));
@@ -3812,7 +3849,7 @@ send_push (struct PeerContext *peer_ctx)
3812} 3849}
3813 3850
3814 3851
3815#ifdef ENABLE_MALICIOUS 3852#if ENABLE_MALICIOUS
3816 3853
3817 3854
3818/** 3855/**
@@ -4534,7 +4571,7 @@ shutdown_task (void *cls)
4534 } 4571 }
4535 GNUNET_CADET_disconnect (cadet_handle); 4572 GNUNET_CADET_disconnect (cadet_handle);
4536 cadet_handle = NULL; 4573 cadet_handle = NULL;
4537#ifdef ENABLE_MALICIOUS 4574#if ENABLE_MALICIOUS
4538 struct AttackedPeer *tmp_att_peer; 4575 struct AttackedPeer *tmp_att_peer;
4539 GNUNET_array_grow (mal_peers, 4576 GNUNET_array_grow (mal_peers,
4540 num_mal_peers, 4577 num_mal_peers,
@@ -4647,7 +4684,7 @@ run (void *cls,
4647 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 4684 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
4648 "STARTING SERVICE (rps) for peer [%s]\n", 4685 "STARTING SERVICE (rps) for peer [%s]\n",
4649 GNUNET_i2s (&own_identity)); 4686 GNUNET_i2s (&own_identity));
4650#ifdef ENABLE_MALICIOUS 4687#if ENABLE_MALICIOUS
4651 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 4688 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
4652 "Malicious execution compiled in.\n"); 4689 "Malicious execution compiled in.\n");
4653#endif /* ENABLE_MALICIOUS */ 4690#endif /* ENABLE_MALICIOUS */
@@ -4740,7 +4777,7 @@ GNUNET_SERVICE_MAIN
4740 GNUNET_MESSAGE_TYPE_RPS_CS_SEED, 4777 GNUNET_MESSAGE_TYPE_RPS_CS_SEED,
4741 struct GNUNET_RPS_CS_SeedMessage, 4778 struct GNUNET_RPS_CS_SeedMessage,
4742 NULL), 4779 NULL),
4743#ifdef ENABLE_MALICIOUS 4780#if ENABLE_MALICIOUS
4744 GNUNET_MQ_hd_var_size (client_act_malicious, 4781 GNUNET_MQ_hd_var_size (client_act_malicious,
4745 GNUNET_MESSAGE_TYPE_RPS_ACT_MALICIOUS, 4782 GNUNET_MESSAGE_TYPE_RPS_ACT_MALICIOUS,
4746 struct GNUNET_RPS_CS_ActMaliciousMessage, 4783 struct GNUNET_RPS_CS_ActMaliciousMessage,
diff --git a/src/rps/gnunet-service-rps_custommap.c b/src/rps/gnunet-service-rps_custommap.c
index 18a433d6b..d3cc8d104 100644
--- a/src/rps/gnunet-service-rps_custommap.c
+++ b/src/rps/gnunet-service-rps_custommap.c
@@ -82,7 +82,8 @@ CustomPeerMap_create (unsigned int len)
82 82
83 c_peer_map = GNUNET_new (struct CustomPeerMap); 83 c_peer_map = GNUNET_new (struct CustomPeerMap);
84 c_peer_map->hash_map = GNUNET_CONTAINER_multihashmap32_create (len); 84 c_peer_map->hash_map = GNUNET_CONTAINER_multihashmap32_create (len);
85 c_peer_map->peer_map = GNUNET_CONTAINER_multipeermap_create (len, GNUNET_NO); 85 c_peer_map->peer_map = GNUNET_CONTAINER_multipeermap_create (len,
86 GNUNET_NO);
86 return c_peer_map; 87 return c_peer_map;
87} 88}
88 89
@@ -129,10 +130,16 @@ CustomPeerMap_put (const struct CustomPeerMap *c_peer_map,
129 p = GNUNET_new (struct GNUNET_PeerIdentity); 130 p = GNUNET_new (struct GNUNET_PeerIdentity);
130 *p = *peer; 131 *p = *peer;
131 GNUNET_assert (p != peer); 132 GNUNET_assert (p != peer);
132 GNUNET_assert (0 == memcmp (p, peer, sizeof(struct GNUNET_PeerIdentity))); 133 GNUNET_assert (0 == memcmp (p,
133 GNUNET_CONTAINER_multipeermap_put (c_peer_map->peer_map, p, index, 134 peer,
135 sizeof(struct GNUNET_PeerIdentity)));
136 GNUNET_CONTAINER_multipeermap_put (c_peer_map->peer_map,
137 p,
138 index,
134 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); 139 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
135 GNUNET_CONTAINER_multihashmap32_put (c_peer_map->hash_map, *index, p, 140 GNUNET_CONTAINER_multihashmap32_put (c_peer_map->hash_map,
141 *index,
142 p,
136 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); 143 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
137 GNUNET_assert (GNUNET_CONTAINER_multihashmap32_size (c_peer_map->hash_map) == 144 GNUNET_assert (GNUNET_CONTAINER_multihashmap32_size (c_peer_map->hash_map) ==
138 GNUNET_CONTAINER_multipeermap_size (c_peer_map->peer_map)); 145 GNUNET_CONTAINER_multipeermap_size (c_peer_map->peer_map));
@@ -194,30 +201,38 @@ CustomPeerMap_remove_peer (const struct CustomPeerMap *c_peer_map,
194 uint32_t *last_index; 201 uint32_t *last_index;
195 struct GNUNET_PeerIdentity *last_p; 202 struct GNUNET_PeerIdentity *last_p;
196 203
197 if (GNUNET_NO == CustomPeerMap_contains_peer (c_peer_map, peer)) 204 if (GNUNET_NO == CustomPeerMap_contains_peer (c_peer_map,
205 peer))
198 { 206 {
199 return GNUNET_NO; 207 return GNUNET_NO;
200 } 208 }
201 index = CustomPeerMap_get_index_pointer (c_peer_map, peer); 209 index = CustomPeerMap_get_index_pointer (c_peer_map,
210 peer);
202 GNUNET_assert (*index < CustomPeerMap_size (c_peer_map)); 211 GNUNET_assert (*index < CustomPeerMap_size (c_peer_map));
203 /* Need to get the pointer stored in the hashmap to free it */ 212 /* Need to get the pointer stored in the hashmap to free it */
204 p = GNUNET_CONTAINER_multihashmap32_get (c_peer_map->hash_map, *index); 213 p = GNUNET_CONTAINER_multihashmap32_get (c_peer_map->hash_map,
214 *index);
205 GNUNET_assert (NULL != p); 215 GNUNET_assert (NULL != p);
206 GNUNET_CONTAINER_multihashmap32_remove_all (c_peer_map->hash_map, *index); 216 GNUNET_CONTAINER_multihashmap32_remove_all (c_peer_map->hash_map,
217 *index);
207 // TODO wrong peerid? 218 // TODO wrong peerid?
208 GNUNET_CONTAINER_multipeermap_remove_all (c_peer_map->peer_map, peer); 219 GNUNET_CONTAINER_multipeermap_remove_all (c_peer_map->peer_map,
220 peer);
209 if (*index != CustomPeerMap_size (c_peer_map)) 221 if (*index != CustomPeerMap_size (c_peer_map))
210 { /* fill 'gap' with peer at last index */ 222 { /* fill 'gap' with peer at last index */
211 last_p = 223 last_p =
212 GNUNET_CONTAINER_multihashmap32_get (c_peer_map->hash_map, 224 GNUNET_CONTAINER_multihashmap32_get (c_peer_map->hash_map,
213 CustomPeerMap_size (c_peer_map)); 225 CustomPeerMap_size (c_peer_map));
214 GNUNET_assert (NULL != last_p); 226 GNUNET_assert (NULL != last_p);
215 last_index = GNUNET_CONTAINER_multipeermap_get (c_peer_map->peer_map, last_p); 227 last_index = GNUNET_CONTAINER_multipeermap_get (c_peer_map->peer_map,
228 last_p);
216 GNUNET_assert (NULL != last_index); 229 GNUNET_assert (NULL != last_index);
217 GNUNET_assert (CustomPeerMap_size (c_peer_map) == *last_index); 230 GNUNET_assert (CustomPeerMap_size (c_peer_map) == *last_index);
218 GNUNET_CONTAINER_multihashmap32_put (c_peer_map->hash_map, *index, last_p, 231 GNUNET_CONTAINER_multihashmap32_put (c_peer_map->hash_map,
232 *index, last_p,
219 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); 233 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
220 GNUNET_CONTAINER_multihashmap32_remove_all (c_peer_map->hash_map, *last_index); 234 GNUNET_CONTAINER_multihashmap32_remove_all (c_peer_map->hash_map,
235 *last_index);
221 *last_index = *index; 236 *last_index = *index;
222 } 237 }
223 GNUNET_free (index); 238 GNUNET_free (index);
diff --git a/src/rps/profiler_rps.conf b/src/rps/profiler_rps.conf
index 1369d3fdf..6049da5a0 100644
--- a/src/rps/profiler_rps.conf
+++ b/src/rps/profiler_rps.conf
@@ -83,8 +83,7 @@ BLUETOOTH_QUOTA_OUT = unlimited
83DISABLE_TRY_CONNECT = YES 83DISABLE_TRY_CONNECT = YES
84 84
85[cadet] 85[cadet]
86#OPTIONS=-l /tmp/rps_profiler_logs/cadet-[]-%Y-%m-%d.log 86OPTIONS=-l /tmp/rps_profiler_logs/cadet-[]-%Y-%m-%d.log
87#PREFIX = valgrind
88 87
89#[arm] 88#[arm]
90#GLOBAL_POSTFIX=-l /tmp/rps_profiler_logs/other-[]-%Y-%m-%d.log 89#GLOBAL_POSTFIX=-l /tmp/rps_profiler_logs/other-[]-%Y-%m-%d.log
diff --git a/src/rps/rps-test_util.c b/src/rps/rps-test_util.c
index 7f54feca1..85829f247 100644
--- a/src/rps/rps-test_util.c
+++ b/src/rps/rps-test_util.c
@@ -80,41 +80,36 @@ get_file_handle (const char *name)
80 if (NULL == open_files) 80 if (NULL == open_files)
81 { 81 {
82 open_files = GNUNET_CONTAINER_multihashmap_create (16, 82 open_files = GNUNET_CONTAINER_multihashmap_create (16,
83 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); 83 GNUNET_NO);
84 LOG (GNUNET_ERROR_TYPE_DEBUG,
85 "Created map of open files.\n");
84 } 86 }
85 GNUNET_CRYPTO_hash (name, 87 GNUNET_CRYPTO_hash (name,
86 strnlen (name, 88 strlen (name),
87 512),
88 &hash); 89 &hash);
89 if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains (open_files, 90 if (NULL != (fh = GNUNET_CONTAINER_multihashmap_get (open_files,
90 &hash)) 91 &hash)))
91 {
92 fh = GNUNET_DISK_file_open (name,
93 GNUNET_DISK_OPEN_WRITE |
94 GNUNET_DISK_OPEN_CREATE |
95 GNUNET_DISK_OPEN_APPEND,
96 GNUNET_DISK_PERM_USER_READ |
97 GNUNET_DISK_PERM_USER_WRITE |
98 GNUNET_DISK_PERM_GROUP_READ);
99 if (NULL == fh)
100 {
101 LOG (GNUNET_ERROR_TYPE_ERROR,
102 "Opening file `%s' failed.\n",
103 name);
104 GNUNET_assert (0);
105 }
106 GNUNET_CONTAINER_multihashmap_put (open_files,
107 &hash,
108 fh,
109 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
110 return fh; 92 return fh;
111 } 93 fh = GNUNET_DISK_file_open (name,
112 else 94 GNUNET_DISK_OPEN_WRITE |
95 GNUNET_DISK_OPEN_CREATE |
96 GNUNET_DISK_OPEN_APPEND,
97 GNUNET_DISK_PERM_USER_READ |
98 GNUNET_DISK_PERM_USER_WRITE |
99 GNUNET_DISK_PERM_GROUP_READ);
100 if (NULL == fh)
113 { 101 {
114 fh = GNUNET_CONTAINER_multihashmap_get (open_files, 102 LOG (GNUNET_ERROR_TYPE_ERROR,
115 &hash); 103 "Opening file `%s' failed.\n",
116 return fh; 104 name);
105 GNUNET_assert (0);
117 } 106 }
107 GNUNET_assert (GNUNET_YES ==
108 GNUNET_CONTAINER_multihashmap_put (open_files,
109 &hash,
110 fh,
111 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
112 return fh;
118} 113}
119 114
120 115
@@ -162,6 +157,7 @@ close_all_files ()
162 close_files_iter, 157 close_files_iter,
163 NULL); 158 NULL);
164 GNUNET_CONTAINER_multihashmap_destroy (open_files); 159 GNUNET_CONTAINER_multihashmap_destroy (open_files);
160 open_files = NULL;
165 return ret; 161 return ret;
166} 162}
167 163
@@ -491,6 +487,7 @@ static int ensure_folder_exist (void)
491 } 487 }
492 if (GNUNET_YES != GNUNET_DISK_directory_test ("/tmp/rps/", GNUNET_NO)) 488 if (GNUNET_YES != GNUNET_DISK_directory_test ("/tmp/rps/", GNUNET_NO))
493 { 489 {
490 LOG (GNUNET_ERROR_TYPE_ERROR, "Could not create directory `/tmp/rps'\n");
494 return GNUNET_SYSERR; 491 return GNUNET_SYSERR;
495 } 492 }
496 return GNUNET_YES; 493 return GNUNET_YES;
diff --git a/src/rps/rps-test_util.h b/src/rps/rps-test_util.h
index cf15a9909..484d0f7da 100644
--- a/src/rps/rps-test_util.h
+++ b/src/rps/rps-test_util.h
@@ -11,7 +11,7 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
@@ -28,7 +28,7 @@
28#ifndef RPS_TEST_UTIL_H 28#ifndef RPS_TEST_UTIL_H
29#define RPS_TEST_UTIL_H 29#define RPS_TEST_UTIL_H
30 30
31#define TO_FILE 1 31#define TO_FILE 0
32 32
33 33
34char * 34char *
diff --git a/src/rps/rps.h b/src/rps/rps.h
index ef968ffbb..5bfef93b0 100644
--- a/src/rps/rps.h
+++ b/src/rps/rps.h
@@ -79,7 +79,7 @@ struct GNUNET_RPS_CS_SeedMessage
79 /* Followed by num_peers * GNUNET_PeerIdentity */ 79 /* Followed by num_peers * GNUNET_PeerIdentity */
80}; 80};
81 81
82#ifdef ENABLE_MALICIOUS 82#if ENABLE_MALICIOUS
83/** 83/**
84 * Message from client to service to turn service malicious. 84 * Message from client to service to turn service malicious.
85 */ 85 */
diff --git a/src/rps/rps_api.c b/src/rps/rps_api.c
index 6fac4cf6f..d0b241a2b 100644
--- a/src/rps/rps_api.c
+++ b/src/rps/rps_api.c
@@ -806,7 +806,7 @@ GNUNET_RPS_seed_ids (struct GNUNET_RPS_Handle *h,
806} 806}
807 807
808 808
809#ifdef ENABLE_MALICIOUS 809#if ENABLE_MALICIOUS
810/** 810/**
811 * Turn RPS service to act malicious. 811 * Turn RPS service to act malicious.
812 * 812 *
diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c
index 126cc5dec..26066bf10 100644
--- a/src/rps/test_rps.c
+++ b/src/rps/test_rps.c
@@ -1357,7 +1357,7 @@ static void mal_init_peer (struct RPSPeer *rps_peer)
1357static void 1357static void
1358mal_pre (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h) 1358mal_pre (struct RPSPeer *rps_peer, struct GNUNET_RPS_Handle *h)
1359{ 1359{
1360 #ifdef ENABLE_MALICIOUS 1360 #if ENABLE_MALICIOUS
1361 uint32_t num_mal_peers; 1361 uint32_t num_mal_peers;
1362 1362
1363 GNUNET_assert ( (1 >= portion) && 1363 GNUNET_assert ( (1 >= portion) &&
@@ -1388,7 +1388,7 @@ mal_cb (struct RPSPeer *rps_peer)
1388 return; 1388 return;
1389 } 1389 }
1390 1390
1391 #ifdef ENABLE_MALICIOUS 1391 #if ENABLE_MALICIOUS
1392 GNUNET_assert ( (1 >= portion) && 1392 GNUNET_assert ( (1 >= portion) &&
1393 (0 < portion) ); 1393 (0 < portion) );
1394 num_mal_peers = round (portion * num_peers); 1394 num_mal_peers = round (portion * num_peers);
diff --git a/src/rps/test_rps.conf b/src/rps/test_rps.conf
index 1555a71a5..c22113af5 100644
--- a/src/rps/test_rps.conf
+++ b/src/rps/test_rps.conf
@@ -82,7 +82,7 @@ DISABLE_TRY_CONNECT = YES
82 82
83[cadet] 83[cadet]
84#OPTIONS=-l /tmp/rps_profiler_logs/cadet-[]-%Y-%m-%d.log 84#OPTIONS=-l /tmp/rps_profiler_logs/cadet-[]-%Y-%m-%d.log
85#PREFIX = valgrind 85#PREFIX = valgrind --log-file=/tmp/rps/valgrind_gnunet-service-cadet_%p
86 86
87#[arm] 87#[arm]
88#GLOBAL_POSTFIX=-l /tmp/rps_profiler_logs/other-[]-%Y-%m-%d.log 88#GLOBAL_POSTFIX=-l /tmp/rps_profiler_logs/other-[]-%Y-%m-%d.log