diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-06-08 19:59:01 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-06-08 19:59:01 +0000 |
commit | 79f5075307fb462d6b1c809e8d0fdc667ed33b0e (patch) | |
tree | 4fc8672aee993c14fb6f5ae6a1f9a14fb9630670 /src | |
parent | f2cabcbdbaff81be2e543cb2d599c608e77c7765 (diff) | |
download | gnunet-79f5075307fb462d6b1c809e8d0fdc667ed33b0e.tar.gz gnunet-79f5075307fb462d6b1c809e8d0fdc667ed33b0e.zip |
-adding additional error checking logic
Diffstat (limited to 'src')
-rw-r--r-- | src/cadet/gnunet-service-cadet_connection.c | 65 |
1 files changed, 43 insertions, 22 deletions
diff --git a/src/cadet/gnunet-service-cadet_connection.c b/src/cadet/gnunet-service-cadet_connection.c index 21a0ee5c8..54c82a837 100644 --- a/src/cadet/gnunet-service-cadet_connection.c +++ b/src/cadet/gnunet-service-cadet_connection.c | |||
@@ -198,6 +198,16 @@ struct CadetConnection | |||
198 | struct CadetPeerQueue *maintenance_q; | 198 | struct CadetPeerQueue *maintenance_q; |
199 | 199 | ||
200 | /** | 200 | /** |
201 | * Should equal #get_next_hop(this). | ||
202 | */ | ||
203 | struct CadetPeer *next_peer; | ||
204 | |||
205 | /** | ||
206 | * Should equal #get_prev_hop(this). | ||
207 | */ | ||
208 | struct CadetPeer *prev_peer; | ||
209 | |||
210 | /** | ||
201 | * State of the connection. | 211 | * State of the connection. |
202 | */ | 212 | */ |
203 | enum CadetConnectionState state; | 213 | enum CadetConnectionState state; |
@@ -1431,7 +1441,7 @@ connection_bck_timeout (void *cls, | |||
1431 | if (GCC_is_origin (c, GNUNET_YES) && 0 < c->fwd_fc.queue_n) | 1441 | if (GCC_is_origin (c, GNUNET_YES) && 0 < c->fwd_fc.queue_n) |
1432 | { | 1442 | { |
1433 | send_broken_unknown (&c->id, &my_full_id, NULL, | 1443 | send_broken_unknown (&c->id, &my_full_id, NULL, |
1434 | GCP_get_id( get_next_hop (c))); | 1444 | GCP_get_id (get_next_hop (c))); |
1435 | resend_messages_and_destroy (c, GNUNET_YES); | 1445 | resend_messages_and_destroy (c, GNUNET_YES); |
1436 | return; | 1446 | return; |
1437 | } | 1447 | } |
@@ -1493,25 +1503,33 @@ connection_reset_timeout (struct CadetConnection *c, int fwd) | |||
1493 | static int | 1503 | static int |
1494 | register_neighbors (struct CadetConnection *c) | 1504 | register_neighbors (struct CadetConnection *c) |
1495 | { | 1505 | { |
1496 | struct CadetPeer *next_peer; | 1506 | c->next_peer = get_next_hop (c); |
1497 | struct CadetPeer *prev_peer; | 1507 | c->prev_peer = get_prev_hop (c); |
1498 | |||
1499 | next_peer = get_next_hop (c); | ||
1500 | prev_peer = get_prev_hop (c); | ||
1501 | 1508 | ||
1502 | LOG (GNUNET_ERROR_TYPE_DEBUG, "register neighbors for connection %s\n", | 1509 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1510 | "register neighbors for connection %s\n", | ||
1503 | GCC_2s (c)); | 1511 | GCC_2s (c)); |
1504 | path_debug (c->path); | 1512 | path_debug (c->path); |
1505 | LOG (GNUNET_ERROR_TYPE_DEBUG, "own pos %u\n", c->own_pos); | 1513 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1506 | LOG (GNUNET_ERROR_TYPE_DEBUG, "putting connection %s to next peer %p\n", | 1514 | "own pos %u\n", c->own_pos); |
1507 | GCC_2s (c), next_peer); | 1515 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1508 | LOG (GNUNET_ERROR_TYPE_DEBUG, "next peer %p %s\n", next_peer, GCP_2s (next_peer)); | 1516 | "putting connection %s to next peer %p\n", |
1509 | LOG (GNUNET_ERROR_TYPE_DEBUG, "putting connection %s to prev peer %p\n", | 1517 | GCC_2s (c), |
1510 | GCC_2s (c), prev_peer); | 1518 | c->next_peer); |
1511 | LOG (GNUNET_ERROR_TYPE_DEBUG, "prev peer %p %s\n", prev_peer, GCP_2s (prev_peer)); | 1519 | LOG (GNUNET_ERROR_TYPE_DEBUG, "next peer %p %s\n", |
1520 | c->next_peer, | ||
1521 | GCP_2s (c->next_peer)); | ||
1522 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1523 | "putting connection %s to prev peer %p\n", | ||
1524 | GCC_2s (c), | ||
1525 | c->prev_peer); | ||
1526 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1527 | "prev peer %p %s\n", | ||
1528 | c->prev_peer, | ||
1529 | GCP_2s (c->prev_peer)); | ||
1512 | 1530 | ||
1513 | if ( (GNUNET_NO == GCP_is_neighbor (next_peer)) || | 1531 | if ( (GNUNET_NO == GCP_is_neighbor (c->next_peer)) || |
1514 | (GNUNET_NO == GCP_is_neighbor (prev_peer)) ) | 1532 | (GNUNET_NO == GCP_is_neighbor (c->prev_peer)) ) |
1515 | { | 1533 | { |
1516 | if (GCC_is_origin (c, GNUNET_YES)) | 1534 | if (GCC_is_origin (c, GNUNET_YES)) |
1517 | GNUNET_STATISTICS_update (stats, "# local bad paths", 1, GNUNET_NO); | 1535 | GNUNET_STATISTICS_update (stats, "# local bad paths", 1, GNUNET_NO); |
@@ -1521,16 +1539,16 @@ register_neighbors (struct CadetConnection *c) | |||
1521 | " register neighbors failed\n"); | 1539 | " register neighbors failed\n"); |
1522 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1540 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1523 | " prev: %s, neighbor?: %d\n", | 1541 | " prev: %s, neighbor?: %d\n", |
1524 | GCP_2s (prev_peer), | 1542 | GCP_2s (c->prev_peer), |
1525 | GCP_is_neighbor (prev_peer)); | 1543 | GCP_is_neighbor (c->prev_peer)); |
1526 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1544 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1527 | " next: %s, neighbor?: %d\n", | 1545 | " next: %s, neighbor?: %d\n", |
1528 | GCP_2s (next_peer), | 1546 | GCP_2s (c->next_peer), |
1529 | GCP_is_neighbor (next_peer)); | 1547 | GCP_is_neighbor (c->next_peer)); |
1530 | return GNUNET_SYSERR; | 1548 | return GNUNET_SYSERR; |
1531 | } | 1549 | } |
1532 | GCP_add_connection (next_peer, c); | 1550 | GCP_add_connection (c->next_peer, c); |
1533 | GCP_add_connection (prev_peer, c); | 1551 | GCP_add_connection (c->prev_peer, c); |
1534 | 1552 | ||
1535 | return GNUNET_OK; | 1553 | return GNUNET_OK; |
1536 | } | 1554 | } |
@@ -1547,8 +1565,10 @@ unregister_neighbors (struct CadetConnection *c) | |||
1547 | struct CadetPeer *peer; | 1565 | struct CadetPeer *peer; |
1548 | 1566 | ||
1549 | peer = get_next_hop (c); | 1567 | peer = get_next_hop (c); |
1568 | GNUNET_assert (c->next_peer == peer); | ||
1550 | GCP_remove_connection (peer, c); | 1569 | GCP_remove_connection (peer, c); |
1551 | peer = get_prev_hop (c); | 1570 | peer = get_prev_hop (c); |
1571 | GNUNET_assert (c->prev_peer == peer); | ||
1552 | GCP_remove_connection (peer, c); | 1572 | GCP_remove_connection (peer, c); |
1553 | } | 1573 | } |
1554 | 1574 | ||
@@ -2162,6 +2182,7 @@ check_message (const struct GNUNET_MessageHeader *message, | |||
2162 | else | 2182 | else |
2163 | { | 2183 | { |
2164 | hop = get_next_hop (c); | 2184 | hop = get_next_hop (c); |
2185 | GNUNET_break (hop == c->next_peer); | ||
2165 | if (neighbor_id == GCP_get_short_id (hop)) | 2186 | if (neighbor_id == GCP_get_short_id (hop)) |
2166 | { | 2187 | { |
2167 | fwd = GNUNET_NO; | 2188 | fwd = GNUNET_NO; |