aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2013-12-16 11:55:37 +0000
committerBart Polot <bart@net.in.tum.de>2013-12-16 11:55:37 +0000
commit3433da9486f4f6064a85fcb7c63e482ec60c8609 (patch)
tree2b816d9356f937ec96335ed80a8f5ef721c2ea45
parentc751c30da5392f186d8fd3d5999b1fe0fae06b46 (diff)
downloadgnunet-3433da9486f4f6064a85fcb7c63e482ec60c8609.tar.gz
gnunet-3433da9486f4f6064a85fcb7c63e482ec60c8609.zip
- don't loop on the same invalid path
-rw-r--r--src/mesh/gnunet-service-mesh_connection.c10
-rw-r--r--src/mesh/gnunet-service-mesh_peer.c26
-rw-r--r--src/mesh/gnunet-service-mesh_peer.h9
-rw-r--r--src/mesh/gnunet-service-mesh_tunnel.c13
-rw-r--r--src/mesh/gnunet-service-mesh_tunnel.h9
5 files changed, 65 insertions, 2 deletions
diff --git a/src/mesh/gnunet-service-mesh_connection.c b/src/mesh/gnunet-service-mesh_connection.c
index 85a10bcfe..8ae297f63 100644
--- a/src/mesh/gnunet-service-mesh_connection.c
+++ b/src/mesh/gnunet-service-mesh_connection.c
@@ -179,7 +179,8 @@ struct MeshConnection
179 enum MeshConnectionState state; 179 enum MeshConnectionState state;
180 180
181 /** 181 /**
182 * Path being used for the tunnel. 182 * Path being used for the tunnel. At the origin of the connection
183 * it's a pointer to the destination's path pool, otherwise just a copy.
183 */ 184 */
184 struct MeshPeerPath *path; 185 struct MeshPeerPath *path;
185 186
@@ -1149,7 +1150,7 @@ register_neighbors (struct MeshConnection *c)
1149 || GNUNET_NO == GMP_is_neighbor (prev_peer)) 1150 || GNUNET_NO == GMP_is_neighbor (prev_peer))
1150 { 1151 {
1151 if (GMC_is_origin (c, GNUNET_YES)) 1152 if (GMC_is_origin (c, GNUNET_YES))
1152 GNUNET_STATISTICS_update (stats, "# local bad paths", 1, GNUNET_NO); 1153 GNUNET_STATISTICS_update (stats, "# local bad paths", 1, GNUNET_NO);
1153 GNUNET_STATISTICS_update (stats, "# bad paths", 1, GNUNET_NO); 1154 GNUNET_STATISTICS_update (stats, "# bad paths", 1, GNUNET_NO);
1154 1155
1155 LOG (GNUNET_ERROR_TYPE_DEBUG, " register neighbors failed\n"); 1156 LOG (GNUNET_ERROR_TYPE_DEBUG, " register neighbors failed\n");
@@ -2220,6 +2221,11 @@ GMC_new (const struct GNUNET_HashCode *cid,
2220 2221
2221 if (GNUNET_OK != register_neighbors (c)) 2222 if (GNUNET_OK != register_neighbors (c))
2222 { 2223 {
2224 if (0 == own_pos)
2225 {
2226 GMT_remove_path (c->t, p);
2227 path_destroy (p);
2228 }
2223 GMC_destroy (c); 2229 GMC_destroy (c);
2224 return NULL; 2230 return NULL;
2225 } 2231 }
diff --git a/src/mesh/gnunet-service-mesh_peer.c b/src/mesh/gnunet-service-mesh_peer.c
index 30c64377f..2adc9483b 100644
--- a/src/mesh/gnunet-service-mesh_peer.c
+++ b/src/mesh/gnunet-service-mesh_peer.c
@@ -1595,6 +1595,32 @@ GMP_add_path_to_all (const struct MeshPeerPath *p, int confirmed)
1595 1595
1596 1596
1597/** 1597/**
1598 * Remove any path to the peer that has the extact same peers as the one given.
1599 *
1600 * @param peer Peer to remove the path from.
1601 * @param path Path to remove.
1602 */
1603void
1604GMP_remove_path (struct MeshPeer *peer, struct MeshPeerPath *path)
1605{
1606 struct MeshPeerPath *iter;
1607 struct MeshPeerPath *next;
1608
1609 GNUNET_assert (myid == path->peers[path->length - 1]);
1610
1611 for (iter = peer->path_head; NULL != iter; iter = next)
1612 {
1613 next = iter->next;
1614 if (0 == memcmp (path->peers, iter->peers,
1615 sizeof (GNUNET_PEER_Id) * path->length))
1616 {
1617 path_destroy (iter);
1618 }
1619 }
1620}
1621
1622
1623/**
1598 * Remove a connection from a neighboring peer. 1624 * Remove a connection from a neighboring peer.
1599 * 1625 *
1600 * @param peer Peer to remove connection from. 1626 * @param peer Peer to remove connection from.
diff --git a/src/mesh/gnunet-service-mesh_peer.h b/src/mesh/gnunet-service-mesh_peer.h
index 58386c0aa..2377c2052 100644
--- a/src/mesh/gnunet-service-mesh_peer.h
+++ b/src/mesh/gnunet-service-mesh_peer.h
@@ -251,6 +251,15 @@ void
251GMP_add_path_to_all (const struct MeshPeerPath *p, int confirmed); 251GMP_add_path_to_all (const struct MeshPeerPath *p, int confirmed);
252 252
253/** 253/**
254 * Remove any path to the peer that has the extact same peers as the one given.
255 *
256 * @param peer Peer to remove the path from.
257 * @param path Path to remove.
258 */
259void
260GMP_remove_path (struct MeshPeer *peer, struct MeshPeerPath *path);
261
262/**
254 * Remove a connection from a neighboring peer. 263 * Remove a connection from a neighboring peer.
255 * 264 *
256 * @param peer Peer to remove connection from. 265 * @param peer Peer to remove connection from.
diff --git a/src/mesh/gnunet-service-mesh_tunnel.c b/src/mesh/gnunet-service-mesh_tunnel.c
index 181395b09..82fcde649 100644
--- a/src/mesh/gnunet-service-mesh_tunnel.c
+++ b/src/mesh/gnunet-service-mesh_tunnel.c
@@ -1756,6 +1756,19 @@ GMT_add_connection (struct MeshTunnel3 *t, struct MeshConnection *c)
1756 1756
1757 1757
1758/** 1758/**
1759 * Mark a path as no longer valid for this tunnel: has been tried and failed.
1760 *
1761 * @param t Tunnel to update.
1762 * @param path Invalid path.
1763 */
1764void
1765GMT_remove_path (struct MeshTunnel3 *t, struct MeshPeerPath *path)
1766{
1767 GMP_remove_path (t->peer, path);
1768}
1769
1770
1771/**
1759 * Remove a connection from a tunnel. 1772 * Remove a connection from a tunnel.
1760 * 1773 *
1761 * @param t Tunnel. 1774 * @param t Tunnel.
diff --git a/src/mesh/gnunet-service-mesh_tunnel.h b/src/mesh/gnunet-service-mesh_tunnel.h
index 26064c642..af36ff4e5 100644
--- a/src/mesh/gnunet-service-mesh_tunnel.h
+++ b/src/mesh/gnunet-service-mesh_tunnel.h
@@ -214,6 +214,15 @@ void
214GMT_add_connection (struct MeshTunnel3 *t, struct MeshConnection *c); 214GMT_add_connection (struct MeshTunnel3 *t, struct MeshConnection *c);
215 215
216/** 216/**
217 * Mark a path as no longer valid for this tunnel: has been tried and failed.
218 *
219 * @param t Tunnel to update.
220 * @param path Invalid path.
221 */
222void
223GMT_remove_path (struct MeshTunnel3 *t, struct MeshPeerPath *path);
224
225/**
217 * Remove a connection from a tunnel. 226 * Remove a connection from a tunnel.
218 * 227 *
219 * @param t Tunnel. 228 * @param t Tunnel.