From 0e341773e7a714bd1d769d5bd727a9758f6453bc Mon Sep 17 00:00:00 2001 From: xrs Date: Fri, 3 Jan 2020 17:22:11 +0100 Subject: [PATCH] add changes for cadet bug fix --- src/cadet/cadet_protocol.h | 5 +++++ src/cadet/gnunet-service-cadet_connection.c | 5 +++++ src/cadet/gnunet-service-cadet_core.c | 12 +++++++++++- src/cadet/gnunet-service-cadet_tunnels.c | 1 - 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/cadet/cadet_protocol.h b/src/cadet/cadet_protocol.h index 762babb8a..30c87b4ea 100644 --- a/src/cadet/cadet_protocol.h +++ b/src/cadet/cadet_protocol.h @@ -84,6 +84,11 @@ struct GNUNET_CADET_ConnectionCreateMessage */ uint32_t options GNUNET_PACKED; + /** + * Infomation of known tunnel state to keep two peers synced. (xrs,t3ss) + */ + int tunnel_up; + /** * ID of the connection */ diff --git a/src/cadet/gnunet-service-cadet_connection.c b/src/cadet/gnunet-service-cadet_connection.c index 0e6423e10..4d9a40927 100644 --- a/src/cadet/gnunet-service-cadet_connection.c +++ b/src/cadet/gnunet-service-cadet_connection.c @@ -620,6 +620,11 @@ send_create (void *cls) //TODO This will be removed in a major release, because this will be a protocol breaking change. We set the deprecated 'reliable' bit here that was removed. create_msg->options = 2; create_msg->cid = cc->cid; + + // check for tunnel state and define tunnel_up (xrs,t3ss) + t = GCP_get_tunnel (cc->destination, GNUNET_YES); + create_msg->tunnel_up = (t->estate == CADET_TUNNEL_KEY_UNINITIALIZED)? GNUNET_NO : GNUNET_YES; + pids = (struct GNUNET_PeerIdentity *) &create_msg[1]; pids[0] = my_full_id; for (unsigned int i = 0; i <= cc->off; i++) diff --git a/src/cadet/gnunet-service-cadet_core.c b/src/cadet/gnunet-service-cadet_core.c index ec70a968b..c90c97fca 100644 --- a/src/cadet/gnunet-service-cadet_core.c +++ b/src/cadet/gnunet-service-cadet_core.c @@ -727,6 +727,7 @@ handle_connection_create ( uint16_t size = ntohs (msg->header.size) - sizeof (*msg); unsigned int path_length; unsigned int off; + struct CadetTunnel *t; path_length = size / sizeof (struct GNUNET_PeerIdentity); if (0 == path_length) @@ -825,8 +826,17 @@ handle_connection_create ( GCP_2s (origin), GNUNET_sh2s (&msg->cid.connection_of_tunnel)); path = GCPP_get_path_from_route (path_length - 1, pids); + t = GCP_get_tunnel (orgin, GNUNET_YES); + + // Check for CADET state in case the other side has lost the tunnel (xrs,t3ss) + if ((GNUNET_NO == msg->tunnel_up) && + (CADET_TUNNEL_KEY_OK == t->estate)) + { + t->estate = CADET_TUNNEL_KEY_UNINITIALIZED; + } + if (GNUNET_OK != - GCT_add_inbound_connection (GCP_get_tunnel (origin, GNUNET_YES), + GCT_add_inbound_connection (t, &msg->cid, path)) { diff --git a/src/cadet/gnunet-service-cadet_tunnels.c b/src/cadet/gnunet-service-cadet_tunnels.c index 4ecdefc65..8999b26da 100644 --- a/src/cadet/gnunet-service-cadet_tunnels.c +++ b/src/cadet/gnunet-service-cadet_tunnels.c @@ -454,7 +454,6 @@ struct CadetTunnel * Force triggering KX_AUTH independent of @e estate. */ int kx_auth_requested; - }; -- 2.25.1