gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r31249 - gnunet/src/dv


From: gnunet
Subject: [GNUnet-SVN] r31249 - gnunet/src/dv
Date: Tue, 10 Dec 2013 10:07:38 +0100

Author: grothoff
Date: 2013-12-10 10:07:38 +0100 (Tue, 10 Dec 2013)
New Revision: 31249

Modified:
   gnunet/src/dv/gnunet-service-dv.c
Log:
-consistently update consensi map whenever peer distances change (should fix 
#3183)

Modified: gnunet/src/dv/gnunet-service-dv.c
===================================================================
--- gnunet/src/dv/gnunet-service-dv.c   2013-12-10 08:59:55 UTC (rev 31248)
+++ gnunet/src/dv/gnunet-service-dv.c   2013-12-10 09:07:38 UTC (rev 31249)
@@ -894,7 +894,6 @@
   neighbor->direct_route = GNUNET_new (struct Route);
   neighbor->direct_route->next_hop = neighbor;
   neighbor->direct_route->target.peer= neighbor->peer;
-  neighbor->direct_route->target.distance = DIRECT_NEIGHBOR_COST;
   allocate_route (neighbor->direct_route, DIRECT_NEIGHBOR_COST);
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1048,9 +1047,8 @@
     return GNUNET_YES; /* distance is too large to be interesting */
   route = GNUNET_new (struct Route);
   route->next_hop = neighbor;
-  route->target.distance = htonl (ntohl (target->distance) + 1);
   route->target.peer = target->peer;
-  allocate_route (route, ntohl (route->target.distance));
+  allocate_route (route, ntohl (target->distance) + 1);
   GNUNET_assert (GNUNET_YES ==
                 GNUNET_CONTAINER_multipeermap_put (all_routes,
                                                    &route->target.peer,
@@ -1402,11 +1400,28 @@
     /* route exists */
     if (current_route->next_hop == neighbor)
     {
-      /* we had the same route before, no change */
+      /* we had the same route before, no change in target */
       if (ntohl (target->distance) + 1 != ntohl 
(current_route->target.distance))
       {
-       current_route->target.distance = htonl (ntohl (target->distance) + 1);
-       send_distance_change_to_plugin (&target->peer, ntohl (target->distance) 
+ 1);
+        /* but distance changed! */
+        if (ntohl (target->distance) + 1 > DEFAULT_FISHEYE_DEPTH)
+        {
+          /* distance increased beyond what is allowed, kill route */
+          GNUNET_assert (GNUNET_YES ==
+                         GNUNET_CONTAINER_multipeermap_remove (all_routes,
+                                                               key,
+                                                               current_route));
+          send_disconnect_to_plugin (key);
+          release_route (current_route);
+          GNUNET_free (current_route);
+        }
+        else
+        {
+          /* distance decreased, update route */
+          move_route (current_route,
+                      ntohl (target->distance) + 1);
+          send_distance_change_to_plugin (&target->peer, ntohl 
(target->distance) + 1);
+        }
       }
       return GNUNET_OK;
     }
@@ -1420,8 +1435,9 @@
        very short routes to take over longer paths; as we don't
        check that the shorter routes actually work, a malicious
        direct neighbor can use this to DoS our long routes */
+
+    move_route (current_route, ntohl (target->distance) + 1);
     current_route->next_hop = neighbor;
-    current_route->target.distance = htonl (ntohl (target->distance) + 1);
     send_distance_change_to_plugin (&target->peer, ntohl (target->distance) + 
1);
     return GNUNET_OK;
   }
@@ -1433,8 +1449,7 @@
   current_route = GNUNET_new (struct Route);
   current_route->next_hop = neighbor;
   current_route->target.peer = target->peer;
-  current_route->target.distance = htonl (ntohl (target->distance) + 1);
-  allocate_route (current_route, ntohl (current_route->target.distance));
+  allocate_route (current_route, ntohl (target.distance) + 1);
   GNUNET_assert (GNUNET_YES ==
                 GNUNET_CONTAINER_multipeermap_put (all_routes,
                                                    &current_route->target.peer,




reply via email to

[Prev in Thread] Current Thread [Next in Thread]