summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/include/gnunet_testing_ng_lib.h14
-rw-r--r--src/testing/testing.c6
-rw-r--r--src/testing/testing_api_loop.c22
-rw-r--r--src/transport/gnunet-communicator-tcp.c25
-rw-r--r--src/transport/gnunet-service-tng.c67
-rw-r--r--src/transport/test_transport_plugin_cmd_simple_send.c3
-rw-r--r--src/transport/test_transport_plugin_cmd_simple_send_broadcast.c2
-rw-r--r--src/transport/test_transport_plugin_cmd_udp_backchannel.c3
-rw-r--r--src/transport/transport-testing-cmds.h41
-rw-r--r--src/transport/transport_api_cmd_connecting_peers.c55
10 files changed, 195 insertions, 43 deletions
diff --git a/src/include/gnunet_testing_ng_lib.h b/src/include/gnunet_testing_ng_lib.h
index 5011aefd8..c9f5e3e00 100644
--- a/src/include/gnunet_testing_ng_lib.h
+++ b/src/include/gnunet_testing_ng_lib.h
@@ -231,6 +231,20 @@ GNUNET_TESTING_interpreter_lookup_command (
/**
+ * Lookup command by label.
+ * All commands, first into the past, then into the furture are looked up.
+ *
+ * @param is interpreter to lookup command in
+ * @param label label of the command to lookup.
+ * @return the command, if it is found, or NULL.
+ */
+const struct GNUNET_TESTING_Command *
+GNUNET_TESTING_interpreter_lookup_command_all (
+ struct GNUNET_TESTING_Interpreter *is,
+ const char *label);
+
+
+/**
* Obtain label of the command being now run.
*
* @param is interpreter state.
diff --git a/src/testing/testing.c b/src/testing/testing.c
index 9e664292b..7474d9b5f 100644
--- a/src/testing/testing.c
+++ b/src/testing/testing.c
@@ -2312,10 +2312,14 @@ GNUNET_TESTING_get_address (struct GNUNET_TESTING_NodeConnection *connection,
{
template = KNOWN_CONNECT_ADDRESS_TEMPLATE;
}
- else
+ else if (1 == connection->node_n)
{
template = ROUTER_CONNECT_ADDRESS_TEMPLATE;
}
+ else
+ {
+ return NULL;
+ }
if (0 == strcmp (PREFIX_TCP, prefix))
{
diff --git a/src/testing/testing_api_loop.c b/src/testing/testing_api_loop.c
index e82ec33ab..290311c59 100644
--- a/src/testing/testing_api_loop.c
+++ b/src/testing/testing_api_loop.c
@@ -192,6 +192,28 @@ GNUNET_TESTING_interpreter_lookup_command (
/**
+ * Lookup command by label.
+ * All commands, first into the past, then into the furture are looked up.
+ *
+ * @param is interpreter to lookup command in
+ * @param label label of the command to lookup.
+ * @return the command, if it is found, or NULL.
+ */
+const struct GNUNET_TESTING_Command *
+GNUNET_TESTING_interpreter_lookup_command_all (
+ struct GNUNET_TESTING_Interpreter *is,
+ const char *label)
+{
+ const struct GNUNET_TESTING_Command *cmd;
+
+ cmd = get_command (is, label, GNUNET_NO);
+ if (NULL == cmd)
+ cmd = get_command (is, label, GNUNET_YES);
+ return cmd;
+}
+
+
+/**
* Finish the test run, return the final result.
*
* @param cls the `struct GNUNET_TESTING_Interpreter`
diff --git a/src/transport/gnunet-communicator-tcp.c b/src/transport/gnunet-communicator-tcp.c
index 6f7e67d7b..2a5e33e2b 100644
--- a/src/transport/gnunet-communicator-tcp.c
+++ b/src/transport/gnunet-communicator-tcp.c
@@ -2556,11 +2556,17 @@ handshake_monotime_cb (void *cls,
handshake_monotonic_time = &queue->handshake_monotonic_time;
pid = &queue->target;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "tcp handshake with us %s\n",
+ GNUNET_i2s (&my_identity));
if (NULL == record)
{
queue->handshake_monotime_get = NULL;
return;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "tcp handshake from peer %s\n",
+ GNUNET_i2s (pid));
if (sizeof(*mtbe) != record->value_size)
{
GNUNET_break (0);
@@ -2610,6 +2616,7 @@ decrypt_and_check_tc (struct Queue *queue,
char *ibuf)
{
struct TcpHandshakeSignature ths;
+ enum GNUNET_GenericReturnValue ret;
GNUNET_assert (
0 ==
@@ -2625,18 +2632,20 @@ decrypt_and_check_tc (struct Queue *queue,
memcpy (&ths.ephemeral, ibuf, sizeof(struct GNUNET_CRYPTO_EcdhePublicKey));
ths.monotonic_time = tc->monotonic_time;
ths.challenge = tc->challenge;
- queue->handshake_monotime_get =
- GNUNET_PEERSTORE_iterate (peerstore,
- "transport_tcp_communicator",
- &queue->target,
- GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE,
- &handshake_monotime_cb,
- queue);
- return GNUNET_CRYPTO_eddsa_verify (
+ ret = GNUNET_CRYPTO_eddsa_verify (
GNUNET_SIGNATURE_COMMUNICATOR_TCP_HANDSHAKE,
&ths,
&tc->sender_sig,
&tc->sender.public_key);
+ if (GNUNET_YES == ret)
+ queue->handshake_monotime_get =
+ GNUNET_PEERSTORE_iterate (peerstore,
+ "transport_tcp_communicator",
+ &queue->target,
+ GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE,
+ &handshake_monotime_cb,
+ queue);
+ return ret;
}
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c
index 4483536f0..f67bc0db5 100644
--- a/src/transport/gnunet-service-tng.c
+++ b/src/transport/gnunet-service-tng.c
@@ -5381,7 +5381,7 @@ handle_raw_message (void *cls, const struct GNUNET_MessageHeader *mh)
int have_core;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Handling message of type %u with %u bytes\n",
+ "Handling raw message of type %u with %u bytes\n",
(unsigned int) ntohs (mh->type),
(unsigned int) ntohs (mh->size));
@@ -6633,11 +6633,10 @@ forward_dv_learn (const struct GNUNET_PeerIdentity *next_hop,
struct DvHopPS dhp = {
.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_TRANSPORT_DV_HOP),
.purpose.size = htonl (sizeof(dhp)),
- .pred = dhops[nhops - 1].hop,
+ .pred = (0 == nhops) ? msg->initiator : dhops[nhops - 1].hop,
.succ = *next_hop,
.challenge = msg->challenge
};
-
GNUNET_CRYPTO_eddsa_sign (GST_my_private_key,
&dhp,
&dhops[nhops].hop_sig);
@@ -6940,7 +6939,14 @@ handle_dv_learn (void *cls, const struct TransportDVLearnMessage *dvl)
struct GNUNET_TIME_Absolute in_time;
struct Neighbour *n;
- nhops = ntohs (dvl->bidirectional); /* 0 = sender is initiator */
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "handle dv learn message from %s\n",
+ GNUNET_i2s (&dvl->initiator));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "handle dv learn message sender %s\n",
+ GNUNET_i2s (&cmc->im.sender));
+
+ nhops = ntohs (dvl->num_hops); /* 0 = sender is initiator */
bi_history = ntohs (dvl->bidirectional);
hops = (const struct DVPathEntryP *) &dvl[1];
if (0 == nhops)
@@ -6955,6 +6961,9 @@ handle_dv_learn (void *cls, const struct TransportDVLearnMessage *dvl)
}
else
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "handle dv learn message last hop %s\n",
+ GNUNET_i2s (&hops[nhops - 1].hop));
/* sanity check */
if (0 != GNUNET_memcmp (&hops[nhops - 1].hop, &cmc->im.sender))
{
@@ -6970,6 +6979,10 @@ handle_dv_learn (void *cls, const struct TransportDVLearnMessage *dvl)
cc); // FIXME: add bi-directional flag to cc?
in_time = GNUNET_TIME_absolute_get ();
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "2 handle dv learn message from %s\n",
+ GNUNET_i2s (&dvl->initiator));
+
/* continue communicator here, everything else can happen asynchronous! */
finish_cmc_handling (cmc);
@@ -6980,6 +6993,9 @@ handle_dv_learn (void *cls, const struct TransportDVLearnMessage *dvl)
(GNUNET_TIME_absolute_ntoh (dvl->monotonic_time).abs_value_us <
n->last_dv_learn_monotime.abs_value_us))
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "DV learn from %s discarded due to time travel",
+ GNUNET_i2s (&dvl->initiator));
GNUNET_STATISTICS_update (GST_stats,
"# DV learn discarded due to time travel",
1,
@@ -6991,6 +7007,9 @@ handle_dv_learn (void *cls, const struct TransportDVLearnMessage *dvl)
&dvl->challenge,
&dvl->init_sig))
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "DV learn signature from %s invalid",
+ GNUNET_i2s (&dvl->initiator));
GNUNET_break_op (0);
return;
}
@@ -7012,6 +7031,9 @@ handle_dv_learn (void *cls, const struct TransportDVLearnMessage *dvl)
n);
}
}
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "3 handle dv learn message from %s\n",
+ GNUNET_i2s (&dvl->initiator));
/* OPTIMIZE-FIXME: asynchronously (!) verify signatures!,
If signature verification load too high, implement random drop strategy */
for (unsigned int i = 0; i < nhops; i++)
@@ -7030,11 +7052,29 @@ handle_dv_learn (void *cls, const struct TransportDVLearnMessage *dvl)
&hops[i].hop_sig,
&hops[i].hop.public_key))
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "DV learn from %s signature of hop %u invalid\n",
+ GNUNET_i2s (&dvl->initiator),
+ i);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "signature of hop %s invalid\n",
+ GNUNET_i2s (&hops[i].hop));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "pred %s\n",
+ GNUNET_i2s (&dhp.pred));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "succ %s\n",
+ GNUNET_i2s (&dhp.succ));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "hash %s\n",
+ GNUNET_sh2s (&dhp.challenge.value));
GNUNET_break_op (0);
return;
}
}
-
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "4 handle dv learn message from %s\n",
+ GNUNET_i2s (&dvl->initiator));
if (GNUNET_EXTRA_LOGGING > 0)
{
char *path;
@@ -7059,7 +7099,9 @@ handle_dv_learn (void *cls, const struct TransportDVLearnMessage *dvl)
GNUNET_i2s (&GST_my_identity));
GNUNET_free (path);
}
-
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "5 handle dv learn message from %s\n",
+ GNUNET_i2s (&dvl->initiator));
do_fwd = GNUNET_YES;
if (0 == GNUNET_memcmp (&GST_my_identity, &dvl->initiator))
{
@@ -7104,6 +7146,9 @@ handle_dv_learn (void *cls, const struct TransportDVLearnMessage *dvl)
do_fwd = GNUNET_NO;
return;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "6 handle dv learn message from %s\n",
+ GNUNET_i2s (&dvl->initiator));
if (bi_hop)
{
/* last hop was bi-directional, we could learn something here! */
@@ -7160,13 +7205,18 @@ handle_dv_learn (void *cls, const struct TransportDVLearnMessage *dvl)
}
}
}
-
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "7 handle dv learn message from %s\n",
+ GNUNET_i2s (&dvl->initiator));
if (MAX_DV_HOPS_ALLOWED == nhops)
{
/* At limit, we're out of here! */
return;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "8 handle dv learn message from %s\n",
+ GNUNET_i2s (&dvl->initiator));
/* Forward to initiator, if path non-trivial and possible */
bi_history = (bi_history << 1) | (bi_hop ? 1 : 0);
did_initiator = GNUNET_NO;
@@ -7220,6 +7270,9 @@ handle_dv_learn (void *cls, const struct TransportDVLearnMessage *dvl)
&dv_neighbour_transmission,
&nsc);
}
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "9 handle dv learn message from %s\n",
+ GNUNET_i2s (&dvl->initiator));
}
diff --git a/src/transport/test_transport_plugin_cmd_simple_send.c b/src/transport/test_transport_plugin_cmd_simple_send.c
index 476fbdf4f..6a6861d77 100644
--- a/src/transport/test_transport_plugin_cmd_simple_send.c
+++ b/src/transport/test_transport_plugin_cmd_simple_send.c
@@ -255,7 +255,8 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
"start-peer",
"system-create",
num,
- topology);
+ topology,
+ 0);
local_prepared = GNUNET_TESTING_cmd_local_test_prepared (
"local-test-prepared",
write_message);
diff --git a/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c b/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c
index e2757671b..526f08e6a 100644
--- a/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c
+++ b/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c
@@ -117,6 +117,8 @@ all_peers_started ()
{
struct GNUNET_TESTING_AsyncContext *ac;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received message\n");
GNUNET_TESTING_get_trait_async_context (&block_send,
&ac);
GNUNET_assert (NULL != ac);
diff --git a/src/transport/test_transport_plugin_cmd_udp_backchannel.c b/src/transport/test_transport_plugin_cmd_udp_backchannel.c
index c98a3075d..b594049c9 100644
--- a/src/transport/test_transport_plugin_cmd_udp_backchannel.c
+++ b/src/transport/test_transport_plugin_cmd_udp_backchannel.c
@@ -242,7 +242,8 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
"start-peer",
"system-create",
num,
- topology);
+ topology,
+ 0);
local_prepared = GNUNET_TESTING_cmd_local_test_prepared (
"local-test-prepared",
write_message);
diff --git a/src/transport/transport-testing-cmds.h b/src/transport/transport-testing-cmds.h
index d2e49c0d3..d64279aeb 100644
--- a/src/transport/transport-testing-cmds.h
+++ b/src/transport/transport-testing-cmds.h
@@ -82,6 +82,21 @@ struct ConnectPeersState
* Number of connections.
*/
unsigned int con_num;
+
+ /**
+ * Number of additional connects this cmd will wait for not triggered by this cmd.
+ */
+ unsigned int additional_connects;
+
+ /**
+ * Number of connections we already have a notification for.
+ */
+ unsigned int con_num_notified;
+
+ /**
+ * Number of additional connects this cmd will wait for not triggered by this cmd we already have a notification for.
+ */
+ unsigned int additional_connects_notified;
};
struct StartPeerState
@@ -227,13 +242,25 @@ GNUNET_TRANSPORT_cmd_stop_peer (const char *label,
const char *start_label);
+/**
+ * Create command
+ *
+ * @param label name for command
+ * @param start_peer_label Label of the cmd to start a peer.
+ * @param create_peer_label Label of the cmd which started the test system.
+ * @param num Number globally identifying the node.
+ * @param The topology for the test setup.
+ * @param additional_connects Number of additional connects this cmd will wait for not triggered by this cmd.
+ * @return command.
+ */
struct GNUNET_TESTING_Command
-GNUNET_TRANSPORT_cmd_connect_peers (const char *label,
- const char *start_peer_label,
- const char *create_label,
- uint32_t num,
- struct GNUNET_TESTING_NetjailTopology *
- topology);
+GNUNET_TRANSPORT_cmd_connect_peers (
+ const char *label,
+ const char *start_peer_label,
+ const char *create_label,
+ uint32_t num,
+ struct GNUNET_TESTING_NetjailTopology *topology,
+ unsigned int additional_connects);
/**
@@ -241,7 +268,7 @@ GNUNET_TRANSPORT_cmd_connect_peers (const char *label,
*
* @param label name for command.
* @param start_peer_label Label of the cmd to start a peer.
- * @param start_peer_label Label of the cmd which started the test system.
+ * @param create_peer_label Label of the cmd which started the test system.
* @param num Number globally identifying the node.
* @param The topology for the test setup.
* @return command.
diff --git a/src/transport/transport_api_cmd_connecting_peers.c b/src/transport/transport_api_cmd_connecting_peers.c
index 3fef7d687..33faee296 100644
--- a/src/transport/transport_api_cmd_connecting_peers.c
+++ b/src/transport/transport_api_cmd_connecting_peers.c
@@ -91,17 +91,20 @@ connect_peers_run (void *cls,
{
addr = GNUNET_TESTING_get_address (pos_connection,
pos_prefix->address_prefix);
- peer = GNUNET_TESTING_get_pub_key (num, tl_system);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "validating peer number %u with identity %s\n",
- num,
- GNUNET_i2s (peer));
- GNUNET_TRANSPORT_application_validate (ah,
- peer,
- nt,
- addr);
- GNUNET_free (peer);
- GNUNET_free (addr);
+ if (NULL != addr)
+ {
+ peer = GNUNET_TESTING_get_pub_key (num, tl_system);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "validating peer number %u with identity %s\n",
+ num,
+ GNUNET_i2s (peer));
+ GNUNET_TRANSPORT_application_validate (ah,
+ peer,
+ nt,
+ addr);
+ GNUNET_free (peer);
+ GNUNET_free (addr);
+ }
}
}
cps->con_num = con_num;
@@ -119,14 +122,15 @@ notify_connect (struct GNUNET_TESTING_Interpreter *is,
const struct GNUNET_TESTING_Command *cmd;
struct ConnectPeersState *cps;
struct GNUNET_PeerIdentity *peer_connection;
- unsigned int con_num = 0;
struct GNUNET_TESTING_NodeConnection *pos_connection;
unsigned int num;
+ unsigned int con_num;
void *ret = NULL;
- cmd = GNUNET_TESTING_interpreter_lookup_command (is,
- "connect-peers");
+ cmd = GNUNET_TESTING_interpreter_lookup_command_all (is,
+ "connect-peers");
cps = cmd->cls;
+ con_num = cps->con_num;
for (pos_connection = cps->node_connections_head; NULL != pos_connection;
pos_connection = pos_connection->next)
{
@@ -134,12 +138,14 @@ notify_connect (struct GNUNET_TESTING_Interpreter *is,
peer_connection = GNUNET_TESTING_get_pub_key (num, cps->tl_system);
if (0 == GNUNET_memcmp (peer,
peer_connection))
- con_num++;
+ cps->con_num_notified++;
GNUNET_free (peer_connection);
}
-
-
if (cps->con_num == con_num)
+ cps->additional_connects_notified++;
+
+ if (cps->con_num + cps->additional_connects == cps->con_num_notified
+ + cps->additional_connects_notified)
{
GNUNET_TESTING_async_finish (&cps->ac);
}
@@ -205,13 +211,25 @@ GNUNET_TRANSPORT_get_trait_connect_peer_state (
}
+/**
+ * Create command
+ *
+ * @param label name for command
+ * @param start_peer_label Label of the cmd to start a peer.
+ * @param create_peer_label Label of the cmd which started the test system.
+ * @param num Number globally identifying the node.
+ * @param The topology for the test setup.
+ * @param additional_connects Number of additional connects this cmd will wait for not triggered by this cmd.
+ * @return command.
+ */
struct GNUNET_TESTING_Command
GNUNET_TRANSPORT_cmd_connect_peers (const char *label,
const char *start_peer_label,
const char *create_label,
uint32_t num,
struct GNUNET_TESTING_NetjailTopology *
- topology)
+ topology,
+ unsigned int additional_connects)
{
struct ConnectPeersState *cps;
@@ -221,6 +239,7 @@ GNUNET_TRANSPORT_cmd_connect_peers (const char *label,
cps->create_label = create_label;
cps->topology = topology;
cps->notify_connect = notify_connect;
+ cps->additional_connects = additional_connects;
{
struct GNUNET_TESTING_Command cmd = {