aboutsummaryrefslogtreecommitdiff
path: root/src/mesh
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2013-10-11 17:51:11 +0000
committerBart Polot <bart@net.in.tum.de>2013-10-11 17:51:11 +0000
commit4e3b061518f83544423304955f6a675949475b02 (patch)
tree11948955e9d8508125db95df9170167a30cba080 /src/mesh
parent9ab259c526d3b8b2923c635dc4255be5b50bdfdf (diff)
downloadgnunet-4e3b061518f83544423304955f6a675949475b02.tar.gz
gnunet-4e3b061518f83544423304955f6a675949475b02.zip
- avoid infinite ACK loops when creating loopback channels
Diffstat (limited to 'src/mesh')
-rw-r--r--src/mesh/gnunet-service-mesh_channel.c27
-rw-r--r--src/mesh/gnunet-service-mesh_tunnel.c7
2 files changed, 24 insertions, 10 deletions
diff --git a/src/mesh/gnunet-service-mesh_channel.c b/src/mesh/gnunet-service-mesh_channel.c
index d36a6df51..170ba955e 100644
--- a/src/mesh/gnunet-service-mesh_channel.c
+++ b/src/mesh/gnunet-service-mesh_channel.c
@@ -603,7 +603,7 @@ rel_message_free (struct MeshReliableMessage *copy)
603 * Confirm we got a channel create. 603 * Confirm we got a channel create.
604 * 604 *
605 * @param ch The channel to confirm. 605 * @param ch The channel to confirm.
606 * @param fwd Should we send the ACK fwd? 606 * @param fwd Should we send a FWD ACK? (going dest->root)
607 */ 607 */
608static void 608static void
609channel_send_ack (struct MeshChannel *ch, int fwd) 609channel_send_ack (struct MeshChannel *ch, int fwd)
@@ -652,7 +652,10 @@ channel_confirm (struct MeshChannel *ch, int fwd)
652 /* TODO return? */ 652 /* TODO return? */
653 } 653 }
654 } 654 }
655 channel_send_ack (ch, fwd); 655
656 /* In case of a FWD ACk (SYNACK) send a BCK ACK (ACK). */
657 if (fwd)
658 channel_send_ack (ch, !fwd);
656} 659}
657 660
658 661
@@ -866,8 +869,8 @@ handle_loopback (struct MeshChannel *ch,
866 869
867 type = ntohs (msgh->type); 870 type = ntohs (msgh->type);
868 LOG (GNUNET_ERROR_TYPE_DEBUG, 871 LOG (GNUNET_ERROR_TYPE_DEBUG,
869 "Loopback %s message!\n", 872 "Loopback %s %s message!\n",
870 GNUNET_MESH_DEBUG_M2S (type)); 873 fwd ? "FWD" : "BCK", GNUNET_MESH_DEBUG_M2S (type));
871 874
872 switch (type) 875 switch (type)
873 { 876 {
@@ -1521,9 +1524,13 @@ GMCH_handle_create (struct MeshTunnel3 *t,
1521 1524
1522 chid = ntohl (msg->chid); 1525 chid = ntohl (msg->chid);
1523 1526
1524 /* Create channel */ 1527 ch = GMT_get_channel (t, chid);
1525 ch = channel_new (t, NULL, 0); 1528 if (NULL == ch)
1526 ch->gid = chid; 1529 {
1530 /* Create channel */
1531 ch = channel_new (t, NULL, 0);
1532 ch->gid = chid;
1533 }
1527 channel_set_options (ch, ntohl (msg->opt)); 1534 channel_set_options (ch, ntohl (msg->opt));
1528 1535
1529 /* Find a destination client */ 1536 /* Find a destination client */
@@ -1543,8 +1550,8 @@ GMCH_handle_create (struct MeshTunnel3 *t,
1543 LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! Reliable\n"); 1550 LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! Reliable\n");
1544 1551
1545 GMCH_send_create (ch); 1552 GMCH_send_create (ch);
1553 channel_send_ack (ch, fwd);
1546 GMCH_send_data_ack (ch, fwd); 1554 GMCH_send_data_ack (ch, fwd);
1547 channel_send_ack (ch, !fwd);
1548 1555
1549 if (GNUNET_NO == ch->dest_rel->client_ready) 1556 if (GNUNET_NO == ch->dest_rel->client_ready)
1550 { 1557 {
@@ -1619,8 +1626,8 @@ void
1619GMCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message, 1626GMCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
1620 struct MeshChannel *ch, int fwd) 1627 struct MeshChannel *ch, int fwd)
1621{ 1628{
1622 LOG (GNUNET_ERROR_TYPE_DEBUG, "Send on Channel %s:%X %s\n", 1629 LOG (GNUNET_ERROR_TYPE_DEBUG, "Send %s on channel %s\n",
1623 GMT_2s (ch->t), ch->gid, fwd ? "FWD" : "BCK"); 1630 fwd ? "FWD" : "BCK", GMCH_2s (ch));
1624 LOG (GNUNET_ERROR_TYPE_DEBUG, " %s\n", 1631 LOG (GNUNET_ERROR_TYPE_DEBUG, " %s\n",
1625 GNUNET_MESH_DEBUG_M2S (ntohs (message->type))); 1632 GNUNET_MESH_DEBUG_M2S (ntohs (message->type)));
1626 1633
diff --git a/src/mesh/gnunet-service-mesh_tunnel.c b/src/mesh/gnunet-service-mesh_tunnel.c
index 3f338ac3f..9bcfc8365 100644
--- a/src/mesh/gnunet-service-mesh_tunnel.c
+++ b/src/mesh/gnunet-service-mesh_tunnel.c
@@ -33,6 +33,9 @@
33 33
34#define LOG(level, ...) GNUNET_log_from(level,"mesh-tun",__VA_ARGS__) 34#define LOG(level, ...) GNUNET_log_from(level,"mesh-tun",__VA_ARGS__)
35 35
36#define START_FUNCTION LOG(GNUNET_ERROR_TYPE_DEBUG, "%s start\n", __FUNCTION__)
37#define END_FUNCTION LOG(GNUNET_ERROR_TYPE_DEBUG, "%s end\n", __FUNCTION__)
38
36 39
37/******************************************************************************/ 40/******************************************************************************/
38/******************************** STRUCTS **********************************/ 41/******************************** STRUCTS **********************************/
@@ -371,6 +374,8 @@ handle_ch_create (struct MeshTunnel3 *t,
371 const struct GNUNET_MESH_ChannelCreate *msg, 374 const struct GNUNET_MESH_ChannelCreate *msg,
372 int fwd) 375 int fwd)
373{ 376{
377 ;
378
374 struct MeshTChannel *tch; 379 struct MeshTChannel *tch;
375 struct MeshChannel *ch; 380 struct MeshChannel *ch;
376 size_t size; 381 size_t size;
@@ -398,6 +403,8 @@ handle_ch_create (struct MeshTunnel3 *t,
398 tch = GNUNET_new (struct MeshTChannel); 403 tch = GNUNET_new (struct MeshTChannel);
399 tch->ch = ch; 404 tch->ch = ch;
400 GNUNET_CONTAINER_DLL_insert (t->channel_head, t->channel_tail, tch); 405 GNUNET_CONTAINER_DLL_insert (t->channel_head, t->channel_tail, tch);
406
407 ;
401} 408}
402 409
403void 410void