From 64c18a74e38a1cb74042d14a4211622a3bde3bee Mon Sep 17 00:00:00 2001 From: Martin Schanzenbach Date: Tue, 23 Feb 2021 22:30:15 +0100 Subject: -flurry of bugfixes for tng service --- src/transport/Makefile.am | 2 +- src/transport/gnunet-service-tng.c | 97 +++++++++++++++++------- src/transport/test_transport_api2_tcp_peer1.conf | 1 + src/transport/test_transport_api2_tcp_peer2.conf | 1 + src/transport/test_transport_api_tcp_peer1.conf | 2 + src/transport/test_transport_api_tcp_peer2.conf | 2 + src/transport/transport-testing2.c | 2 +- 7 files changed, 79 insertions(+), 28 deletions(-) (limited to 'src/transport') diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am index 67b35365d..a1ffbdb5c 100644 --- a/src/transport/Makefile.am +++ b/src/transport/Makefile.am @@ -954,7 +954,7 @@ test_transport_api_tcp_LDADD = \ libgnunettransporttesting.la test_transport_api2_tcp_SOURCES = \ - test_transport_api.c + test_transport_api2.c test_transport_api2_tcp_LDADD = \ libgnunettransport.la \ $(top_builddir)/src/hello/libgnunethello.la \ diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c index 9c37f15e2..7e1953663 100644 --- a/src/transport/gnunet-service-tng.c +++ b/src/transport/gnunet-service-tng.c @@ -2693,12 +2693,12 @@ static struct GNUNET_CONTAINER_MultiShortmap *dvlearn_map; /** * Head of a DLL sorted by launch time. */ -static struct LearnLaunchEntry *lle_head; +static struct LearnLaunchEntry *lle_head = NULL; /** * Tail of a DLL sorted by launch time. */ -static struct LearnLaunchEntry *lle_tail; +static struct LearnLaunchEntry *lle_tail = NULL; /** * MIN Heap sorted by "next_challenge" to `struct ValidationState` entries @@ -3497,13 +3497,17 @@ check_link_down (void *cls) vl->visibility_task = NULL; dvh_timeout = GNUNET_TIME_UNIT_ZERO_ABS; - for (struct DistanceVectorHop *pos = dv->dv_head; NULL != pos; - pos = pos->next_dv) - dvh_timeout = GNUNET_TIME_absolute_max (dvh_timeout, pos->path_valid_until); - if (0 == GNUNET_TIME_absolute_get_remaining (dvh_timeout).rel_value_us) + if (NULL != dv) { - vl->dv->vl = NULL; - vl->dv = NULL; + for (struct DistanceVectorHop *pos = dv->dv_head; NULL != pos; + pos = pos->next_dv) + dvh_timeout = GNUNET_TIME_absolute_max (dvh_timeout, + pos->path_valid_until); + if (0 == GNUNET_TIME_absolute_get_remaining (dvh_timeout).rel_value_us) + { + vl->dv->vl = NULL; + vl->dv = NULL; + } } q_timeout = GNUNET_TIME_UNIT_ZERO_ABS; for (struct Queue *q = n->queue_head; NULL != q; q = q->next_neighbour) @@ -4702,6 +4706,24 @@ route_control_message_without_fc (const struct GNUNET_PeerIdentity *target, } +static void +consider_sending_fc (void *cls); + +/** + * Something changed on the virtual link with respect to flow + * control. Consider retransmitting the FC window size. + * + * @param cls a `struct VirtualLink` to work with + */ +static void +task_consider_sending_fc (void *cls) +{ + struct VirtualLink *vl = cls; + vl->fc_retransmit_task = NULL; + consider_sending_fc (cls); +} + + /** * Something changed on the virtual link with respect to flow * control. Consider retransmitting the FC window size. @@ -4759,7 +4781,7 @@ consider_sending_fc (void *cls) if (NULL != vl->fc_retransmit_task) GNUNET_SCHEDULER_cancel (vl->fc_retransmit_task); vl->fc_retransmit_task = - GNUNET_SCHEDULER_add_delayed (rtt, &consider_sending_fc, vl); + GNUNET_SCHEDULER_add_delayed (rtt, &task_consider_sending_fc, vl); } @@ -7637,7 +7659,7 @@ start_address_validation (const struct GNUNET_PeerIdentity *pid, validation_map, &vs->pid, vs, - GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); + GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); update_next_challenge_time (vs, now); } @@ -7674,6 +7696,8 @@ handle_hello_for_incoming (void *cls, } + + /** * Communicator gave us a transport address validation challenge. Process the * request. @@ -7730,12 +7754,22 @@ handle_validation_challenge ( &tvp, &tvr.signature); } - route_control_message_without_fc (&cmc->im.sender, - &tvr.header, - RMO_ANYTHING_GOES | RMO_REDUNDANT); sender = cmc->im.sender; - finish_cmc_handling (cmc); vl = lookup_virtual_link (&sender); + if (NULL != vl) + { + route_control_message_without_fc (&cmc->im.sender, + &tvr.header, + RMO_ANYTHING_GOES | RMO_REDUNDANT); + } else { + /* Use route via neighbour */ + n = lookup_neighbour (&sender); + if (NULL != n) + for (struct Queue *q = n->queue_head; NULL != q; q = q->next_neighbour) + queue_send_msg (q, NULL, &tvr, sizeof(tvr)); + } + + finish_cmc_handling (cmc); if (NULL != vl) return; @@ -8149,41 +8183,41 @@ demultiplex_with_cmc (struct CommunicatorMessageContext *cmc, { GNUNET_MQ_hd_var_size (fragment_box, GNUNET_MESSAGE_TYPE_TRANSPORT_FRAGMENT, struct TransportFragmentBoxMessage, - &cmc), + cmc), GNUNET_MQ_hd_var_size (reliability_box, GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_BOX, struct TransportReliabilityBoxMessage, - &cmc), + cmc), GNUNET_MQ_hd_var_size (reliability_ack, GNUNET_MESSAGE_TYPE_TRANSPORT_RELIABILITY_ACK, struct TransportReliabilityAckMessage, - &cmc), + cmc), GNUNET_MQ_hd_var_size (backchannel_encapsulation, GNUNET_MESSAGE_TYPE_TRANSPORT_BACKCHANNEL_ENCAPSULATION, struct TransportBackchannelEncapsulationMessage, - &cmc), + cmc), GNUNET_MQ_hd_var_size (dv_learn, GNUNET_MESSAGE_TYPE_TRANSPORT_DV_LEARN, struct TransportDVLearnMessage, - &cmc), + cmc), GNUNET_MQ_hd_var_size (dv_box, GNUNET_MESSAGE_TYPE_TRANSPORT_DV_BOX, struct TransportDVBoxMessage, - &cmc), + cmc), GNUNET_MQ_hd_fixed_size ( validation_challenge, GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_CHALLENGE, struct TransportValidationChallengeMessage, - &cmc), + cmc), GNUNET_MQ_hd_fixed_size (flow_control, GNUNET_MESSAGE_TYPE_TRANSPORT_FLOW_CONTROL, struct TransportFlowControlMessage, - &cmc), + cmc), GNUNET_MQ_hd_fixed_size ( validation_response, GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_VALIDATION_RESPONSE, struct TransportValidationResponseMessage, - &cmc), + cmc), GNUNET_MQ_handler_end () }; int ret; @@ -8202,7 +8236,7 @@ demultiplex_with_cmc (struct CommunicatorMessageContext *cmc, if (GNUNET_NO == ret) { /* unencapsulated 'raw' message */ - handle_raw_message (&cmc, msg); + handle_raw_message (cmc, msg); } } @@ -8949,20 +8983,30 @@ handle_send_message_ack (void *cls, /* find our queue entry matching the ACK */ qe = NULL; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Looking for queue for PID %s\n", + GNUNET_i2s (&sma->receiver)); for (struct Queue *queue = tc->details.communicator.queue_head; NULL != queue; queue = queue->next_client) { if (0 != GNUNET_memcmp (&queue->neighbour->pid, &sma->receiver)) continue; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Found PID %s\n", + GNUNET_i2s (&queue->neighbour->pid)); + + for (struct QueueEntry *qep = queue->queue_head; NULL != qep; qep = qep->next) { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "QueueEntry MID: %lu, Ack MID: %lu\n", + qep->mid, sma->mid); if (qep->mid != sma->mid) continue; qe = qep; break; } - break; } if (NULL == qe) { @@ -9333,6 +9377,7 @@ start_dv_learn (void *cls) return; /* lost all connectivity, cannot do learning */ qqc.quality_count = 0; qqc.num_queues = 0; + qqc.k = GNUNET_CONTAINER_multipeermap_size (neighbours); GNUNET_CONTAINER_multipeermap_iterate (neighbours, &check_connection_quality, &qqc); @@ -9352,7 +9397,7 @@ start_dv_learn (void *cls) return; } /* remove old entries in #dvlearn_map if it has grown too big */ - while (MAX_DV_LEARN_PENDING >= + while (MAX_DV_LEARN_PENDING <= GNUNET_CONTAINER_multishortmap_size (dvlearn_map)) { lle = lle_tail; diff --git a/src/transport/test_transport_api2_tcp_peer1.conf b/src/transport/test_transport_api2_tcp_peer1.conf index 5b5fcb55b..36e00c00f 100644 --- a/src/transport/test_transport_api2_tcp_peer1.conf +++ b/src/transport/test_transport_api2_tcp_peer1.conf @@ -5,6 +5,7 @@ GNUNET_TEST_HOME = $GNUNET_TMP/test-transport/api-tcp-p1/ [transport] BINARY = gnunet-service-tng PLUGINS = tcp +PREFIX = valgrind --log-file=/tmp/vg_peer1-%p [communicator-tcp] BINARY = gnunet-communicator-tcp diff --git a/src/transport/test_transport_api2_tcp_peer2.conf b/src/transport/test_transport_api2_tcp_peer2.conf index 42d7c7b7e..f4de8df8b 100644 --- a/src/transport/test_transport_api2_tcp_peer2.conf +++ b/src/transport/test_transport_api2_tcp_peer2.conf @@ -4,6 +4,7 @@ GNUNET_TEST_HOME = $GNUNET_TMP/test-transport/api-tcp-p2/ [transport] BINARY = gnunet-service-tng +PREFIX = valgrind --log-file=/tmp/vg_peer2-%p [communicator-tcp] BINARY = gnunet-communicator-tcp diff --git a/src/transport/test_transport_api_tcp_peer1.conf b/src/transport/test_transport_api_tcp_peer1.conf index eabd6b701..1a46cf227 100644 --- a/src/transport/test_transport_api_tcp_peer1.conf +++ b/src/transport/test_transport_api_tcp_peer1.conf @@ -4,6 +4,8 @@ GNUNET_TEST_HOME = $GNUNET_TMP/test-transport/api-tcp-p1/ [transport] PLUGINS = tcp +PREFIX = valgrind --log-file=/tmp/vg_peer1 +START_ON_DEMAND = NO #[transport] #PREFIX = valgrind diff --git a/src/transport/test_transport_api_tcp_peer2.conf b/src/transport/test_transport_api_tcp_peer2.conf index 58ce0777f..934fe460f 100644 --- a/src/transport/test_transport_api_tcp_peer2.conf +++ b/src/transport/test_transport_api_tcp_peer2.conf @@ -4,6 +4,8 @@ GNUNET_TEST_HOME = $GNUNET_TMP/test-transport/api-tcp-p2/ [transport] PLUGINS = tcp +PREFIX = valgrind --log-file=/tmp/vg_peer2 +START_ON_DEMAND = NO #[transport] #PREFIX = valgrind diff --git a/src/transport/transport-testing2.c b/src/transport/transport-testing2.c index d9f1d5e56..23173e763 100644 --- a/src/transport/transport-testing2.c +++ b/src/transport/transport-testing2.c @@ -536,7 +536,7 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct p->ah = GNUNET_TRANSPORT_application_init (p->cfg); GNUNET_assert (NULL != p->ah); // FIXME Error handleing - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10), retrieve_hello, p); //GNUNET_assert (NULL != p->pic); -- cgit v1.2.3