From 94f9c245e43e1291bf4b3e800e6becdeb5f71e97 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 22 May 2015 09:58:51 +0000 Subject: -diagnose tunnel issues --- src/vpn/gnunet-service-vpn.c | 63 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 49 insertions(+), 14 deletions(-) (limited to 'src/vpn') diff --git a/src/vpn/gnunet-service-vpn.c b/src/vpn/gnunet-service-vpn.c index 33ffa913a..d9395cf48 100644 --- a/src/vpn/gnunet-service-vpn.c +++ b/src/vpn/gnunet-service-vpn.c @@ -324,7 +324,7 @@ struct ChannelState /** - * Return value from 'main'. + * Return value from #main(). */ static int global_ret; @@ -445,12 +445,12 @@ get_destination_key_from_ip (int af, */ static void get_channel_key_from_ips (int af, - uint8_t protocol, - const void *source_ip, - uint16_t source_port, - const void *destination_ip, - uint16_t destination_port, - struct GNUNET_HashCode *key) + uint8_t protocol, + const void *source_ip, + uint16_t source_port, + const void *destination_ip, + uint16_t destination_port, + struct GNUNET_HashCode *key) { char *off; @@ -744,7 +744,7 @@ handle_regex_result (void *cls, */ static struct ChannelState * create_channel_to_destination (struct DestinationChannel *dt, - int client_af) + int client_af) { struct ChannelState *ts; unsigned int apptype; @@ -774,10 +774,10 @@ create_channel_to_destination (struct DestinationChannel *dt, if (dt->destination->is_service) { ts->channel = GNUNET_CADET_channel_create (cadet_handle, - ts, - &dt->destination->details.service_destination.target, - apptype, - GNUNET_CADET_OPTION_DEFAULT); + ts, + &dt->destination->details.service_destination.target, + apptype, + GNUNET_CADET_OPTION_DEFAULT); if (NULL == ts->channel) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -803,7 +803,8 @@ create_channel_to_destination (struct DestinationChannel *dt, GNUNET_TUN_ipv4toregexsearch (&dt->destination->details.exit_destination.ip.v4, dt->destination_port, address); - GNUNET_asprintf (&policy, "%s%s", + GNUNET_asprintf (&policy, + "%s%s", GNUNET_APPLICATION_TYPE_EXIT_REGEX_PREFIX, address); break; @@ -856,6 +857,36 @@ expire_channel (struct ChannelState *except) } +/** + * Output destination of a channel for diagnostics. + * + * @param de destination to process + * @return diagnostic string describing destination + */ +static const char * +print_channel_destination (const struct DestinationEntry *de) +{ + static char dest[256]; + + if (de->is_service) + { + GNUNET_snprintf (dest, + sizeof (dest), + "HS: %s-%s\n", + GNUNET_i2s (&de->details.service_destination.target), + GNUNET_h2s (&de->details.service_destination.service_descriptor)); + } + else + { + inet_ntop (de->details.exit_destination.af, + &de->details.exit_destination.ip, + dest, + sizeof (dest)); + } + return dest; +} + + /** * Route a packet via cadet to the given destination. * @@ -1098,7 +1129,11 @@ route_packet (struct DestinationEntry *destination, if (NULL == ts->channel) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Packet dropped, channel not yet ready\n"); + "Packet dropped, channel to %s not yet ready (%s)\n", + print_channel_destination (&ts->destination), + (NULL == ts->search) + ? "EXIT search failed" + : "EXIT search active"); GNUNET_STATISTICS_update (stats, gettext_noop ("# Packets dropped (channel not yet online)"), 1, -- cgit v1.2.3