diff options
author | Martin Schanzenbach <schanzen@gnunet.org> | 2024-03-15 08:34:38 +0100 |
---|---|---|
committer | Martin Schanzenbach <schanzen@gnunet.org> | 2024-03-15 08:34:38 +0100 |
commit | b8da22a9bc54610bb21ccbf982a678e276a47586 (patch) | |
tree | d8f101c31e4c764ee01c83f47c1ba5611977696c | |
parent | 49d1265242337c58d678b85af4742a8ee0bd8c31 (diff) | |
download | gnunet-b8da22a9bc54610bb21ccbf982a678e276a47586.tar.gz gnunet-b8da22a9bc54610bb21ccbf982a678e276a47586.zip |
TRANSPORT: Fix IPv6 setting in UDP communicator.
4 files changed, 48 insertions, 12 deletions
diff --git a/src/include/gnunet_transport_communication_service.h b/src/include/gnunet_transport_communication_service.h index 92facb0e0..ea947911f 100644 --- a/src/include/gnunet_transport_communication_service.h +++ b/src/include/gnunet_transport_communication_service.h | |||
@@ -74,7 +74,7 @@ extern "C" { | |||
74 | * @param address where to send the message, human-readable | 74 | * @param address where to send the message, human-readable |
75 | * communicator-specific format, 0-terminated, UTF-8 | 75 | * communicator-specific format, 0-terminated, UTF-8 |
76 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if the provided address is | 76 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if the provided address is |
77 | * invalid | 77 | * invalid, #GNUNET_NO if this address is already (beging) connected to. |
78 | */ | 78 | */ |
79 | typedef int (*GNUNET_TRANSPORT_CommunicatorMqInit) ( | 79 | typedef int (*GNUNET_TRANSPORT_CommunicatorMqInit) ( |
80 | void *cls, | 80 | void *cls, |
diff --git a/src/service/transport/gnunet-communicator-tcp.c b/src/service/transport/gnunet-communicator-tcp.c index 2ff7c4fc7..02a547335 100644 --- a/src/service/transport/gnunet-communicator-tcp.c +++ b/src/service/transport/gnunet-communicator-tcp.c | |||
@@ -3349,7 +3349,7 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity *peer, const char *address) | |||
3349 | { | 3349 | { |
3350 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3350 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3351 | "Queue for %s already exists or is in construction\n", address); | 3351 | "Queue for %s already exists or is in construction\n", address); |
3352 | return GNUNET_SYSERR; | 3352 | return GNUNET_NO; |
3353 | } | 3353 | } |
3354 | switch (in->sa_family) | 3354 | switch (in->sa_family) |
3355 | { | 3355 | { |
diff --git a/src/service/transport/gnunet-communicator-udp.c b/src/service/transport/gnunet-communicator-udp.c index b132080cf..e9496c571 100644 --- a/src/service/transport/gnunet-communicator-udp.c +++ b/src/service/transport/gnunet-communicator-udp.c | |||
@@ -850,6 +850,11 @@ static struct GNUNET_NAT_Handle *nat; | |||
850 | */ | 850 | */ |
851 | static uint16_t my_port; | 851 | static uint16_t my_port; |
852 | 852 | ||
853 | /** | ||
854 | * IPv6 disabled or not. | ||
855 | */ | ||
856 | static int disable_v6; | ||
857 | |||
853 | 858 | ||
854 | /** | 859 | /** |
855 | * An interface went away, stop broadcasting on it. | 860 | * An interface went away, stop broadcasting on it. |
@@ -2245,11 +2250,7 @@ udp_address_to_sockaddr (const char *bindto, socklen_t *sock_len) | |||
2245 | bindto); | 2250 | bindto); |
2246 | return NULL; | 2251 | return NULL; |
2247 | } | 2252 | } |
2248 | if ((GNUNET_NO == GNUNET_NETWORK_test_pf (PF_INET6)) || | 2253 | if (GNUNET_YES == disable_v6) |
2249 | (GNUNET_YES == | ||
2250 | GNUNET_CONFIGURATION_get_value_yesno (cfg, | ||
2251 | COMMUNICATOR_CONFIG_SECTION, | ||
2252 | "DISABLE_V6"))) | ||
2253 | { | 2254 | { |
2254 | struct sockaddr_in *i4; | 2255 | struct sockaddr_in *i4; |
2255 | 2256 | ||
@@ -2865,6 +2866,21 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity *peer, const char *address) | |||
2865 | path = &address[strlen (COMMUNICATOR_ADDRESS_PREFIX "-")]; | 2866 | path = &address[strlen (COMMUNICATOR_ADDRESS_PREFIX "-")]; |
2866 | in = udp_address_to_sockaddr (path, &in_len); | 2867 | in = udp_address_to_sockaddr (path, &in_len); |
2867 | 2868 | ||
2869 | if (NULL == in) | ||
2870 | { | ||
2871 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
2872 | "Failed to setup UDP socket address\n"); | ||
2873 | return GNUNET_SYSERR; | ||
2874 | } | ||
2875 | if ((AF_INET6 == in->sa_family) && | ||
2876 | (GNUNET_YES == disable_v6)) | ||
2877 | { | ||
2878 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2879 | "IPv6 disabled, skipping %s\n", address); | ||
2880 | GNUNET_free (in); | ||
2881 | return GNUNET_SYSERR; | ||
2882 | } | ||
2883 | |||
2868 | hsh = GNUNET_CRYPTO_hash_context_start (); | 2884 | hsh = GNUNET_CRYPTO_hash_context_start (); |
2869 | GNUNET_CRYPTO_hash_context_read (hsh, in, in_len); | 2885 | GNUNET_CRYPTO_hash_context_read (hsh, in, in_len); |
2870 | GNUNET_CRYPTO_hash_context_read (hsh, peer, sizeof(*peer)); | 2886 | GNUNET_CRYPTO_hash_context_read (hsh, peer, sizeof(*peer)); |
@@ -2874,9 +2890,9 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity *peer, const char *address) | |||
2874 | if (NULL != receiver) | 2890 | if (NULL != receiver) |
2875 | { | 2891 | { |
2876 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2892 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2877 | "receiver %s already exist or is begin connected to\n", | 2893 | "receiver %s already exist or is being connected to\n", |
2878 | address); | 2894 | address); |
2879 | return GNUNET_SYSERR; | 2895 | return GNUNET_NO; |
2880 | } | 2896 | } |
2881 | 2897 | ||
2882 | receiver = GNUNET_new (struct ReceiverAddress); | 2898 | receiver = GNUNET_new (struct ReceiverAddress); |
@@ -3054,14 +3070,15 @@ handle_ack_by_sender (void *cls, const struct GNUNET_HashCode *key, void *value) | |||
3054 | struct ReceiverAddress *receiver = value; | 3070 | struct ReceiverAddress *receiver = value; |
3055 | struct AckInfo *ai = cls; | 3071 | struct AckInfo *ai = cls; |
3056 | 3072 | ||
3057 | if (0 != GNUNET_memcmp(ai->sender, &receiver->target)) | 3073 | if (0 != GNUNET_memcmp (ai->sender, &receiver->target)) |
3058 | { | 3074 | { |
3059 | return GNUNET_YES; | 3075 | return GNUNET_YES; |
3060 | } | 3076 | } |
3061 | handle_ack((void*) ai->ack, key, receiver); | 3077 | handle_ack ((void*) ai->ack, key, receiver); |
3062 | return GNUNET_YES; | 3078 | return GNUNET_YES; |
3063 | } | 3079 | } |
3064 | 3080 | ||
3081 | |||
3065 | /** | 3082 | /** |
3066 | * Function called when the transport service has received a | 3083 | * Function called when the transport service has received a |
3067 | * backchannel message for this communicator (!) via a different return | 3084 | * backchannel message for this communicator (!) via a different return |
@@ -3432,7 +3449,18 @@ run (void *cls, | |||
3432 | COMMUNICATOR_CONFIG_SECTION, | 3449 | COMMUNICATOR_CONFIG_SECTION, |
3433 | "REKEY_MAX_BYTES", | 3450 | "REKEY_MAX_BYTES", |
3434 | &rekey_max_bytes)) | 3451 | &rekey_max_bytes)) |
3452 | { | ||
3435 | rekey_max_bytes = DEFAULT_REKEY_MAX_BYTES; | 3453 | rekey_max_bytes = DEFAULT_REKEY_MAX_BYTES; |
3454 | } | ||
3455 | disable_v6 = GNUNET_NO; | ||
3456 | if ((GNUNET_NO == GNUNET_NETWORK_test_pf (PF_INET6)) || | ||
3457 | (GNUNET_YES == | ||
3458 | GNUNET_CONFIGURATION_get_value_yesno (cfg, | ||
3459 | COMMUNICATOR_CONFIG_SECTION, | ||
3460 | "DISABLE_V6"))) | ||
3461 | { | ||
3462 | disable_v6 = GNUNET_YES; | ||
3463 | } | ||
3436 | 3464 | ||
3437 | in = udp_address_to_sockaddr (bindto, &in_len); | 3465 | in = udp_address_to_sockaddr (bindto, &in_len); |
3438 | if (NULL == in) | 3466 | if (NULL == in) |
diff --git a/src/service/transport/transport_api2_communication.c b/src/service/transport/transport_api2_communication.c index fe7e69158..e0fdad214 100644 --- a/src/service/transport/transport_api2_communication.c +++ b/src/service/transport/transport_api2_communication.c | |||
@@ -598,8 +598,16 @@ handle_create_queue (void *cls, const struct GNUNET_TRANSPORT_CreateQueue *cq) | |||
598 | const char *addr = (const char *) &cq[1]; | 598 | const char *addr = (const char *) &cq[1]; |
599 | struct GNUNET_TRANSPORT_CreateQueueResponse *cqr; | 599 | struct GNUNET_TRANSPORT_CreateQueueResponse *cqr; |
600 | struct GNUNET_MQ_Envelope *env; | 600 | struct GNUNET_MQ_Envelope *env; |
601 | int ret = ch->mq_init (ch->mq_init_cls, &cq->receiver, addr); | ||
601 | 602 | ||
602 | if (GNUNET_OK != ch->mq_init (ch->mq_init_cls, &cq->receiver, addr)) | 603 | if (GNUNET_NO == ret) |
604 | { | ||
605 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
606 | "Address `%s' is already (beging) connected to.\n", | ||
607 | addr); | ||
608 | env = GNUNET_MQ_msg (cqr, GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_FAIL); | ||
609 | } | ||
610 | else if (GNUNET_SYSERR == ret) | ||
603 | { | 611 | { |
604 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 612 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
605 | "Address `%s' invalid for this communicator\n", | 613 | "Address `%s' invalid for this communicator\n", |