aboutsummaryrefslogtreecommitdiff
path: root/src/dv
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-12-10 09:07:38 +0000
committerChristian Grothoff <christian@grothoff.org>2013-12-10 09:07:38 +0000
commitc368be672b98ef5aa8ebda8f12035d9c7df84e5a (patch)
treea20c47cb8183bf89d4475345d95958f355e2fb1c /src/dv
parent8019567e4bf8f9c3dcace8774771e464cdc13c75 (diff)
downloadgnunet-c368be672b98ef5aa8ebda8f12035d9c7df84e5a.tar.gz
gnunet-c368be672b98ef5aa8ebda8f12035d9c7df84e5a.zip
-consistently update consensi map whenever peer distances change (should fix #3183)
Diffstat (limited to 'src/dv')
-rw-r--r--src/dv/gnunet-service-dv.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/src/dv/gnunet-service-dv.c b/src/dv/gnunet-service-dv.c
index 04176d747..1a2235853 100644
--- a/src/dv/gnunet-service-dv.c
+++ b/src/dv/gnunet-service-dv.c
@@ -894,7 +894,6 @@ handle_direct_connect (struct DirectNeighbor *neighbor)
894 neighbor->direct_route = GNUNET_new (struct Route); 894 neighbor->direct_route = GNUNET_new (struct Route);
895 neighbor->direct_route->next_hop = neighbor; 895 neighbor->direct_route->next_hop = neighbor;
896 neighbor->direct_route->target.peer= neighbor->peer; 896 neighbor->direct_route->target.peer= neighbor->peer;
897 neighbor->direct_route->target.distance = DIRECT_NEIGHBOR_COST;
898 allocate_route (neighbor->direct_route, DIRECT_NEIGHBOR_COST); 897 allocate_route (neighbor->direct_route, DIRECT_NEIGHBOR_COST);
899 898
900 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 899 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1048,9 +1047,8 @@ check_possible_route (void *cls,
1048 return GNUNET_YES; /* distance is too large to be interesting */ 1047 return GNUNET_YES; /* distance is too large to be interesting */
1049 route = GNUNET_new (struct Route); 1048 route = GNUNET_new (struct Route);
1050 route->next_hop = neighbor; 1049 route->next_hop = neighbor;
1051 route->target.distance = htonl (ntohl (target->distance) + 1);
1052 route->target.peer = target->peer; 1050 route->target.peer = target->peer;
1053 allocate_route (route, ntohl (route->target.distance)); 1051 allocate_route (route, ntohl (target->distance) + 1);
1054 GNUNET_assert (GNUNET_YES == 1052 GNUNET_assert (GNUNET_YES ==
1055 GNUNET_CONTAINER_multipeermap_put (all_routes, 1053 GNUNET_CONTAINER_multipeermap_put (all_routes,
1056 &route->target.peer, 1054 &route->target.peer,
@@ -1402,11 +1400,28 @@ check_target_added (void *cls,
1402 /* route exists */ 1400 /* route exists */
1403 if (current_route->next_hop == neighbor) 1401 if (current_route->next_hop == neighbor)
1404 { 1402 {
1405 /* we had the same route before, no change */ 1403 /* we had the same route before, no change in target */
1406 if (ntohl (target->distance) + 1 != ntohl (current_route->target.distance)) 1404 if (ntohl (target->distance) + 1 != ntohl (current_route->target.distance))
1407 { 1405 {
1408 current_route->target.distance = htonl (ntohl (target->distance) + 1); 1406 /* but distance changed! */
1409 send_distance_change_to_plugin (&target->peer, ntohl (target->distance) + 1); 1407 if (ntohl (target->distance) + 1 > DEFAULT_FISHEYE_DEPTH)
1408 {
1409 /* distance increased beyond what is allowed, kill route */
1410 GNUNET_assert (GNUNET_YES ==
1411 GNUNET_CONTAINER_multipeermap_remove (all_routes,
1412 key,
1413 current_route));
1414 send_disconnect_to_plugin (key);
1415 release_route (current_route);
1416 GNUNET_free (current_route);
1417 }
1418 else
1419 {
1420 /* distance decreased, update route */
1421 move_route (current_route,
1422 ntohl (target->distance) + 1);
1423 send_distance_change_to_plugin (&target->peer, ntohl (target->distance) + 1);
1424 }
1410 } 1425 }
1411 return GNUNET_OK; 1426 return GNUNET_OK;
1412 } 1427 }
@@ -1420,8 +1435,9 @@ check_target_added (void *cls,
1420 very short routes to take over longer paths; as we don't 1435 very short routes to take over longer paths; as we don't
1421 check that the shorter routes actually work, a malicious 1436 check that the shorter routes actually work, a malicious
1422 direct neighbor can use this to DoS our long routes */ 1437 direct neighbor can use this to DoS our long routes */
1438
1439 move_route (current_route, ntohl (target->distance) + 1);
1423 current_route->next_hop = neighbor; 1440 current_route->next_hop = neighbor;
1424 current_route->target.distance = htonl (ntohl (target->distance) + 1);
1425 send_distance_change_to_plugin (&target->peer, ntohl (target->distance) + 1); 1441 send_distance_change_to_plugin (&target->peer, ntohl (target->distance) + 1);
1426 return GNUNET_OK; 1442 return GNUNET_OK;
1427 } 1443 }
@@ -1433,8 +1449,7 @@ check_target_added (void *cls,
1433 current_route = GNUNET_new (struct Route); 1449 current_route = GNUNET_new (struct Route);
1434 current_route->next_hop = neighbor; 1450 current_route->next_hop = neighbor;
1435 current_route->target.peer = target->peer; 1451 current_route->target.peer = target->peer;
1436 current_route->target.distance = htonl (ntohl (target->distance) + 1); 1452 allocate_route (current_route, ntohl (target.distance) + 1);
1437 allocate_route (current_route, ntohl (current_route->target.distance));
1438 GNUNET_assert (GNUNET_YES == 1453 GNUNET_assert (GNUNET_YES ==
1439 GNUNET_CONTAINER_multipeermap_put (all_routes, 1454 GNUNET_CONTAINER_multipeermap_put (all_routes,
1440 &current_route->target.peer, 1455 &current_route->target.peer,