aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-01-18 21:18:30 +0100
committerChristian Grothoff <christian@grothoff.org>2022-02-19 12:41:01 +0100
commit0bd15d392c8c1c4dab56c794ec88fdbd7245cc51 (patch)
tree6370f222cdb735efdbae3022b1c94fc4c7207dc4
parente5f00fda52a45ebd22716debf0d9af36fb6fce0a (diff)
downloadgnunet-0bd15d392c8c1c4dab56c794ec88fdbd7245cc51.tar.gz
gnunet-0bd15d392c8c1c4dab56c794ec88fdbd7245cc51.zip
-adding logging, minor dthu bugfixes
-rw-r--r--src/dht/gnunet-service-dht.c6
-rw-r--r--src/dht/gnunet-service-dht_clients.c8
-rw-r--r--src/dht/gnunet-service-dht_neighbours.c15
-rw-r--r--src/dhtu/plugin_dhtu_ip.c82
4 files changed, 100 insertions, 11 deletions
diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c
index 4b0a290b9..39433791d 100644
--- a/src/dht/gnunet-service-dht.c
+++ b/src/dht/gnunet-service-dht.c
@@ -265,6 +265,9 @@ u_address_add (void *cls,
265 struct GDS_Underlay *u = cls; 265 struct GDS_Underlay *u = cls;
266 struct MyAddress *a; 266 struct MyAddress *a;
267 267
268 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
269 "Underlay adds address %s for this peer\n",
270 address);
268 a = GNUNET_new (struct MyAddress); 271 a = GNUNET_new (struct MyAddress);
269 a->source = source; 272 a->source = source;
270 a->url = GNUNET_strdup (address); 273 a->url = GNUNET_strdup (address);
@@ -292,6 +295,9 @@ u_address_del (void *ctx)
292{ 295{
293 struct MyAddress *a = ctx; 296 struct MyAddress *a = ctx;
294 297
298 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
299 "Underlay deletes address %s for this peer\n",
300 a->url);
295 GNUNET_HELLO_builder_del_address (GDS_my_hello, 301 GNUNET_HELLO_builder_del_address (GDS_my_hello,
296 a->url); 302 a->url);
297 GNUNET_CONTAINER_DLL_remove (a_head, 303 GNUNET_CONTAINER_DLL_remove (a_head,
diff --git a/src/dht/gnunet-service-dht_clients.c b/src/dht/gnunet-service-dht_clients.c
index e5819b193..dc451ed15 100644
--- a/src/dht/gnunet-service-dht_clients.c
+++ b/src/dht/gnunet-service-dht_clients.c
@@ -562,6 +562,9 @@ handle_local_result (void *cls,
562 const struct GDS_DATACACHE_BlockData *bd) 562 const struct GDS_DATACACHE_BlockData *bd)
563{ 563{
564 /* FIXME: use 'cls' instead of looking up the client? */ 564 /* FIXME: use 'cls' instead of looking up the client? */
565 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
566 "Datacache provided result for query key %s\n",
567 GNUNET_h2s (&bd->key));
565 GDS_CLIENTS_handle_reply (bd, 568 GDS_CLIENTS_handle_reply (bd,
566 &bd->key, 569 &bd->key,
567 0, NULL /* get_path */); 570 0, NULL /* get_path */);
@@ -1081,6 +1084,8 @@ handle_dht_local_hello_get (void *cls,
1081 struct GNUNET_MessageHeader *hdr; 1084 struct GNUNET_MessageHeader *hdr;
1082 struct GNUNET_MQ_Envelope *env; 1085 struct GNUNET_MQ_Envelope *env;
1083 1086
1087 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1088 "Handling request from local client for my HELLO\n");
1084 env = GNUNET_MQ_msg_extra (hdr, 1089 env = GNUNET_MQ_msg_extra (hdr,
1085 slen, 1090 slen,
1086 GNUNET_MESSAGE_TYPE_DHT_CLIENT_HELLO_URL); 1091 GNUNET_MESSAGE_TYPE_DHT_CLIENT_HELLO_URL);
@@ -1134,6 +1139,9 @@ handle_dht_local_hello_offer (void *cls,
1134 struct GNUNET_HELLO_Builder *b; 1139 struct GNUNET_HELLO_Builder *b;
1135 struct GNUNET_PeerIdentity pid; 1140 struct GNUNET_PeerIdentity pid;
1136 1141
1142 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1143 "Local client provided HELLO URL %s\n",
1144 url);
1137 b = GNUNET_HELLO_builder_from_url (url); 1145 b = GNUNET_HELLO_builder_from_url (url);
1138 if (NULL == b) 1146 if (NULL == b)
1139 { 1147 {
diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c
index 63307dea2..c4d6b7428 100644
--- a/src/dht/gnunet-service-dht_neighbours.c
+++ b/src/dht/gnunet-service-dht_neighbours.c
@@ -2260,7 +2260,11 @@ GDS_try_connect (void *cls,
2260 2260
2261 if (0 == GNUNET_memcmp (&GDS_my_identity, 2261 if (0 == GNUNET_memcmp (&GDS_my_identity,
2262 pid)) 2262 pid))
2263 {
2264 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2265 "Got a HELLO for my own PID, ignoring it\n");
2263 return; /* that's us! */ 2266 return; /* that's us! */
2267 }
2264 GNUNET_CRYPTO_hash (pid, 2268 GNUNET_CRYPTO_hash (pid,
2265 sizeof(*pid), 2269 sizeof(*pid),
2266 &phash); 2270 &phash);
@@ -2282,6 +2286,13 @@ GDS_try_connect (void *cls,
2282 alternative address??? */ 2286 alternative address??? */
2283 return; 2287 return;
2284 } 2288 }
2289 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
2290 "Discovered peer %s at %s suitable for bucket %d (%u/%u), trying to connect\n",
2291 GNUNET_i2s (pid),
2292 uri,
2293 peer_bucket,
2294 bucket->peers_size,
2295 bucket_size);
2285 /* new peer that we like! */ 2296 /* new peer that we like! */
2286 GDS_u_try_connect (pid, 2297 GDS_u_try_connect (pid,
2287 uri); 2298 uri);
@@ -2492,6 +2503,10 @@ GDS_u_receive (void *cls,
2492 GNUNET_break_op (0); 2503 GNUNET_break_op (0);
2493 return; 2504 return;
2494 } 2505 }
2506 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
2507 "Handling message of type %u from peer %s\n",
2508 ntohs (mh->type),
2509 GNUNET_i2s (&pi->id));
2495 if (GNUNET_OK != 2510 if (GNUNET_OK !=
2496 GNUNET_MQ_handle_message (core_handlers, 2511 GNUNET_MQ_handle_message (core_handlers,
2497 mh)) 2512 mh))
diff --git a/src/dhtu/plugin_dhtu_ip.c b/src/dhtu/plugin_dhtu_ip.c
index 123a372b6..617f722b5 100644
--- a/src/dhtu/plugin_dhtu_ip.c
+++ b/src/dhtu/plugin_dhtu_ip.c
@@ -250,7 +250,7 @@ create_target (struct Plugin *plugin,
250{ 250{
251 struct GNUNET_DHTU_Target *dst; 251 struct GNUNET_DHTU_Target *dst;
252 252
253 if (MAX_DESTS > 253 if (MAX_DESTS <=
254 GNUNET_CONTAINER_multihashmap_size (plugin->dsts)) 254 GNUNET_CONTAINER_multihashmap_size (plugin->dsts))
255 { 255 {
256 struct GNUNET_HashCode key; 256 struct GNUNET_HashCode key;
@@ -567,6 +567,55 @@ create_source (struct Plugin *plugin,
567 567
568 568
569/** 569/**
570 * Compare two addresses for equality. Only
571 * compares IP address and port. Must only be
572 * called on AF_INET or AF_INET6 addresses.
573 *
574 * @param a1 address to compare
575 * @param a2 address to compare
576 * @param alen number of bytes in @a a1 and @a a2
577 * @return 0 if @a a1 == @a a2.
578 */
579static int
580addrcmp (const struct sockaddr *a1,
581 const struct sockaddr *a2,
582 size_t alen)
583{
584 GNUNET_assert (a1->sa_family == a2->sa_family);
585 switch (a1->sa_family)
586 {
587 case AF_INET:
588 GNUNET_assert (sizeof (struct sockaddr_in) == alen);
589 {
590 const struct sockaddr_in *s1 = (const struct sockaddr_in *) a1;
591 const struct sockaddr_in *s2 = (const struct sockaddr_in *) a2;
592
593 if (s1->sin_port != s2->sin_port)
594 return 1;
595 if (s1->sin_addr.s_addr != s2->sin_addr.s_addr)
596 return 1;
597 break;
598 }
599 case AF_INET6:
600 GNUNET_assert (sizeof (struct sockaddr_in6) == alen);
601 {
602 const struct sockaddr_in6 *s1 = (const struct sockaddr_in6 *) a1;
603 const struct sockaddr_in6 *s2 = (const struct sockaddr_in6 *) a2;
604 if (s1->sin6_port != s2->sin6_port)
605 return 1;
606 if (0 != GNUNET_memcmp (&s1->sin6_addr,
607 &s2->sin6_addr))
608 return 1;
609 break;
610 }
611 default:
612 GNUNET_assert (0);
613 }
614 return 0;
615}
616
617
618/**
570 * Callback function invoked for each interface found. 619 * Callback function invoked for each interface found.
571 * 620 *
572 * @param cls closure 621 * @param cls closure
@@ -595,9 +644,9 @@ process_ifcs (void *cls,
595 src = src->next) 644 src = src->next)
596 { 645 {
597 if ( (addrlen == src->addrlen) && 646 if ( (addrlen == src->addrlen) &&
598 (0 == memcmp (addr, 647 (0 == addrcmp (addr,
599 &src->addr, 648 (const struct sockaddr *) &src->addr,
600 addrlen)) ) 649 addrlen)) )
601 { 650 {
602 src->scan_generation = plugin->scan_generation; 651 src->scan_generation = plugin->scan_generation;
603 return GNUNET_OK; 652 return GNUNET_OK;
@@ -691,9 +740,9 @@ find_source (struct Plugin *plugin,
691 src = src->next) 740 src = src->next)
692 { 741 {
693 if ( (addrlen == src->addrlen) && 742 if ( (addrlen == src->addrlen) &&
694 (0 == memcmp (addr, 743 (0 == addrcmp (addr,
695 &src->addr, 744 (const struct sockaddr *) &src->addr,
696 addrlen)) ) 745 addrlen)) )
697 return src; 746 return src;
698 } 747 }
699 748
@@ -731,7 +780,6 @@ read_cb (void *cls)
731 }; 780 };
732 struct GNUNET_DHTU_Target *dst = NULL; 781 struct GNUNET_DHTU_Target *dst = NULL;
733 struct GNUNET_DHTU_Source *src = NULL; 782 struct GNUNET_DHTU_Source *src = NULL;
734 struct cmsghdr *cmsg;
735 783
736 ret = recvmsg (GNUNET_NETWORK_get_fd (plugin->sock), 784 ret = recvmsg (GNUNET_NETWORK_get_fd (plugin->sock),
737 &mh, 785 &mh,
@@ -749,11 +797,19 @@ read_cb (void *cls)
749 return; 797 return;
750 } 798 }
751 /* find IP where we received message */ 799 /* find IP where we received message */
752 for (cmsg = CMSG_FIRSTHDR (&mh); 800 for (struct cmsghdr *cmsg = CMSG_FIRSTHDR (&mh);
753 NULL != cmsg; 801 NULL != cmsg;
754 cmsg = CMSG_NXTHDR (&mh, 802 cmsg = CMSG_NXTHDR (&mh,
755 cmsg)) 803 cmsg))
756 { 804 {
805 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
806 "Got CMSG level %u (%d/%d), type %u (%d/%d)\n",
807 cmsg->cmsg_level,
808 (cmsg->cmsg_level == IPPROTO_IP),
809 (cmsg->cmsg_level == IPPROTO_IPV6),
810 cmsg->cmsg_type,
811 (cmsg->cmsg_type == IP_PKTINFO),
812 (cmsg->cmsg_type == IPV6_RECVPKTINFO));
757 if ( (cmsg->cmsg_level == IPPROTO_IP) && 813 if ( (cmsg->cmsg_level == IPPROTO_IP) &&
758 (cmsg->cmsg_type == IP_PKTINFO) ) 814 (cmsg->cmsg_type == IP_PKTINFO) )
759 { 815 {
@@ -808,13 +864,17 @@ read_cb (void *cls)
808 GNUNET_break (0); 864 GNUNET_break (0);
809 } 865 }
810 } 866 }
867 if (NULL == src)
868 {
869 GNUNET_break (0);
870 return;
871 }
811 pid = (const struct GNUNET_PeerIdentity *) buf; 872 pid = (const struct GNUNET_PeerIdentity *) buf;
812 dst = find_target (plugin, 873 dst = find_target (plugin,
813 pid, 874 pid,
814 &sa, 875 &sa,
815 mh.msg_namelen); 876 mh.msg_namelen);
816 if ( (NULL == src) || 877 if (NULL == dst)
817 (NULL == dst) )
818 { 878 {
819 GNUNET_break (0); 879 GNUNET_break (0);
820 return; 880 return;