[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] branch master updated: -more tng service fixes
From: |
gnunet |
Subject: |
[gnunet] branch master updated: -more tng service fixes |
Date: |
Fri, 26 Feb 2021 10:37:11 +0100 |
This is an automated email from the git hooks/post-receive script.
martin-schanzenbach pushed a commit to branch master
in repository gnunet.
The following commit(s) were added to refs/heads/master by this push:
new 6edac715d -more tng service fixes
6edac715d is described below
commit 6edac715d38f2126ea7316373cfd27c3d76b05cf
Author: Martin Schanzenbach <mschanzenbach@posteo.de>
AuthorDate: Fri Feb 26 10:34:12 2021 +0100
-more tng service fixes
---
src/transport/gnunet-communicator-tcp.c | 42 +++++++++++++--
src/transport/gnunet-service-tng.c | 65 +++++++++++++++++++++++-
src/transport/test_transport_api2_tcp_peer1.conf | 2 +
src/transport/test_transport_api2_tcp_peer2.conf | 3 ++
src/transport/transport-testing2.c | 32 ++++++++----
src/transport/transport-testing2.h | 5 ++
6 files changed, 131 insertions(+), 18 deletions(-)
diff --git a/src/transport/gnunet-communicator-tcp.c
b/src/transport/gnunet-communicator-tcp.c
index 273dbac48..c8a4c0375 100644
--- a/src/transport/gnunet-communicator-tcp.c
+++ b/src/transport/gnunet-communicator-tcp.c
@@ -739,7 +739,6 @@ struct Addresses
};
-
/**
* Maximum queue length before we stop reading towards the transport service.
*/
@@ -953,6 +952,9 @@ queue_destroy (struct Queue *queue)
else
GNUNET_free (queue);
+ if (NULL == lt)
+ return;
+
if ((! shutdown_running) && (NULL == lt->listen_task))
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1193,6 +1195,7 @@ setup_cipher (const struct GNUNET_HashCode *dh,
0));
}
+
/**
* Callback called when peerstore store operation for rekey monotime value is
finished.
* @param cls Queue context the store operation was executed.
@@ -1210,6 +1213,7 @@ rekey_monotime_store_cb (void *cls, int success)
queue->rekey_monotime_sc = NULL;
}
+
/**
* Callback called by peerstore when records for
GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_REKEY
* where found.
@@ -1266,6 +1270,7 @@ rekey_monotime_cb (void *cls,
queue);
}
+
/**
* Setup cipher of @a queue for decryption.
*
@@ -1344,6 +1349,7 @@ do_rekey (struct Queue *queue, const struct TCPRekey
*rekey)
setup_in_cipher (&rekey->ephemeral, queue);
}
+
/**
* Callback called when peerstore store operation for handshake ack monotime
value is finished.
* @param cls Queue context the store operation was executed.
@@ -1362,6 +1368,7 @@ handshake_ack_monotime_store_cb (void *cls, int success)
queue->handshake_ack_monotime_sc = NULL;
}
+
/**
* Callback called by peerstore when records for
GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE_ACK
* where found.
@@ -1420,6 +1427,7 @@ handshake_ack_monotime_cb (void *cls,
queue);
}
+
/**
* Sending challenge with TcpConfirmationAck back to sender of ephemeral key.
*
@@ -1465,6 +1473,7 @@ send_challenge (struct ChallengeNonceP challenge, struct
Queue *queue)
"sending challenge done\n");
}
+
/**
* Setup cipher for outgoing data stream based on target and
* our ephemeral private key.
@@ -1545,6 +1554,7 @@ inject_rekey (struct Queue *queue)
setup_out_cipher (queue);
}
+
/**
* We have been notified that our socket is ready to write.
* Then reschedule this function to be called again once more is available.
@@ -1634,6 +1644,7 @@ queue_write (void *cls)
queue);
}
+
/**
* Test if we have received a full message in plaintext.
* If so, handle it.
@@ -1975,6 +1986,7 @@ queue_read (void *cls)
queue_finish (queue);
}
+
/**
* Convert a `struct sockaddr_in6 to a `struct sockaddr *`
*
@@ -2001,6 +2013,7 @@ tcp_address_to_sockaddr_numeric_v6 (socklen_t *sock_len,
struct sockaddr_in6 v6,
return in;
}
+
/**
* Convert a `struct sockaddr_in4 to a `struct sockaddr *`
*
@@ -2024,6 +2037,7 @@ tcp_address_to_sockaddr_numeric_v4 (socklen_t *sock_len,
struct sockaddr_in v4,
return in;
}
+
/**
* Convert TCP bind specification to a `struct PortOnlyIpv4Ipv6 *`
*
@@ -2083,6 +2097,7 @@ tcp_address_to_sockaddr_port_only (const char *bindto,
unsigned int *port)
return po;
}
+
/**
* This Method extracts the address part of the BINDTO string.
*
@@ -2117,7 +2132,8 @@ extract_address (const char *bindto)
start++; /* skip over '['*/
cp[strlen (cp) - 1] = '\0'; /* eat ']'*/
}
- else {
+ else
+ {
token = strtok_r (cp, "]", &rest);
if (strlen (bindto) == strlen (token))
{
@@ -2139,6 +2155,7 @@ extract_address (const char *bindto)
return start;
}
+
/**
* This Method extracts the port part of the BINDTO string.
*
@@ -2217,6 +2234,7 @@ extract_port (const char *addr_and_port)
return port;
}
+
/**
* Convert TCP bind specification to a `struct sockaddr *`
*
@@ -2245,7 +2263,6 @@ tcp_address_to_sockaddr (const char *bindto, socklen_t
*sock_len)
bindto);
-
if (1 == inet_pton (AF_INET, start, &v4.sin_addr))
{
// colon = strrchr (cp, ':');
@@ -2263,7 +2280,8 @@ tcp_address_to_sockaddr (const char *bindto, socklen_t
*sock_len)
port = extract_port (bindto);
in = tcp_address_to_sockaddr_numeric_v6 (sock_len, v6, port);
}
- else{
+ else
+ {
GNUNET_assert (0);
}
@@ -2272,6 +2290,7 @@ tcp_address_to_sockaddr (const char *bindto, socklen_t
*sock_len)
return in;
}
+
/**
* Signature of functions implementing the sending functionality of a
* message queue.
@@ -2510,6 +2529,7 @@ start_initial_kx_out (struct Queue *queue)
transmit_kx (queue, &epub);
}
+
/**
* Callback called when peerstore store operation for handshake monotime is
finished.
* @param cls Queue context the store operation was executed.
@@ -2527,6 +2547,7 @@ handshake_monotime_store_cb (void *cls, int success)
queue->handshake_monotime_sc = NULL;
}
+
/**
* Callback called by peerstore when records for
GNUNET_PEERSTORE_TRANSPORT_TCP_COMMUNICATOR_HANDSHAKE
* where found.
@@ -2585,6 +2606,7 @@ handshake_monotime_cb (void *cls,
queue);
}
+
/**
* We have received the first bytes from the other side on a @a queue.
* Decrypt the @a tc contained in @a ibuf and check the signature.
@@ -2651,6 +2673,7 @@ free_proto_queue (struct ProtoQueue *pq)
GNUNET_free (pq);
}
+
/**
* Read from the socket of the proto queue until we have enough data
* to upgrade to full queue.
@@ -2892,6 +2915,7 @@ queue_read_kx (void *cls)
queue->read_task = GNUNET_SCHEDULER_add_now (&queue_read, queue);
}
+
/**
* Function called by the transport service to initialize a
* message queue given address information about another peer.
@@ -2991,6 +3015,7 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity
*peer, const char *address)
return GNUNET_OK;
}
+
/**
* Iterator over all ListenTasks to clean up.
*
@@ -3021,6 +3046,7 @@ get_lt_delete_it (void *cls,
return GNUNET_OK;
}
+
/**
* Iterator over all message queues to clean up.
*
@@ -3042,6 +3068,7 @@ get_queue_delete_it (void *cls,
return GNUNET_OK;
}
+
/**
* Shutdown the UNIX communicator.
*
@@ -3182,6 +3209,7 @@ nat_address_cb (void *cls,
}
}
+
/**
* This method adds addresses to the DLL, that are later register at the NAT
service.
*/
@@ -3211,6 +3239,7 @@ add_addr (struct sockaddr *in, socklen_t in_len)
addrs_lens++;
}
+
/**
* This method launch network interactions for each address we like to bind to.
*
@@ -3336,7 +3365,7 @@ init_socket (struct sockaddr *addr,
if (NULL == queue_map)
queue_map = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO);
- if (NULL == ch )
+ if (NULL == ch)
ch = GNUNET_TRANSPORT_communicator_connect (cfg,
COMMUNICATOR_CONFIG_SECTION,
COMMUNICATOR_ADDRESS_PREFIX,
@@ -3360,6 +3389,7 @@ init_socket (struct sockaddr *addr,
}
+
/**
* This method reads from the DLL addrs_head to register them at the NAT
service.
*/
@@ -3421,6 +3451,7 @@ nat_register ()
}
}
+
/**
* This method is the callback called by the resolver API, and wraps method
init_socket.
*
@@ -3476,6 +3507,7 @@ init_socket_resolv (void *cls,
}
}
+
/**
* Setup communicator and launch network interactions.
*
diff --git a/src/transport/gnunet-service-tng.c
b/src/transport/gnunet-service-tng.c
index f57d08395..64cb53ad8 100644
--- a/src/transport/gnunet-service-tng.c
+++ b/src/transport/gnunet-service-tng.c
@@ -5164,9 +5164,10 @@ handle_del_address (void *cls,
ale->address);
free_address_list_entry (ale);
GNUNET_SERVICE_client_continue (tc->client);
+ return;
}
GNUNET_break (0);
- GNUNET_SERVICE_client_drop (tc->client);
+ //GNUNET_SERVICE_client_drop (tc->client);
}
@@ -10045,6 +10046,52 @@ free_ack_cummulator_cb (void *cls,
return GNUNET_OK;
}
+void
+cleanup_client (struct TransportClient *tc)
+{
+ switch (tc->type)
+ {
+ case CT_NONE:
+ break;
+
+ case CT_CORE: {
+ struct PendingMessage *pm;
+
+ while (NULL != (pm = tc->details.core.pending_msg_head))
+ {
+ GNUNET_CONTAINER_MDLL_remove (client,
+ tc->details.core.pending_msg_head,
+ tc->details.core.pending_msg_tail,
+ pm);
+ pm->client = NULL;
+ }
+ }
+ break;
+
+ case CT_MONITOR:
+ break;
+
+ case CT_COMMUNICATOR: {
+ struct Queue *q;
+ struct AddressListEntry *ale;
+
+ while (NULL != (q = tc->details.communicator.queue_head))
+ free_queue (q);
+ while (NULL != (ale = tc->details.communicator.addr_head))
+ free_address_list_entry (ale);
+ GNUNET_free (tc->details.communicator.address_prefix);
+ }
+ break;
+
+ case CT_APPLICATION:
+ GNUNET_CONTAINER_multipeermap_iterate (tc->details.application.requests,
+ &stop_peer_request,
+ tc);
+ GNUNET_CONTAINER_multipeermap_destroy (tc->details.application.requests);
+ break;
+ }
+
+}
/**
* Function called when the service shuts down. Unloads our plugins
@@ -10056,9 +10103,13 @@ static void
do_shutdown (void *cls)
{
struct LearnLaunchEntry *lle;
+ struct TransportClient *client;
(void) cls;
-
+ for (client = clients_head; NULL != client; client = client->next)
+ {
+ cleanup_client (client);
+ }
//GNUNET_CONTAINER_multipeermap_iterate (neighbours,
//&free_neighbour_cb, NULL);
if (NULL != peerstore)
@@ -10066,6 +10117,16 @@ do_shutdown (void *cls)
GNUNET_PEERSTORE_disconnect (peerstore, GNUNET_NO);
peerstore = NULL;
}
+ if (NULL != validation_task)
+ {
+ GNUNET_SCHEDULER_cancel (validation_task);
+ validation_task = NULL;
+ }
+ if (NULL != dvlearn_task)
+ {
+ GNUNET_SCHEDULER_cancel (dvlearn_task);
+ dvlearn_task = NULL;
+ }
if (NULL != GST_stats)
{
GNUNET_STATISTICS_destroy (GST_stats, GNUNET_NO);
diff --git a/src/transport/test_transport_api2_tcp_peer1.conf
b/src/transport/test_transport_api2_tcp_peer1.conf
index 417a855ad..bc3434069 100644
--- a/src/transport/test_transport_api2_tcp_peer1.conf
+++ b/src/transport/test_transport_api2_tcp_peer1.conf
@@ -6,12 +6,14 @@ GNUNET_TEST_HOME = $GNUNET_TMP/test-transport/api-tcp-p1/
BINARY = gnunet-service-tng
PLUGINS = tcp
#PREFIX = valgrind --log-file=/tmp/vg_peer1-%p
+UNIXPATH = $GNUNET_RUNTIME_DIR/tng-p1.sock
[communicator-tcp]
BINARY = gnunet-communicator-tcp
BINDTO = 60002
DISABLE_V6 = YES
IMMEDIATE_START = YES
+UNIXPATH = $GNUNET_RUNTIME_DIR/tcp-comm-p1.sock
[peerstore]
IMMEDIATE_START = YES
diff --git a/src/transport/test_transport_api2_tcp_peer2.conf
b/src/transport/test_transport_api2_tcp_peer2.conf
index 949bd95f3..437fac65d 100644
--- a/src/transport/test_transport_api2_tcp_peer2.conf
+++ b/src/transport/test_transport_api2_tcp_peer2.conf
@@ -5,12 +5,15 @@ GNUNET_TEST_HOME = $GNUNET_TMP/test-transport/api-tcp-p2/
[transport]
BINARY = gnunet-service-tng
#PREFIX = valgrind --log-file=/tmp/vg_peer2-%p
+UNIXPATH = $GNUNET_RUNTIME_DIR/tng-p2.sock
[communicator-tcp]
BINARY = gnunet-communicator-tcp
BINDTO = 60003
DISABLE_V6 = YES
IMMEDIATE_START = YES
+PREFIX = valgrind --log-file=/tmp/vg_comm2-%p
+UNIXPATH = $GNUNET_RUNTIME_DIR/tcp-comm-p2.sock
[peerstore]
IMMEDIATE_START = YES
diff --git a/src/transport/transport-testing2.c
b/src/transport/transport-testing2.c
index d553a3961..1461915f0 100644
--- a/src/transport/transport-testing2.c
+++ b/src/transport/transport-testing2.c
@@ -341,11 +341,11 @@ hello_iter_cb (void *cb_cls,
LOG (GNUNET_ERROR_TYPE_DEBUG, "Iteration End\n");
return;
}
- //Check record type et al?
+ // Check record type et al?
p->hello_size = record->value_size;
p->hello = GNUNET_malloc (p->hello_size);
memcpy (p->hello, record->value, p->hello_size);
- p->hello[p->hello_size-1] = '\0';
+ p->hello[p->hello_size - 1] = '\0';
GNUNET_PEERSTORE_iterate_cancel (p->pic);
p->pic = NULL;
@@ -360,13 +360,15 @@ hello_iter_cb (void *cb_cls,
}
}
+
static void
-retrieve_hello(void *cls)
+retrieve_hello (void *cls)
{
struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls;
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Getting hello...\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Getting hello...\n");
+ p->rh_task = NULL;
p->pic = GNUNET_PEERSTORE_iterate (p->ph,
"transport",
&p->id,
@@ -377,7 +379,6 @@ retrieve_hello(void *cls)
}
-
/**
* Start a peer with the given configuration
* @param tth the testing handle
@@ -536,10 +537,11 @@ 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_relative_multiply
(GNUNET_TIME_UNIT_SECONDS, 10),
- retrieve_hello,
- p);
- //GNUNET_assert (NULL != p->pic);
+ p->rh_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (
+ GNUNET_TIME_UNIT_SECONDS, 10),
+ retrieve_hello,
+ p);
+ // GNUNET_assert (NULL != p->pic);
return p;
}
@@ -650,6 +652,11 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct
struct GNUNET_TRANSPORT_TESTING_Handle *tth = p->tth;
struct GNUNET_TRANSPORT_TESTING_ConnectRequest *cc;
struct GNUNET_TRANSPORT_TESTING_ConnectRequest *ccn;
+ /* shutdown */
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Stopping peer %u (`%s')\n",
+ p->no,
+ GNUNET_i2s (&p->id));
for (cc = tth->cc_head; NULL != cc; cc = ccn)
{
@@ -660,7 +667,7 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct
}
if (NULL != p->pic)
{
- //GNUNET_PEERSTORE_iterate_cancel (p->pic);
+ // GNUNET_PEERSTORE_iterate_cancel (p->pic);
p->pic = NULL;
}
if (NULL != p->th)
@@ -718,6 +725,9 @@ GNUNET_TRANSPORT_TESTING_stop_peer (struct
"Peer %u (`%s') stopped\n",
p->no,
GNUNET_i2s (&p->id));
+ if (NULL != p->rh_task)
+ GNUNET_SCHEDULER_cancel (p->rh_task);
+ p->rh_task = NULL;
GNUNET_free (p);
}
diff --git a/src/transport/transport-testing2.h
b/src/transport/transport-testing2.h
index 8c0f03556..db8700df9 100644
--- a/src/transport/transport-testing2.h
+++ b/src/transport/transport-testing2.h
@@ -144,6 +144,11 @@ struct GNUNET_TRANSPORT_TESTING_PeerContext
*/
GNUNET_SCHEDULER_TaskCallback start_cb;
+ /**
+ * Hello get task
+ */
+ struct GNUNET_SCHEDULER_Task *rh_task;
+
/**
* Closure for the @a nc and @a nd callbacks
*/
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnunet] branch master updated: -more tng service fixes,
gnunet <=