aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSupriti Singh <supritisingh08@gmail.com>2014-07-31 09:06:58 +0000
committerSupriti Singh <supritisingh08@gmail.com>2014-07-31 09:06:58 +0000
commit35d40eca953a9e2e1b5bd021dbabe4d591941afa (patch)
tree0e1c8f98825a5ddf9224a5758c01037b94dc0e40 /src
parent21db96c7ef17c463ae7127f48b29de0568424c2f (diff)
downloadgnunet-35d40eca953a9e2e1b5bd021dbabe4d591941afa.tar.gz
gnunet-35d40eca953a9e2e1b5bd021dbabe4d591941afa.zip
XVine: Fixes
Diffstat (limited to 'src')
-rw-r--r--src/dht/gnunet-service-xdht.c2
-rw-r--r--src/dht/gnunet-service-xdht_neighbours.c738
-rw-r--r--src/dht/gnunet-service-xdht_routing.c16
-rw-r--r--src/dht/gnunet-service-xdht_routing.h4
-rw-r--r--src/dht/gnunet_dht_profiler.c2
5 files changed, 406 insertions, 356 deletions
diff --git a/src/dht/gnunet-service-xdht.c b/src/dht/gnunet-service-xdht.c
index c8bc11686..3f44c2a69 100644
--- a/src/dht/gnunet-service-xdht.c
+++ b/src/dht/gnunet-service-xdht.c
@@ -168,7 +168,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
168 GDS_block_context = GNUNET_BLOCK_context_create (GDS_cfg); 168 GDS_block_context = GNUNET_BLOCK_context_create (GDS_cfg);
169 GDS_stats = GNUNET_STATISTICS_create ("dht", GDS_cfg); 169 GDS_stats = GNUNET_STATISTICS_create ("dht", GDS_cfg);
170 GDS_ROUTING_init (); 170 GDS_ROUTING_init ();
171 GDS_NSE_init (); 171 GDS_NSE_init (); //FIXME:not used in x0vine, remove
172 GDS_DATACACHE_init (); 172 GDS_DATACACHE_init ();
173 GDS_HELLO_init (); 173 GDS_HELLO_init ();
174 GDS_CLIENTS_init (server); 174 GDS_CLIENTS_init (server);
diff --git a/src/dht/gnunet-service-xdht_neighbours.c b/src/dht/gnunet-service-xdht_neighbours.c
index d8b52b0e8..b38c8332d 100644
--- a/src/dht/gnunet-service-xdht_neighbours.c
+++ b/src/dht/gnunet-service-xdht_neighbours.c
@@ -66,7 +66,12 @@
66/** 66/**
67 * How long to wait before sending another find finger trail request 67 * How long to wait before sending another find finger trail request
68 */ 68 */
69#define DHT_FIND_FINGER_TRAIL_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) 69#define DHT_FIND_FINGER_TRAIL_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2)
70
71/**
72 * How long to wait before sending another verify successor message.
73 */
74#define DHT_SEND_VERIFY_SUCCESSOR_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
70 75
71/** 76/**
72 * How long at most to wait for transmission of a request to a friend ? 77 * How long at most to wait for transmission of a request to a friend ?
@@ -840,6 +845,12 @@ struct Selected_Finger_Trail
840static GNUNET_SCHEDULER_TaskIdentifier find_finger_trail_task; 845static GNUNET_SCHEDULER_TaskIdentifier find_finger_trail_task;
841 846
842/** 847/**
848 * Task that sends verify successor message. This task is started when we get
849 * our successor for the first time.
850 */
851static GNUNET_SCHEDULER_TaskIdentifier send_verify_successor_task;
852
853/**
843 * Identity of this peer. 854 * Identity of this peer.
844 */ 855 */
845static struct GNUNET_PeerIdentity my_identity; 856static struct GNUNET_PeerIdentity my_identity;
@@ -1753,7 +1764,6 @@ test_friend_peermap_print ()
1753 } 1764 }
1754} 1765}
1755 1766
1756
1757/** 1767/**
1758 * This is a test function, to print all the entries of finger table. 1768 * This is a test function, to print all the entries of finger table.
1759 */ 1769 */
@@ -1946,7 +1956,7 @@ compare_finger_and_current_successor (struct Closest_Peer *current_closest_peer)
1946 /* In case no trail found, ignore this finger. */ 1956 /* In case no trail found, ignore this finger. */
1947 if (NULL == finger_trail) 1957 if (NULL == finger_trail)
1948 continue; 1958 continue;
1949 1959
1950 closest_peer = select_closest_peer (&finger->finger_identity, 1960 closest_peer = select_closest_peer (&finger->finger_identity,
1951 &current_closest_peer->best_known_destination, 1961 &current_closest_peer->best_known_destination,
1952 current_closest_peer->destination_finger_value, 1962 current_closest_peer->destination_finger_value,
@@ -1995,7 +2005,7 @@ compare_friend_and_current_closest_peer (void *cls,
1995 GNUNET_CRYPTO_cmp_peer_identity (&friend->id, 2005 GNUNET_CRYPTO_cmp_peer_identity (&friend->id,
1996 &current_closest_peer->best_known_destination)) 2006 &current_closest_peer->best_known_destination))
1997 return GNUNET_YES; 2007 return GNUNET_YES;
1998 2008
1999 closest_peer = select_closest_peer (&friend->id, 2009 closest_peer = select_closest_peer (&friend->id,
2000 &current_closest_peer->best_known_destination, 2010 &current_closest_peer->best_known_destination,
2001 current_closest_peer->destination_finger_value, 2011 current_closest_peer->destination_finger_value,
@@ -2495,7 +2505,7 @@ send_find_finger_trail_message (void *cls,
2495 struct FriendInfo *target_friend; 2505 struct FriendInfo *target_friend;
2496 struct GNUNET_TIME_Relative next_send_time; 2506 struct GNUNET_TIME_Relative next_send_time;
2497 struct GNUNET_HashCode trail_id; 2507 struct GNUNET_HashCode trail_id;
2498 struct GNUNET_HashCode new_intermediate_trail_id; 2508 struct GNUNET_HashCode intermediate_trail_id;
2499 unsigned int is_predecessor; 2509 unsigned int is_predecessor;
2500 uint64_t finger_id_value; 2510 uint64_t finger_id_value;
2501 2511
@@ -2508,18 +2518,31 @@ send_find_finger_trail_message (void *cls,
2508 GNUNET_SCHEDULER_add_delayed (next_send_time, &send_find_finger_trail_message, 2518 GNUNET_SCHEDULER_add_delayed (next_send_time, &send_find_finger_trail_message,
2509 NULL); 2519 NULL);
2510 2520
2511 /* No space in my routing table. (Source and destination peers also store entries 2521 //FIXME: adding this check, so that once we found an entry for 0 and 64 then
2522 //don't schedule. Remove it afterwards.
2523 struct FingerInfo *succ;
2524 struct FingerInfo *pred;
2525 succ = &finger_table[0];
2526 pred = &finger_table[PREDECESSOR_FINGER_ID];
2527
2528 if((GNUNET_YES == succ->is_present) &&
2529 (GNUNET_YES == pred->is_present))
2530 return;
2531
2532 /* No space in my routing table. (Source and destination peers also store entries
2512 * in their routing table). */ 2533 * in their routing table). */
2513 if (GNUNET_YES == GDS_ROUTING_threshold_reached()) 2534 if (GNUNET_YES == GDS_ROUTING_threshold_reached())
2514 return; 2535 return;
2515 2536
2537
2516 target_friend = select_random_friend (); 2538 target_friend = select_random_friend ();
2517 if (NULL == target_friend) 2539 if (NULL == target_friend)
2518 { 2540 {
2519 return; 2541 return;
2520 } 2542 }
2521 2543
2522 finger_id_value = compute_finger_identity_value (current_search_finger_index); 2544 finger_id_value = compute_finger_identity_value (current_search_finger_index);
2545
2523 if (PREDECESSOR_FINGER_ID == current_search_finger_index) 2546 if (PREDECESSOR_FINGER_ID == current_search_finger_index)
2524 is_predecessor = 1; 2547 is_predecessor = 1;
2525 else 2548 else
@@ -2528,12 +2551,12 @@ send_find_finger_trail_message (void *cls,
2528 /* Generate a unique trail id for trail we are trying to setup. */ 2551 /* Generate a unique trail id for trail we are trying to setup. */
2529 GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG, 2552 GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG,
2530 &trail_id, sizeof (trail_id)); 2553 &trail_id, sizeof (trail_id));
2531 memset(&new_intermediate_trail_id, 0, sizeof (struct GNUNET_HashCode)); 2554 memset(&intermediate_trail_id, 0, sizeof (struct GNUNET_HashCode));
2532 2555
2533 GDS_NEIGHBOURS_send_trail_setup (my_identity, finger_id_value, 2556 GDS_NEIGHBOURS_send_trail_setup (my_identity, finger_id_value,
2534 target_friend->id, target_friend, 0, NULL, 2557 target_friend->id, target_friend, 0, NULL,
2535 is_predecessor, trail_id, 2558 is_predecessor, trail_id,
2536 new_intermediate_trail_id); 2559 intermediate_trail_id);
2537} 2560}
2538 2561
2539 2562
@@ -2820,7 +2843,6 @@ free_trail (struct Trail *trail)
2820 GNUNET_CONTAINER_DLL_remove (trail->trail_head, 2843 GNUNET_CONTAINER_DLL_remove (trail->trail_head,
2821 trail->trail_tail, 2844 trail->trail_tail,
2822 trail_element); 2845 trail_element);
2823
2824 GNUNET_free_non_null (trail_element); 2846 GNUNET_free_non_null (trail_element);
2825 } 2847 }
2826 trail->trail_head = NULL; 2848 trail->trail_head = NULL;
@@ -3061,50 +3083,84 @@ scan_and_compress_trail (struct GNUNET_PeerIdentity finger_identity,
3061 return new_trail; 3083 return new_trail;
3062} 3084}
3063 3085
3064 3086#if 0
3065/** 3087/**
3066 * Send verify successor message to your current successor over the shortest 3088 * Periodic task to verify current successor. There can be multiple trails to reach
3067 * trail. 3089 * to successor, choose the shortest one and send verify successor message
3068 * @param successor Current successor. 3090 * across that trail.
3091 * @param cls closure for this task
3092 * @param tc the context under which the task is running
3069 */ 3093 */
3070static void 3094static void
3071send_verify_successor_message (struct FingerInfo *successor) 3095send_verify_successor_message (void *cls,
3096 const struct GNUNET_SCHEDULER_TaskContext *tc)
3097{
3098 struct FingerInfo *current_successor;
3099 struct GNUNET_TIME_Relative next_send_time;
3100 struct GNUNET_PeerIdentity *trail;
3101 struct GNUNET_HashCode trail_id;
3102 unsigned int trail_length;
3103
3104 /* Schedule another send_verify_successor_message. */
3105 next_send_time.rel_value_us =
3106 DHT_SEND_VERIFY_SUCCESSOR_INTERVAL.rel_value_us +
3107 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
3108 DHT_SEND_VERIFY_SUCCESSOR_INTERVAL.rel_value_us);
3109 send_verify_successor_task =
3110 GNUNET_SCHEDULER_add_delayed (next_send_time, &send_verify_successor_message,
3111 NULL);
3112
3113 /* We should never be our own successor. */
3114 GNUNET_assert(0 !=
3115 GNUNET_CRYTPO_cmp_peer_identity (&my_identity,
3116 &current_successor->finger_identity));
3117
3118
3119 trail = get_shortest_trail (successor, &trail_length, &trail_id);
3120
3121 if(trail_length > 0)
3122 {
3123
3124 }
3125 else
3126 {
3127
3128 }
3129}
3130#endif
3131
3132
3133static void
3134send_verify_successor_message (void *cls,
3135 const struct GNUNET_SCHEDULER_TaskContext *tc)
3072{ 3136{
3073 /*
3074 * FIXME: should we send a verify successor message across all the trails
3075 * in case we send through all friends. It complicates the logic, don't
3076 * do it at the moment. Write it as optimization and do it later.
3077 * 1. Here we can have 3 types of fingers
3078 * --> my own identity
3079 * Assumption that the calling function will not send request for
3080 * such successor. Move the logic here.
3081 * --> friend is a finger
3082 * Need to verify if we keep the trails count for a friend. In case of
3083 * friend there is no trail to reach to that friend, so
3084 * 1. no entry in routing table
3085 * 2. no trail id
3086 * 3. no trails count
3087 * 4. but do we increment the count of trails through the friend?
3088 * Trails count is used only to keep a limit on number of trails
3089 * that a friend should be part of. No need to increment the trails
3090 * count for a friend which is a finegr also. so, if finger = friend
3091 * then don't increment the trails count. But if the same friend
3092 * is the first friend to reach to some other finger then increment
3093 * the trails count. Not sure if this design is correct need to verify
3094 * again.
3095 * --> real finger
3096 */
3097 struct FriendInfo *target_friend; 3137 struct FriendInfo *target_friend;
3098 struct GNUNET_HashCode trail_id; 3138 struct GNUNET_HashCode trail_id;
3099 int i; 3139 int i;
3140 struct GNUNET_TIME_Relative next_send_time;
3100 struct Trail *trail; 3141 struct Trail *trail;
3101 struct Trail_Element *element; 3142 struct Trail_Element *element;
3102 unsigned int trail_length; 3143 unsigned int trail_length;
3103 unsigned int j = 0; 3144 unsigned int j = 0;
3104 3145 struct FingerInfo *successor;
3146
3147 /* Schedule another send_find_finger_trail_message task. */
3148 next_send_time.rel_value_us =
3149 DHT_FIND_FINGER_TRAIL_INTERVAL.rel_value_us +
3150 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
3151 DHT_FIND_FINGER_TRAIL_INTERVAL.rel_value_us);
3152 send_verify_successor_task =
3153 GNUNET_SCHEDULER_add_delayed (next_send_time, &send_verify_successor_message,
3154 NULL);
3155
3156 successor = &finger_table[0];
3105 i = 0; 3157 i = 0;
3106 trail = &successor->trail_list[i]; 3158 trail = &successor->trail_list[i];
3107 3159
3160 if(0 == GNUNET_CRYPTO_cmp_peer_identity (&my_identity,
3161 &successor->finger_identity))
3162 return;
3163
3108 /* Trail stored at this index. */ 3164 /* Trail stored at this index. */
3109 GNUNET_assert (GNUNET_YES == trail->is_present); 3165 GNUNET_assert (GNUNET_YES == trail->is_present);
3110 3166
@@ -3169,10 +3225,17 @@ update_current_search_finger_index (struct GNUNET_PeerIdentity finger_identity,
3169 current_search_finger_index = PREDECESSOR_FINGER_ID; 3225 current_search_finger_index = PREDECESSOR_FINGER_ID;
3170 3226
3171 /* If I am not my own successor, then send a verify successor message. */ 3227 /* If I am not my own successor, then send a verify successor message. */
3228 //if (0 != GNUNET_CRYPTO_cmp_peer_identity (&my_identity, &finger_identity))
3229 //{
3230 //send_verify_successor_message (successor);
3231 //}
3232
3172 if (0 != GNUNET_CRYPTO_cmp_peer_identity (&my_identity, &finger_identity)) 3233 if (0 != GNUNET_CRYPTO_cmp_peer_identity (&my_identity, &finger_identity))
3173 { 3234 {
3174 send_verify_successor_message (successor); 3235 if (GNUNET_SCHEDULER_NO_TASK == send_verify_successor_task)
3236 send_verify_successor_task = GNUNET_SCHEDULER_add_now (&send_verify_successor_message, NULL);
3175 } 3237 }
3238
3176 return; 3239 return;
3177 } 3240 }
3178 3241
@@ -3312,7 +3375,7 @@ finger_table_add (struct GNUNET_PeerIdentity finger_identity,
3312 3375
3313 /* Get the finger_table_index corresponding to finger_value we got from network.*/ 3376 /* Get the finger_table_index corresponding to finger_value we got from network.*/
3314 finger_table_index = get_finger_table_index (finger_value, is_predecessor); 3377 finger_table_index = get_finger_table_index (finger_value, is_predecessor);
3315 3378
3316 /* Invalid finger_table_index. */ 3379 /* Invalid finger_table_index. */
3317 if ((finger_table_index > PREDECESSOR_FINGER_ID)) 3380 if ((finger_table_index > PREDECESSOR_FINGER_ID))
3318 { 3381 {
@@ -3335,7 +3398,7 @@ finger_table_add (struct GNUNET_PeerIdentity finger_identity,
3335 } 3398 }
3336 3399
3337 existing_finger = &finger_table[finger_table_index]; 3400 existing_finger = &finger_table[finger_table_index];
3338 3401
3339 /* No entry present in finger_table for given finger map index. */ 3402 /* No entry present in finger_table for given finger map index. */
3340 if (GNUNET_NO == existing_finger->is_present) 3403 if (GNUNET_NO == existing_finger->is_present)
3341 { 3404 {
@@ -3347,6 +3410,7 @@ finger_table_add (struct GNUNET_PeerIdentity finger_identity,
3347 scan_and_compress_trail (finger_identity, finger_trail, 3410 scan_and_compress_trail (finger_identity, finger_trail,
3348 finger_trail_length, finger_trail_id, 3411 finger_trail_length, finger_trail_id,
3349 &updated_finger_trail_length); 3412 &updated_finger_trail_length);
3413
3350 add_new_finger (finger_identity, updated_trail, 3414 add_new_finger (finger_identity, updated_trail,
3351 updated_finger_trail_length, 3415 updated_finger_trail_length,
3352 finger_trail_id, finger_table_index); 3416 finger_trail_id, finger_table_index);
@@ -3375,7 +3439,6 @@ finger_table_add (struct GNUNET_PeerIdentity finger_identity,
3375 scan_and_compress_trail (finger_identity, finger_trail, 3439 scan_and_compress_trail (finger_identity, finger_trail,
3376 finger_trail_length, finger_trail_id, 3440 finger_trail_length, finger_trail_id,
3377 &updated_finger_trail_length); 3441 &updated_finger_trail_length);
3378
3379 remove_existing_finger (existing_finger, finger_table_index); 3442 remove_existing_finger (existing_finger, finger_table_index);
3380 add_new_finger (finger_identity, updated_trail, updated_finger_trail_length, 3443 add_new_finger (finger_identity, updated_trail, updated_finger_trail_length,
3381 finger_trail_id, finger_table_index); 3444 finger_trail_id, finger_table_index);
@@ -3396,6 +3459,7 @@ finger_table_add (struct GNUNET_PeerIdentity finger_identity,
3396 GDS_ROUTING_SRC_TO_DEST, 3459 GDS_ROUTING_SRC_TO_DEST,
3397 finger_identity); 3460 finger_identity);
3398 } 3461 }
3462
3399 /* Store the successor for path tracking */ 3463 /* Store the successor for path tracking */
3400 if (track_topology && (NULL != GDS_stats) && (0 == finger_table_index)) 3464 if (track_topology && (NULL != GDS_stats) && (0 == finger_table_index))
3401 { 3465 {
@@ -3831,7 +3895,7 @@ get_local_best_known_next_hop (uint64_t final_dest_finger_val,
3831 struct Closest_Peer peer; 3895 struct Closest_Peer peer;
3832 3896
3833 /* Find a local best known peer. */ 3897 /* Find a local best known peer. */
3834 peer = find_successor (final_dest_finger_val, is_predecessor); 3898 peer = find_successor (final_dest_finger_val, is_predecessor);//FIXME: chnage to better name
3835 3899
3836 /* Am I just a part of a trail towards a finger (current_destination)? */ 3900 /* Am I just a part of a trail towards a finger (current_destination)? */
3837 if (0 != (GNUNET_CRYPTO_cmp_peer_identity (&my_identity, current_dest))) 3901 if (0 != (GNUNET_CRYPTO_cmp_peer_identity (&my_identity, current_dest)))
@@ -3842,11 +3906,16 @@ get_local_best_known_next_hop (uint64_t final_dest_finger_val,
3842 current_dest)) 3906 current_dest))
3843 { 3907 {
3844 struct GNUNET_PeerIdentity *closest_peer; 3908 struct GNUNET_PeerIdentity *closest_peer;
3845 closest_peer = select_closest_peer (&peer.best_known_destination, 3909 struct GNUNET_PeerIdentity *local_best_known_dest;
3910 local_best_known_dest = GNUNET_new(struct GNUNET_PeerIdentity);
3911 memcpy(local_best_known_dest, &peer.best_known_destination, sizeof(struct GNUNET_PeerIdentity));
3912
3913 closest_peer = select_closest_peer (local_best_known_dest,
3846 current_dest, 3914 current_dest,
3847 final_dest_finger_val, 3915 final_dest_finger_val,
3848 is_predecessor); 3916 is_predecessor);
3849 3917
3918 GNUNET_free(local_best_known_dest);
3850 /* Is current dest (end point of the trail of which I am a part) closest_peer? */ 3919 /* Is current dest (end point of the trail of which I am a part) closest_peer? */
3851 if (0 == GNUNET_CRYPTO_cmp_peer_identity (current_dest, closest_peer)) 3920 if (0 == GNUNET_CRYPTO_cmp_peer_identity (current_dest, closest_peer))
3852 { 3921 {
@@ -3914,6 +3983,12 @@ handle_dht_p2p_trail_setup (void *cls, const struct GNUNET_PeerIdentity *peer,
3914 is_predecessor = ntohl (trail_setup->is_predecessor); 3983 is_predecessor = ntohl (trail_setup->is_predecessor);
3915 intermediate_trail_id = trail_setup->intermediate_trail_id; 3984 intermediate_trail_id = trail_setup->intermediate_trail_id;
3916 3985
3986 /* If I was the source and got the message back, then set trail length to 0.*/
3987 if (0 == GNUNET_CRYPTO_cmp_peer_identity(&my_identity, &source))
3988 {
3989 trail_length = 0;
3990 }
3991
3917 /* Is my routing table full? */ 3992 /* Is my routing table full? */
3918 if (GNUNET_YES == GDS_ROUTING_threshold_reached()) 3993 if (GNUNET_YES == GDS_ROUTING_threshold_reached())
3919 { 3994 {
@@ -3927,12 +4002,7 @@ handle_dht_p2p_trail_setup (void *cls, const struct GNUNET_PeerIdentity *peer,
3927 CONGESTION_TIMEOUT); 4002 CONGESTION_TIMEOUT);
3928 return GNUNET_OK; 4003 return GNUNET_OK;
3929 } 4004 }
3930 4005
3931 /* If I was the source and got the message back, then set trail length to 0.*/
3932 if (0 == GNUNET_CRYPTO_cmp_peer_identity(&my_identity, &source))
3933 {
3934 trail_length = 0;
3935 }
3936 /* Get the next hop to forward the trail setup request. */ 4006 /* Get the next hop to forward the trail setup request. */
3937 struct Closest_Peer next_peer = 4007 struct Closest_Peer next_peer =
3938 get_local_best_known_next_hop (final_dest_finger_val, 4008 get_local_best_known_next_hop (final_dest_finger_val,
@@ -3941,11 +4011,12 @@ handle_dht_p2p_trail_setup (void *cls, const struct GNUNET_PeerIdentity *peer,
3941 *peer, 4011 *peer,
3942 source, 4012 source,
3943 &current_dest); 4013 &current_dest);
3944 4014
3945 /* Am I the final destination? */ 4015 /* Am I the final destination? */
3946 if (0 == (GNUNET_CRYPTO_cmp_peer_identity (&next_peer.best_known_destination, 4016 if (0 == (GNUNET_CRYPTO_cmp_peer_identity (&next_peer.best_known_destination,
3947 &my_identity))) 4017 &my_identity)))
3948 { 4018 {
4019 //
3949 /* If I was not the source of this message for which now I am destination */ 4020 /* If I was not the source of this message for which now I am destination */
3950 if (0 != GNUNET_CRYPTO_cmp_peer_identity (&source, &my_identity)) 4021 if (0 != GNUNET_CRYPTO_cmp_peer_identity (&source, &my_identity))
3951 { 4022 {
@@ -4129,7 +4200,7 @@ handle_dht_p2p_trail_setup_result(void *cls, const struct GNUNET_PeerIdentity *p
4129 GNUNET_break_op (0); 4200 GNUNET_break_op (0);
4130 return GNUNET_OK; 4201 return GNUNET_OK;
4131 } 4202 }
4132 4203
4133 is_predecessor = ntohl (trail_result->is_predecessor); 4204 is_predecessor = ntohl (trail_result->is_predecessor);
4134 querying_peer = trail_result->querying_peer; 4205 querying_peer = trail_result->querying_peer;
4135 finger_identity = trail_result->finger_identity; 4206 finger_identity = trail_result->finger_identity;
@@ -4228,74 +4299,143 @@ invert_trail (const struct GNUNET_PeerIdentity *trail,
4228 4299
4229 4300
4230/** 4301/**
4231 * Return the shortest trail to reach from me to my_predecessor. 4302 * Return the shortest trail among all the trails to reach to finger from me.
4232 * @param current_trail Trail from source to me. 4303 * @param finger Finger
4233 * @param current_trail_length Total number of peers in @a current_trail 4304 * @param shortest_trail_length[out] Trail length of shortest trail from me
4234 * @param trail_length [out] Total number of peers in selected trail. 4305 * to @a finger
4235 * @return Updated trail from source peer to my_predecessor. 4306 * @return Shortest trail.
4236 */ 4307 */
4237static struct GNUNET_PeerIdentity * 4308static struct GNUNET_PeerIdentity *
4238trail_me_to_my_predecessor (const struct GNUNET_PeerIdentity *current_trail, 4309get_shortest_trail (struct FingerInfo *finger,
4239 unsigned int current_trail_length, 4310 unsigned int *trail_length)
4240 unsigned int *trail_length)
4241{ 4311{
4242 struct GNUNET_PeerIdentity *trail_me_to_predecessor;
4243 struct Trail *trail; 4312 struct Trail *trail;
4313 unsigned int flag = 0;
4314 unsigned int shortest_trail_index = 0;
4315 int shortest_trail_length = -1;
4244 struct Trail_Element *trail_element; 4316 struct Trail_Element *trail_element;
4245 struct FingerInfo *my_predecessor; 4317 struct GNUNET_PeerIdentity *trail_list;
4246 unsigned int i; 4318 unsigned int i;
4247 unsigned int shortest_trail_length = 0;
4248 unsigned int trail_index = 0;
4249 unsigned int flag = 0;
4250
4251 my_predecessor = &finger_table[PREDECESSOR_FINGER_ID];
4252 4319
4253 GNUNET_assert (GNUNET_YES == my_predecessor->is_present); 4320 trail = GNUNET_new (struct Trail);
4254
4255 *trail_length = 0;
4256 4321
4257 /* Choose the shortest path from me to my predecessor. */ 4322 /* Get the shortest trail to reach to current successor. */
4258 for (i = 0; i < my_predecessor->trails_count; i++) 4323 for (i = 0; i < finger->trails_count; i++)
4259 { 4324 {
4260 trail = &my_predecessor->trail_list[i]; 4325 trail = &finger->trail_list[i];
4326
4261 if (0 == flag) 4327 if (0 == flag)
4262 { 4328 {
4263 shortest_trail_length = trail->trail_length; 4329 shortest_trail_index = i;
4264 trail_index = i; 4330 shortest_trail_length = trail->trail_length;
4265 flag = 1; 4331 flag = 1;
4332 continue;
4266 } 4333 }
4267 4334
4268 if (trail->trail_length > shortest_trail_length) 4335 if (shortest_trail_length > trail->trail_length)
4269 continue; 4336 {
4270 shortest_trail_length = trail->trail_length; 4337 shortest_trail_index = i;
4271 trail_index = i; 4338 shortest_trail_length = trail->trail_length;
4339 }
4340 continue;
4272 } 4341 }
4273
4274 *trail_length = shortest_trail_length;
4275 GNUNET_assert(*trail_length != 0);
4276 trail_me_to_predecessor = GNUNET_malloc (sizeof (struct GNUNET_PeerIdentity)
4277 * (*trail_length));
4278 4342
4279 /* Copy the selected trail and send this trail to calling function. */ 4343 /* Copy the shortest trail and return. */
4280 i = 0; 4344 trail = &finger->trail_list[shortest_trail_index];
4281 trail = &my_predecessor->trail_list[trail_index];
4282 trail_element = trail->trail_head; 4345 trail_element = trail->trail_head;
4283 while ( i < shortest_trail_length) 4346 trail_list = GNUNET_malloc (sizeof(struct GNUNET_PeerIdentity)*
4347 shortest_trail_length);
4348
4349 for(i = 0; i < shortest_trail_length; i++,trail_element = trail_element->next)
4284 { 4350 {
4285 trail_me_to_predecessor[i] = trail_element->peer; 4351 trail_list[i] = trail_element->peer;
4286 i++;
4287 trail_element = trail_element->next;
4288 } 4352 }
4353
4354 GNUNET_assert(shortest_trail_length != -1);
4355
4356 *trail_length = shortest_trail_length;
4357 return trail_list;
4358}
4359
4289 4360
4290 return trail_me_to_predecessor; 4361/**
4362 * Return the trail from source to my current predecessor. Check if source
4363 * is already part of the this trail, if yes then return the shorten trail.
4364 * @param current_trail Trail from source to me, NOT including the endpoints.
4365 * @param current_trail_length Number of peers in @a current_trail.
4366 * @param trail_src_to_curr_pred_length[out] Number of peers in trail from
4367 * source to my predecessor, NOT including
4368 * the endpoints.
4369 * @return Trail from source to my predecessor.
4370 */
4371static struct GNUNET_PeerIdentity *
4372get_trail_src_to_curr_pred (struct GNUNET_PeerIdentity source_peer,
4373 const struct GNUNET_PeerIdentity *trail_src_to_me,
4374 unsigned int trail_src_to_me_len,
4375 unsigned int *trail_src_to_curr_pred_length)
4376{
4377 struct GNUNET_PeerIdentity *trail_me_to_curr_pred;
4378 struct GNUNET_PeerIdentity *trail_src_to_curr_pred;
4379 unsigned int trail_me_to_curr_pred_length;
4380 struct FingerInfo *current_predecessor;
4381 unsigned int i;
4382 unsigned int j;
4383
4384 current_predecessor = &finger_table[PREDECESSOR_FINGER_ID];
4385 trail_me_to_curr_pred = get_shortest_trail (current_predecessor,
4386 &trail_me_to_curr_pred_length);
4387
4388 /* Check if trail_me_to_curr_pred contains source. */
4389 if (trail_me_to_curr_pred_length > 0)
4390 {
4391 for(i = trail_me_to_curr_pred_length - 1; i >= 0; i--)
4392 {
4393 if(0 != GNUNET_CRYPTO_cmp_peer_identity (&source_peer,
4394 &trail_me_to_curr_pred[i]))
4395 continue;
4396
4397 i = i+1;
4398
4399 /* Source is the last element in the trail to reach to my pred.
4400 Source is direct friend of the pred. */
4401 if (trail_me_to_curr_pred_length == i)
4402 {
4403 *trail_src_to_curr_pred_length = 0;
4404 return NULL;
4405 }
4406
4407 *trail_src_to_curr_pred_length = trail_me_to_curr_pred_length - i;
4408 trail_src_to_curr_pred = GNUNET_malloc (sizeof (struct GNUNET_PeerIdentity)*
4409 *trail_src_to_curr_pred_length);
4410 for(j = 0; i < *trail_src_to_curr_pred_length; i++,j++)
4411 {
4412 trail_src_to_curr_pred[j] = trail_me_to_curr_pred[i];
4413 }
4414 return trail_src_to_curr_pred;
4415 }
4416 }
4417
4418 /* Append trail from source to me to my current_predecessor. */
4419 *trail_src_to_curr_pred_length = trail_src_to_me_len +
4420 trail_me_to_curr_pred_length + 1;
4421
4422 trail_src_to_curr_pred = GNUNET_malloc (sizeof(struct GNUNET_PeerIdentity)*
4423 *trail_src_to_curr_pred_length);
4424
4425 for (i = 0; i < trail_src_to_me_len; i++)
4426 trail_src_to_curr_pred[i] = trail_src_to_me[i];
4427
4428 trail_src_to_curr_pred[i] = my_identity;
4429 i++;
4430
4431 for (j = 0; i < *trail_src_to_curr_pred_length; i++,j++)
4432 trail_src_to_curr_pred[i] = trail_me_to_curr_pred[j];
4433
4434 return trail_src_to_curr_pred;
4291} 4435}
4292 4436
4293 4437
4294/** 4438/**
4295 * FIXME In case predecessor is a friend then do we add it in routing table.
4296 * if not then check the logic of trail teardown in case we compress the trail
4297 * such that friend is finger. then do we remove the entry from end points or
4298 * not. Ideally we should remove the entries from end point.
4299 * Add finger as your predecessor. To add, first generate a new trail id, invert 4439 * Add finger as your predecessor. To add, first generate a new trail id, invert
4300 * the trail to get the trail from me to finger, add an entry in your routing 4440 * the trail to get the trail from me to finger, add an entry in your routing
4301 * table, send add trail message to peers which are part of trail from me to 4441 * table, send add trail message to peers which are part of trail from me to
@@ -4317,17 +4457,15 @@ update_predecessor (struct GNUNET_PeerIdentity finger,
4317 GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG, 4457 GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG,
4318 &trail_to_new_predecessor_id, 4458 &trail_to_new_predecessor_id,
4319 sizeof (trail_to_new_predecessor_id)); 4459 sizeof (trail_to_new_predecessor_id));
4320 //test_finger_table_print(); 4460
4321 /* Finger is a friend. */ 4461 /* Finger is a friend. */
4322 if (trail_length == 0) 4462 if (trail_length == 0)
4323 { 4463 {
4324 trail_to_new_predecessor = NULL; 4464 trail_to_new_predecessor = NULL;
4325 /* FIXME: check that you always add trail entry even if your finger is 4465 GDS_ROUTING_add (trail_to_new_predecessor_id, my_identity, finger);
4326 friend. */
4327 GDS_ROUTING_add (trail_to_new_predecessor_id, my_identity, finger); /*FIXME; Check that the corresponding pred adds entry also. */
4328 GNUNET_assert (NULL != (target_friend = 4466 GNUNET_assert (NULL != (target_friend =
4329 GNUNET_CONTAINER_multipeermap_get (friend_peermap, 4467 GNUNET_CONTAINER_multipeermap_get (friend_peermap,
4330 &finger))); 4468 &finger)));
4331 } 4469 }
4332 else 4470 else
4333 { 4471 {
@@ -4356,48 +4494,22 @@ update_predecessor (struct GNUNET_PeerIdentity finger,
4356 trail_to_new_predecessor, 4494 trail_to_new_predecessor,
4357 trail_length, 4495 trail_length,
4358 target_friend); 4496 target_friend);
4359 4497
4360 add_new_finger (finger, trail_to_new_predecessor, trail_length, 4498 add_new_finger (finger, trail_to_new_predecessor, trail_length,
4361 trail_to_new_predecessor_id, PREDECESSOR_FINGER_ID); 4499 trail_to_new_predecessor_id, PREDECESSOR_FINGER_ID);
4362 GNUNET_free_non_null (trail_to_new_predecessor); 4500 GNUNET_free_non_null (trail_to_new_predecessor);
4363} 4501}
4364 4502
4365 4503
4366/* 3. In case you are successor, then 4504/*
4367 * 3.1 check if you have a predecessor 4505 * Check if you already have a predecessor. If not then add finger as your
4368 * 3.2 if no predecessor, then add the source of this message as your 4506 * predecessor. If you have predecessor, then compare two peer identites.
4369 * predecessor. To add, first you should generate a new trail id, 4507 * If finger is correct predecessor, then remove the old entry, add finger in
4370 * invert the trail, send add trail message across new trail, add 4508 * finger table and send add_trail message to add the trail in the routing
4371 * an entry in finger table. Now, destination also have routing 4509 * table of all peers which are part of trail to reach from me to finger.
4372 * table entry so add in your routing table also. 4510 * @param finger New peer which may be our predecessor.
4373 * 3.3 If its closer than existing one, then do everything in step 1 and 4511 * @param trail List of peers to reach from @finger to me.
4374 * free existing finger. 4512 * @param trail_length Total number of peer in @a trail.
4375 * 3.3 If its same as the old one, then do nothing.
4376 * 3.4 if its not same as old one, and between source and old one, old one
4377 * is the correct predecessor, then construct a trail from source
4378 * to your old successor. scan the trail to remove duplicate entries.
4379 * 4. send verify successor result, with trail id of trail from source to
4380 * me. And also send the new trail from source to reach to its probable
4381 * predecessor. */
4382 /*
4383 * 1. this function is called from both verify and notify.
4384 * 2. so write in a way that it is used in both.
4385 */
4386/**
4387 * Check if you have a predecessor.
4388 * 1. if no predecessor, then add finger as your predecessor. To add, first
4389 * generate a new trail id, invert the trail to get the trail from me to finger,
4390 * add an entry in your routing table, send add trail message to peers which
4391 * are part of trail from me to finger and add finger in finger table.
4392 * 2. If there is a predecessor, then compare existing one and finger.
4393 * 2.1 If finger is correct predecessor, then remove current_predecessor. And
4394 * do everything in step 1 to add finger into finger table.
4395 * 2.2 If current_predecessor is correct predecessor, the construct a trail from
4396 * finger to current_predecessor.
4397 * @param finger
4398 * @param trail
4399 * @param trail_length
4400 * @return
4401 */ 4513 */
4402static void 4514static void
4403compare_and_update_predecessor (struct GNUNET_PeerIdentity finger, 4515compare_and_update_predecessor (struct GNUNET_PeerIdentity finger,
@@ -4410,6 +4522,7 @@ compare_and_update_predecessor (struct GNUNET_PeerIdentity finger,
4410 unsigned int is_predecessor = 1; 4522 unsigned int is_predecessor = 1;
4411 4523
4412 current_predecessor = &finger_table[PREDECESSOR_FINGER_ID]; 4524 current_predecessor = &finger_table[PREDECESSOR_FINGER_ID];
4525
4413 GNUNET_assert (0 != GNUNET_CRYPTO_cmp_peer_identity (&finger, &my_identity)); 4526 GNUNET_assert (0 != GNUNET_CRYPTO_cmp_peer_identity (&finger, &my_identity));
4414 4527
4415 /* No predecessor. Add finger as your predecessor. */ 4528 /* No predecessor. Add finger as your predecessor. */
@@ -4418,11 +4531,13 @@ compare_and_update_predecessor (struct GNUNET_PeerIdentity finger,
4418 update_predecessor (finger, trail, trail_length); 4531 update_predecessor (finger, trail, trail_length);
4419 return; 4532 return;
4420 } 4533 }
4534
4421 if (0 == GNUNET_CRYPTO_cmp_peer_identity (&current_predecessor->finger_identity, 4535 if (0 == GNUNET_CRYPTO_cmp_peer_identity (&current_predecessor->finger_identity,
4422 &finger)) 4536 &finger))
4537 {
4423 return; 4538 return;
4539 }
4424 4540
4425 //test_finger_table_print();
4426 predecessor_value = compute_finger_identity_value (PREDECESSOR_FINGER_ID); 4541 predecessor_value = compute_finger_identity_value (PREDECESSOR_FINGER_ID);
4427 closest_peer = select_closest_peer (&finger, 4542 closest_peer = select_closest_peer (&finger,
4428 &current_predecessor->finger_identity, 4543 &current_predecessor->finger_identity,
@@ -4436,36 +4551,10 @@ compare_and_update_predecessor (struct GNUNET_PeerIdentity finger,
4436 update_predecessor (finger, trail, trail_length); 4551 update_predecessor (finger, trail, trail_length);
4437 return; 4552 return;
4438 } 4553 }
4439
4440 return; 4554 return;
4441} 4555}
4442 4556
4443 4557
4444/**
4445 * Check if the the peer from which we got the message is the valid peer from
4446 * which we should expect the message.
4447 * @param peer Peer from which we got the message.
4448 * @param trail_id Trail in which peer should be either my prev_hop or next_hop
4449 * depending on the @a trail_direction.
4450 * @param trail_direction Is trail from source to destination or opposite way.
4451 * @return #GNUNET_YES if Peer is valid.
4452 * #GNUNET_NO if Peer is not valid.
4453 */
4454static int
4455is_sender_peer_valid (const struct GNUNET_PeerIdentity *peer,
4456 struct GNUNET_HashCode trail_id,
4457 enum GDS_ROUTING_trail_direction trail_direction)
4458{
4459 struct GNUNET_PeerIdentity *peer_routing_table;
4460
4461 peer_routing_table = GDS_ROUTING_get_next_hop (trail_id, !trail_direction);
4462
4463 if(0 == GNUNET_CRYPTO_cmp_peer_identity (peer, peer_routing_table))
4464 return GNUNET_YES;
4465 else
4466 return GNUNET_NO;
4467}
4468
4469/* 4558/*
4470 * Core handle for p2p verify successor messages. 4559 * Core handle for p2p verify successor messages.
4471 * @param cls closure 4560 * @param cls closure
@@ -4484,10 +4573,10 @@ handle_dht_p2p_verify_successor(void *cls,
4484 struct GNUNET_PeerIdentity source_peer; 4573 struct GNUNET_PeerIdentity source_peer;
4485 struct GNUNET_PeerIdentity *trail; 4574 struct GNUNET_PeerIdentity *trail;
4486 struct GNUNET_PeerIdentity *next_hop; 4575 struct GNUNET_PeerIdentity *next_hop;
4487 struct GNUNET_PeerIdentity *trail_to_predecessor; //used unintialized somewhere.
4488 struct FingerInfo *current_predecessor; 4576 struct FingerInfo *current_predecessor;
4489 struct FriendInfo *target_friend; 4577 struct FriendInfo *target_friend;
4490 unsigned int trail_to_predecessor_length = 0; 4578 unsigned int trail_src_to_curr_pred_len = 0;
4579 struct GNUNET_PeerIdentity *trail_src_to_curr_pred;
4491 size_t msize; 4580 size_t msize;
4492 unsigned int trail_length; 4581 unsigned int trail_length;
4493 4582
@@ -4514,12 +4603,7 @@ handle_dht_p2p_verify_successor(void *cls,
4514 successor = vsm->successor; 4603 successor = vsm->successor;
4515 trail = (struct GNUNET_PeerIdentity *)&vsm[1]; 4604 trail = (struct GNUNET_PeerIdentity *)&vsm[1];
4516 4605
4517 if(GNUNET_NO == is_sender_peer_valid (peer,trail_id, GDS_ROUTING_SRC_TO_DEST)) 4606
4518 {
4519 GNUNET_break_op(0);
4520 return GNUNET_SYSERR;
4521 }
4522
4523 /* I am NOT the successor of source_peer. Pass the message to next_hop on 4607 /* I am NOT the successor of source_peer. Pass the message to next_hop on
4524 * the trail. */ 4608 * the trail. */
4525 if(0 != (GNUNET_CRYPTO_cmp_peer_identity (&successor, &my_identity))) 4609 if(0 != (GNUNET_CRYPTO_cmp_peer_identity (&successor, &my_identity)))
@@ -4545,72 +4629,61 @@ handle_dht_p2p_verify_successor(void *cls,
4545 /* Check if the source_peer could be our predecessor and if yes then update 4629 /* Check if the source_peer could be our predecessor and if yes then update
4546 * it. */ 4630 * it. */
4547 compare_and_update_predecessor (source_peer, trail, trail_length); 4631 compare_and_update_predecessor (source_peer, trail, trail_length);
4548
4549 current_predecessor = &finger_table[PREDECESSOR_FINGER_ID]; 4632 current_predecessor = &finger_table[PREDECESSOR_FINGER_ID];
4550 4633
4551 /* Is source of this message NOT my predecessor. */ 4634 /* Is source of this message NOT my predecessor. */
4552 if (0 != (GNUNET_CRYPTO_cmp_peer_identity (&current_predecessor->finger_identity, 4635 if (0 != (GNUNET_CRYPTO_cmp_peer_identity (&current_predecessor->finger_identity,
4553 &source_peer))) 4636 &source_peer)))
4554 { 4637 {
4555 /* if current predecessor is not a friend, we have a trail to reach to it*/ 4638 trail_src_to_curr_pred = get_trail_src_to_curr_pred (source_peer,
4556 if (NULL == (GNUNET_CONTAINER_multipeermap_get (friend_peermap, 4639 trail,
4557 &current_predecessor->finger_identity))) 4640 trail_length,
4558 { 4641 &trail_src_to_curr_pred_len);
4559 trail_to_predecessor = 4642
4560 trail_me_to_my_predecessor (trail,
4561 trail_length,
4562 &trail_to_predecessor_length);
4563 }
4564 } 4643 }
4565 else 4644 else
4566 { 4645 {
4567 trail_to_predecessor = GNUNET_new(struct GNUNET_PeerIdentity); 4646 trail_src_to_curr_pred = GNUNET_new(struct GNUNET_PeerIdentity);
4568 trail_to_predecessor = NULL; 4647 trail_src_to_curr_pred = NULL;
4569 trail_to_predecessor_length = 0; 4648 trail_src_to_curr_pred_len = 0;
4570 } 4649 }
4650
4571 GNUNET_assert (NULL != 4651 GNUNET_assert (NULL !=
4572 (target_friend = 4652 (target_friend =
4573 GNUNET_CONTAINER_multipeermap_get (friend_peermap, peer))); 4653 GNUNET_CONTAINER_multipeermap_get (friend_peermap, peer)));
4574 GDS_NEIGHBOURS_send_verify_successor_result (source_peer, my_identity, 4654 GDS_NEIGHBOURS_send_verify_successor_result (source_peer, my_identity,
4575 current_predecessor->finger_identity, 4655 current_predecessor->finger_identity,
4576 trail_id, trail_to_predecessor, 4656 trail_id, trail_src_to_curr_pred,
4577 trail_to_predecessor_length, 4657 trail_src_to_curr_pred_len,
4578 GDS_ROUTING_DEST_TO_SRC, 4658 GDS_ROUTING_DEST_TO_SRC,
4579 target_friend); 4659 target_friend);
4580 GNUNET_free_non_null (trail_to_predecessor); 4660
4581 return GNUNET_OK; 4661 return GNUNET_OK;
4582} 4662}
4583 4663
4584 4664
4585/** 4665/**
4586 * Construct the trail from me to probable successor that goes through current 4666 * If the trail from me to my probable successor contains a friend not
4587 * successor. Scan this trail to check if you can shortcut the trail somehow. 4667 * at index 0, then we can shorten the trail.
4588 * In case we can shortcut the trail, don't send trail compression as we don't 4668 * @param probable_successor Peer which is our probable successor
4589 * have any entry in routing table. 4669 * @param trail_me_to_probable_successor Peers in path from me to my probable
4590 * @param current_successor 4670 * successor, NOT including the endpoints.
4591 * @param probable_successor 4671 * @param trail_me_to_probable_successor_len Total number of peers in
4592 * @param trail_from_curr_to_probable_successor 4672 * @a trail_me_to_probable_succesor.
4593 * @param trail_from_curr_to_probable_successor_length 4673 * @return Updated trail, if any friend found.
4594 * @param trail_to_new_successor_length 4674 * Else the trail_me_to_probable_successor.
4595 * @return
4596 */ 4675 */
4597static struct GNUNET_PeerIdentity * 4676struct GNUNET_PeerIdentity *
4598get_trail_to_new_successor (struct FingerInfo *current_successor, 4677check_trail_me_to_probable_succ (struct GNUNET_PeerIdentity probable_successor,
4599 struct GNUNET_PeerIdentity probable_successor, 4678 const struct GNUNET_PeerIdentity *trail_me_to_probable_successor,
4600 const struct GNUNET_PeerIdentity *trail_from_curr_to_probable_successor, 4679 unsigned int trail_me_to_probable_successor_len,
4601 unsigned int trail_from_curr_to_probable_successor_length, 4680 unsigned int *trail_to_new_successor_length)
4602 unsigned int *trail_to_new_successor_length)
4603{ 4681{
4682 unsigned int i;
4683 unsigned int j;
4604 struct GNUNET_PeerIdentity *trail_to_new_successor; 4684 struct GNUNET_PeerIdentity *trail_to_new_successor;
4605 unsigned int shortest_trail_length = 0;
4606 unsigned int flag = 0;
4607 unsigned int shortest_trail_index = 0;
4608 struct Trail *trail;
4609 struct Trail_Element *trail_element;
4610 int i;
4611 4685
4612 /* If the probable successor is a friend, then we don't need to have a trail 4686 /* Probable successor is a friend */
4613 * to reach to it.*/
4614 if (NULL != GNUNET_CONTAINER_multipeermap_get (friend_peermap, 4687 if (NULL != GNUNET_CONTAINER_multipeermap_get (friend_peermap,
4615 &probable_successor)) 4688 &probable_successor))
4616 { 4689 {
@@ -4619,155 +4692,112 @@ get_trail_to_new_successor (struct FingerInfo *current_successor,
4619 return trail_to_new_successor; 4692 return trail_to_new_successor;
4620 } 4693 }
4621 4694
4622 /* 4695 /* Is there any friend of yours in this trail. */
4623 * FIXME: can we some how use the select_finger_trail here?? 4696 for (i = trail_me_to_probable_successor_len - 1; i > 0; i--)
4624 * complete this logic.
4625 * 1. Choose the shortest trail to reach to current successor.
4626 * 2. append the trail with the current trail
4627 * 3. scan the trail for duplicate elements
4628 * 4. scan the trail for friend
4629 * 5. get the shortest trail.
4630 * 6. send back the trail.
4631 */
4632
4633
4634 /* Choose the shortest trail to reach the current_successor */
4635 for (i = 0; i < current_successor->trails_count; i++)
4636 { 4697 {
4637 trail = &current_successor->trail_list[i]; 4698 if (NULL == GNUNET_CONTAINER_multipeermap_get (friend_peermap,
4638 if (0 == flag) 4699 &trail_me_to_probable_successor[i]))
4639 {
4640 shortest_trail_index = i;
4641 shortest_trail_length = trail->trail_length;
4642 flag = 1;
4643 continue; 4700 continue;
4644 }
4645 4701
4646 if (shortest_trail_length > trail->trail_length) 4702 j = 0;
4647 { 4703 *trail_to_new_successor_length = (trail_me_to_probable_successor_len - i);
4648 shortest_trail_index = i; 4704 trail_to_new_successor = GNUNET_malloc (sizeof(struct GNUNET_PeerIdentity)*
4649 shortest_trail_length = trail->trail_length; 4705 *trail_to_new_successor_length);
4650 }
4651 continue;
4652 }
4653
4654 /* It means that probable successor is the friend of current successor. */
4655 if (0 == trail_from_curr_to_probable_successor_length)
4656 {
4657 *trail_to_new_successor_length = shortest_trail_length + 1;
4658 trail_to_new_successor = GNUNET_malloc (sizeof(struct GNUNET_PeerIdentity) *
4659 (*trail_to_new_successor_length));
4660 /* Copy the selected trail and send this trail to calling function. */
4661 i = 0;
4662 trail = &current_successor->trail_list[shortest_trail_index];
4663 trail_element = trail->trail_head;
4664 while ( i < shortest_trail_length)
4665 {
4666 trail_to_new_successor[i] = trail_element->peer;
4667 i++;
4668 trail_element = trail_element->next;
4669 }
4670 4706
4671 trail_to_new_successor[i] = current_successor->finger_identity; 4707 for(j = 0;i < trail_me_to_probable_successor_len;i++,j++)
4672 }
4673 else
4674 {
4675 *trail_to_new_successor_length = shortest_trail_length +
4676 trail_from_curr_to_probable_successor_length;
4677 trail_to_new_successor = GNUNET_malloc (sizeof(struct GNUNET_PeerIdentity) *
4678 (*trail_to_new_successor_length));
4679 /* Copy the selected trail and send this trail to calling function. */
4680 i = 0;
4681 trail = &current_successor->trail_list[shortest_trail_index];
4682 trail_element = trail->trail_head;
4683 while ( i < shortest_trail_length)
4684 { 4708 {
4685 trail_to_new_successor[i] = trail_element->peer; 4709 trail_to_new_successor[j] = trail_me_to_probable_successor[i];
4686 i++;
4687 trail_element = trail_element->next;
4688 }
4689
4690 int j = 0;
4691 while (j < trail_from_curr_to_probable_successor_length)
4692 {
4693 trail_to_new_successor[i] = trail_from_curr_to_probable_successor[j];
4694 i++;
4695 j++;
4696 } 4710 }
4711
4712 return trail_to_new_successor;
4697 } 4713 }
4714
4715
4716 trail_to_new_successor = GNUNET_malloc (sizeof (struct GNUNET_PeerIdentity)*
4717 trail_me_to_probable_successor_len);
4718
4719 for(i = 0; i < trail_me_to_probable_successor_len; i++)
4720 trail_to_new_successor[i] = trail_me_to_probable_successor[i];
4721
4698 return trail_to_new_successor; 4722 return trail_to_new_successor;
4699} 4723}
4700 4724
4701 4725
4702/** 4726/**
4703 * Compare probable successor and current successor. 4727 *
4704 * If the probable successor is the correct successor, then construct the trail 4728 * @param curr_succ
4705 * from me to probable successor that goes through current successor. Scan this 4729 * @param probable_successor
4706 * trail to check if you can shortcut the trail somehow. In case we can short 4730 * @param trail
4707 * cut the trail, don't send trail compression as we don't have any entry in 4731 * @param trail_length
4708 * routing table.
4709 * Once you have scanned trail, then add an entry in finger table.
4710 * Add an entry in routing table (Only if new successor is NOT a friend).
4711 * @param probable_successor Peer which could be our successor
4712 * @param trail_from_curr_to_probable_successor Trail from current successor
4713 * to probable successor, NOT
4714 * including them.
4715 * @param trail_from_curr_to_probable_successor_length Total number of peers
4716 * in @a trail_from_curr_to_probable_successor
4717 */ 4732 */
4718static void 4733static void
4719compare_and_update_successor (struct GNUNET_PeerIdentity probable_successor, 4734compare_and_update_successor (struct GNUNET_PeerIdentity curr_succ,
4720 const struct GNUNET_PeerIdentity *trail_from_curr_to_probable_successor, 4735 struct GNUNET_PeerIdentity probable_successor,
4721 unsigned int trail_from_curr_to_probable_successor_length) 4736 const struct GNUNET_PeerIdentity *trail,
4737 unsigned int trail_length)
4722{ 4738{
4739 struct FingerInfo *current_successor;
4723 struct GNUNET_PeerIdentity *closest_peer; 4740 struct GNUNET_PeerIdentity *closest_peer;
4724 struct GNUNET_PeerIdentity *trail_to_new_successor;
4725 struct GNUNET_HashCode trail_id; 4741 struct GNUNET_HashCode trail_id;
4726 unsigned int trail_to_new_successor_length; 4742 struct GNUNET_PeerIdentity *trail_me_to_probable_succ;
4727 uint64_t successor_value;
4728 struct FingerInfo *current_successor;
4729 struct FriendInfo *target_friend; 4743 struct FriendInfo *target_friend;
4730 unsigned int is_predecessor = 0; 4744 unsigned int trail_me_to_probable_succ_len;
4731 //test_finger_table_print(); 4745 unsigned int is_predecessor = GNUNET_NO;
4746 uint64_t successor_value;
4747
4732 current_successor = &finger_table[0]; 4748 current_successor = &finger_table[0];
4733 GNUNET_assert (GNUNET_YES == current_successor->is_present); 4749 successor_value = compute_finger_identity_value(0);
4734 4750
4735 /* Compute the 64 bit value of successor identity. We need this as we need to 4751 /* Have we found some other successor, while waiting for verify successor result. */
4736 * find the closest peer w.r.t this value.*/ 4752 if(0 != GNUNET_CRYPTO_cmp_peer_identity(&curr_succ, &current_successor->finger_identity))
4737 successor_value = compute_finger_identity_value (0); 4753 {
4738 closest_peer = select_closest_peer (&current_successor->finger_identity, 4754 /* We could have added this new successor, only if it was closer the old one. */
4739 &probable_successor, 4755 closest_peer = select_closest_peer (&curr_succ,
4756 &current_successor->finger_identity,
4757 successor_value, is_predecessor);
4758
4759 /* FIXME: it may fail in case we have done more number of iterations of
4760 find _finger_trail_task. */
4761 GNUNET_assert (0 ==
4762 GNUNET_CRYPTO_cmp_peer_identity (closest_peer,
4763 &current_successor->finger_identity));
4764
4765 }
4766
4767 closest_peer = select_closest_peer (&probable_successor,
4768 &current_successor->finger_identity,
4740 successor_value, is_predecessor); 4769 successor_value, is_predecessor);
4741 4770
4742 /* If the current_successor is the closest one, then exit. */ 4771 /* If the current_successor in the finger table is closest, then do nothing. */
4743 if (0 == GNUNET_CRYPTO_cmp_peer_identity (closest_peer, 4772 if (0 == GNUNET_CRYPTO_cmp_peer_identity (closest_peer,
4744 &current_successor->finger_identity)) 4773 &current_successor->finger_identity))
4745 return; 4774 return;
4746 4775
4747 /* probable successor is the closest_peer. */ 4776 /* Probable successor is the closest peer.*/
4777
4778 GNUNET_assert(NULL != GNUNET_CONTAINER_multipeermap_get (friend_peermap,
4779 &trail[0]));
4780
4781 /* TODO: Check if the path to reach to probable successor contains a friend. */
4782 trail_me_to_probable_succ =
4783 check_trail_me_to_probable_succ (probable_successor,
4784 trail, trail_length,
4785 &trail_me_to_probable_succ_len);
4748 4786
4749 /* Get the trail to reach to your new successor. */
4750 trail_to_new_successor = get_trail_to_new_successor (current_successor,
4751 probable_successor,
4752 trail_from_curr_to_probable_successor,
4753 trail_from_curr_to_probable_successor_length,
4754 &trail_to_new_successor_length);
4755 /* Remove the existing successor. */ 4787 /* Remove the existing successor. */
4756 remove_existing_finger (current_successor, 0); 4788 remove_existing_finger (current_successor, 0);
4757 4789
4758 /* Generate a new trail id to reach to your new successor. */ 4790 /* Generate a new trail id to reach to your new successor. */
4759 GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG, 4791 GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG,
4760 &trail_id, sizeof (trail_id)); 4792 &trail_id, sizeof (trail_id));
4761 add_new_finger (probable_successor, trail_to_new_successor,
4762 trail_to_new_successor_length, trail_id, 0);
4763 4793
4764 4794 if (trail_me_to_probable_succ_len > 0)
4765 if (trail_to_new_successor_length > 0)
4766 { 4795 {
4767 GDS_ROUTING_add (trail_id, my_identity, trail_to_new_successor[0]); 4796 GDS_ROUTING_add (trail_id, my_identity, trail_me_to_probable_succ[0]);
4768 GNUNET_assert (NULL != 4797 GNUNET_assert (NULL !=
4769 (target_friend = GNUNET_CONTAINER_multipeermap_get (friend_peermap, 4798 (target_friend =
4770 &trail_to_new_successor[0]))); 4799 GNUNET_CONTAINER_multipeermap_get (friend_peermap,
4800 &trail_me_to_probable_succ[0])));
4771 } 4801 }
4772 else 4802 else
4773 { 4803 {
@@ -4778,9 +4808,12 @@ compare_and_update_successor (struct GNUNET_PeerIdentity probable_successor,
4778 &probable_successor))); 4808 &probable_successor)));
4779 } 4809 }
4780 4810
4811 add_new_finger (probable_successor, trail_me_to_probable_succ,
4812 trail_me_to_probable_succ_len, trail_id, 0);
4813
4781 GDS_NEIGHBOURS_send_notify_new_successor (my_identity, probable_successor, 4814 GDS_NEIGHBOURS_send_notify_new_successor (my_identity, probable_successor,
4782 trail_from_curr_to_probable_successor, 4815 trail_me_to_probable_succ,
4783 trail_from_curr_to_probable_successor_length, 4816 trail_me_to_probable_succ_len,
4784 trail_id, 4817 trail_id,
4785 target_friend); 4818 target_friend);
4786 return; 4819 return;
@@ -4806,6 +4839,7 @@ handle_dht_p2p_verify_successor_result(void *cls,
4806 struct GNUNET_PeerIdentity *next_hop; 4839 struct GNUNET_PeerIdentity *next_hop;
4807 struct FriendInfo *target_friend; 4840 struct FriendInfo *target_friend;
4808 struct GNUNET_PeerIdentity probable_successor; 4841 struct GNUNET_PeerIdentity probable_successor;
4842 struct GNUNET_PeerIdentity current_successor;
4809 const struct GNUNET_PeerIdentity *trail; 4843 const struct GNUNET_PeerIdentity *trail;
4810 unsigned int trail_length; 4844 unsigned int trail_length;
4811 size_t msize; 4845 size_t msize;
@@ -4835,13 +4869,14 @@ handle_dht_p2p_verify_successor_result(void *cls,
4835 trail_direction = ntohl (vsrm->trail_direction); 4869 trail_direction = ntohl (vsrm->trail_direction);
4836 trail_id = vsrm->trail_id; 4870 trail_id = vsrm->trail_id;
4837 probable_successor = vsrm->probable_successor; 4871 probable_successor = vsrm->probable_successor;
4872 current_successor = vsrm->current_successor;
4873
4838 4874
4839 //FIXME: add a check to ensure that peer from which you got the message is
4840 //the correct peer.
4841 /* I am the querying_peer. */ 4875 /* I am the querying_peer. */
4842 if(0 == (GNUNET_CRYPTO_cmp_peer_identity (&querying_peer, &my_identity))) 4876 if(0 == (GNUNET_CRYPTO_cmp_peer_identity (&querying_peer, &my_identity)))
4843 { 4877 {
4844 compare_and_update_successor (probable_successor, trail, trail_length); 4878 compare_and_update_successor (current_successor,
4879 probable_successor, trail, trail_length);
4845 return GNUNET_OK; 4880 return GNUNET_OK;
4846 } 4881 }
4847 4882
@@ -4885,6 +4920,7 @@ handle_dht_p2p_notify_new_successor(void *cls,
4885 uint32_t trail_length; 4920 uint32_t trail_length;
4886 4921
4887 msize = ntohs (message->size); 4922 msize = ntohs (message->size);
4923
4888 /* We have the trail to reach from source to new successor. */ 4924 /* We have the trail to reach from source to new successor. */
4889 if (msize < sizeof (struct PeerNotifyNewSuccessorMessage)) 4925 if (msize < sizeof (struct PeerNotifyNewSuccessorMessage))
4890 { 4926 {
@@ -4895,7 +4931,7 @@ handle_dht_p2p_notify_new_successor(void *cls,
4895 nsm = (const struct PeerNotifyNewSuccessorMessage *) message; 4931 nsm = (const struct PeerNotifyNewSuccessorMessage *) message;
4896 trail_length = (msize - sizeof (struct PeerNotifyNewSuccessorMessage))/ 4932 trail_length = (msize - sizeof (struct PeerNotifyNewSuccessorMessage))/
4897 sizeof (struct GNUNET_PeerIdentity); 4933 sizeof (struct GNUNET_PeerIdentity);
4898 if ((msize - sizeof (struct PeerTrailRejectionMessage)) % 4934 if ((msize - sizeof (struct PeerNotifyNewSuccessorMessage)) %
4899 sizeof (struct GNUNET_PeerIdentity) != 0) 4935 sizeof (struct GNUNET_PeerIdentity) != 0)
4900 { 4936 {
4901 GNUNET_break_op (0); 4937 GNUNET_break_op (0);
@@ -4906,7 +4942,7 @@ handle_dht_p2p_notify_new_successor(void *cls,
4906 source = nsm->source_peer; 4942 source = nsm->source_peer;
4907 new_successor = nsm->new_successor; 4943 new_successor = nsm->new_successor;
4908 trail_id = nsm->trail_id; 4944 trail_id = nsm->trail_id;
4909 4945
4910 //FIXME: add a check to make sure peer is correct. 4946 //FIXME: add a check to make sure peer is correct.
4911 4947
4912 /* I am the new_successor to source_peer. */ 4948 /* I am the new_successor to source_peer. */
@@ -4917,23 +4953,27 @@ handle_dht_p2p_notify_new_successor(void *cls,
4917 return GNUNET_OK; 4953 return GNUNET_OK;
4918 } 4954 }
4919 4955
4956 GNUNET_assert(trail_length > 0);
4920 /* I am part of trail to reach to successor. */ 4957 /* I am part of trail to reach to successor. */
4921 my_index = search_my_index (trail, trail_length); 4958 my_index = search_my_index (trail, trail_length);
4922 if (-1 == my_index) 4959 if (-1 == my_index)
4923 { 4960 {
4924 GNUNET_break_op (0); 4961 GNUNET_break_op (0);
4925 return GNUNET_SYSERR; 4962 return GNUNET_SYSERR;
4926 } 4963 }
4964
4927 if ((trail_length-1) == my_index) //FIXMe: SHOULD IT BE TRAIL_LENGTH - 1.s 4965 if ((trail_length-1) == my_index) //FIXMe: SHOULD IT BE TRAIL_LENGTH - 1.s
4928 next_hop = new_successor; 4966 next_hop = new_successor;
4929 else 4967 else
4930 next_hop = trail[my_index + 1]; 4968 next_hop = trail[my_index + 1];
4931 4969
4970
4932 /* Add an entry in routing table for trail from source to its new successor. */ 4971 /* Add an entry in routing table for trail from source to its new successor. */
4933 GNUNET_assert (GNUNET_OK == GDS_ROUTING_add (trail_id, *peer, next_hop)); 4972 GNUNET_assert (GNUNET_OK == GDS_ROUTING_add (trail_id, *peer, next_hop));
4973
4934 GNUNET_assert (NULL != 4974 GNUNET_assert (NULL !=
4935 (target_friend = 4975 (target_friend =
4936 GNUNET_CONTAINER_multipeermap_get (friend_peermap, &next_hop))); 4976 GNUNET_CONTAINER_multipeermap_get (friend_peermap, &next_hop)));
4937 GDS_NEIGHBOURS_send_notify_new_successor (source, new_successor, trail, 4977 GDS_NEIGHBOURS_send_notify_new_successor (source, new_successor, trail,
4938 trail_length, 4978 trail_length,
4939 trail_id, target_friend); 4979 trail_id, target_friend);
@@ -5038,13 +5078,13 @@ handle_dht_p2p_trail_setup_rejection (void *cls,
5038 my_identity, is_predecessor, 5078 my_identity, is_predecessor,
5039 new_trail,new_trail_length,trail_id, 5079 new_trail,new_trail_length,trail_id,
5040 target_friend, CONGESTION_TIMEOUT); 5080 target_friend, CONGESTION_TIMEOUT);
5041
5042 GNUNET_free (new_trail); 5081 GNUNET_free (new_trail);
5043 return GNUNET_OK; 5082 return GNUNET_OK;
5044 } 5083 }
5045 5084
5046 struct Closest_Peer successor; 5085 struct Closest_Peer successor;
5047 successor = find_successor (ultimate_destination_finger_value, is_predecessor); 5086 successor = find_successor (ultimate_destination_finger_value, is_predecessor);
5087
5048 /* Am I the final destination? */ 5088 /* Am I the final destination? */
5049 if (0 == (GNUNET_CRYPTO_cmp_peer_identity (&successor.best_known_destination, 5089 if (0 == (GNUNET_CRYPTO_cmp_peer_identity (&successor.best_known_destination,
5050 &my_identity))) 5090 &my_identity)))
@@ -5133,8 +5173,7 @@ handle_dht_p2p_trail_compression (void *cls, const struct GNUNET_PeerIdentity *p
5133 5173
5134 /* Pass the message to next hop to finally reach to new_first_friend. */ 5174 /* Pass the message to next hop to finally reach to new_first_friend. */
5135 next_hop = GDS_ROUTING_get_next_hop (trail_id, GDS_ROUTING_SRC_TO_DEST); 5175 next_hop = GDS_ROUTING_get_next_hop (trail_id, GDS_ROUTING_SRC_TO_DEST);
5136 GDS_ROUTING_test_print(); 5176
5137
5138 if (NULL == next_hop) 5177 if (NULL == next_hop)
5139 { 5178 {
5140 GNUNET_break (0); 5179 GNUNET_break (0);
@@ -5510,7 +5549,7 @@ handle_core_disconnect (void *cls,
5510 5549
5511 if (0 != GNUNET_CONTAINER_multipeermap_size (friend_peermap)) 5550 if (0 != GNUNET_CONTAINER_multipeermap_size (friend_peermap))
5512 return; 5551 return;
5513 5552
5514 if (GNUNET_SCHEDULER_NO_TASK != find_finger_trail_task) 5553 if (GNUNET_SCHEDULER_NO_TASK != find_finger_trail_task)
5515 { 5554 {
5516 GNUNET_SCHEDULER_cancel (find_finger_trail_task); 5555 GNUNET_SCHEDULER_cancel (find_finger_trail_task);
@@ -5560,7 +5599,7 @@ handle_core_connect (void *cls, const struct GNUNET_PeerIdentity *peer_identity)
5560 5599
5561 5600
5562 /* got a first connection, good time to start with FIND FINGER TRAIL requests...*/ 5601 /* got a first connection, good time to start with FIND FINGER TRAIL requests...*/
5563 if (GNUNET_SCHEDULER_NO_TASK == find_finger_trail_task) 5602 if (GNUNET_SCHEDULER_NO_TASK == find_finger_trail_task)
5564 find_finger_trail_task = GNUNET_SCHEDULER_add_now (&send_find_finger_trail_message, NULL); 5603 find_finger_trail_task = GNUNET_SCHEDULER_add_now (&send_find_finger_trail_message, NULL);
5565} 5604}
5566 5605
@@ -5582,6 +5621,7 @@ core_init (void *cls,
5582 my_id64 = GNUNET_ntohll (my_id64); 5621 my_id64 = GNUNET_ntohll (my_id64);
5583 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 5622 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
5584 "my_indentity = %s, my_id64=%llu\n",GNUNET_i2s(&my_identity),(unsigned long long)my_id64); 5623 "my_indentity = %s, my_id64=%llu\n",GNUNET_i2s(&my_identity),(unsigned long long)my_id64);
5624
5585} 5625}
5586 5626
5587 5627
@@ -5665,6 +5705,12 @@ GDS_NEIGHBOURS_done (void)
5665 GNUNET_SCHEDULER_cancel (find_finger_trail_task); 5705 GNUNET_SCHEDULER_cancel (find_finger_trail_task);
5666 find_finger_trail_task = GNUNET_SCHEDULER_NO_TASK; 5706 find_finger_trail_task = GNUNET_SCHEDULER_NO_TASK;
5667 } 5707 }
5708
5709 if (GNUNET_SCHEDULER_NO_TASK != send_verify_successor_task)
5710 {
5711 GNUNET_SCHEDULER_cancel (send_verify_successor_task);
5712 send_verify_successor_task = GNUNET_SCHEDULER_NO_TASK;
5713 }
5668} 5714}
5669 5715
5670 5716
diff --git a/src/dht/gnunet-service-xdht_routing.c b/src/dht/gnunet-service-xdht_routing.c
index a8fd1b4ed..eaaa606bb 100644
--- a/src/dht/gnunet-service-xdht_routing.c
+++ b/src/dht/gnunet-service-xdht_routing.c
@@ -45,7 +45,7 @@
45/** 45/**
46 * Maximum number of entries in routing table. 46 * Maximum number of entries in routing table.
47 */ 47 */
48#define ROUTING_TABLE_THRESHOLD 64 48#define ROUTING_TABLE_THRESHOLD 1000
49 49
50/** 50/**
51 * FIXME: Store friend pointer instead of peer identifier. 51 * FIXME: Store friend pointer instead of peer identifier.
@@ -237,7 +237,7 @@ static int remove_matching_trails (void *cls,
237 return GNUNET_YES; 237 return GNUNET_YES;
238} 238}
239 239
240 240#if 0
241/** 241/**
242 * TEST FUNCTION 242 * TEST FUNCTION
243 * Remove after using. 243 * Remove after using.
@@ -270,7 +270,7 @@ GDS_ROUTING_test_print (void)
270 } 270 }
271 } 271 }
272} 272}
273 273#endif
274 274
275/** 275/**
276 * Remove every trail where peer is either next_hop or prev_hop. Also send a 276 * Remove every trail where peer is either next_hop or prev_hop. Also send a
@@ -309,15 +309,19 @@ GDS_ROUTING_add (struct GNUNET_HashCode new_trail_id,
309 struct GNUNET_PeerIdentity next_hop) 309 struct GNUNET_PeerIdentity next_hop)
310{ 310{
311 struct RoutingTrail *new_entry; 311 struct RoutingTrail *new_entry;
312 312 int ret;
313
313 new_entry = GNUNET_new (struct RoutingTrail); 314 new_entry = GNUNET_new (struct RoutingTrail);
314 new_entry->trail_id = new_trail_id; 315 new_entry->trail_id = new_trail_id;
315 new_entry->next_hop = next_hop; 316 new_entry->next_hop = next_hop;
316 new_entry->prev_hop = prev_hop; 317 new_entry->prev_hop = prev_hop;
317 318
318 return GNUNET_CONTAINER_multihashmap_put (routing_table, 319
320 ret = GNUNET_CONTAINER_multihashmap_put (routing_table,
319 &new_trail_id, new_entry, 321 &new_trail_id, new_entry,
320 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); 322 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
323 //GNUNET_assert(ret == GNUNET_OK);
324 return ret;
321} 325}
322 326
323 327
diff --git a/src/dht/gnunet-service-xdht_routing.h b/src/dht/gnunet-service-xdht_routing.h
index 73d493046..d909ea813 100644
--- a/src/dht/gnunet-service-xdht_routing.h
+++ b/src/dht/gnunet-service-xdht_routing.h
@@ -115,13 +115,13 @@ GDS_ROUTING_add (struct GNUNET_HashCode new_trail_id,
115int 115int
116GDS_ROUTING_threshold_reached (void); 116GDS_ROUTING_threshold_reached (void);
117 117
118#if 0
118/** 119/**
119 * Test function. Remove afterwards. 120 * Test function. Remove afterwards.
120 */ 121 */
121void 122void
122GDS_ROUTING_test_print (void); 123GDS_ROUTING_test_print (void);
123 124#endif
124
125 125
126/** 126/**
127 * Initialize routing subsystem. 127 * Initialize routing subsystem.
diff --git a/src/dht/gnunet_dht_profiler.c b/src/dht/gnunet_dht_profiler.c
index 97af79b1a..d72c3875f 100644
--- a/src/dht/gnunet_dht_profiler.c
+++ b/src/dht/gnunet_dht_profiler.c
@@ -38,7 +38,7 @@
38/** 38/**
39 * Number of peers which should perform a PUT out of 100 peers 39 * Number of peers which should perform a PUT out of 100 peers
40 */ 40 */
41#define PUT_PROBABILITY 50 41#define PUT_PROBABILITY 100
42 42
43/** 43/**
44 * Configuration 44 * Configuration