From 6b659c8a65c34d194d6440489442c411bb3f4c26 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 13 Feb 2019 17:51:29 +0100 Subject: [PATCH] trying to fix #5532 --- src/cadet/cadet.h | 10 +++++----- src/cadet/cadet_api_get_path.c | 13 +++++++------ src/cadet/gnunet-cadet.c | 16 ++++++++-------- src/cadet/gnunet-service-cadet.c | 10 +++++++++- src/include/gnunet_cadet_service.h | 21 +++++++++++++-------- src/rps/profiler_rps.conf | 2 +- 6 files changed, 43 insertions(+), 29 deletions(-) diff --git a/src/cadet/cadet.h b/src/cadet/cadet.h index 51296ae50..f6cc860cc 100644 --- a/src/cadet/cadet.h +++ b/src/cadet/cadet.h @@ -11,7 +11,7 @@ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . @@ -323,9 +323,9 @@ struct GNUNET_CADET_LocalInfoPath struct GNUNET_MessageHeader header; /** - * Zero. + * Offset of the peer that was requested. */ - uint32_t reserved GNUNET_PACKED; + uint32_t off GNUNET_PACKED; }; @@ -338,7 +338,7 @@ struct GNUNET_CADET_LocalInfoPeers * Type: #GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEERS */ struct GNUNET_MessageHeader header; - + /** * Number of paths. */ @@ -348,7 +348,7 @@ struct GNUNET_CADET_LocalInfoPeers * Do we have a tunnel toward this peer? */ int16_t tunnel GNUNET_PACKED; - + /** * Shortest known path. */ diff --git a/src/cadet/cadet_api_get_path.c b/src/cadet/cadet_api_get_path.c index 2f35e365e..fcc79c3d5 100644 --- a/src/cadet/cadet_api_get_path.c +++ b/src/cadet/cadet_api_get_path.c @@ -11,7 +11,7 @@ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . @@ -66,7 +66,7 @@ struct GNUNET_CADET_GetPath * Backoff for reconnect attempts. */ struct GNUNET_TIME_Relative backoff; - + /** * Peer we want information about. */ @@ -109,7 +109,7 @@ check_get_path (void *cls, /** * Process a local peer info reply, pass info to the user. * - * @param cls Closure + * @param cls Closure * @param message Message itself. */ static void @@ -118,9 +118,10 @@ handle_get_path (void *cls, { struct GNUNET_CADET_GetPath *gp = cls; struct GNUNET_CADET_PeerPathDetail ppd; - + ppd.peer = gp->id; ppd.path = (const struct GNUNET_PeerIdentity *) &message[1]; + ppd.target_offset = ntohl (message->off); ppd.path_length = (ntohs (message->header.size) - sizeof (*message)) / sizeof (struct GNUNET_PeerIdentity); gp->path_cb (gp->path_cb_cls, @@ -131,7 +132,7 @@ handle_get_path (void *cls, /** * Process a local peer info reply, pass info to the user. * - * @param cls Closure + * @param cls Closure * @param message Message itself. */ static void @@ -177,7 +178,7 @@ error_handler (void *cls, gp); } - + /** * Reconnect to the service and try again. * diff --git a/src/cadet/gnunet-cadet.c b/src/cadet/gnunet-cadet.c index dba517a7b..932d069a1 100644 --- a/src/cadet/gnunet-cadet.c +++ b/src/cadet/gnunet-cadet.c @@ -11,7 +11,7 @@ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . @@ -103,7 +103,7 @@ static struct GNUNET_CADET_GetPath *gpo; /** * Active peer listing operation. - */ + */ static struct GNUNET_CADET_PeersLister *plo; /** @@ -220,7 +220,7 @@ shutdown_task (void *cls) { GNUNET_CADET_channel_destroy (ch); ch = NULL; - } + } if (NULL != gpo) { GNUNET_CADET_get_path_cancel (gpo); @@ -306,12 +306,12 @@ read_stdio (void *cls) if (GNUNET_NO == echo) { // Use MQ's notification if too much data of stdin is pooring in too fast. - if (STREAM_BUFFER_SIZE < sent_pkt) + if (STREAM_BUFFER_SIZE < sent_pkt) { GNUNET_MQ_notify_sent (env, mq_cb, cls); sent_pkt = 0; } - else + else { listen_stdio (); } @@ -563,7 +563,7 @@ path_callback (void *cls, ppd->path_length); for (unsigned int i = 0; i < ppd->path_length; i++) FPRINTF (stdout, - "%s ", + (i == ppd->target_offset) ? "*%s* " : "%s ", GNUNET_i2s (&ppd->path[i])); FPRINTF (stdout, "\n"); @@ -626,7 +626,7 @@ show_peer (void *cls) GNUNET_CRYPTO_eddsa_public_key_from_string (peer_id, strlen (peer_id), &pid.public_key)) - { + { fprintf (stderr, _("Invalid peer ID `%s'\n"), peer_id); @@ -859,7 +859,7 @@ main (int argc, GNUNET_GETOPT_option_flag ('e', "echo", gettext_noop ("Activate echo mode"), - &echo), + &echo), GNUNET_GETOPT_option_string ('o', "open-port", "SHARED_SECRET", diff --git a/src/cadet/gnunet-service-cadet.c b/src/cadet/gnunet-service-cadet.c index d64242943..e29330f99 100644 --- a/src/cadet/gnunet-service-cadet.c +++ b/src/cadet/gnunet-service-cadet.c @@ -885,6 +885,13 @@ path_info_iterator (void *cls, path_length = GCPP_get_length (path); path_size = sizeof (struct GNUNET_PeerIdentity) * path_length; if (sizeof (*resp) + path_size > UINT16_MAX) + { + /* try just giving the relevant path */ + path_length = GNUNET_MIN ((UINT16_MAX - sizeof (*resp)) / sizeof (struct GNUNET_PeerIdentity), + off); + path_size = sizeof (struct GNUNET_PeerIdentity) * path_length; + } + if (sizeof (*resp) + path_size > UINT16_MAX) { LOG (GNUNET_ERROR_TYPE_WARNING, "Path of %u entries is too long for info message\n", @@ -899,9 +906,10 @@ path_info_iterator (void *cls, /* Don't copy first peer. First peer is always the local one. Last * peer is always the destination (leave as 0, EOL). */ - for (unsigned int i = 0; i <= off; i++) + for (unsigned int i = 0; i < path_length; i++) id[i] = *GCP_get_id (GCPP_get_peer_at_offset (path, i)); + resp->off = htonl (off); GNUNET_MQ_send (mq, env); return GNUNET_YES; diff --git a/src/include/gnunet_cadet_service.h b/src/include/gnunet_cadet_service.h index ac3d11216..b8326657d 100644 --- a/src/include/gnunet_cadet_service.h +++ b/src/include/gnunet_cadet_service.h @@ -11,7 +11,7 @@ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . @@ -369,7 +369,7 @@ GNUNET_CADET_channel_get_info (struct GNUNET_CADET_Channel *channel, /** * Internal details about a channel. - */ + */ struct GNUNET_CADET_ChannelInternals { /** @@ -431,7 +431,7 @@ GNUNET_CADET_get_channel_cancel (struct GNUNET_CADET_ChannelMonitor *cm); /** * Information we return per peer. - */ + */ struct GNUNET_CADET_PeerListEntry { /** @@ -446,7 +446,7 @@ struct GNUNET_CADET_PeerListEntry /** * Number of disjoint known paths to @e peer. - */ + */ unsigned int n_paths; /** @@ -504,7 +504,7 @@ GNUNET_CADET_list_peers_cancel (struct GNUNET_CADET_PeersLister *pl); /** * Detailed information we return per peer. - */ + */ struct GNUNET_CADET_PeerPathDetail { /** @@ -512,6 +512,11 @@ struct GNUNET_CADET_PeerPathDetail */ struct GNUNET_PeerIdentity peer; + /** + * Offset of the target peer on the @e path. + */ + unsigned int target_offset; + /** * Number of entries on the @e path. */ @@ -583,7 +588,7 @@ struct GNUNET_CADET_TunnelDetails /** * How many channels use the tunnel. - */ + */ uint32_t channels; /** @@ -597,8 +602,8 @@ struct GNUNET_CADET_TunnelDetails uint16_t estate; /** - * What is our connectivity state? - */ + * What is our connectivity state? + */ uint16_t cstate; }; diff --git a/src/rps/profiler_rps.conf b/src/rps/profiler_rps.conf index 375015cae..dc156f876 100644 --- a/src/rps/profiler_rps.conf +++ b/src/rps/profiler_rps.conf @@ -84,7 +84,7 @@ DISABLE_TRY_CONNECT = YES [cadet] OPTIONS=-l /tmp/rps_profiler_logs/cadet-[]-%Y-%m-%d.log -PREFIX = valgrind +PREFIX = valgrind --log-file=/home/grothoff/cadet.%p.log #[arm] #GLOBAL_POSTFIX=-l /tmp/rps_profiler_logs/other-[]-%Y-%m-%d.log -- 2.25.1