summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authort3sserakt <t3ss@posteo.de>2021-01-05 13:19:57 +0100
committert3sserakt <t3ss@posteo.de>2021-01-05 13:19:57 +0100
commit5affc9ad078e8d90c47a2972d67cd9d65529792d (patch)
treefe02ace1af4d386044c64ddbb78ad6db0d791d09 /src
parent561596641606ecc0b5f71658c34eab1312ad8f18 (diff)
- started making tng communicator test code more resilient
Diffstat (limited to 'src')
-rw-r--r--src/transport/gnunet-communicator-tcp.c111
-rw-r--r--src/transport/test_communicator_basic.c46
-rw-r--r--src/transport/test_communicator_tcp_basic_peer1.conf2
-rw-r--r--src/transport/test_communicator_tcp_basic_peer2.conf2
-rw-r--r--src/transport/test_communicator_tcp_rekey_peer2.conf2
-rw-r--r--src/transport/transport-testing-communicator.c1
6 files changed, 116 insertions, 48 deletions
diff --git a/src/transport/gnunet-communicator-tcp.c b/src/transport/gnunet-communicator-tcp.c
index 59f42496a..0c79fc1b4 100644
--- a/src/transport/gnunet-communicator-tcp.c
+++ b/src/transport/gnunet-communicator-tcp.c
@@ -541,6 +541,11 @@ struct Queue
enum GNUNET_NetworkType nt;
/**
+ * The connection status of this queue.
+ */
+ enum GNUNET_TRANSPORT_ConnectionStatus cs;
+
+ /**
* Is MQ awaiting a #GNUNET_MQ_impl_send_continue() call?
*/
int mq_awaits_continue;
@@ -828,7 +833,8 @@ int addrs_lens;
/**
* Size of data received without KX challenge played back.
*/
-size_t unverified_size;
+// TODO remove?
+// size_t unverified_size;
/**
* Database for peer's HELLOs.
@@ -1434,6 +1440,9 @@ try_handle_plaintext (struct Queue *queue)
struct TcpHandshakeAckSignature thas;
const struct ChallengeNonceP challenge = queue->challenge;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "try handle plaintext!\n");
+
if ((sizeof(*hdr) > queue->pread_off))
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1441,16 +1450,16 @@ try_handle_plaintext (struct Queue *queue)
return 0; /* not even a header */
}
- if ((-1 != unverified_size) && (unverified_size > INITIAL_CORE_KX_SIZE))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Already received data of size %lu bigger than KX size %lu!\n",
- unverified_size,
- INITIAL_CORE_KX_SIZE);
- GNUNET_break_op (0);
- queue_finish (queue);
- return 0;
- }
+ /* if ((-1 != unverified_size) && (unverified_size > INITIAL_CORE_KX_SIZE)) */
+ /* { */
+ /* GNUNET_log (GNUNET_ERROR_TYPE_ERROR, */
+ /* "Already received data of size %lu bigger than KX size %lu!\n", */
+ /* unverified_size, */
+ /* INITIAL_CORE_KX_SIZE); */
+ /* GNUNET_break_op (0); */
+ /* queue_finish (queue); */
+ /* return 0; */
+ /* } */
type = ntohs (hdr->type);
switch (type)
@@ -1513,7 +1522,41 @@ try_handle_plaintext (struct Queue *queue)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Handling plaintext, ack processed!");
- unverified_size = -1;
+ // unverified_size = -1;
+
+ /* char *foreign_addr; */
+
+ /* switch (queue->address->sa_family) */
+ /* { */
+ /* case AF_INET: */
+ /* GNUNET_asprintf (&foreign_addr, */
+ /* "%s-%s", */
+ /* COMMUNICATOR_ADDRESS_PREFIX, */
+ /* GNUNET_a2s (queue->address, queue->address_len)); */
+ /* break; */
+
+ /* case AF_INET6: */
+ /* GNUNET_asprintf (&foreign_addr, */
+ /* "%s-%s", */
+ /* COMMUNICATOR_ADDRESS_PREFIX, */
+ /* GNUNET_a2s (queue->address, queue->address_len)); */
+ /* break; */
+
+ /* default: */
+ /* GNUNET_assert (0); */
+ /* } */
+
+ /* queue->qh = GNUNET_TRANSPORT_communicator_mq_add (ch, */
+ /* &queue->target, */
+ /* foreign_addr, */
+ /* 0 /\* no MTU *\/, */
+ /* GNUNET_TRANSPORT_QUEUE_LENGTH_UNLIMITED, */
+ /* 0, /\* Priority *\/ */
+ /* queue->nt, */
+ /* queue->cs, */
+ /* queue->mq); */
+
+ /* GNUNET_free (foreign_addr); */
size = ntohs (hdr->size);
break;
@@ -1590,8 +1633,8 @@ try_handle_plaintext (struct Queue *queue)
return 0;
}
GNUNET_assert (0 != size);
- if (-1 != unverified_size)
- unverified_size += size;
+ /* if (-1 != unverified_size) */
+ /* unverified_size += size; */
return size;
}
@@ -2139,11 +2182,12 @@ queue_write (void *cls)
queue->cwrite_off += queue->pwrite_off;
queue->pwrite_off = 0;
}
- if ((-1 != unverified_size)&& ((0 == queue->pwrite_off) &&
- ((0 == queue->rekey_left_bytes) ||
- (0 ==
- GNUNET_TIME_absolute_get_remaining (
- queue->rekey_time).rel_value_us))))
+ // if ((-1 != unverified_size)&& ((0 == queue->pwrite_off) &&
+ if (((0 == queue->pwrite_off) &&
+ ((0 == queue->rekey_left_bytes) ||
+ (0 ==
+ GNUNET_TIME_absolute_get_remaining (
+ queue->rekey_time).rel_value_us))))
{
inject_rekey (queue);
}
@@ -2282,7 +2326,7 @@ mq_error (void *cls, enum GNUNET_MQ_Error error)
* @param queue queue to boot
*/
static void
-boot_queue (struct Queue *queue, enum GNUNET_TRANSPORT_ConnectionStatus cs)
+boot_queue (struct Queue *queue)
{
queue->nt =
GNUNET_NT_scanner_get_type (is, queue->address, queue->address_len);
@@ -2333,7 +2377,7 @@ boot_queue (struct Queue *queue, enum GNUNET_TRANSPORT_ConnectionStatus cs)
GNUNET_TRANSPORT_QUEUE_LENGTH_UNLIMITED,
0, /* Priority */
queue->nt,
- cs,
+ queue->cs,
queue->mq);
GNUNET_free (foreign_addr);
}
@@ -2557,7 +2601,7 @@ free_proto_queue (struct ProtoQueue *pq)
* @param queue The queue context.
*/
static void
-send_challenge (struct TCPConfirmation tc, struct Queue *queue)
+send_challenge (struct ChallengeNonceP challenge, struct Queue *queue)
{
struct TCPConfirmationAck tca;
struct TcpHandshakeAckSignature thas;
@@ -2569,7 +2613,7 @@ send_challenge (struct TCPConfirmation tc, struct Queue *queue)
tca.header.type = ntohs (
GNUNET_MESSAGE_TYPE_COMMUNICATOR_TCP_CONFIRMATION_ACK);
tca.header.size = ntohs (sizeof(tca));
- tca.challenge = tc.challenge;
+ tca.challenge = challenge;
tca.sender = my_identity;
tca.monotonic_time =
GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get_monotonic (cfg));
@@ -2665,7 +2709,8 @@ proto_read_kx (void *cls)
"start kx proto\n");
start_initial_kx_out (queue);
- boot_queue (queue, GNUNET_TRANSPORT_CS_INBOUND);
+ queue->cs = GNUNET_TRANSPORT_CS_INBOUND;
+ boot_queue (queue);
queue->read_task =
GNUNET_SCHEDULER_add_read_net (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
queue->sock,
@@ -2676,7 +2721,8 @@ proto_read_kx (void *cls)
queue->sock,
&queue_write,
queue);
- send_challenge (tc, queue);
+ // TODO To early! Move it somewhere else.
+ // send_challenge (tc, queue);
GNUNET_CONTAINER_DLL_remove (proto_head, proto_tail, pq);
GNUNET_free (pq);
@@ -2762,7 +2808,9 @@ queue_read_kx (void *cls)
rcvd = GNUNET_NETWORK_socket_recv (queue->sock,
&queue->cread_buf[queue->cread_off],
BUF_SIZE - queue->cread_off);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received %lu bytes for KX\n", rcvd);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received %lu bytes for KX\n",
+ rcvd);
if (-1 == rcvd)
{
if ((EAGAIN != errno) && (EINTR != errno))
@@ -2804,14 +2852,20 @@ queue_read_kx (void *cls)
queue_destroy (queue);
return;
}
- send_challenge (tc, queue);
+ send_challenge (tc.challenge, queue);
/* update queue timeout */
reschedule_queue_timeout (queue);
/* prepare to continue with regular read task immediately */
memmove (queue->cread_buf,
&queue->cread_buf[INITIAL_KX_SIZE],
queue->cread_off - (INITIAL_KX_SIZE));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "cread_off is %lu bytes before adjusting\n",
+ queue->cread_off);
queue->cread_off -= INITIAL_KX_SIZE;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "cread_off set to %lu bytes\n",
+ queue->cread_off);
if (0 < queue->cread_off)
queue->read_task = GNUNET_SCHEDULER_add_now (&queue_read, queue);
}
@@ -2893,7 +2947,8 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity *peer, const char *address)
queue->address = in;
queue->address_len = in_len;
queue->sock = sock;
- boot_queue (queue, GNUNET_TRANSPORT_CS_OUTBOUND);
+ queue->cs = GNUNET_TRANSPORT_CS_OUTBOUND;
+ boot_queue (queue);
// queue->mq_awaits_continue = GNUNET_YES;
queue->read_task =
GNUNET_SCHEDULER_add_read_net (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
diff --git a/src/transport/test_communicator_basic.c b/src/transport/test_communicator_basic.c
index 10c942daa..0eeaecb6c 100644
--- a/src/transport/test_communicator_basic.c
+++ b/src/transport/test_communicator_basic.c
@@ -61,6 +61,8 @@ static char *cfg_peers_name[NUM_PEERS];
static int ret;
+static int bidirect = GNUNET_NO;
+
static size_t long_message_size;
static struct GNUNET_TIME_Absolute start_short;
@@ -71,6 +73,8 @@ static struct GNUNET_TIME_Absolute timeout;
static struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *my_tc;
+static char *communicator_name;
+
static char *test_name;
static struct GNUNET_STATISTICS_GetHandle *box_stats;
@@ -343,11 +347,8 @@ long_test_cb (void *cls)
payload = make_payload (long_message_size);
num_sent_long++;
GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc,
- ((BURST_PACKETS
- * 0.91 ==
- num_received_long) ||
- (BURST_PACKETS ==
- num_sent_long))
+ (BURST_PACKETS ==
+ num_sent_long)
? NULL
: &long_test,
NULL,
@@ -385,11 +386,8 @@ short_test_cb (void *cls)
payload = make_payload (SHORT_MESSAGE_SIZE);
num_sent_short++;
GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc,
- ((BURST_PACKETS
- * 0.91 ==
- num_received_short) ||
- (BURST_PACKETS ==
- num_sent_short))
+ (BURST_PACKETS ==
+ num_sent_short)
? NULL
: &short_test,
NULL,
@@ -625,7 +623,8 @@ incoming_message_cb (void *cls,
num_received_short++;
duration = GNUNET_TIME_absolute_get_duration (start_short);
update_avg_latency (payload);
- if (num_received_short == BURST_PACKETS * 0.91)
+ if ((num_sent_short == BURST_PACKETS) && (num_received_short >
+ BURST_PACKETS * 0.91) )
{
LOG (GNUNET_ERROR_TYPE_MESSAGE,
"Short size packet test done.\n");
@@ -647,6 +646,9 @@ incoming_message_cb (void *cls,
// num_sent_short = 0;
avg_latency = 0;
// num_received = 0;
+ /*LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Finished\n");
+ GNUNET_SCHEDULER_shutdown ();*/
long_test (NULL);
}
break;
@@ -662,7 +664,8 @@ incoming_message_cb (void *cls,
num_received_long++;
duration = GNUNET_TIME_absolute_get_duration (start_long);
update_avg_latency (payload);
- if (num_received_long == BURST_PACKETS * 0.91)
+ if ((num_sent_long == BURST_PACKETS) && (num_received_long > BURST_PACKETS
+ * 0.91) )
{
LOG (GNUNET_ERROR_TYPE_MESSAGE,
"Long size packet test done.\n");
@@ -723,8 +726,11 @@ incoming_message_cb (void *cls,
short_test (NULL);
break;
}
- if ((0 == strcmp ("rekey", test_name))||(0 == strcmp ("backchannel",
- test_name)) )
+ if ((0 == strcmp ("udp", communicator_name)) && ((0 == strcmp ("rekey",
+ test_name))
+ ||(0 == strcmp (
+ "backchannel",
+ test_name))) )
{
if (NULL != box_stats)
GNUNET_STATISTICS_get_cancel (box_stats);
@@ -810,12 +816,19 @@ run (void *cls)
&handle_backchannel_cb,
cfg_peers_name[i]); /* cls */
- if ((0 == strcmp ("rekey", test_name))||(0 == strcmp ("backchannel",
- test_name)) )
+ if ((0 == strcmp ("udp", communicator_name)) && ((0 == strcmp ("rekey",
+ test_name))||
+ (0 == strcmp (
+ "backchannel",
+ test_name))) )
{
stats[i] = GNUNET_STATISTICS_create ("C-UDP",
cfg_peers[i]);
}
+ else if ((0 == strcmp ("bidirect", test_name)))
+ {
+ bidirect = GNUNET_YES;
+ }
}
GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
NULL);
@@ -827,7 +840,6 @@ main (int argc,
char *const *argv)
{
struct GNUNET_CRYPTO_EddsaPrivateKey *private_key;
- char *communicator_name;
char *test_mode;
char *cfg_peer;
diff --git a/src/transport/test_communicator_tcp_basic_peer1.conf b/src/transport/test_communicator_tcp_basic_peer1.conf
index 2411f485b..b32aa1c17 100644
--- a/src/transport/test_communicator_tcp_basic_peer1.conf
+++ b/src/transport/test_communicator_tcp_basic_peer1.conf
@@ -33,7 +33,7 @@ UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_1.sock
#PREFIX = xterm -geometry 100x85 -T peer1 -e gdb --args
#PREFIX = valgrind --leak-check=full --track-origins=yes
BINDTO = 60002
-DISABLE_V6 = NO
+DISABLE_V6 = YES
[communicator-udp]
BINDTO = 60002
diff --git a/src/transport/test_communicator_tcp_basic_peer2.conf b/src/transport/test_communicator_tcp_basic_peer2.conf
index 8005718bf..b73157f0d 100644
--- a/src/transport/test_communicator_tcp_basic_peer2.conf
+++ b/src/transport/test_communicator_tcp_basic_peer2.conf
@@ -34,7 +34,7 @@ UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_2.sock
#PREFIX = xterm -geometry 100x85 -T peer2 -e gdb --args
#PREFIX = valgrind --leak-check=full --track-origins=yes
BINDTO = 60003
-DISABLE_V6 = NO
+DISABLE_V6 = YES
[communicator-udp]
BINDTO = 60003
diff --git a/src/transport/test_communicator_tcp_rekey_peer2.conf b/src/transport/test_communicator_tcp_rekey_peer2.conf
index 1036039c4..086a996ae 100644
--- a/src/transport/test_communicator_tcp_rekey_peer2.conf
+++ b/src/transport/test_communicator_tcp_rekey_peer2.conf
@@ -38,7 +38,7 @@ UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_2.sock
#PREFIX = xterm -geometry 100x85 -T peer2 -e gdb --args
#PREFIX = valgrind --leak-check=full --track-origins=yes
BINDTO = 60003
-DISABLE_V6 = NO
+DISABLE_V6 = YES
REKEY_INTERVAL = 100ms
[communicator-udp]
diff --git a/src/transport/transport-testing-communicator.c b/src/transport/transport-testing-communicator.c
index 56240864c..de356fb9c 100644
--- a/src/transport/transport-testing-communicator.c
+++ b/src/transport/transport-testing-communicator.c
@@ -317,6 +317,7 @@ handle_add_address (void *cls,
client->tc;
uint16_t size;
size = ntohs (msg->header.size) - sizeof(*msg);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "received add address cb %u\n", size);
if (0 == size)
return; /* receive-only communicator */
LOG (GNUNET_ERROR_TYPE_DEBUG, "received add address cb %u\n", size);