diff options
author | Bart Polot <bart@net.in.tum.de> | 2011-11-28 17:51:36 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2011-11-28 17:51:36 +0000 |
commit | 9f1e7420469ff9cc79c5097a76a0625a9345f18e (patch) | |
tree | 9dc3be65978f671e2a350662b156152ea225373d | |
parent | a8fd51eade6a83e71660c533890d33fbdcd2b1b0 (diff) | |
download | gnunet-9f1e7420469ff9cc79c5097a76a0625a9345f18e.tar.gz gnunet-9f1e7420469ff9cc79c5097a76a0625a9345f18e.zip |
Mesh adds info about paths to peers as early as possible to avoid unoptimal routes and artifacts caused by parallel path creation of less optimal paths (loops, path corruption, etc)
-rw-r--r-- | src/mesh/gnunet-service-mesh.c | 47 |
1 files changed, 32 insertions, 15 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c index ff58bf824..ce90b224c 100644 --- a/src/mesh/gnunet-service-mesh.c +++ b/src/mesh/gnunet-service-mesh.c | |||
@@ -1698,6 +1698,32 @@ path_build_from_dht (const struct GNUNET_PeerIdentity *get_path, | |||
1698 | 1698 | ||
1699 | 1699 | ||
1700 | /** | 1700 | /** |
1701 | * Adds a path to the peer_infos of all the peers in the path | ||
1702 | * | ||
1703 | * @param p Path to process. | ||
1704 | * @param confirmed Whether we know if the path works or not. FIXME use | ||
1705 | */ | ||
1706 | static void | ||
1707 | path_add_to_peers (struct MeshPeerPath *p, int confirmed) | ||
1708 | { | ||
1709 | unsigned int i; | ||
1710 | |||
1711 | /* TODO: invert and add */ | ||
1712 | for (i = 1; i < p->length && p->peers[i] != myid; i++) /* skip'em */; | ||
1713 | for (i++; i < p->length; i++) | ||
1714 | { | ||
1715 | struct MeshPeerInfo *aux; | ||
1716 | struct MeshPeerPath *copy; | ||
1717 | |||
1718 | aux = peer_info_get_short(p->peers[i]); | ||
1719 | copy = path_duplicate(p); | ||
1720 | copy->length = i; | ||
1721 | peer_info_add_path(aux, copy, GNUNET_NO); | ||
1722 | } | ||
1723 | } | ||
1724 | |||
1725 | |||
1726 | /** | ||
1701 | * Send keepalive packets for a peer | 1727 | * Send keepalive packets for a peer |
1702 | * | 1728 | * |
1703 | * @param cls Closure (tunnel for which to send the keepalive). | 1729 | * @param cls Closure (tunnel for which to send the keepalive). |
@@ -2575,6 +2601,7 @@ handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
2575 | /* FIXME error. destroy tunnel? leave for timeout? */ | 2601 | /* FIXME error. destroy tunnel? leave for timeout? */ |
2576 | return 0; | 2602 | return 0; |
2577 | } | 2603 | } |
2604 | path_add_to_peers(path, GNUNET_NO); | ||
2578 | tunnel_add_path (t, path, own_pos); | 2605 | tunnel_add_path (t, path, own_pos); |
2579 | if (own_pos == size - 1) | 2606 | if (own_pos == size - 1) |
2580 | { | 2607 | { |
@@ -3056,7 +3083,6 @@ handle_mesh_path_ack (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
3056 | struct MeshPeerInfo *peer_info; | 3083 | struct MeshPeerInfo *peer_info; |
3057 | struct MeshPeerPath *p; | 3084 | struct MeshPeerPath *p; |
3058 | struct MeshTunnel *t; | 3085 | struct MeshTunnel *t; |
3059 | unsigned int i; | ||
3060 | 3086 | ||
3061 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: Received a path ACK msg [%s]\n", | 3087 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MESH: Received a path ACK msg [%s]\n", |
3062 | GNUNET_i2s (&my_full_id)); | 3088 | GNUNET_i2s (&my_full_id)); |
@@ -3068,22 +3094,13 @@ handle_mesh_path_ack (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
3068 | return GNUNET_OK; | 3094 | return GNUNET_OK; |
3069 | } | 3095 | } |
3070 | 3096 | ||
3071 | /* Add paths to peers */ | ||
3072 | peer_info = peer_info_get (&msg->peer_id); | 3097 | peer_info = peer_info_get (&msg->peer_id); |
3098 | |||
3099 | /* Add paths to peers? */ | ||
3073 | p = tree_get_path_to_peer(t->tree, peer_info->id); | 3100 | p = tree_get_path_to_peer(t->tree, peer_info->id); |
3074 | if (NULL != p) | 3101 | if (NULL != p) |
3075 | { | 3102 | { |
3076 | for (i = 1; i < p->length && p->peers[i] != myid; i++) /* skip'em */; | 3103 | path_add_to_peers (p, GNUNET_YES); |
3077 | for (i++; i < p->length; i++) | ||
3078 | { | ||
3079 | struct MeshPeerInfo *aux; | ||
3080 | struct MeshPeerPath *copy; | ||
3081 | |||
3082 | aux = peer_info_get_short(p->peers[i]); | ||
3083 | copy = path_duplicate(p); | ||
3084 | copy->length = i; | ||
3085 | peer_info_add_path(aux, copy, 0); | ||
3086 | } | ||
3087 | path_destroy(p); | 3104 | path_destroy(p); |
3088 | } | 3105 | } |
3089 | else | 3106 | else |
@@ -3291,7 +3308,7 @@ dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp, | |||
3291 | 3308 | ||
3292 | p = path_build_from_dht (get_path, get_path_length, put_path, | 3309 | p = path_build_from_dht (get_path, get_path_length, put_path, |
3293 | put_path_length); | 3310 | put_path_length); |
3294 | peer_info_add_path (path_info->peer, p, GNUNET_NO); | 3311 | path_add_to_peers(p, GNUNET_NO); |
3295 | for (i = 0; i < path_info->peer->ntunnels; i++) | 3312 | for (i = 0; i < path_info->peer->ntunnels; i++) |
3296 | { | 3313 | { |
3297 | tunnel_add_peer (path_info->peer->tunnels[i], path_info->peer); | 3314 | tunnel_add_peer (path_info->peer->tunnels[i], path_info->peer); |
@@ -3345,7 +3362,7 @@ dht_get_type_handler (void *cls, struct GNUNET_TIME_Absolute exp, | |||
3345 | 3362 | ||
3346 | p = path_build_from_dht (get_path, get_path_length, put_path, | 3363 | p = path_build_from_dht (get_path, get_path_length, put_path, |
3347 | put_path_length); | 3364 | put_path_length); |
3348 | peer_info_add_path (peer_info, p, GNUNET_NO); | 3365 | path_add_to_peers(p, GNUNET_NO); |
3349 | tunnel_add_peer (t, peer_info); | 3366 | tunnel_add_peer (t, peer_info); |
3350 | peer_info_connect (peer_info, t); | 3367 | peer_info_connect (peer_info, t); |
3351 | } | 3368 | } |