[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet] 02/02: mostly logging, avoid having more than one
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet] 02/02: mostly logging, avoid having more than one typemap in transmission queue, accept port=0 as not an error, tolerate link-local addrs |
Date: |
Sun, 19 Feb 2017 20:31:16 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository gnunet.
commit 3902d240e408e85f08d9c444356eb18fc6ea44e7
Author: Christian Grothoff <address@hidden>
AuthorDate: Sun Feb 19 20:31:12 2017 +0100
mostly logging, avoid having more than one typemap in transmission queue,
accept port=0 as not an error, tolerate link-local addrs
---
src/core/gnunet-service-core.c | 11 +++-
src/core/gnunet-service-core_kx.c | 23 +++++---
src/core/gnunet-service-core_sessions.c | 96 +++++++++++++++++++++++++++------
src/core/gnunet-service-core_typemap.c | 21 ++++----
src/transport/plugin_transport_udp.c | 15 ++----
src/transport/transport_api_core.c | 3 +-
6 files changed, 122 insertions(+), 47 deletions(-)
diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c
index b0d7b24ba..52c6f72ab 100644
--- a/src/core/gnunet-service-core.c
+++ b/src/core/gnunet-service-core.c
@@ -696,6 +696,11 @@ GSC_CLIENTS_notify_client_about_neighbour (struct
GSC_Client *client,
new_match = GSC_TYPEMAP_test_match (tmap_new,
client->types,
client->tcnt);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Notifying client about neighbour %s (%d/%d)\n",
+ GNUNET_i2s (neighbour),
+ old_match,
+ new_match);
if (old_match == new_match)
{
GNUNET_assert (old_match ==
@@ -720,7 +725,8 @@ GSC_CLIENTS_notify_client_about_neighbour (struct
GSC_Client *client,
GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT);
cnm->reserved = htonl (0);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Sending NOTIFY_CONNECT message to client.\n");
+ "Sending NOTIFY_CONNECT message about peer %s to client.\n",
+ GNUNET_i2s (neighbour));
cnm->peer = *neighbour;
GNUNET_MQ_send (client->mq,
env);
@@ -740,6 +746,9 @@ GSC_CLIENTS_notify_client_about_neighbour (struct
GSC_Client *client,
env = GNUNET_MQ_msg (dcm,
GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT);
dcm->reserved = htonl (0);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Sending NOTIFY_DISCONNECT message about peer %s to client.\n",
+ GNUNET_i2s (neighbour));
dcm->peer = *neighbour;
GNUNET_MQ_send (client->mq,
env);
diff --git a/src/core/gnunet-service-core_kx.c
b/src/core/gnunet-service-core_kx.c
index 6743ce215..a0c343737 100644
--- a/src/core/gnunet-service-core_kx.c
+++ b/src/core/gnunet-service-core_kx.c
@@ -261,7 +261,7 @@ struct GSC_KeyExchangeInfo
* Message queue for sending messages to @a peer.
*/
struct GNUNET_MQ_Handle *mq;
-
+
/**
* PING message we transmit to the other peer.
*/
@@ -777,7 +777,7 @@ handle_transport_notify_disconnect (void *cls,
void *handler_cls)
{
struct GSC_KeyExchangeInfo *kx = handler_cls;
-
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peer `%s' disconnected from us.\n",
GNUNET_i2s (peer));
@@ -814,7 +814,7 @@ static void
send_ping (struct GSC_KeyExchangeInfo *kx)
{
struct GNUNET_MQ_Envelope *env;
-
+
GNUNET_STATISTICS_update (GSC_stats,
gettext_noop ("# PING messages transmitted"),
1,
@@ -1332,7 +1332,7 @@ static void
send_key (struct GSC_KeyExchangeInfo *kx)
{
struct GNUNET_MQ_Envelope *env;
-
+
GNUNET_assert (GNUNET_CORE_KX_STATE_DOWN != kx->status);
if (NULL != kx->retry_set_key_task)
{
@@ -1520,7 +1520,7 @@ handle_encrypted (void *cls,
sizeof (struct GNUNET_HashCode)))
{
/* checksum failed */
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Failed checksum validation for a message from `%s'\n",
GNUNET_i2s (kx->peer));
return;
@@ -1536,7 +1536,10 @@ handle_encrypted (void *cls,
&m->sequence_number,
&buf[ENCRYPTED_HEADER_SIZE],
size - ENCRYPTED_HEADER_SIZE))
+ {
+ GNUNET_break_op (0);
return;
+ }
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Decrypted %u bytes from %s\n",
(unsigned int) (size - ENCRYPTED_HEADER_SIZE),
@@ -1642,7 +1645,7 @@ handle_transport_notify_excess_bw (void *cls,
const struct GNUNET_PeerIdentity *pid,
void *connect_cls)
{
- struct GSC_KeyExchangeInfo *kx = connect_cls;
+ struct GSC_KeyExchangeInfo *kx = connect_cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peer %s has excess bandwidth available\n",
@@ -1668,6 +1671,10 @@ deliver_message (void *cls,
{
struct DeliverMessageContext *dmc = client;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Decrypted message of type %d from %s\n",
+ ntohs (m->type),
+ GNUNET_i2s (dmc->peer));
if (GNUNET_CORE_KX_STATE_UP != dmc->kx->status)
{
GNUNET_STATISTICS_update (GSC_stats,
@@ -1824,7 +1831,7 @@ GSC_KX_init (struct GNUNET_CRYPTO_EddsaPrivateKey *pk)
NULL);
mst = GNUNET_SERVER_mst_create (&deliver_message,
NULL);
- transport
+ transport
= GNUNET_TRANSPORT_core_connect (GSC_cfg,
&GSC_my_identity,
handlers,
@@ -1927,7 +1934,7 @@ GSC_KX_handle_client_monitor_peers (struct
GNUNET_MQ_Handle *mq)
{
struct GNUNET_MQ_Envelope *env;
struct MonitorNotifyMessage *msg;
-
+
env = GNUNET_MQ_msg (msg,
GNUNET_MESSAGE_TYPE_CORE_MONITOR_NOTIFY);
msg->state = htonl ((uint32_t) kx->status);
diff --git a/src/core/gnunet-service-core_sessions.c
b/src/core/gnunet-service-core_sessions.c
index 6687b4819..034f2e883 100644
--- a/src/core/gnunet-service-core_sessions.c
+++ b/src/core/gnunet-service-core_sessions.c
@@ -57,6 +57,21 @@ struct SessionMessageEntry
struct SessionMessageEntry *prev;
/**
+ * How important is this message.
+ */
+ enum GNUNET_CORE_Priority priority;
+
+ /**
+ * Flag set to #GNUNET_YES if this is a typemap message.
+ */
+ int is_typemap;
+
+ /**
+ * Flag set to #GNUNET_YES if this is a typemap confirmation message.
+ */
+ int is_typemap_confirm;
+
+ /**
* Deadline for transmission, 1s after we received it (if we
* are not corking), otherwise "now". Note that this message
* does NOT expire past its deadline.
@@ -70,11 +85,6 @@ struct SessionMessageEntry
*/
size_t size;
- /**
- * How important is this message.
- */
- enum GNUNET_CORE_Priority priority;
-
};
@@ -275,14 +285,19 @@ transmit_typemap_task (void *cls)
struct GNUNET_MessageHeader *hdr;
struct GNUNET_TIME_Relative delay;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Sending TYPEMAP to %s\n",
+ GNUNET_i2s (session->peer));
session->typemap_delay = GNUNET_TIME_STD_BACKOFF (session->typemap_delay);
delay = session->typemap_delay;
/* randomize a bit to avoid spont. sync */
delay.rel_value_us +=
- GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 1000 * 1000);
+ GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
+ 1000 * 1000);
session->typemap_task =
GNUNET_SCHEDULER_add_delayed (delay,
- &transmit_typemap_task, session);
+ &transmit_typemap_task,
+ session);
GNUNET_STATISTICS_update (GSC_stats,
gettext_noop ("# type map refreshes sent"),
1,
@@ -326,7 +341,7 @@ GSC_SESSIONS_create (const struct GNUNET_PeerIdentity *peer,
struct Session *session;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Creating session for peer `%4s'\n",
+ "Creating session for peer `%s'\n",
GNUNET_i2s (peer));
session = GNUNET_new (struct Session);
session->tmap = GSC_TYPEMAP_create ();
@@ -406,8 +421,14 @@ GSC_SESSIONS_confirm_typemap (const struct
GNUNET_PeerIdentity *peer,
gettext_noop
("# outdated typemap confirmations received"),
1, GNUNET_NO);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Got outdated typemap confirmated from peer `%s'\n",
+ GNUNET_i2s (session->peer));
return;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Got typemap confirmation from peer `%s'\n",
+ GNUNET_i2s (session->peer));
if (NULL != session->typemap_task)
{
GNUNET_SCHEDULER_cancel (session->typemap_task);
@@ -502,9 +523,9 @@ GSC_SESSIONS_queue_request (struct GSC_ClientActiveRequest
*car)
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received client transmission request. queueing\n");
- GNUNET_CONTAINER_DLL_insert (session->active_client_request_head,
- session->active_client_request_tail,
- car);
+ GNUNET_CONTAINER_DLL_insert_tail (session->active_client_request_head,
+ session->active_client_request_tail,
+ car);
try_transmission (session);
}
@@ -751,7 +772,15 @@ try_transmission (struct Session *session)
while ( (NULL != (pos = session->sme_head)) &&
(used + pos->size <= msize) )
{
- GNUNET_memcpy (&pbuf[used], &pos[1], pos->size);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Adding message of type %d (%d/%d) to payload for %s\n",
+ ntohs (((const struct GNUNET_MessageHeader *)&pos[1])->type),
+ pos->is_typemap,
+ pos->is_typemap_confirm,
+ GNUNET_i2s (session->peer));
+ GNUNET_memcpy (&pbuf[used],
+ &pos[1],
+ pos->size);
used += pos->size;
GNUNET_CONTAINER_DLL_remove (session->sme_head,
session->sme_tail,
@@ -799,8 +828,23 @@ do_restart_typemap_message (void *cls,
struct SessionMessageEntry *sme;
uint16_t size;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Restarting sending TYPEMAP to %s\n",
+ GNUNET_i2s (session->peer));
size = ntohs (hdr->size);
+ for (sme = session->sme_head; NULL != sme; sme = sme->next)
+ {
+ if (GNUNET_YES == sme->is_typemap)
+ {
+ GNUNET_CONTAINER_DLL_remove (session->sme_head,
+ session->sme_tail,
+ sme);
+ GNUNET_free (sme);
+ break;
+ }
+ }
sme = GNUNET_malloc (sizeof (struct SessionMessageEntry) + size);
+ sme->is_typemap = GNUNET_YES;
GNUNET_memcpy (&sme[1],
hdr,
size);
@@ -924,18 +968,36 @@ GSC_SESSIONS_set_typemap (const struct
GNUNET_PeerIdentity *peer,
nmap = GSC_TYPEMAP_get_from_message (msg);
if (NULL == nmap)
+ {
+ GNUNET_break_op (0);
return; /* malformed */
+ }
session = find_session (peer);
if (NULL == session)
{
GNUNET_break (0);
return;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received TYPEMAP from %s\n",
+ GNUNET_i2s (session->peer));
+ for (sme = session->sme_head; NULL != sme; sme = sme->next)
+ {
+ if (GNUNET_YES == sme->is_typemap_confirm)
+ {
+ GNUNET_CONTAINER_DLL_remove (session->sme_head,
+ session->sme_tail,
+ sme);
+ GNUNET_free (sme);
+ break;
+ }
+ }
sme = GNUNET_malloc (sizeof (struct SessionMessageEntry) +
sizeof (struct TypeMapConfirmationMessage));
sme->deadline = GNUNET_TIME_absolute_get ();
sme->size = sizeof (struct TypeMapConfirmationMessage);
sme->priority = GNUNET_CORE_PRIO_CRITICAL_CONTROL;
+ sme->is_typemap_confirm = GNUNET_YES;
tmc = (struct TypeMapConfirmationMessage *) &sme[1];
tmc->header.size = htons (sizeof (struct TypeMapConfirmationMessage));
tmc->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_CONFIRM_TYPE_MAP);
@@ -975,11 +1037,15 @@ GSC_SESSIONS_add_to_typemap (const struct
GNUNET_PeerIdentity *peer,
return;
session = find_session (peer);
GNUNET_assert (NULL != session);
- if (GNUNET_YES == GSC_TYPEMAP_test_match (session->tmap, &type, 1))
+ if (GNUNET_YES == GSC_TYPEMAP_test_match (session->tmap,
+ &type, 1))
return; /* already in it */
- nmap = GSC_TYPEMAP_extend (session->tmap, &type, 1);
+ nmap = GSC_TYPEMAP_extend (session->tmap,
+ &type,
+ 1);
GSC_CLIENTS_notify_clients_about_neighbour (peer,
- session->tmap, nmap);
+ session->tmap,
+ nmap);
GSC_TYPEMAP_destroy (session->tmap);
session->tmap = nmap;
}
diff --git a/src/core/gnunet-service-core_typemap.c
b/src/core/gnunet-service-core_typemap.c
index d400c0b8b..0600f59ef 100644
--- a/src/core/gnunet-service-core_typemap.c
+++ b/src/core/gnunet-service-core_typemap.c
@@ -177,8 +177,10 @@ GSC_TYPEMAP_get_from_message (const struct
GNUNET_MessageHeader *msg)
GNUNET_memcpy (ret, &msg[1], sizeof (struct GSC_TypeMap));
return ret;
case GNUNET_MESSAGE_TYPE_CORE_COMPRESSED_TYPE_MAP:
- GNUNET_STATISTICS_update (GSC_stats, gettext_noop ("# type maps received"),
- 1, GNUNET_NO);
+ GNUNET_STATISTICS_update (GSC_stats,
+ gettext_noop ("# type maps received"),
+ 1,
+ GNUNET_NO);
ret = GNUNET_new (struct GSC_TypeMap);
dlen = sizeof (struct GSC_TypeMap);
if ((Z_OK !=
@@ -207,7 +209,8 @@ broadcast_my_type_map ()
hdr = GSC_TYPEMAP_compute_type_map_message ();
GNUNET_STATISTICS_update (GSC_stats,
- gettext_noop ("# updates to my type map"), 1,
+ gettext_noop ("# updates to my type map"),
+ 1,
GNUNET_NO);
GSC_SESSIONS_broadcast_typemap (hdr);
GNUNET_free (hdr);
@@ -238,6 +241,8 @@ GSC_TYPEMAP_add (const uint16_t *types,
}
if (GNUNET_YES == changed)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Typemap changed, broadcasting!\n");
rehash_typemap ();
broadcast_my_type_map ();
}
@@ -254,11 +259,10 @@ void
GSC_TYPEMAP_remove (const uint16_t *types,
unsigned int tlen)
{
- unsigned int i;
int changed;
changed = GNUNET_NO;
- for (i = 0; i < tlen; i++)
+ for (unsigned int i = 0; i < tlen; i++)
{
if (0 == --map_counters[types[i]])
{
@@ -288,13 +292,11 @@ GSC_TYPEMAP_test_match (const struct GSC_TypeMap *tmap,
const uint16_t *types,
unsigned int tcnt)
{
- unsigned int i;
-
if (NULL == tmap)
return GNUNET_NO;
if (0 == tcnt)
return GNUNET_YES; /* matches all */
- for (i = 0; i < tcnt; i++)
+ for (unsigned int i = 0; i < tcnt; i++)
if (0 != (tmap->bits[types[i] / 32] & (1 << (types[i] % 32))))
return GNUNET_YES;
return GNUNET_NO;
@@ -315,12 +317,11 @@ GSC_TYPEMAP_extend (const struct GSC_TypeMap *tmap,
unsigned int tcnt)
{
struct GSC_TypeMap *ret;
- unsigned int i;
ret = GNUNET_new (struct GSC_TypeMap);
if (NULL != tmap)
GNUNET_memcpy (ret, tmap, sizeof (struct GSC_TypeMap));
- for (i = 0; i < tcnt; i++)
+ for (unsigned int i = 0; i < tcnt; i++)
ret->bits[types[i] / 32] |= (1 << (types[i] % 32));
return ret;
}
diff --git a/src/transport/plugin_transport_udp.c
b/src/transport/plugin_transport_udp.c
index fd8493e5f..76132523b 100644
--- a/src/transport/plugin_transport_udp.c
+++ b/src/transport/plugin_transport_udp.c
@@ -1271,10 +1271,7 @@ udp_plugin_check_address (void *cls,
v6 = (const struct IPv6UdpAddress *) addr;
if (IN6_IS_ADDR_LINKLOCAL (&v6->ipv6_addr))
- {
- GNUNET_break_op (0);
- return GNUNET_SYSERR;
- }
+ return GNUNET_OK; /* plausible, if unlikely... */
memset (&s6, 0, sizeof (s6));
s6.sin6_family = AF_INET6;
#if HAVE_SOCKADDR_IN_SIN_LEN
@@ -1338,10 +1335,7 @@ udp_nat_port_map_callback (void *cls,
GNUNET_assert (sizeof(struct sockaddr_in) == addrlen);
i4 = (const struct sockaddr_in *) addr;
if (0 == ntohs (i4->sin_port))
- {
- GNUNET_break (0);
- return;
- }
+ return; /* Port = 0 means unmapped, ignore these for UDP. */
memset (&u4,
0,
sizeof(u4));
@@ -1359,10 +1353,7 @@ udp_nat_port_map_callback (void *cls,
GNUNET_assert (sizeof(struct sockaddr_in6) == addrlen);
i6 = (const struct sockaddr_in6 *) addr;
if (0 == ntohs (i6->sin6_port))
- {
- GNUNET_break (0);
- return;
- }
+ return; /* Port = 0 means unmapped, ignore these for UDP. */
memset (&u6,
0,
sizeof(u6));
diff --git a/src/transport/transport_api_core.c
b/src/transport/transport_api_core.c
index a693cb889..c99ade92f 100644
--- a/src/transport/transport_api_core.c
+++ b/src/transport/transport_api_core.c
@@ -447,7 +447,8 @@ mq_send_impl (struct GNUNET_MQ_Handle *mq,
GNUNET_MQ_send (h->mq,
n->env);
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Queued message for neighbour `%s'.\n",
+ "Queued message of type %u for neighbour `%s'.\n",
+ ntohs (msg->type),
GNUNET_i2s (&n->id));
}
--
To stop receiving notification emails like this one, please contact
address@hidden