diff options
Diffstat (limited to 'src')
22 files changed, 1720 insertions, 75 deletions
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h index 41f2876e6..9e278eb92 100644 --- a/src/include/gnunet_protocols.h +++ b/src/include/gnunet_protocols.h | |||
@@ -3579,7 +3579,11 @@ extern "C" { | |||
3579 | 3579 | ||
3580 | #define GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED 1703 | 3580 | #define GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED 1703 |
3581 | 3581 | ||
3582 | #define GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED 1704 | 3582 | #define GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_TEST_PREPARED 1704 |
3583 | |||
3584 | #define GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_LOCAL_TESTS_PREPARED 1705 | ||
3585 | |||
3586 | #define GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED 1706 | ||
3583 | 3587 | ||
3584 | /*********************************************************************************/ | 3588 | /*********************************************************************************/ |
3585 | 3589 | ||
diff --git a/src/include/gnunet_testing_ng_lib.h b/src/include/gnunet_testing_ng_lib.h index adf5453e1..96e9af252 100644 --- a/src/include/gnunet_testing_ng_lib.h +++ b/src/include/gnunet_testing_ng_lib.h | |||
@@ -17,6 +17,7 @@ | |||
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | |||
20 | /** | 21 | /** |
21 | * @brief API for writing an interpreter to test GNUnet components | 22 | * @brief API for writing an interpreter to test GNUnet components |
22 | * @author Christian Grothoff <christian@grothoff.org> | 23 | * @author Christian Grothoff <christian@grothoff.org> |
@@ -83,17 +84,17 @@ enum GNUNET_TESTING_NODE_TYPE | |||
83 | 84 | ||
84 | 85 | ||
85 | // FIXME: this does not belong here! | 86 | // FIXME: this does not belong here! |
86 | struct GNUNET_TESTING_ADDRESS_PREFIX | 87 | struct GNUNET_TESTING_AddressPrefix |
87 | { | 88 | { |
88 | /** | 89 | /** |
89 | * Pointer to the previous prefix in the DLL. | 90 | * Pointer to the previous prefix in the DLL. |
90 | */ | 91 | */ |
91 | struct GNUNET_TESTING_ADDRESS_PREFIX *prev; | 92 | struct GNUNET_TESTING_AddressPrefix *prev; |
92 | 93 | ||
93 | /** | 94 | /** |
94 | * Pointer to the next prefix in the DLL. | 95 | * Pointer to the next prefix in the DLL. |
95 | */ | 96 | */ |
96 | struct GNUNET_TESTING_ADDRESS_PREFIX *next; | 97 | struct GNUNET_TESTING_AddressPrefix *next; |
97 | 98 | ||
98 | /** | 99 | /** |
99 | * The address prefix. | 100 | * The address prefix. |
@@ -145,12 +146,12 @@ struct GNUNET_TESTING_NodeConnection | |||
145 | /** | 146 | /** |
146 | * Head of the DLL with the address prefixes for the protocolls this node is reachable. | 147 | * Head of the DLL with the address prefixes for the protocolls this node is reachable. |
147 | */ | 148 | */ |
148 | struct GNUNET_TESTING_ADDRESS_PREFIX *address_prefixes_head; | 149 | struct GNUNET_TESTING_AddressPrefix *address_prefixes_head; |
149 | 150 | ||
150 | /** | 151 | /** |
151 | * Tail of the DLL with the address prefixes for the protocolls this node is reachable. | 152 | * Tail of the DLL with the address prefixes for the protocolls this node is reachable. |
152 | */ | 153 | */ |
153 | struct GNUNET_TESTING_ADDRESS_PREFIX *address_prefixes_tail; | 154 | struct GNUNET_TESTING_AddressPrefix *address_prefixes_tail; |
154 | }; | 155 | }; |
155 | 156 | ||
156 | /** | 157 | /** |
@@ -656,6 +657,55 @@ GNUNET_TESTING_get_topo_from_file (const char *filename); | |||
656 | 657 | ||
657 | 658 | ||
658 | /** | 659 | /** |
660 | * Get the connections to other nodes for a specific node. | ||
661 | * | ||
662 | * @param num The specific node we want the connections for. | ||
663 | * @param topology The topology we get the connections from. | ||
664 | * @return The connections of the node. | ||
665 | */ | ||
666 | struct GNUNET_TESTING_NodeConnection * | ||
667 | GNUNET_TESTING_get_connections (unsigned int num, struct | ||
668 | GNUNET_TESTING_NetjailTopology *topology); | ||
669 | |||
670 | |||
671 | /** | ||
672 | * Get the address for a specific communicator from a connection. | ||
673 | * | ||
674 | * @param connection The connection we like to have the address from. | ||
675 | * @param prefix The communicator protocol prefix. | ||
676 | * @return The address of the communicator. | ||
677 | */ | ||
678 | char * | ||
679 | GNUNET_TESTING_get_address (struct GNUNET_TESTING_NodeConnection *connection, | ||
680 | char *prefix); | ||
681 | |||
682 | |||
683 | /** | ||
684 | * Calculate the unique id identifying a node from a given connction. | ||
685 | * | ||
686 | * @param node_connection The connection we calculate the id from. | ||
687 | * @param topology The topology we get all needed information from. | ||
688 | * @return The unique id of the node from the connection. | ||
689 | */ | ||
690 | unsigned int | ||
691 | GNUNET_TESTING_calculate_num (struct | ||
692 | GNUNET_TESTING_NodeConnection *node_connection, | ||
693 | struct GNUNET_TESTING_NetjailTopology *topology); | ||
694 | |||
695 | |||
696 | /** | ||
697 | * Retrieve the public key from the test system with the unique node id. | ||
698 | * | ||
699 | * @param num The unique node id. | ||
700 | * @param tl_system The test system. | ||
701 | * @return The peer identity wrapping the public key. | ||
702 | */ | ||
703 | struct GNUNET_PeerIdentity * | ||
704 | GNUNET_TESTING_get_pub_key (unsigned int num, struct | ||
705 | GNUNET_TESTING_System *tl_system); | ||
706 | |||
707 | |||
708 | /** | ||
659 | * Obtain performance data from the interpreter. | 709 | * Obtain performance data from the interpreter. |
660 | * | 710 | * |
661 | * @param timers what commands (by label) to obtain runtimes for | 711 | * @param timers what commands (by label) to obtain runtimes for |
@@ -1149,9 +1199,31 @@ struct GNUNET_TESTING_Command | |||
1149 | GNUNET_TESTING_cmd_send_peer_ready (const char *label, | 1199 | GNUNET_TESTING_cmd_send_peer_ready (const char *label, |
1150 | TESTING_CMD_HELPER_write_cb write_message); | 1200 | TESTING_CMD_HELPER_write_cb write_message); |
1151 | 1201 | ||
1202 | |||
1203 | /** | ||
1204 | * Create command. | ||
1205 | * | ||
1206 | * @param label name for command. | ||
1207 | * @param write_message Callback to write messages to the master loop. | ||
1208 | * @return command. | ||
1209 | */ | ||
1152 | struct GNUNET_TESTING_Command | 1210 | struct GNUNET_TESTING_Command |
1153 | GNUNET_TESTING_cmd_local_test_finished ( | 1211 | GNUNET_TESTING_cmd_local_test_finished ( |
1154 | const char *label, | 1212 | const char *label, |
1155 | TESTING_CMD_HELPER_write_cb write_message); | 1213 | TESTING_CMD_HELPER_write_cb write_message); |
1156 | 1214 | ||
1215 | /** | ||
1216 | * Create command. | ||
1217 | * | ||
1218 | * @param label name for command. | ||
1219 | * @param write_message Callback to write messages to the master loop. | ||
1220 | * @param all_local_tests_prepared Flag which will be set from outside. | ||
1221 | * @return command. | ||
1222 | */ | ||
1223 | struct GNUNET_TESTING_Command | ||
1224 | GNUNET_TESTING_cmd_local_test_prepared (const char *label, | ||
1225 | TESTING_CMD_HELPER_write_cb | ||
1226 | write_message, | ||
1227 | unsigned int * | ||
1228 | all_local_tests_prepared); | ||
1157 | #endif | 1229 | #endif |
diff --git a/src/include/gnunet_testing_plugin.h b/src/include/gnunet_testing_plugin.h index 151827d4b..4a6a9368e 100644 --- a/src/include/gnunet_testing_plugin.h +++ b/src/include/gnunet_testing_plugin.h | |||
@@ -48,9 +48,15 @@ typedef void | |||
48 | char *m, | 48 | char *m, |
49 | char *local_m); | 49 | char *local_m); |
50 | 50 | ||
51 | |||
51 | typedef void | 52 | typedef void |
52 | (*GNUNET_TESTING_PLUGIN_ALL_PEERS_STARTED) (); | 53 | (*GNUNET_TESTING_PLUGIN_ALL_PEERS_STARTED) (); |
53 | 54 | ||
55 | |||
56 | typedef void | ||
57 | (*GNUNET_TESTING_PLUGIN_ALL_LOCAL_TESTS_PREPARED) (); | ||
58 | |||
59 | |||
54 | struct GNUNET_TESTING_PluginFunctions | 60 | struct GNUNET_TESTING_PluginFunctions |
55 | { | 61 | { |
56 | /** | 62 | /** |
@@ -61,6 +67,8 @@ struct GNUNET_TESTING_PluginFunctions | |||
61 | GNUNET_TESTING_PLUGIN_StartTestCase start_testcase; | 67 | GNUNET_TESTING_PLUGIN_StartTestCase start_testcase; |
62 | 68 | ||
63 | GNUNET_TESTING_PLUGIN_ALL_PEERS_STARTED all_peers_started; | 69 | GNUNET_TESTING_PLUGIN_ALL_PEERS_STARTED all_peers_started; |
70 | |||
71 | GNUNET_TESTING_PLUGIN_ALL_LOCAL_TESTS_PREPARED all_local_tests_prepared; | ||
64 | }; | 72 | }; |
65 | 73 | ||
66 | #if 0 /* keep Emacsens' auto-indent happy */ | 74 | #if 0 /* keep Emacsens' auto-indent happy */ |
diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am index 39e85c4ac..3daa29e1e 100644 --- a/src/testing/Makefile.am +++ b/src/testing/Makefile.am | |||
@@ -47,6 +47,7 @@ libgnunettesting_la_SOURCES = \ | |||
47 | testing_api_cmd_end.c \ | 47 | testing_api_cmd_end.c \ |
48 | testing_api_cmd_finish.c \ | 48 | testing_api_cmd_finish.c \ |
49 | testing_api_cmd_local_test_finished.c \ | 49 | testing_api_cmd_local_test_finished.c \ |
50 | testing_api_cmd_local_test_prepared.c \ | ||
50 | testing_api_cmd_send_peer_ready.c \ | 51 | testing_api_cmd_send_peer_ready.c \ |
51 | testing_api_cmd_block_until_all_peers_started.c \ | 52 | testing_api_cmd_block_until_all_peers_started.c \ |
52 | testing_api_cmd_block_until_external_trigger.c \ | 53 | testing_api_cmd_block_until_external_trigger.c \ |
diff --git a/src/testing/gnunet-cmds-helper.c b/src/testing/gnunet-cmds-helper.c index e50db0cf6..4aeccb115 100644 --- a/src/testing/gnunet-cmds-helper.c +++ b/src/testing/gnunet-cmds-helper.c | |||
@@ -418,9 +418,19 @@ tokenizer_cb (void *cls, const struct GNUNET_MessageHeader *message) | |||
418 | else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED == ntohs ( | 418 | else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED == ntohs ( |
419 | message->type)) | 419 | message->type)) |
420 | { | 420 | { |
421 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
422 | "all peers started\n"); | ||
421 | plugin->api->all_peers_started (); | 423 | plugin->api->all_peers_started (); |
422 | return GNUNET_OK; | 424 | return GNUNET_OK; |
423 | } | 425 | } |
426 | else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_LOCAL_TESTS_PREPARED == ntohs ( | ||
427 | message->type)) | ||
428 | { | ||
429 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
430 | "all local tests prepared\n"); | ||
431 | plugin->api->all_local_tests_prepared (); | ||
432 | return GNUNET_OK; | ||
433 | } | ||
424 | else | 434 | else |
425 | { | 435 | { |
426 | LOG (GNUNET_ERROR_TYPE_WARNING, "Received unexpected message -- exiting\n"); | 436 | LOG (GNUNET_ERROR_TYPE_WARNING, "Received unexpected message -- exiting\n"); |
diff --git a/src/testing/test_testing_topology.c b/src/testing/test_testing_topology.c new file mode 100644 index 000000000..cfc91e609 --- /dev/null +++ b/src/testing/test_testing_topology.c | |||
@@ -0,0 +1,44 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2021 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file testbed/plugin_testcmd.c | ||
23 | * @brief a plugin to provide the API for running test cases. | ||
24 | * @author t3sserakt | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_util_lib.h" | ||
28 | #include "gnunet_testing_ng_lib.h" | ||
29 | |||
30 | #define LOG(kind, ...) GNUNET_log_from (kind, "testing-api", __VA_ARGS__) | ||
31 | |||
32 | int | ||
33 | main (int argc, | ||
34 | char *const *argv) | ||
35 | { | ||
36 | GNUNET_log_setup ("test-topology", | ||
37 | "DEBUG", | ||
38 | NULL); | ||
39 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
40 | "Test\n"); | ||
41 | GNUNET_TESTING_get_topo_from_file ("topo.conf"); | ||
42 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
43 | "Test2\n"); | ||
44 | } | ||
diff --git a/src/testing/testing.c b/src/testing/testing.c index 766c7b084..4d9b7c0cb 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c | |||
@@ -38,6 +38,15 @@ | |||
38 | 38 | ||
39 | #define LOG(kind, ...) GNUNET_log_from (kind, "testing-api", __VA_ARGS__) | 39 | #define LOG(kind, ...) GNUNET_log_from (kind, "testing-api", __VA_ARGS__) |
40 | 40 | ||
41 | #define CONNECT_ADDRESS_TEMPLATE "%s-192.168.15.%u:60002" | ||
42 | |||
43 | #define ROUTER_CONNECT_ADDRESS_TEMPLATE "%s-92.68.150.%u:60002" | ||
44 | |||
45 | #define KNOWN_CONNECT_ADDRESS_TEMPLATE "%s-92.68.151.%u:60002" | ||
46 | |||
47 | #define PREFIX_TCP "tcp" | ||
48 | |||
49 | #define PREFIX_UDP "udp" | ||
41 | 50 | ||
42 | /** | 51 | /** |
43 | * Lowest port used for GNUnet testing. Should be high enough to not | 52 | * Lowest port used for GNUnet testing. Should be high enough to not |
@@ -1901,7 +1910,7 @@ get_connect_value (char *line, struct GNUNET_TESTING_NetjailNode *node) | |||
1901 | unsigned int namespace_n; | 1910 | unsigned int namespace_n; |
1902 | char *rest = NULL; | 1911 | char *rest = NULL; |
1903 | char *rest2 = NULL; | 1912 | char *rest2 = NULL; |
1904 | struct GNUNET_TESTING_ADDRESS_PREFIX *prefix; | 1913 | struct GNUNET_TESTING_AddressPrefix *prefix; |
1905 | 1914 | ||
1906 | node_connection = GNUNET_new (struct GNUNET_TESTING_NodeConnection); | 1915 | node_connection = GNUNET_new (struct GNUNET_TESTING_NodeConnection); |
1907 | node_connection->node = node; | 1916 | node_connection->node = node; |
@@ -1937,7 +1946,7 @@ get_connect_value (char *line, struct GNUNET_TESTING_NetjailNode *node) | |||
1937 | } | 1946 | } |
1938 | while (NULL != (token = strtok_r (NULL, ":", &rest))) | 1947 | while (NULL != (token = strtok_r (NULL, ":", &rest))) |
1939 | { | 1948 | { |
1940 | prefix = GNUNET_new (struct GNUNET_TESTING_ADDRESS_PREFIX); | 1949 | prefix = GNUNET_new (struct GNUNET_TESTING_AddressPrefix); |
1941 | token2 = strtok_r (token, "}", &rest2); | 1950 | token2 = strtok_r (token, "}", &rest2); |
1942 | if (NULL != token2) | 1951 | if (NULL != token2) |
1943 | { | 1952 | { |
@@ -1959,6 +1968,9 @@ get_connect_value (char *line, struct GNUNET_TESTING_NetjailNode *node) | |||
1959 | GNUNET_CONTAINER_DLL_insert (node_connection->address_prefixes_head, | 1968 | GNUNET_CONTAINER_DLL_insert (node_connection->address_prefixes_head, |
1960 | node_connection->address_prefixes_tail, | 1969 | node_connection->address_prefixes_tail, |
1961 | prefix); | 1970 | prefix); |
1971 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
1972 | "address_prefix %s\n", | ||
1973 | prefix->address_prefix); | ||
1962 | } | 1974 | } |
1963 | 1975 | ||
1964 | GNUNET_free (copy); | 1976 | GNUNET_free (copy); |
@@ -2003,6 +2015,250 @@ node_connections (char *line, struct GNUNET_TESTING_NetjailNode *node) | |||
2003 | } | 2015 | } |
2004 | 2016 | ||
2005 | 2017 | ||
2018 | static int | ||
2019 | log_nodes (void *cls, const struct GNUNET_ShortHashCode *id, void *value) | ||
2020 | { | ||
2021 | struct GNUNET_TESTING_NetjailNode *node = value; | ||
2022 | struct GNUNET_TESTING_NodeConnection *pos_connection; | ||
2023 | struct GNUNET_TESTING_AddressPrefix *pos_prefix; | ||
2024 | |||
2025 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
2026 | "plugin: %s space: %u node: %u global: %u\n", | ||
2027 | node->plugin, | ||
2028 | node->namespace_n, | ||
2029 | node->node_n, | ||
2030 | node->is_global); | ||
2031 | |||
2032 | for (pos_connection = node->node_connections_head; NULL != pos_connection; | ||
2033 | pos_connection = pos_connection->next) | ||
2034 | { | ||
2035 | |||
2036 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
2037 | "namespace_n: %u node_n: %u node_type: %u\n", | ||
2038 | pos_connection->namespace_n, | ||
2039 | pos_connection->node_n, | ||
2040 | pos_connection->node_type); | ||
2041 | |||
2042 | for (pos_prefix = pos_connection->address_prefixes_head; NULL != pos_prefix; | ||
2043 | pos_prefix = | ||
2044 | pos_prefix->next) | ||
2045 | { | ||
2046 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
2047 | "prefix: %s\n", | ||
2048 | pos_prefix->address_prefix); | ||
2049 | } | ||
2050 | } | ||
2051 | return GNUNET_YES; | ||
2052 | } | ||
2053 | |||
2054 | |||
2055 | static int | ||
2056 | log_namespaces (void *cls, const struct GNUNET_ShortHashCode *id, void *value) | ||
2057 | { | ||
2058 | struct GNUNET_TESTING_NetjailNamespace *namespace = value; | ||
2059 | struct GNUNET_TESTING_NetjailRouter *router = namespace->router; | ||
2060 | |||
2061 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
2062 | "router_tcp: %u router_udp: %u spaces: %u\n", | ||
2063 | router->tcp_port, | ||
2064 | router->udp_port, | ||
2065 | namespace->namespace_n); | ||
2066 | GNUNET_CONTAINER_multishortmap_iterate (namespace->nodes, &log_nodes, NULL); | ||
2067 | return GNUNET_YES; | ||
2068 | } | ||
2069 | |||
2070 | |||
2071 | static int | ||
2072 | log_topo (struct GNUNET_TESTING_NetjailTopology *topology) | ||
2073 | { | ||
2074 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
2075 | "plugin: %s spaces: %u nodes: %u known: %u\n", | ||
2076 | topology->plugin, | ||
2077 | topology->namespaces_n, | ||
2078 | topology->nodes_m, | ||
2079 | topology->nodes_x); | ||
2080 | |||
2081 | GNUNET_CONTAINER_multishortmap_iterate (topology->map_namespaces, | ||
2082 | log_namespaces, NULL); | ||
2083 | GNUNET_CONTAINER_multishortmap_iterate (topology->map_globals, &log_nodes, | ||
2084 | NULL); | ||
2085 | return GNUNET_YES; | ||
2086 | } | ||
2087 | |||
2088 | |||
2089 | /** | ||
2090 | * Get the connections to other nodes for a specific node. | ||
2091 | * | ||
2092 | * @param num The specific node we want the connections for. | ||
2093 | * @param topology The topology we get the connections from. | ||
2094 | * @return The connections of the node. | ||
2095 | */ | ||
2096 | struct GNUNET_TESTING_NodeConnection * | ||
2097 | GNUNET_TESTING_get_connections (unsigned int num, struct | ||
2098 | GNUNET_TESTING_NetjailTopology *topology) | ||
2099 | { | ||
2100 | struct GNUNET_TESTING_NetjailNode *node; | ||
2101 | struct GNUNET_ShortHashCode *hkey; | ||
2102 | struct GNUNET_HashCode hc; | ||
2103 | struct GNUNET_TESTING_NetjailNamespace *namespace; | ||
2104 | unsigned int namespace_n, node_m; | ||
2105 | |||
2106 | log_topo (topology); | ||
2107 | |||
2108 | hkey = GNUNET_new (struct GNUNET_ShortHashCode); | ||
2109 | if (topology->nodes_x >= num) | ||
2110 | { | ||
2111 | |||
2112 | GNUNET_CRYPTO_hash (&num, sizeof(num), &hc); | ||
2113 | memcpy (hkey, | ||
2114 | &hc, | ||
2115 | sizeof (*hkey)); | ||
2116 | node = GNUNET_CONTAINER_multishortmap_get (topology->map_globals, | ||
2117 | hkey); | ||
2118 | } | ||
2119 | else | ||
2120 | { | ||
2121 | namespace_n = (unsigned int) floor ((num - topology->nodes_x) | ||
2122 | / topology->nodes_m); | ||
2123 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
2124 | "num: %u nodes_x: %u nodes_m: %u namespace_n: %u\n", | ||
2125 | num, | ||
2126 | topology->nodes_x, | ||
2127 | topology->nodes_m, | ||
2128 | namespace_n); | ||
2129 | hkey = GNUNET_new (struct GNUNET_ShortHashCode); | ||
2130 | GNUNET_CRYPTO_hash (&namespace_n, sizeof(namespace_n), &hc); | ||
2131 | memcpy (hkey, | ||
2132 | &hc, | ||
2133 | sizeof (*hkey)); | ||
2134 | namespace = GNUNET_CONTAINER_multishortmap_get (topology->map_namespaces, | ||
2135 | hkey); | ||
2136 | node_m = num - topology->nodes_x - topology->nodes_m * (namespace_n - 1); | ||
2137 | hkey = GNUNET_new (struct GNUNET_ShortHashCode); | ||
2138 | GNUNET_CRYPTO_hash (&node_m, sizeof(node_m), &hc); | ||
2139 | memcpy (hkey, | ||
2140 | &hc, | ||
2141 | sizeof (*hkey)); | ||
2142 | node = GNUNET_CONTAINER_multishortmap_get (namespace->nodes, | ||
2143 | hkey); | ||
2144 | } | ||
2145 | |||
2146 | |||
2147 | return node->node_connections_head; | ||
2148 | } | ||
2149 | |||
2150 | |||
2151 | /** | ||
2152 | * Retrieve the public key from the test system with the unique node id. | ||
2153 | * | ||
2154 | * @param num The unique node id. | ||
2155 | * @param tl_system The test system. | ||
2156 | * @return The peer identity wrapping the public key. | ||
2157 | */ | ||
2158 | struct GNUNET_PeerIdentity * | ||
2159 | GNUNET_TESTING_get_pub_key (unsigned int num, struct | ||
2160 | GNUNET_TESTING_System *tl_system) | ||
2161 | { | ||
2162 | struct GNUNET_PeerIdentity *peer = GNUNET_new (struct GNUNET_PeerIdentity); | ||
2163 | struct GNUNET_CRYPTO_EddsaPublicKey *pub_key = GNUNET_new (struct | ||
2164 | GNUNET_CRYPTO_EddsaPublicKey); | ||
2165 | struct GNUNET_CRYPTO_EddsaPrivateKey *priv_key = GNUNET_new (struct | ||
2166 | GNUNET_CRYPTO_EddsaPrivateKey); | ||
2167 | |||
2168 | priv_key = GNUNET_TESTING_hostkey_get (tl_system, | ||
2169 | num, | ||
2170 | peer); | ||
2171 | |||
2172 | GNUNET_CRYPTO_eddsa_key_get_public (priv_key, | ||
2173 | pub_key); | ||
2174 | peer->public_key = *pub_key; | ||
2175 | return peer; | ||
2176 | } | ||
2177 | |||
2178 | |||
2179 | /** | ||
2180 | * Calculate the unique id identifying a node from a given connction. | ||
2181 | * | ||
2182 | * @param node_connection The connection we calculate the id from. | ||
2183 | * @param topology The topology we get all needed information from. | ||
2184 | * @return The unique id of the node from the connection. | ||
2185 | */ | ||
2186 | unsigned int | ||
2187 | GNUNET_TESTING_calculate_num (struct | ||
2188 | GNUNET_TESTING_NodeConnection *node_connection, | ||
2189 | struct GNUNET_TESTING_NetjailTopology *topology) | ||
2190 | { | ||
2191 | unsigned int n, m, num; | ||
2192 | |||
2193 | n = node_connection->namespace_n; | ||
2194 | m = node_connection->node_n; | ||
2195 | |||
2196 | if (0 == n) | ||
2197 | num = m; | ||
2198 | else | ||
2199 | num = (n - 1) * topology->nodes_m + m + topology->nodes_x; | ||
2200 | |||
2201 | return num; | ||
2202 | } | ||
2203 | |||
2204 | |||
2205 | /** | ||
2206 | * Get the address for a specific communicator from a connection. | ||
2207 | * | ||
2208 | * @param connection The connection we like to have the address from. | ||
2209 | * @param prefix The communicator protocol prefix. | ||
2210 | * @return The address of the communicator. | ||
2211 | */ | ||
2212 | char * | ||
2213 | GNUNET_TESTING_get_address (struct GNUNET_TESTING_NodeConnection *connection, | ||
2214 | char *prefix) | ||
2215 | { | ||
2216 | struct GNUNET_TESTING_NetjailNode *node; | ||
2217 | char *addr; | ||
2218 | char *template; | ||
2219 | |||
2220 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
2221 | "node_n: %u\n", | ||
2222 | connection->node_n); | ||
2223 | |||
2224 | node = connection->node; | ||
2225 | if (connection->namespace_n == node->namespace_n) | ||
2226 | { | ||
2227 | template = CONNECT_ADDRESS_TEMPLATE; | ||
2228 | } | ||
2229 | else if (0 == connection->namespace_n) | ||
2230 | { | ||
2231 | template = KNOWN_CONNECT_ADDRESS_TEMPLATE; | ||
2232 | } | ||
2233 | else | ||
2234 | { | ||
2235 | template = ROUTER_CONNECT_ADDRESS_TEMPLATE; | ||
2236 | } | ||
2237 | |||
2238 | if (0 == strcmp (PREFIX_TCP, prefix)) | ||
2239 | { | ||
2240 | |||
2241 | GNUNET_asprintf (&addr, | ||
2242 | template, | ||
2243 | prefix, | ||
2244 | connection->node_n); | ||
2245 | } | ||
2246 | else if (0 == strcmp (PREFIX_UDP, prefix)) | ||
2247 | { | ||
2248 | GNUNET_asprintf (&addr, | ||
2249 | template, | ||
2250 | prefix, | ||
2251 | connection->node_n); | ||
2252 | } | ||
2253 | else | ||
2254 | { | ||
2255 | GNUNET_break (0); | ||
2256 | } | ||
2257 | |||
2258 | return addr; | ||
2259 | } | ||
2260 | |||
2261 | |||
2006 | /** | 2262 | /** |
2007 | * Create a GNUNET_CMDS_LOCAL_FINISHED message. | 2263 | * Create a GNUNET_CMDS_LOCAL_FINISHED message. |
2008 | * | 2264 | * |
diff --git a/src/testing/testing_api_cmd_local_test_prepared.c b/src/testing/testing_api_cmd_local_test_prepared.c new file mode 100644 index 000000000..4e915c7c0 --- /dev/null +++ b/src/testing/testing_api_cmd_local_test_prepared.c | |||
@@ -0,0 +1,168 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2021 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file testing_api_cmd_local_test_prepared.c | ||
23 | * @brief cmd to block the interpreter loop until all peers started. | ||
24 | * @author t3sserakt | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_util_lib.h" | ||
28 | #include "gnunet_testing_ng_lib.h" | ||
29 | #include "testing_cmds.h" | ||
30 | |||
31 | /** | ||
32 | * Generic logging shortcut | ||
33 | */ | ||
34 | #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) | ||
35 | |||
36 | |||
37 | /** | ||
38 | * Struct to hold information for callbacks. | ||
39 | * | ||
40 | */ | ||
41 | struct LocalPreparedState | ||
42 | { | ||
43 | /** | ||
44 | * Callback to write messages to the master loop. | ||
45 | * | ||
46 | */ | ||
47 | TESTING_CMD_HELPER_write_cb write_message; | ||
48 | |||
49 | /** | ||
50 | * The message send back to the master loop. | ||
51 | * | ||
52 | */ | ||
53 | struct GNUNET_CMDS_LOCAL_TEST_PREPARED *reply; | ||
54 | |||
55 | /** | ||
56 | * Flag indicating if all local tests finished. | ||
57 | */ | ||
58 | unsigned int *all_local_tests_prepared; | ||
59 | }; | ||
60 | |||
61 | |||
62 | /** | ||
63 | * Trait function of this cmd does nothing. | ||
64 | * | ||
65 | */ | ||
66 | static int | ||
67 | local_test_prepared_traits (void *cls, | ||
68 | const void **ret, | ||
69 | const char *trait, | ||
70 | unsigned int index) | ||
71 | { | ||
72 | return GNUNET_OK; | ||
73 | } | ||
74 | |||
75 | |||
76 | /** | ||
77 | * The cleanup function of this cmd frees resources the cmd allocated. | ||
78 | * | ||
79 | */ | ||
80 | static void | ||
81 | local_test_prepared_cleanup (void *cls, | ||
82 | const struct GNUNET_TESTING_Command *cmd) | ||
83 | { | ||
84 | struct LocalPreparedState *lfs = cls; | ||
85 | |||
86 | GNUNET_free (lfs->reply); | ||
87 | GNUNET_free (lfs); | ||
88 | } | ||
89 | |||
90 | |||
91 | /** | ||
92 | * This function sends a GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_TESTS_PREPARED message to the master loop. | ||
93 | * | ||
94 | */ | ||
95 | static void | ||
96 | local_test_prepared_run (void *cls, | ||
97 | const struct GNUNET_TESTING_Command *cmd, | ||
98 | struct GNUNET_TESTING_Interpreter *is) | ||
99 | { | ||
100 | struct LocalPreparedState *lfs = cls; | ||
101 | |||
102 | struct GNUNET_CMDS_LOCAL_TEST_PREPARED *reply; | ||
103 | size_t msg_length; | ||
104 | |||
105 | msg_length = sizeof(struct GNUNET_CMDS_LOCAL_TEST_PREPARED); | ||
106 | reply = GNUNET_new (struct GNUNET_CMDS_LOCAL_TEST_PREPARED); | ||
107 | reply->header.type = htons ( | ||
108 | GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_TEST_PREPARED); | ||
109 | reply->header.size = htons ((uint16_t) msg_length); | ||
110 | lfs->reply = reply; | ||
111 | lfs->write_message ((struct GNUNET_MessageHeader *) reply, msg_length); | ||
112 | } | ||
113 | |||
114 | |||
115 | /** | ||
116 | * This finish function will stop the local loop without shutting down the scheduler, because we do not call the continuation, which is the interpreter_next method. | ||
117 | * | ||
118 | */ | ||
119 | static int | ||
120 | local_test_prepared_finish (void *cls, | ||
121 | GNUNET_SCHEDULER_TaskCallback cont, | ||
122 | void *cont_cls) | ||
123 | { | ||
124 | struct LocalPreparedState *lfs = cls; | ||
125 | unsigned int *ret = lfs->all_local_tests_prepared; | ||
126 | |||
127 | if (GNUNET_YES == *ret) | ||
128 | { | ||
129 | cont (cont_cls); | ||
130 | } | ||
131 | |||
132 | return *ret; | ||
133 | |||
134 | } | ||
135 | |||
136 | |||
137 | /** | ||
138 | * Create command. | ||
139 | * | ||
140 | * @param label name for command. | ||
141 | * @param write_message Callback to write messages to the master loop. | ||
142 | * @param all_local_tests_prepared Flag which will be set from outside. | ||
143 | * @return command. | ||
144 | */ | ||
145 | struct GNUNET_TESTING_Command | ||
146 | GNUNET_TESTING_cmd_local_test_prepared (const char *label, | ||
147 | TESTING_CMD_HELPER_write_cb | ||
148 | write_message, | ||
149 | unsigned int * | ||
150 | all_local_tests_prepared) | ||
151 | { | ||
152 | struct LocalPreparedState *lfs; | ||
153 | |||
154 | lfs = GNUNET_new (struct LocalPreparedState); | ||
155 | lfs->write_message = write_message; | ||
156 | lfs->all_local_tests_prepared = all_local_tests_prepared; | ||
157 | |||
158 | struct GNUNET_TESTING_Command cmd = { | ||
159 | .cls = lfs, | ||
160 | .label = label, | ||
161 | .run = &local_test_prepared_run, | ||
162 | .finish = &local_test_prepared_finish, | ||
163 | .cleanup = &local_test_prepared_cleanup, | ||
164 | .traits = &local_test_prepared_traits | ||
165 | }; | ||
166 | |||
167 | return cmd; | ||
168 | } | ||
diff --git a/src/testing/testing_cmds.h b/src/testing/testing_cmds.h index 09e4f2dcb..12db87d19 100644 --- a/src/testing/testing_cmds.h +++ b/src/testing/testing_cmds.h | |||
@@ -87,6 +87,23 @@ struct GNUNET_CMDS_LOCAL_FINISHED | |||
87 | enum GNUNET_GenericReturnValue result; | 87 | enum GNUNET_GenericReturnValue result; |
88 | }; | 88 | }; |
89 | 89 | ||
90 | struct GNUNET_CMDS_LOCAL_TEST_PREPARED | ||
91 | { | ||
92 | /** | ||
93 | * Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_TEST_PREPARED | ||
94 | */ | ||
95 | struct GNUNET_MessageHeader header; | ||
96 | }; | ||
97 | |||
98 | struct GNUNET_CMDS_ALL_LOCAL_TESTS_PREPARED | ||
99 | { | ||
100 | /** | ||
101 | * Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_LOCAL_TESTS_PREPARED | ||
102 | */ | ||
103 | struct GNUNET_MessageHeader header; | ||
104 | }; | ||
105 | |||
90 | GNUNET_NETWORK_STRUCT_END | 106 | GNUNET_NETWORK_STRUCT_END |
107 | |||
91 | #endif | 108 | #endif |
92 | /* end of testing_cmds.h */ | 109 | /* end of testing_cmds.h */ |
diff --git a/src/testing/topo.sh b/src/testing/topo.sh index 090c3053f..0046622b6 100755 --- a/src/testing/topo.sh +++ b/src/testing/topo.sh | |||
@@ -20,8 +20,7 @@ extract_attributes() | |||
20 | number=$(echo $line|cut -d \| -f 1| cut -c 2-|cut -d : -f 2 ) | 20 | number=$(echo $line|cut -d \| -f 1| cut -c 2-|cut -d : -f 2 ) |
21 | echo $number | 21 | echo $number |
22 | fi | 22 | fi |
23 | 23 | ||
24 | |||
25 | nf=$(echo $line|awk -F: '{print NF}') | 24 | nf=$(echo $line|awk -F: '{print NF}') |
26 | for ((i=2;i<=$nf;i++)) | 25 | for ((i=2;i<=$nf;i++)) |
27 | do | 26 | do |
@@ -67,6 +66,11 @@ while read line; do | |||
67 | then | 66 | then |
68 | GLOBAL_N=$(cut -d : -f 2 <<< $line) | 67 | GLOBAL_N=$(cut -d : -f 2 <<< $line) |
69 | echo $GLOBAL_N | 68 | echo $GLOBAL_N |
69 | for ((i=1;i<=$GLOBAL_N;i++)) | ||
70 | do | ||
71 | R_TCP[$i]=0 | ||
72 | R_UDP[$i]=0 | ||
73 | done | ||
70 | elif [ "$key" = "X" ] | 74 | elif [ "$key" = "X" ] |
71 | then | 75 | then |
72 | KNOWN=$(cut -d : -f 2 <<< $line) | 76 | KNOWN=$(cut -d : -f 2 <<< $line) |
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am index 0df422976..d281c4ffb 100644 --- a/src/transport/Makefile.am +++ b/src/transport/Makefile.am | |||
@@ -159,6 +159,7 @@ libgnunettransporttesting_la_LDFLAGS = \ | |||
159 | 159 | ||
160 | libgnunettransporttesting2_la_SOURCES = \ | 160 | libgnunettransporttesting2_la_SOURCES = \ |
161 | transport_api_cmd_connecting_peers.c \ | 161 | transport_api_cmd_connecting_peers.c \ |
162 | transport_api_cmd_backchannel_check.c \ | ||
162 | transport_api_cmd_start_peer.c \ | 163 | transport_api_cmd_start_peer.c \ |
163 | transport_api_cmd_stop_peer.c \ | 164 | transport_api_cmd_stop_peer.c \ |
164 | transport_api_cmd_send_simple.c \ | 165 | transport_api_cmd_send_simple.c \ |
diff --git a/src/transport/gnunet-communicator-tcp.c b/src/transport/gnunet-communicator-tcp.c index d8bf7c1a8..025326de7 100644 --- a/src/transport/gnunet-communicator-tcp.c +++ b/src/transport/gnunet-communicator-tcp.c | |||
@@ -1119,6 +1119,10 @@ pass_plaintext_to_core (struct Queue *queue, | |||
1119 | const struct GNUNET_MessageHeader *hdr = plaintext; | 1119 | const struct GNUNET_MessageHeader *hdr = plaintext; |
1120 | int ret; | 1120 | int ret; |
1121 | 1121 | ||
1122 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1123 | "pass message from %s to core\n", | ||
1124 | GNUNET_i2s (&queue->target)); | ||
1125 | |||
1122 | if (ntohs (hdr->size) != plaintext_len) | 1126 | if (ntohs (hdr->size) != plaintext_len) |
1123 | { | 1127 | { |
1124 | /* NOTE: If we ever allow multiple CORE messages in one | 1128 | /* NOTE: If we ever allow multiple CORE messages in one |
@@ -1132,6 +1136,8 @@ pass_plaintext_to_core (struct Queue *queue, | |||
1132 | ADDRESS_VALIDITY_PERIOD, | 1136 | ADDRESS_VALIDITY_PERIOD, |
1133 | &core_read_finished_cb, | 1137 | &core_read_finished_cb, |
1134 | queue); | 1138 | queue); |
1139 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1140 | "passed to core\n"); | ||
1135 | if (GNUNET_OK == ret) | 1141 | if (GNUNET_OK == ret) |
1136 | queue->backpressure++; | 1142 | queue->backpressure++; |
1137 | GNUNET_break (GNUNET_NO != ret); /* backpressure not working!? */ | 1143 | GNUNET_break (GNUNET_NO != ret); /* backpressure not working!? */ |
@@ -1795,7 +1801,7 @@ try_handle_plaintext (struct Queue *queue) | |||
1795 | queue->qh = GNUNET_TRANSPORT_communicator_mq_add (ch, | 1801 | queue->qh = GNUNET_TRANSPORT_communicator_mq_add (ch, |
1796 | &queue->target, | 1802 | &queue->target, |
1797 | foreign_addr, | 1803 | foreign_addr, |
1798 | UINT32_MAX, /* no MTU */ | 1804 | UINT16_MAX, /* no MTU */ |
1799 | GNUNET_TRANSPORT_QUEUE_LENGTH_UNLIMITED, | 1805 | GNUNET_TRANSPORT_QUEUE_LENGTH_UNLIMITED, |
1800 | 0, /* Priority */ | 1806 | 0, /* Priority */ |
1801 | queue->nt, | 1807 | queue->nt, |
@@ -2444,7 +2450,7 @@ boot_queue (struct Queue *queue) | |||
2444 | * Generate and transmit our ephemeral key and the signature for | 2450 | * Generate and transmit our ephemeral key and the signature for |
2445 | * the initial KX with the other peer. Must be called first, before | 2451 | * the initial KX with the other peer. Must be called first, before |
2446 | * any other bytes are ever written to the output buffer. Note that | 2452 | * any other bytes are ever written to the output buffer. Note that |
2447 | * our cipher must already be initialized when calling this function. | 2453 | * our cipher must already be initialized when calling thi function. |
2448 | * Helper function for #start_initial_kx_out(). | 2454 | * Helper function for #start_initial_kx_out(). |
2449 | * | 2455 | * |
2450 | * @param queue queue to do KX for | 2456 | * @param queue queue to do KX for |
@@ -2725,6 +2731,9 @@ proto_read_kx (void *cls) | |||
2725 | queue->listen_sock = pq->listen_sock; | 2731 | queue->listen_sock = pq->listen_sock; |
2726 | queue->sock = pq->sock; | 2732 | queue->sock = pq->sock; |
2727 | 2733 | ||
2734 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2735 | "created queue with target %s\n", | ||
2736 | GNUNET_i2s (&queue->target)); | ||
2728 | 2737 | ||
2729 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2738 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2730 | "start kx proto\n"); | 2739 | "start kx proto\n"); |
@@ -2984,6 +2993,9 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity *peer, const char *address) | |||
2984 | queue->sock = sock; | 2993 | queue->sock = sock; |
2985 | queue->cs = GNUNET_TRANSPORT_CS_OUTBOUND; | 2994 | queue->cs = GNUNET_TRANSPORT_CS_OUTBOUND; |
2986 | boot_queue (queue); | 2995 | boot_queue (queue); |
2996 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2997 | "booted queue with target %s\n", | ||
2998 | GNUNET_i2s (&queue->target)); | ||
2987 | // queue->mq_awaits_continue = GNUNET_YES; | 2999 | // queue->mq_awaits_continue = GNUNET_YES; |
2988 | queue->read_task = | 3000 | queue->read_task = |
2989 | GNUNET_SCHEDULER_add_read_net (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, | 3001 | GNUNET_SCHEDULER_add_read_net (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, |
@@ -3646,6 +3658,10 @@ main (int argc, char *const *argv) | |||
3646 | }; | 3658 | }; |
3647 | int ret; | 3659 | int ret; |
3648 | 3660 | ||
3661 | GNUNET_log_from_nocheck (GNUNET_ERROR_TYPE_DEBUG, | ||
3662 | "transport", | ||
3663 | "Starting tcp communicator\n"); | ||
3664 | |||
3649 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) | 3665 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) |
3650 | return 2; | 3666 | return 2; |
3651 | 3667 | ||
diff --git a/src/transport/gnunet-communicator-udp.c b/src/transport/gnunet-communicator-udp.c index ef7b1d6c0..659fd7d26 100644 --- a/src/transport/gnunet-communicator-udp.c +++ b/src/transport/gnunet-communicator-udp.c | |||
@@ -1494,7 +1494,27 @@ add_acks (struct SharedSecret *ss, int acks_to_add) | |||
1494 | 1494 | ||
1495 | GNUNET_assert (NULL != ss); | 1495 | GNUNET_assert (NULL != ss); |
1496 | GNUNET_assert (NULL != receiver); | 1496 | GNUNET_assert (NULL != receiver); |
1497 | GNUNET_assert (NULL != receiver->d_qh); | 1497 | |
1498 | if (NULL == receiver->d_qh) | ||
1499 | { | ||
1500 | receiver->d_qh = | ||
1501 | GNUNET_TRANSPORT_communicator_mq_add (ch, | ||
1502 | &receiver->target, | ||
1503 | receiver->foreign_addr, | ||
1504 | receiver->d_mtu, | ||
1505 | acks_to_add, | ||
1506 | 1, /* Priority */ | ||
1507 | receiver->nt, | ||
1508 | GNUNET_TRANSPORT_CS_OUTBOUND, | ||
1509 | receiver->d_mq); | ||
1510 | } | ||
1511 | else | ||
1512 | { | ||
1513 | GNUNET_TRANSPORT_communicator_mq_update (ch, | ||
1514 | receiver->d_qh, | ||
1515 | acks_to_add, | ||
1516 | 1); | ||
1517 | } | ||
1498 | 1518 | ||
1499 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1519 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1500 | "Tell transport we have %u more acks!\n", | 1520 | "Tell transport we have %u more acks!\n", |
@@ -1502,10 +1522,7 @@ add_acks (struct SharedSecret *ss, int acks_to_add) | |||
1502 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1522 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1503 | "%u kce for rekeying.\n", | 1523 | "%u kce for rekeying.\n", |
1504 | receiver->number_rekeying_kce); | 1524 | receiver->number_rekeying_kce); |
1505 | GNUNET_TRANSPORT_communicator_mq_update (ch, | 1525 | |
1506 | receiver->d_qh, | ||
1507 | acks_to_add, | ||
1508 | 1); | ||
1509 | // Until here for alternativ 1 | 1526 | // Until here for alternativ 1 |
1510 | 1527 | ||
1511 | /* move ss to head to avoid discarding it anytime soon! */ | 1528 | /* move ss to head to avoid discarding it anytime soon! */ |
@@ -1744,7 +1761,7 @@ kce_generate_cb (void *cls) | |||
1744 | if (((GNUNET_NO == ss->sender->rekeying) && (ss->sender->acks_available < | 1761 | if (((GNUNET_NO == ss->sender->rekeying) && (ss->sender->acks_available < |
1745 | KCN_TARGET) ) || | 1762 | KCN_TARGET) ) || |
1746 | ((ss->sender->ss_rekey == ss) && (GNUNET_YES == ss->sender->rekeying) && | 1763 | ((ss->sender->ss_rekey == ss) && (GNUNET_YES == ss->sender->rekeying) && |
1747 | (ss->sender->acks_available < 128))) | 1764 | (ss->sender->acks_available < KCN_TARGET))) |
1748 | { | 1765 | { |
1749 | 1766 | ||
1750 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1767 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1754,20 +1771,24 @@ kce_generate_cb (void *cls) | |||
1754 | for (int i = 0; i < GENERATE_AT_ONCE; i++) | 1771 | for (int i = 0; i < GENERATE_AT_ONCE; i++) |
1755 | kce_generate (ss, ++ss->sequence_allowed); | 1772 | kce_generate (ss, ++ss->sequence_allowed); |
1756 | 1773 | ||
1757 | ss->sender->kce_task = GNUNET_SCHEDULER_add_delayed ( | 1774 | if (KCN_TARGET > ss->sender->acks_available) |
1758 | WORKING_QUEUE_INTERVALL, | 1775 | { |
1759 | kce_generate_cb, | 1776 | ss->sender->kce_task = GNUNET_SCHEDULER_add_delayed ( |
1760 | ss); | 1777 | WORKING_QUEUE_INTERVALL, |
1761 | } | 1778 | kce_generate_cb, |
1762 | else | 1779 | ss); |
1763 | { | 1780 | } |
1764 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1781 | else |
1765 | "We have enough keys.\n"); | 1782 | { |
1766 | ss_finished = ss; | 1783 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1767 | ss->sender->kce_task_finished = GNUNET_YES; | 1784 | "We have enough keys.\n"); |
1785 | ss_finished = ss; | ||
1786 | ss->sender->kce_task_finished = GNUNET_YES; | ||
1787 | } | ||
1768 | } | 1788 | } |
1769 | 1789 | ||
1770 | 1790 | ||
1791 | |||
1771 | } | 1792 | } |
1772 | 1793 | ||
1773 | 1794 | ||
@@ -1850,7 +1871,17 @@ consider_ss_ack (struct SharedSecret *ss, int initial) | |||
1850 | kce_generate (ss, ++ss->sequence_allowed); | 1871 | kce_generate (ss, ++ss->sequence_allowed); |
1851 | }*/ | 1872 | }*/ |
1852 | 1873 | ||
1853 | if (((NULL != kce_task) && kce_task_finished) || (GNUNET_NO == initial)) | 1874 | if (NULL != kce_task) |
1875 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1876 | "kce_task is not NULL\n"); | ||
1877 | if (kce_task_finished) | ||
1878 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1879 | "kce_task_finished: GNUNET_YES\n"); | ||
1880 | if (initial) | ||
1881 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1882 | "initial: GNUNET_YES\n"); | ||
1883 | |||
1884 | if ( kce_task_finished || (GNUNET_NO == initial)) | ||
1854 | { | 1885 | { |
1855 | struct UDPAck ack; | 1886 | struct UDPAck ack; |
1856 | struct SharedSecret *ss_tell; | 1887 | struct SharedSecret *ss_tell; |
@@ -1877,8 +1908,7 @@ consider_ss_ack (struct SharedSecret *ss, int initial) | |||
1877 | if (GNUNET_NO != initial) | 1908 | if (GNUNET_NO != initial) |
1878 | { | 1909 | { |
1879 | destroy_all_secrets (ss, GNUNET_YES); | 1910 | destroy_all_secrets (ss, GNUNET_YES); |
1880 | kce_task = NULL; | 1911 | ss->sender->kce_task_finished = GNUNET_NO; |
1881 | kce_task_finished = GNUNET_NO; | ||
1882 | } | 1912 | } |
1883 | } | 1913 | } |
1884 | else if ((NULL == kce_task) && ((KCN_THRESHOLD > | 1914 | else if ((NULL == kce_task) && ((KCN_THRESHOLD > |
@@ -2678,8 +2708,10 @@ mq_send_kx (struct GNUNET_MQ_Handle *mq, | |||
2678 | receiver->address_len)) | 2708 | receiver->address_len)) |
2679 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "send"); | 2709 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "send"); |
2680 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2710 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2681 | "Sending KX to %s\n", GNUNET_a2s (receiver->address, | 2711 | "Sending KX with payload size %u to %s\n", |
2682 | receiver->address_len)); | 2712 | msize, |
2713 | GNUNET_a2s (receiver->address, | ||
2714 | receiver->address_len)); | ||
2683 | GNUNET_MQ_impl_send_continue (mq); | 2715 | GNUNET_MQ_impl_send_continue (mq); |
2684 | } | 2716 | } |
2685 | 2717 | ||
@@ -2940,7 +2972,8 @@ mq_send_d (struct GNUNET_MQ_Handle *mq, | |||
2940 | receiver->address_len)) | 2972 | receiver->address_len)) |
2941 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "send"); | 2973 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "send"); |
2942 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2974 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2943 | "Sending UDPBox %u acks left\n", | 2975 | "Sending UDPBox with payload size %u, %u acks left\n", |
2976 | msize, | ||
2944 | receiver->acks_available); | 2977 | receiver->acks_available); |
2945 | GNUNET_MQ_impl_send_continue (mq); | 2978 | GNUNET_MQ_impl_send_continue (mq); |
2946 | receiver->acks_available--; | 2979 | receiver->acks_available--; |
@@ -3135,17 +3168,6 @@ setup_receiver_mq (struct ReceiverAddress *receiver) | |||
3135 | receiver->nt, | 3168 | receiver->nt, |
3136 | GNUNET_TRANSPORT_CS_OUTBOUND, | 3169 | GNUNET_TRANSPORT_CS_OUTBOUND, |
3137 | receiver->kx_mq); | 3170 | receiver->kx_mq); |
3138 | receiver->d_qh = | ||
3139 | GNUNET_TRANSPORT_communicator_mq_add (ch, | ||
3140 | &receiver->target, | ||
3141 | receiver->foreign_addr, | ||
3142 | receiver->d_mtu, | ||
3143 | 0, /* Initialize with 0 acks */ | ||
3144 | 1, /* Priority */ | ||
3145 | receiver->nt, | ||
3146 | GNUNET_TRANSPORT_CS_OUTBOUND, | ||
3147 | receiver->d_mq); | ||
3148 | |||
3149 | } | 3171 | } |
3150 | 3172 | ||
3151 | 3173 | ||
@@ -3755,9 +3777,11 @@ run (void *cls, | |||
3755 | GNUNET_free (bindto); | 3777 | GNUNET_free (bindto); |
3756 | in = (struct sockaddr *) &in_sto; | 3778 | in = (struct sockaddr *) &in_sto; |
3757 | in_len = sto_len; | 3779 | in_len = sto_len; |
3758 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3780 | GNUNET_log_from_nocheck (GNUNET_ERROR_TYPE_DEBUG, |
3759 | "Bound to `%s'\n", | 3781 | "transport", |
3760 | GNUNET_a2s ((const struct sockaddr *) &in_sto, sto_len)); | 3782 | "Bound to `%s'\n", |
3783 | GNUNET_a2s ((const struct sockaddr *) &in_sto, | ||
3784 | sto_len)); | ||
3761 | switch (in->sa_family) | 3785 | switch (in->sa_family) |
3762 | { | 3786 | { |
3763 | case AF_INET: | 3787 | case AF_INET: |
@@ -3853,6 +3877,9 @@ main (int argc, char *const *argv) | |||
3853 | }; | 3877 | }; |
3854 | int ret; | 3878 | int ret; |
3855 | 3879 | ||
3880 | GNUNET_log_from_nocheck (GNUNET_ERROR_TYPE_DEBUG, | ||
3881 | "transport", | ||
3882 | "Starting udp communicator\n"); | ||
3856 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) | 3883 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) |
3857 | return 2; | 3884 | return 2; |
3858 | 3885 | ||
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c index a7e2a8c04..a90bef3b5 100644 --- a/src/transport/gnunet-service-tng.c +++ b/src/transport/gnunet-service-tng.c | |||
@@ -1736,6 +1736,11 @@ struct Queue | |||
1736 | const char *address; | 1736 | const char *address; |
1737 | 1737 | ||
1738 | /** | 1738 | /** |
1739 | * Is this queue of unlimited length. | ||
1740 | */ | ||
1741 | unsigned int unlimited_length; | ||
1742 | |||
1743 | /** | ||
1739 | * Task scheduled for the time when this queue can (likely) transmit the | 1744 | * Task scheduled for the time when this queue can (likely) transmit the |
1740 | * next message. | 1745 | * next message. |
1741 | */ | 1746 | */ |
@@ -1787,6 +1792,11 @@ struct Queue | |||
1787 | unsigned int queue_length; | 1792 | unsigned int queue_length; |
1788 | 1793 | ||
1789 | /** | 1794 | /** |
1795 | * Capacity of the queue. | ||
1796 | */ | ||
1797 | uint64_t q_capacity; | ||
1798 | |||
1799 | /** | ||
1790 | * Queue priority | 1800 | * Queue priority |
1791 | */ | 1801 | */ |
1792 | uint32_t priority; | 1802 | uint32_t priority; |
@@ -3446,6 +3456,35 @@ transmit_on_queue (void *cls); | |||
3446 | 3456 | ||
3447 | 3457 | ||
3448 | /** | 3458 | /** |
3459 | * Check if the communicator has another queue with higher prio ready for sending. | ||
3460 | */ | ||
3461 | static unsigned int | ||
3462 | check_for_queue_with_higher_prio (struct Queue *queue, struct Queue *queue_head) | ||
3463 | { | ||
3464 | for (struct Queue *s = queue_head; NULL != s; | ||
3465 | s = s->next_client) | ||
3466 | { | ||
3467 | if (s->tc->details.communicator.address_prefix != | ||
3468 | queue->tc->details.communicator.address_prefix) | ||
3469 | { | ||
3470 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3471 | "queue address %s qid %u compare with queue: address %s qid %u\n", | ||
3472 | queue->address, | ||
3473 | queue->qid, | ||
3474 | s->address, | ||
3475 | s->qid); | ||
3476 | if ((s->priority > queue->priority) && (0 < s->q_capacity) && | ||
3477 | (QUEUE_LENGTH_LIMIT > s->queue_length) ) | ||
3478 | return GNUNET_YES; | ||
3479 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3480 | "Lower prio\n"); | ||
3481 | } | ||
3482 | } | ||
3483 | return GNUNET_NO; | ||
3484 | } | ||
3485 | |||
3486 | |||
3487 | /** | ||
3449 | * Called whenever something changed that might effect when we | 3488 | * Called whenever something changed that might effect when we |
3450 | * try to do the next transmission on @a queue using #transmit_on_queue(). | 3489 | * try to do the next transmission on @a queue using #transmit_on_queue(). |
3451 | * | 3490 | * |
@@ -3456,6 +3495,11 @@ static void | |||
3456 | schedule_transmit_on_queue (struct Queue *queue, | 3495 | schedule_transmit_on_queue (struct Queue *queue, |
3457 | enum GNUNET_SCHEDULER_Priority p) | 3496 | enum GNUNET_SCHEDULER_Priority p) |
3458 | { | 3497 | { |
3498 | if (check_for_queue_with_higher_prio (queue, | ||
3499 | queue->tc->details.communicator. | ||
3500 | queue_head)) | ||
3501 | return; | ||
3502 | |||
3459 | if (queue->tc->details.communicator.total_queue_length >= | 3503 | if (queue->tc->details.communicator.total_queue_length >= |
3460 | COMMUNICATOR_TOTAL_QUEUE_LIMIT) | 3504 | COMMUNICATOR_TOTAL_QUEUE_LIMIT) |
3461 | { | 3505 | { |
@@ -3480,6 +3524,19 @@ schedule_transmit_on_queue (struct Queue *queue, | |||
3480 | queue->idle = GNUNET_NO; | 3524 | queue->idle = GNUNET_NO; |
3481 | return; | 3525 | return; |
3482 | } | 3526 | } |
3527 | if (0 == queue->q_capacity) | ||
3528 | { | ||
3529 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3530 | "Transmission throttled due to communicator message queue qid %u has capacity %lu.\n", | ||
3531 | queue->qid, | ||
3532 | queue->q_capacity); | ||
3533 | GNUNET_STATISTICS_update (GST_stats, | ||
3534 | "# Transmission throttled due to message queue capacity", | ||
3535 | 1, | ||
3536 | GNUNET_NO); | ||
3537 | queue->idle = GNUNET_NO; | ||
3538 | return; | ||
3539 | } | ||
3483 | /* queue might indeed be ready, schedule it */ | 3540 | /* queue might indeed be ready, schedule it */ |
3484 | if (NULL != queue->transmit_task) | 3541 | if (NULL != queue->transmit_task) |
3485 | GNUNET_SCHEDULER_cancel (queue->transmit_task); | 3542 | GNUNET_SCHEDULER_cancel (queue->transmit_task); |
@@ -3582,8 +3639,9 @@ free_queue (struct Queue *queue) | |||
3582 | tc->details.communicator.queue_head, | 3639 | tc->details.communicator.queue_head, |
3583 | tc->details.communicator.queue_tail, | 3640 | tc->details.communicator.queue_tail, |
3584 | queue); | 3641 | queue); |
3585 | maxxed = (COMMUNICATOR_TOTAL_QUEUE_LIMIT >= | 3642 | maxxed = (COMMUNICATOR_TOTAL_QUEUE_LIMIT <= |
3586 | tc->details.communicator.total_queue_length); | 3643 | tc->details.communicator. |
3644 | total_queue_length); | ||
3587 | while (NULL != (qe = queue->queue_head)) | 3645 | while (NULL != (qe = queue->queue_head)) |
3588 | { | 3646 | { |
3589 | GNUNET_CONTAINER_DLL_remove (queue->queue_head, queue->queue_tail, qe); | 3647 | GNUNET_CONTAINER_DLL_remove (queue->queue_head, queue->queue_tail, qe); |
@@ -3597,7 +3655,7 @@ free_queue (struct Queue *queue) | |||
3597 | GNUNET_free (qe); | 3655 | GNUNET_free (qe); |
3598 | } | 3656 | } |
3599 | GNUNET_assert (0 == queue->queue_length); | 3657 | GNUNET_assert (0 == queue->queue_length); |
3600 | if ((maxxed) && (COMMUNICATOR_TOTAL_QUEUE_LIMIT < | 3658 | if ((maxxed) && (COMMUNICATOR_TOTAL_QUEUE_LIMIT > |
3601 | tc->details.communicator.total_queue_length)) | 3659 | tc->details.communicator.total_queue_length)) |
3602 | { | 3660 | { |
3603 | /* Communicator dropped below threshold, resume all _other_ queues */ | 3661 | /* Communicator dropped below threshold, resume all _other_ queues */ |
@@ -4223,18 +4281,36 @@ queue_send_msg (struct Queue *queue, | |||
4223 | if (NULL != pm) | 4281 | if (NULL != pm) |
4224 | { | 4282 | { |
4225 | qe->pm = pm; | 4283 | qe->pm = pm; |
4226 | GNUNET_assert (NULL == pm->qe); | 4284 | // TODO Why do we have a retransmission. When we know, make decision if we still want this. |
4285 | // GNUNET_assert (NULL == pm->qe); | ||
4286 | /*if (NULL != pm->qe) | ||
4287 | { | ||
4288 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
4289 | "Retransmitting message <%llu> remove pm from qe with MID: %llu \n", | ||
4290 | pm->logging_uuid, | ||
4291 | (unsigned long long) pm->qe->mid); | ||
4292 | pm->qe->pm = NULL; | ||
4293 | }*/ | ||
4227 | pm->qe = qe; | 4294 | pm->qe = qe; |
4228 | } | 4295 | } |
4229 | GNUNET_CONTAINER_DLL_insert (queue->queue_head, queue->queue_tail, qe); | 4296 | GNUNET_CONTAINER_DLL_insert (queue->queue_head, queue->queue_tail, qe); |
4230 | GNUNET_assert (CT_COMMUNICATOR == queue->tc->type); | 4297 | GNUNET_assert (CT_COMMUNICATOR == queue->tc->type); |
4231 | queue->queue_length++; | 4298 | queue->queue_length++; |
4232 | queue->tc->details.communicator.total_queue_length++; | 4299 | queue->tc->details.communicator.total_queue_length++; |
4300 | if (GNUNET_NO == queue->unlimited_length) | ||
4301 | queue->q_capacity--; | ||
4302 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
4303 | "Queue %s with qid %u has capacity %lu\n", | ||
4304 | queue->address, | ||
4305 | queue->qid, | ||
4306 | queue->q_capacity); | ||
4233 | if (COMMUNICATOR_TOTAL_QUEUE_LIMIT == | 4307 | if (COMMUNICATOR_TOTAL_QUEUE_LIMIT == |
4234 | queue->tc->details.communicator.total_queue_length) | 4308 | queue->tc->details.communicator.total_queue_length) |
4235 | queue->idle = GNUNET_NO; | 4309 | queue->idle = GNUNET_NO; |
4236 | if (QUEUE_LENGTH_LIMIT == queue->queue_length) | 4310 | if (QUEUE_LENGTH_LIMIT == queue->queue_length) |
4237 | queue->idle = GNUNET_NO; | 4311 | queue->idle = GNUNET_NO; |
4312 | if (0 == queue->q_capacity) | ||
4313 | queue->idle = GNUNET_NO; | ||
4238 | GNUNET_MQ_send (queue->tc->mq, env); | 4314 | GNUNET_MQ_send (queue->tc->mq, env); |
4239 | } | 4315 | } |
4240 | } | 4316 | } |
@@ -4672,8 +4748,16 @@ route_control_message_without_fc (const struct GNUNET_PeerIdentity *target, | |||
4672 | struct GNUNET_TIME_Relative rtt1; | 4748 | struct GNUNET_TIME_Relative rtt1; |
4673 | struct GNUNET_TIME_Relative rtt2; | 4749 | struct GNUNET_TIME_Relative rtt2; |
4674 | 4750 | ||
4751 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
4752 | "Trying to route message of type %u to %s without fc\n", | ||
4753 | ntohs (hdr->type), | ||
4754 | GNUNET_i2s (target)); | ||
4755 | |||
4756 | // TODO Do this elsewhere. vl should be given as parameter to method. | ||
4675 | vl = lookup_virtual_link (target); | 4757 | vl = lookup_virtual_link (target); |
4676 | GNUNET_assert (NULL != vl); | 4758 | GNUNET_assert (NULL != vl); |
4759 | if (NULL == vl) | ||
4760 | return GNUNET_TIME_UNIT_FOREVER_REL; | ||
4677 | n = vl->n; | 4761 | n = vl->n; |
4678 | dv = (0 != (options & RMO_DV_ALLOWED)) ? vl->dv : NULL; | 4762 | dv = (0 != (options & RMO_DV_ALLOWED)) ? vl->dv : NULL; |
4679 | if (0 == (options & RMO_UNCONFIRMED_ALLOWED)) | 4763 | if (0 == (options & RMO_UNCONFIRMED_ALLOWED)) |
@@ -4718,6 +4802,10 @@ route_control_message_without_fc (const struct GNUNET_PeerIdentity *target, | |||
4718 | rtt2 = GNUNET_TIME_UNIT_FOREVER_REL; | 4802 | rtt2 = GNUNET_TIME_UNIT_FOREVER_REL; |
4719 | if (NULL != n) | 4803 | if (NULL != n) |
4720 | { | 4804 | { |
4805 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
4806 | "Try to route message of type %u to %s without fc via neighbour\n", | ||
4807 | ntohs (hdr->type), | ||
4808 | GNUNET_i2s (target)); | ||
4721 | rtt1 = route_via_neighbour (n, hdr, options); | 4809 | rtt1 = route_via_neighbour (n, hdr, options); |
4722 | } | 4810 | } |
4723 | if (NULL != dv) | 4811 | if (NULL != dv) |
@@ -4889,7 +4977,9 @@ check_vl_transmission (struct VirtualLink *vl) | |||
4889 | schedule_transmit_on_queue (queue, GNUNET_SCHEDULER_PRIORITY_DEFAULT); | 4977 | schedule_transmit_on_queue (queue, GNUNET_SCHEDULER_PRIORITY_DEFAULT); |
4890 | else | 4978 | else |
4891 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 4979 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4892 | "Queue busy or invalid\n"); | 4980 | "Neighbour Queue QID: %u (%u) busy or invalid\n", |
4981 | queue->qid, | ||
4982 | queue->idle); | ||
4893 | } | 4983 | } |
4894 | } | 4984 | } |
4895 | /* Notify queues via DV that we are interested */ | 4985 | /* Notify queues via DV that we are interested */ |
@@ -4910,6 +5000,11 @@ check_vl_transmission (struct VirtualLink *vl) | |||
4910 | (queue->validated_until.abs_value_us > now.abs_value_us)) | 5000 | (queue->validated_until.abs_value_us > now.abs_value_us)) |
4911 | schedule_transmit_on_queue (queue, | 5001 | schedule_transmit_on_queue (queue, |
4912 | GNUNET_SCHEDULER_PRIORITY_BACKGROUND); | 5002 | GNUNET_SCHEDULER_PRIORITY_BACKGROUND); |
5003 | else | ||
5004 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
5005 | "DV Queue QID: %u (%u) busy or invalid\n", | ||
5006 | queue->qid, | ||
5007 | queue->idle); | ||
4913 | } | 5008 | } |
4914 | } | 5009 | } |
4915 | } | 5010 | } |
@@ -4996,8 +5091,9 @@ handle_communicator_backchannel ( | |||
4996 | (const struct GNUNET_MessageHeader *) &cb[1]; | 5091 | (const struct GNUNET_MessageHeader *) &cb[1]; |
4997 | uint16_t isize = ntohs (inbox->size); | 5092 | uint16_t isize = ntohs (inbox->size); |
4998 | const char *is = ((const char *) &cb[1]) + isize; | 5093 | const char *is = ((const char *) &cb[1]) + isize; |
5094 | size_t slen = strlen (is) + 1; | ||
4999 | char | 5095 | char |
5000 | mbuf[isize | 5096 | mbuf[slen + isize |
5001 | + sizeof(struct | 5097 | + sizeof(struct |
5002 | TransportBackchannelEncapsulationMessage)] GNUNET_ALIGN; | 5098 | TransportBackchannelEncapsulationMessage)] GNUNET_ALIGN; |
5003 | struct TransportBackchannelEncapsulationMessage *be = | 5099 | struct TransportBackchannelEncapsulationMessage *be = |
@@ -5006,9 +5102,10 @@ handle_communicator_backchannel ( | |||
5006 | /* 0-termination of 'is' was checked already in | 5102 | /* 0-termination of 'is' was checked already in |
5007 | #check_communicator_backchannel() */ | 5103 | #check_communicator_backchannel() */ |
5008 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 5104 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
5009 | "Preparing backchannel transmission to %s:%s of type %u\n", | 5105 | "Preparing backchannel transmission to %s:%s of type %u and size %u\n", |
5010 | GNUNET_i2s (&cb->pid), | 5106 | GNUNET_i2s (&cb->pid), |
5011 | is, | 5107 | is, |
5108 | ntohs (inbox->type), | ||
5012 | ntohs (inbox->size)); | 5109 | ntohs (inbox->size)); |
5013 | /* encapsulate and encrypt message */ | 5110 | /* encapsulate and encrypt message */ |
5014 | be->header.type = | 5111 | be->header.type = |
@@ -5264,6 +5361,11 @@ handle_raw_message (void *cls, const struct GNUNET_MessageHeader *mh) | |||
5264 | uint16_t size = ntohs (mh->size); | 5361 | uint16_t size = ntohs (mh->size); |
5265 | int have_core; | 5362 | int have_core; |
5266 | 5363 | ||
5364 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
5365 | "Handling message of type %u with %u bytes\n", | ||
5366 | (unsigned int) ntohs (mh->type), | ||
5367 | (unsigned int) ntohs (mh->size)); | ||
5368 | |||
5267 | if ((size > UINT16_MAX - sizeof(struct InboundMessage)) || | 5369 | if ((size > UINT16_MAX - sizeof(struct InboundMessage)) || |
5268 | (size < sizeof(struct GNUNET_MessageHeader))) | 5370 | (size < sizeof(struct GNUNET_MessageHeader))) |
5269 | { | 5371 | { |
@@ -5290,6 +5392,10 @@ handle_raw_message (void *cls, const struct GNUNET_MessageHeader *mh) | |||
5290 | 1, | 5392 | 1, |
5291 | GNUNET_NO); | 5393 | GNUNET_NO); |
5292 | 5394 | ||
5395 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
5396 | "CORE messages of type %u with %u bytes dropped (virtual link still down)\n", | ||
5397 | (unsigned int) ntohs (mh->type), | ||
5398 | (unsigned int) ntohs (mh->size)); | ||
5293 | finish_cmc_handling (cmc); | 5399 | finish_cmc_handling (cmc); |
5294 | return; | 5400 | return; |
5295 | } | 5401 | } |
@@ -5299,7 +5405,10 @@ handle_raw_message (void *cls, const struct GNUNET_MessageHeader *mh) | |||
5299 | "# CORE messages dropped (FC arithmetic overflow)", | 5405 | "# CORE messages dropped (FC arithmetic overflow)", |
5300 | 1, | 5406 | 1, |
5301 | GNUNET_NO); | 5407 | GNUNET_NO); |
5302 | 5408 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | |
5409 | "CORE messages of type %u with %u bytes dropped (FC arithmetic overflow)\n", | ||
5410 | (unsigned int) ntohs (mh->type), | ||
5411 | (unsigned int) ntohs (mh->size)); | ||
5303 | finish_cmc_handling (cmc); | 5412 | finish_cmc_handling (cmc); |
5304 | return; | 5413 | return; |
5305 | } | 5414 | } |
@@ -5309,6 +5418,10 @@ handle_raw_message (void *cls, const struct GNUNET_MessageHeader *mh) | |||
5309 | "# CORE messages dropped (FC window overflow)", | 5418 | "# CORE messages dropped (FC window overflow)", |
5310 | 1, | 5419 | 1, |
5311 | GNUNET_NO); | 5420 | GNUNET_NO); |
5421 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
5422 | "CORE messages of type %u with %u bytes dropped (FC window overflow)\n", | ||
5423 | (unsigned int) ntohs (mh->type), | ||
5424 | (unsigned int) ntohs (mh->size)); | ||
5312 | finish_cmc_handling (cmc); | 5425 | finish_cmc_handling (cmc); |
5313 | return; | 5426 | return; |
5314 | } | 5427 | } |
@@ -5345,6 +5458,10 @@ handle_raw_message (void *cls, const struct GNUNET_MessageHeader *mh) | |||
5345 | perspective of the other peer! */ | 5458 | perspective of the other peer! */ |
5346 | vl->incoming_fc_window_size_used += size; | 5459 | vl->incoming_fc_window_size_used += size; |
5347 | /* TODO-M1 */ | 5460 | /* TODO-M1 */ |
5461 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
5462 | "Dropped message of type %u with %u bytes to CORE: no CORE client connected!", | ||
5463 | (unsigned int) ntohs (mh->type), | ||
5464 | (unsigned int) ntohs (mh->size)); | ||
5348 | finish_cmc_handling (cmc); | 5465 | finish_cmc_handling (cmc); |
5349 | return; | 5466 | return; |
5350 | } | 5467 | } |
@@ -6074,6 +6191,15 @@ handle_backchannel_encapsulation ( | |||
6074 | (const struct GNUNET_MessageHeader *) &be[1]; | 6191 | (const struct GNUNET_MessageHeader *) &be[1]; |
6075 | uint16_t isize = ntohs (inbox->size); | 6192 | uint16_t isize = ntohs (inbox->size); |
6076 | const char *target_communicator = ((const char *) inbox) + isize; | 6193 | const char *target_communicator = ((const char *) inbox) + isize; |
6194 | char *sender; | ||
6195 | char *self; | ||
6196 | |||
6197 | GNUNET_asprintf (&sender, | ||
6198 | "%s", | ||
6199 | GNUNET_i2s (&cmc->im.sender)); | ||
6200 | GNUNET_asprintf (&self, | ||
6201 | "%s", | ||
6202 | GNUNET_i2s (&GST_my_identity)); | ||
6077 | 6203 | ||
6078 | /* Find client providing this communicator */ | 6204 | /* Find client providing this communicator */ |
6079 | for (tc = clients_head; NULL != tc; tc = tc->next) | 6205 | for (tc = clients_head; NULL != tc; tc = tc->next) |
@@ -6095,8 +6221,9 @@ handle_backchannel_encapsulation ( | |||
6095 | } | 6221 | } |
6096 | /* Finally, deliver backchannel message to communicator */ | 6222 | /* Finally, deliver backchannel message to communicator */ |
6097 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 6223 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
6098 | "Delivering backchannel message from %s of type %u to %s\n", | 6224 | "Delivering backchannel message from %s to %s of type %u to %s\n", |
6099 | GNUNET_i2s (&cmc->im.sender), | 6225 | sender, |
6226 | self, | ||
6100 | ntohs (inbox->type), | 6227 | ntohs (inbox->type), |
6101 | target_communicator); | 6228 | target_communicator); |
6102 | env = GNUNET_MQ_msg_extra ( | 6229 | env = GNUNET_MQ_msg_extra ( |
@@ -8407,14 +8534,15 @@ fragment_message (struct Queue *queue, | |||
8407 | struct PendingMessage *ff; | 8534 | struct PendingMessage *ff; |
8408 | uint16_t mtu; | 8535 | uint16_t mtu; |
8409 | 8536 | ||
8410 | mtu = (0 == queue->mtu) | 8537 | mtu = (UINT16_MAX == queue->mtu) |
8411 | ? UINT16_MAX - sizeof(struct GNUNET_TRANSPORT_SendMessageTo) | 8538 | ? UINT16_MAX - sizeof(struct GNUNET_TRANSPORT_SendMessageTo) |
8412 | : queue->mtu; | 8539 | : queue->mtu; |
8413 | set_pending_message_uuid (pm); | 8540 | set_pending_message_uuid (pm); |
8414 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 8541 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
8415 | "Fragmenting message %llu <%llu> to %s for MTU %u\n", | 8542 | "Fragmenting message %llu <%llu> with size %u to %s for MTU %u\n", |
8416 | (unsigned long long) pm->msg_uuid.uuid, | 8543 | (unsigned long long) pm->msg_uuid.uuid, |
8417 | pm->logging_uuid, | 8544 | pm->logging_uuid, |
8545 | pm->bytes_msg, | ||
8418 | GNUNET_i2s (&pm->vl->target), | 8546 | GNUNET_i2s (&pm->vl->target), |
8419 | (unsigned int) mtu); | 8547 | (unsigned int) mtu); |
8420 | pa = prepare_pending_acknowledgement (queue, dvh, pm); | 8548 | pa = prepare_pending_acknowledgement (queue, dvh, pm); |
@@ -8700,7 +8828,7 @@ select_best_pending_from_link (struct PendingMessageScoreContext *sc, | |||
8700 | GNUNET_TRANSPORT_SendMessageTo)) | 8828 | GNUNET_TRANSPORT_SendMessageTo)) |
8701 | || | 8829 | || |
8702 | (NULL != pos->head_frag /* fragments already exist, should | 8830 | (NULL != pos->head_frag /* fragments already exist, should |
8703 | respect that even if MTU is 0 for | 8831 | respect that even if MTU is UINT16_MAX for |
8704 | this queue */)) | 8832 | this queue */)) |
8705 | { | 8833 | { |
8706 | frag = GNUNET_YES; | 8834 | frag = GNUNET_YES; |
@@ -9069,12 +9197,17 @@ handle_send_message_ack (void *cls, | |||
9069 | qep = qep->next) | 9197 | qep = qep->next) |
9070 | { | 9198 | { |
9071 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 9199 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
9072 | "QueueEntry MID: %llu, Ack MID: %llu\n", | 9200 | "QueueEntry MID: %llu on queue QID: %llu, Ack MID: %llu\n", |
9073 | (unsigned long long) qep->mid, | 9201 | (unsigned long long) qep->mid, |
9202 | (unsigned long long) queue->qid, | ||
9074 | (unsigned long long) sma->mid); | 9203 | (unsigned long long) sma->mid); |
9075 | if (qep->mid != sma->mid) | 9204 | if (qep->mid != sma->mid) |
9076 | continue; | 9205 | continue; |
9077 | qe = qep; | 9206 | qe = qep; |
9207 | if ((NULL != qe->pm)&&(qe->pm->qe != qe)) | ||
9208 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
9209 | "For pending message %llu we had retransmissions.\n", | ||
9210 | qe->pm->logging_uuid); | ||
9078 | break; | 9211 | break; |
9079 | } | 9212 | } |
9080 | } | 9213 | } |
@@ -9125,12 +9258,26 @@ handle_send_message_ack (void *cls, | |||
9125 | GNUNET_NO); | 9258 | GNUNET_NO); |
9126 | schedule_transmit_on_queue (qe->queue, GNUNET_SCHEDULER_PRIORITY_DEFAULT); | 9259 | schedule_transmit_on_queue (qe->queue, GNUNET_SCHEDULER_PRIORITY_DEFAULT); |
9127 | } | 9260 | } |
9261 | else if (1 == qe->queue->q_capacity) | ||
9262 | { | ||
9263 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
9264 | "Transmission rescheduled due to communicator message queue with qid %u has capacity %lu.\n", | ||
9265 | qe->queue->qid, | ||
9266 | qe->queue->q_capacity); | ||
9267 | /* message queue has capacity; only resume this one queue */ | ||
9268 | /* queue dropped below threshold; only resume this one queue */ | ||
9269 | GNUNET_STATISTICS_update (GST_stats, | ||
9270 | "# Transmission throttled due to message queue capacity", | ||
9271 | -1, | ||
9272 | GNUNET_NO); | ||
9273 | schedule_transmit_on_queue (qe->queue, GNUNET_SCHEDULER_PRIORITY_DEFAULT); | ||
9274 | } | ||
9128 | 9275 | ||
9129 | if (NULL != (pm = qe->pm)) | 9276 | if (NULL != (pm = qe->pm)) |
9130 | { | 9277 | { |
9131 | struct VirtualLink *vl; | 9278 | struct VirtualLink *vl; |
9132 | 9279 | ||
9133 | GNUNET_assert (qe == pm->qe); | 9280 | // GNUNET_assert (qe == pm->qe); |
9134 | pm->qe = NULL; | 9281 | pm->qe = NULL; |
9135 | /* If waiting for this communicator may have blocked transmission | 9282 | /* If waiting for this communicator may have blocked transmission |
9136 | of pm on other queues for this neighbour, force schedule | 9283 | of pm on other queues for this neighbour, force schedule |
@@ -9671,16 +9818,20 @@ handle_add_queue_message (void *cls, | |||
9671 | addr_len = ntohs (aqm->header.size) - sizeof(*aqm); | 9818 | addr_len = ntohs (aqm->header.size) - sizeof(*aqm); |
9672 | addr = (const char *) &aqm[1]; | 9819 | addr = (const char *) &aqm[1]; |
9673 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 9820 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
9674 | "New queue %s to %s available with QID %llu\n", | 9821 | "New queue %s to %s available with QID %llu and q_len %lu \n", |
9675 | addr, | 9822 | addr, |
9676 | GNUNET_i2s (&aqm->receiver), | 9823 | GNUNET_i2s (&aqm->receiver), |
9677 | (unsigned long long) aqm->qid); | 9824 | (unsigned long long) aqm->qid, |
9825 | GNUNET_ntohll (aqm->q_len)); | ||
9678 | queue = GNUNET_malloc (sizeof(struct Queue) + addr_len); | 9826 | queue = GNUNET_malloc (sizeof(struct Queue) + addr_len); |
9679 | queue->tc = tc; | 9827 | queue->tc = tc; |
9680 | queue->address = (const char *) &queue[1]; | 9828 | queue->address = (const char *) &queue[1]; |
9681 | queue->pd.aged_rtt = GNUNET_TIME_UNIT_FOREVER_REL; | 9829 | queue->pd.aged_rtt = GNUNET_TIME_UNIT_FOREVER_REL; |
9682 | queue->qid = aqm->qid; | 9830 | queue->qid = aqm->qid; |
9683 | queue->neighbour = neighbour; | 9831 | queue->neighbour = neighbour; |
9832 | if (GNUNET_TRANSPORT_QUEUE_LENGTH_UNLIMITED == GNUNET_ntohll (aqm->q_len)) | ||
9833 | queue->unlimited_length = GNUNET_YES; | ||
9834 | queue->q_capacity = GNUNET_ntohll (aqm->q_len); | ||
9684 | memcpy (&queue[1], addr, addr_len); | 9835 | memcpy (&queue[1], addr, addr_len); |
9685 | /* notify monitors about new queue */ | 9836 | /* notify monitors about new queue */ |
9686 | { | 9837 | { |
@@ -9752,10 +9903,14 @@ handle_update_queue_message (void *cls, | |||
9752 | target_queue->mtu = ntohl (msg->mtu); | 9903 | target_queue->mtu = ntohl (msg->mtu); |
9753 | target_queue->cs = msg->cs; | 9904 | target_queue->cs = msg->cs; |
9754 | target_queue->priority = ntohl (msg->priority); | 9905 | target_queue->priority = ntohl (msg->priority); |
9755 | /* The update message indicates how many _additional_ | 9906 | /* The update message indicates how many messages |
9756 | * messages the queue should be able to handle | 9907 | * the queue should be able to handle. |
9757 | */ | 9908 | */ |
9758 | target_queue->queue_length += GNUNET_ntohll (msg->q_len); | 9909 | if (GNUNET_TRANSPORT_QUEUE_LENGTH_UNLIMITED == GNUNET_ntohll (msg->q_len)) |
9910 | target_queue->unlimited_length = GNUNET_YES; | ||
9911 | else | ||
9912 | target_queue->unlimited_length = GNUNET_NO; | ||
9913 | target_queue->q_capacity = GNUNET_ntohll (msg->q_len); | ||
9759 | GNUNET_SERVICE_client_continue (tc->client); | 9914 | GNUNET_SERVICE_client_continue (tc->client); |
9760 | } | 9915 | } |
9761 | 9916 | ||
@@ -10179,8 +10334,18 @@ static void | |||
10179 | shutdown_task (void *cls) | 10334 | shutdown_task (void *cls) |
10180 | { | 10335 | { |
10181 | in_shutdown = GNUNET_YES; | 10336 | in_shutdown = GNUNET_YES; |
10337 | |||
10182 | if (NULL == clients_head) | 10338 | if (NULL == clients_head) |
10183 | do_shutdown (cls); | 10339 | { |
10340 | for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next) | ||
10341 | { | ||
10342 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
10343 | "client still connected: %u\n", | ||
10344 | tc->type); | ||
10345 | } | ||
10346 | } | ||
10347 | do_shutdown (cls); | ||
10348 | |||
10184 | } | 10349 | } |
10185 | 10350 | ||
10186 | 10351 | ||
diff --git a/src/transport/test_transport_plugin_cmd_simple_send.c b/src/transport/test_transport_plugin_cmd_simple_send.c index 5384bf24d..8889f9d06 100644 --- a/src/transport/test_transport_plugin_cmd_simple_send.c +++ b/src/transport/test_transport_plugin_cmd_simple_send.c | |||
@@ -37,7 +37,6 @@ | |||
37 | 37 | ||
38 | #define BASE_DIR "testdir" | 38 | #define BASE_DIR "testdir" |
39 | 39 | ||
40 | #define TOPOLOGY_CONFIG "test_transport_simple_send_topo.conf" | ||
41 | 40 | ||
42 | struct TestState | 41 | struct TestState |
43 | { | 42 | { |
@@ -280,6 +279,10 @@ libgnunet_test_transport_plugin_cmd_simple_send_init (void *cls) | |||
280 | { | 279 | { |
281 | struct GNUNET_TESTING_PluginFunctions *api; | 280 | struct GNUNET_TESTING_PluginFunctions *api; |
282 | 281 | ||
282 | GNUNET_log_setup ("simple-send", | ||
283 | "DEBUG", | ||
284 | NULL); | ||
285 | |||
283 | api = GNUNET_new (struct GNUNET_TESTING_PluginFunctions); | 286 | api = GNUNET_new (struct GNUNET_TESTING_PluginFunctions); |
284 | api->start_testcase = &start_testcase; | 287 | api->start_testcase = &start_testcase; |
285 | api->all_peers_started = &all_peers_started; | 288 | api->all_peers_started = &all_peers_started; |
diff --git a/src/transport/test_transport_plugin_cmd_udp_backchannel.c b/src/transport/test_transport_plugin_cmd_udp_backchannel.c index 108e1ac09..b0ca37447 100644 --- a/src/transport/test_transport_plugin_cmd_udp_backchannel.c +++ b/src/transport/test_transport_plugin_cmd_udp_backchannel.c | |||
@@ -165,6 +165,14 @@ notify_connect (void *cls, | |||
165 | return ret; | 165 | return ret; |
166 | } | 166 | } |
167 | 167 | ||
168 | /** | ||
169 | * Callback to set the flag indicating all peers are prepared to finish. Will be called via the plugin api. | ||
170 | */ | ||
171 | static void | ||
172 | all_local_tests_prepared () | ||
173 | { | ||
174 | are_all_local_tests_prepared = GNUNET_YES; | ||
175 | } | ||
168 | 176 | ||
169 | /** | 177 | /** |
170 | * Function to start a local test case. | 178 | * Function to start a local test case. |
@@ -251,9 +259,16 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
251 | write_message), | 259 | write_message), |
252 | block_send, | 260 | block_send, |
253 | connect_peers, | 261 | connect_peers, |
254 | GNUNET_TRANSPORT_cmd_send_simple ("send-simple", | 262 | GNUNET_TRANSPORT_cmd_backchannel_check ("backchannel-check", |
255 | "start-peer", | 263 | "start-peer", |
256 | num), | 264 | "system-create", |
265 | num, | ||
266 | m_int, | ||
267 | n_int, | ||
268 | topology), | ||
269 | GNUNET_TESTING_cmd_local_test_prepared ("local-test-prepared", | ||
270 | write_message, | ||
271 | &are_all_local_tests_prepared), | ||
257 | block_receive, | 272 | block_receive, |
258 | GNUNET_TRANSPORT_cmd_stop_peer ("stop-peer", | 273 | GNUNET_TRANSPORT_cmd_stop_peer ("stop-peer", |
259 | "start-peer"), | 274 | "start-peer"), |
@@ -287,6 +302,7 @@ libgnunet_test_transport_plugin_cmd_udp_backchannel_init (void *cls) | |||
287 | api = GNUNET_new (struct GNUNET_TESTING_PluginFunctions); | 302 | api = GNUNET_new (struct GNUNET_TESTING_PluginFunctions); |
288 | api->start_testcase = &start_testcase; | 303 | api->start_testcase = &start_testcase; |
289 | api->all_peers_started = &all_peers_started; | 304 | api->all_peers_started = &all_peers_started; |
305 | api->all_local_tests_prepared = all_local_tests_prepared; | ||
290 | return api; | 306 | return api; |
291 | } | 307 | } |
292 | 308 | ||
diff --git a/src/transport/test_transport_simple_send_topo.conf b/src/transport/test_transport_simple_send_topo.conf new file mode 100644 index 000000000..f878f9719 --- /dev/null +++ b/src/transport/test_transport_simple_send_topo.conf | |||
@@ -0,0 +1,4 @@ | |||
1 | M:2 | ||
2 | N:1 | ||
3 | X:0 | ||
4 | T:libgnunet_test_transport_plugin_cmd_simple_send \ No newline at end of file | ||
diff --git a/src/transport/test_transport_udp_backchannel.sh b/src/transport/test_transport_udp_backchannel.sh index 3322e5853..0c37be469 100755 --- a/src/transport/test_transport_udp_backchannel.sh +++ b/src/transport/test_transport_udp_backchannel.sh | |||
@@ -1,2 +1,4 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | #exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; valgrind --leak-check=full --track-origins=yes --trace-children=yes --trace-children-skip=/usr/bin/awk,/usr/bin/cut,/usr/bin/seq,/sbin/ip ./test_transport_start_with_config test_transport_udp_backchannel_topo.conf" | ||
2 | exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; ./test_transport_start_with_config test_transport_udp_backchannel_topo.conf" | 3 | exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; ./test_transport_start_with_config test_transport_udp_backchannel_topo.conf" |
4 | # exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; valgrind --leak-check=full --track-origins=yes ./test_transport_start_with_config test_transport_udp_backchannel_topo.conf" | ||
diff --git a/src/transport/transport_api2_communication.c b/src/transport/transport_api2_communication.c index 446add6f6..2a80db87b 100644 --- a/src/transport/transport_api2_communication.c +++ b/src/transport/transport_api2_communication.c | |||
@@ -904,6 +904,10 @@ GNUNET_TRANSPORT_communicator_receive ( | |||
904 | struct GNUNET_TRANSPORT_IncomingMessage *im; | 904 | struct GNUNET_TRANSPORT_IncomingMessage *im; |
905 | uint16_t msize; | 905 | uint16_t msize; |
906 | 906 | ||
907 | |||
908 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
909 | "communicator receive\n"); | ||
910 | |||
907 | if (NULL == ch->mq) | 911 | if (NULL == ch->mq) |
908 | return GNUNET_SYSERR; | 912 | return GNUNET_SYSERR; |
909 | if ((NULL == cb) && (GNUNET_MQ_get_length (ch->mq) >= ch->max_queue_length)) | 913 | if ((NULL == cb) && (GNUNET_MQ_get_length (ch->mq) >= ch->max_queue_length)) |
@@ -986,6 +990,9 @@ GNUNET_TRANSPORT_communicator_mq_add ( | |||
986 | { | 990 | { |
987 | struct GNUNET_TRANSPORT_QueueHandle *qh; | 991 | struct GNUNET_TRANSPORT_QueueHandle *qh; |
988 | 992 | ||
993 | // Do not notify the service if there is no intial capacity. | ||
994 | GNUNET_assert (0 < q_len); | ||
995 | |||
989 | qh = GNUNET_new (struct GNUNET_TRANSPORT_QueueHandle); | 996 | qh = GNUNET_new (struct GNUNET_TRANSPORT_QueueHandle); |
990 | qh->ch = ch; | 997 | qh->ch = ch; |
991 | qh->peer = *peer; | 998 | qh->peer = *peer; |
@@ -1106,7 +1113,7 @@ GNUNET_TRANSPORT_communicator_address_remove ( | |||
1106 | */ | 1113 | */ |
1107 | void | 1114 | void |
1108 | GNUNET_TRANSPORT_communicator_address_remove_all ( | 1115 | GNUNET_TRANSPORT_communicator_address_remove_all ( |
1109 | struct GNUNET_TRANSPORT_CommunicatorHandle *ch) | 1116 | struct GNUNET_TRANSPORT_CommunicatorHandle *ch) |
1110 | { | 1117 | { |
1111 | for (struct GNUNET_TRANSPORT_AddressIdentifier *ai = ch->ai_head; NULL != ai; | 1118 | for (struct GNUNET_TRANSPORT_AddressIdentifier *ai = ch->ai_head; NULL != ai; |
1112 | ai = ai->next) | 1119 | ai = ai->next) |
diff --git a/src/transport/transport_api_cmd_backchannel_check.c b/src/transport/transport_api_cmd_backchannel_check.c new file mode 100644 index 000000000..5cc13dbfa --- /dev/null +++ b/src/transport/transport_api_cmd_backchannel_check.c | |||
@@ -0,0 +1,622 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2021 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file testing_api_cmd_backchannel_check.c | ||
23 | * @brief cmd to start a peer. | ||
24 | * @author t3sserakt | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_common.h" | ||
28 | #include "gnunet_util_lib.h" | ||
29 | #include "gnunet_testing_ng_lib.h" | ||
30 | #include "gnunet_transport_application_service.h" | ||
31 | #include "gnunet_hello_lib.h" | ||
32 | #include "gnunet_transport_service.h" | ||
33 | #include "transport-testing-cmds.h" | ||
34 | |||
35 | /** | ||
36 | * Generic logging shortcut | ||
37 | */ | ||
38 | #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) | ||
39 | |||
40 | #define UDP "udp" | ||
41 | |||
42 | /** | ||
43 | * Maximum length allowed for line input. | ||
44 | */ | ||
45 | #define MAX_LINE_LENGTH 1024 | ||
46 | |||
47 | /** | ||
48 | * Struct to store information needed in callbacks. | ||
49 | * | ||
50 | */ | ||
51 | struct CheckState | ||
52 | { | ||
53 | /** | ||
54 | * The number of the node in a network namespace. | ||
55 | */ | ||
56 | unsigned int node_n; | ||
57 | |||
58 | /** | ||
59 | * The number of the network namespace. | ||
60 | */ | ||
61 | unsigned int namespace_n; | ||
62 | |||
63 | /** | ||
64 | * The testing system of this node. | ||
65 | */ | ||
66 | struct GNUNET_TESTING_System *tl_system; | ||
67 | |||
68 | // Label of the cmd which started the test system. | ||
69 | const char *create_label; | ||
70 | |||
71 | /** | ||
72 | * Number globally identifying the node. | ||
73 | * | ||
74 | */ | ||
75 | uint32_t num; | ||
76 | |||
77 | /** | ||
78 | * Label of the cmd to start a peer. | ||
79 | * | ||
80 | */ | ||
81 | const char *start_peer_label; | ||
82 | |||
83 | /** | ||
84 | * The topology of the test setup. | ||
85 | */ | ||
86 | struct GNUNET_TESTING_NetjailTopology *topology; | ||
87 | |||
88 | /** | ||
89 | * Connections to other peers. | ||
90 | */ | ||
91 | struct GNUNET_TESTING_NodeConnection *node_connections_head; | ||
92 | |||
93 | /** | ||
94 | * Number of connections. | ||
95 | */ | ||
96 | unsigned int con_num; | ||
97 | |||
98 | /** | ||
99 | * Number of received backchannel messages. | ||
100 | */ | ||
101 | unsigned int received_backchannel_msgs; | ||
102 | |||
103 | /** | ||
104 | * Array with search strings. | ||
105 | */ | ||
106 | char **search_string; | ||
107 | |||
108 | /** | ||
109 | * File handle for log file. | ||
110 | */ | ||
111 | struct GNUNET_DISK_FileHandle *fh; | ||
112 | |||
113 | /** | ||
114 | * Task which handles the reading | ||
115 | */ | ||
116 | struct GNUNET_SCHEDULER_Task *task; | ||
117 | |||
118 | /** | ||
119 | * Stream to read log file lines. | ||
120 | */ | ||
121 | FILE *stream; | ||
122 | |||
123 | /** | ||
124 | * Did we get all bachchannel messages. | ||
125 | */ | ||
126 | enum GNUNET_GenericReturnValue finished; | ||
127 | }; | ||
128 | |||
129 | /** | ||
130 | * | ||
131 | * @param cls The cmd state CheckState. | ||
132 | */ | ||
133 | static void | ||
134 | read_from_log (void *cls) | ||
135 | { | ||
136 | struct CheckState *cs = cls; | ||
137 | char line[MAX_LINE_LENGTH + 1]; | ||
138 | char *search_string; | ||
139 | |||
140 | |||
141 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
142 | "read_from_log\n"); | ||
143 | |||
144 | cs->fh = GNUNET_DISK_file_open ("test.out", | ||
145 | GNUNET_DISK_OPEN_READ, | ||
146 | GNUNET_DISK_PERM_USER_READ); | ||
147 | |||
148 | cs->task = NULL; | ||
149 | |||
150 | /* read message from line and handle it */ | ||
151 | cs->stream = fdopen (cs->fh->fd, "r"); | ||
152 | memset (line, 0, MAX_LINE_LENGTH + 1); | ||
153 | |||
154 | // fgets (line, MAX_LINE_LENGTH, cs->stream); | ||
155 | // while (NULL != line && 0 != strcmp (line, ""))// '\0' != line[0]) | ||
156 | while (NULL != fgets (line, MAX_LINE_LENGTH, cs->stream)) | ||
157 | { | ||
158 | /*LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
159 | "cs->received_backchannel_msgs: %u\n", | ||
160 | cs->received_backchannel_msgs);*/ | ||
161 | /*if (NULL == strstr (line, "line")) | ||
162 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
163 | "line: %s", | ||
164 | line);*/ | ||
165 | |||
166 | |||
167 | for (int i = 0; i < cs->con_num; i++) | ||
168 | { | ||
169 | search_string = cs->search_string[i]; | ||
170 | /*LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
171 | "search %u %u: %s %p\n", | ||
172 | i, | ||
173 | cs->con_num, | ||
174 | cs->search_string[i], | ||
175 | cs->search_string); | ||
176 | fprintf (stderr, | ||
177 | line);*/ | ||
178 | if (NULL != strstr (line, | ||
179 | search_string)) | ||
180 | // "Delivering backchannel message from 4TTC to F7B5 of type 1460 to udp")) | ||
181 | // cs->search_string[i])) | ||
182 | { | ||
183 | cs->received_backchannel_msgs++; | ||
184 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
185 | "received_backchannel_msgs %u con_num %u\n", | ||
186 | cs->received_backchannel_msgs, | ||
187 | cs->con_num); | ||
188 | if (cs->received_backchannel_msgs == cs->con_num) | ||
189 | { | ||
190 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
191 | "search finished %lu %lu %u\n", | ||
192 | strlen (cs->search_string[i]), | ||
193 | strlen ( | ||
194 | "Delivering backchannel message from 4TTC to F7B5 of type 1460 to udp"), | ||
195 | strcmp ( | ||
196 | "Delivering backchannel message from 4TTC to F7B5 of type 1460 to udp", | ||
197 | cs->search_string[i])); | ||
198 | cs->finished = GNUNET_YES; | ||
199 | fclose (cs->stream); | ||
200 | return; | ||
201 | } | ||
202 | } | ||
203 | } | ||
204 | } | ||
205 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
206 | "read_from_log end\n"); | ||
207 | fclose (cs->stream); | ||
208 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS, | ||
209 | &read_from_log, | ||
210 | cs); | ||
211 | /*if (NULL == fgets (line, MAX_LINE_LENGTH, cs->stream)) | ||
212 | { | ||
213 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
214 | "read null\n"); | ||
215 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | ||
216 | &read_from_log, | ||
217 | cs); | ||
218 | return; | ||
219 | }*/ | ||
220 | /*else { | ||
221 | cs->task = | ||
222 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, | ||
223 | cs->fh, | ||
224 | &read_from_log, | ||
225 | cs); | ||
226 | |||
227 | |||
228 | }*/ | ||
229 | } | ||
230 | |||
231 | |||
232 | static enum GNUNET_GenericReturnValue | ||
233 | will_the_other_node_connect_via_udp ( | ||
234 | struct CheckState *cs, | ||
235 | const struct GNUNET_TESTING_NetjailNode *node) | ||
236 | // struct GNUNET_TESTING_NodeConnection *connection) | ||
237 | { | ||
238 | // struct GNUNET_TESTING_NetjailTopology *topology = cs->topology; | ||
239 | // unsigned int node_n = connection->node_n; | ||
240 | // unsigned int namespace_n = connection->namespace_n; | ||
241 | // struct GNUNET_HashCode hc; | ||
242 | // struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode); | ||
243 | // struct GNUNET_HashCode hc_namespace; | ||
244 | /*struct GNUNET_ShortHashCode *key_namespace = GNUNET_new (struct | ||
245 | GNUNET_ShortHashCode);*/ | ||
246 | // struct GNUNET_TESTING_NetjailNode *node; | ||
247 | struct GNUNET_TESTING_NodeConnection *pos_connection; | ||
248 | struct GNUNET_TESTING_AddressPrefix *pos_prefix; | ||
249 | // struct GNUNET_TESTING_NetjailNamespace *namespace; | ||
250 | // struct GNUNET_CONTAINER_MultiShortmap *map; | ||
251 | |||
252 | /* if (0 == connection->namespace_n) */ | ||
253 | /* { */ | ||
254 | /* map = topology->map_globals; */ | ||
255 | /* } */ | ||
256 | /* else */ | ||
257 | /* { */ | ||
258 | /* GNUNET_CRYPTO_hash (&namespace_n, sizeof(namespace_n), &hc_namespace); */ | ||
259 | /* memcpy (key_namespace, */ | ||
260 | /* &hc_namespace, */ | ||
261 | /* sizeof (*key_namespace)); */ | ||
262 | /* if (GNUNET_YES == GNUNET_CONTAINER_multishortmap_contains ( */ | ||
263 | /* topology->map_namespaces, */ | ||
264 | /* key_namespace)) */ | ||
265 | /* { */ | ||
266 | /* namespace = GNUNET_CONTAINER_multishortmap_get (topology->map_namespaces, */ | ||
267 | /* key_namespace); */ | ||
268 | /* map = namespace->nodes; */ | ||
269 | /* } */ | ||
270 | /* else */ | ||
271 | /* GNUNET_assert (0); */ | ||
272 | /* } */ | ||
273 | |||
274 | /* GNUNET_CRYPTO_hash (&node_n, sizeof(node_n), &hc); */ | ||
275 | /* memcpy (key, */ | ||
276 | /* &hc, */ | ||
277 | /* sizeof (*key)); */ | ||
278 | /* if (GNUNET_YES == GNUNET_CONTAINER_multishortmap_contains ( */ | ||
279 | /* map, */ | ||
280 | /* key)) */ | ||
281 | /* { */ | ||
282 | /* node = GNUNET_CONTAINER_multishortmap_get (cs->topology->map_globals, */ | ||
283 | /* key); */ | ||
284 | /* for (pos_connection = node->node_connections_head; NULL != pos_connection; */ | ||
285 | /* pos_connection = pos_connection->next) */ | ||
286 | /* { */ | ||
287 | /* if ((node->namespace_n == pos_connection->namespace_n) && */ | ||
288 | /* (node->node_n == pos_connection->node_n) ) */ | ||
289 | /* { */ | ||
290 | /* for (pos_prefix = pos_connection->address_prefixes_head; NULL != */ | ||
291 | /* pos_prefix; */ | ||
292 | /* pos_prefix = */ | ||
293 | /* pos_prefix->next) */ | ||
294 | /* { */ | ||
295 | /* if (0 == strcmp (UDP, pos_prefix->address_prefix)) */ | ||
296 | /* { */ | ||
297 | /* return GNUNET_YES; */ | ||
298 | /* } */ | ||
299 | /* } */ | ||
300 | /* } */ | ||
301 | /* } */ | ||
302 | /* } */ | ||
303 | |||
304 | for (pos_connection = node->node_connections_head; NULL != pos_connection; | ||
305 | pos_connection = pos_connection->next) | ||
306 | { | ||
307 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
308 | "connect via udp %u %u %u %u\n", | ||
309 | node->namespace_n, | ||
310 | cs->namespace_n, | ||
311 | node->node_n, | ||
312 | cs->node_n); | ||
313 | if ((pos_connection->namespace_n == cs->namespace_n) && | ||
314 | (pos_connection->node_n == cs->node_n) ) | ||
315 | { | ||
316 | for (pos_prefix = pos_connection->address_prefixes_head; NULL != | ||
317 | pos_prefix; | ||
318 | pos_prefix = | ||
319 | pos_prefix->next) | ||
320 | { | ||
321 | if (0 == strcmp (UDP, pos_prefix->address_prefix)) | ||
322 | { | ||
323 | return GNUNET_YES; | ||
324 | } | ||
325 | } | ||
326 | } | ||
327 | } | ||
328 | |||
329 | return GNUNET_NO; | ||
330 | } | ||
331 | |||
332 | static void | ||
333 | add_search_string (struct CheckState *cs, const struct | ||
334 | GNUNET_TESTING_NetjailNode *node) | ||
335 | { | ||
336 | unsigned int num; | ||
337 | struct GNUNET_PeerIdentity *peer; | ||
338 | struct GNUNET_PeerIdentity *us; | ||
339 | char *buf; | ||
340 | char *part_one = "Delivering backchannel message from "; | ||
341 | char *part_two = " to "; | ||
342 | char *part_three = " of type 1460 to udp"; | ||
343 | char *peer_id; | ||
344 | char *us_id; | ||
345 | |||
346 | if (0 == node->namespace_n) | ||
347 | num = node->node_n; | ||
348 | else | ||
349 | num = (node->namespace_n - 1) * cs->topology->nodes_m + node->node_n | ||
350 | + cs->topology->nodes_x; | ||
351 | |||
352 | // num = GNUNET_TESTING_calculate_num (pos_connection, cs->topology); | ||
353 | peer = GNUNET_TESTING_get_pub_key (num, cs->tl_system); | ||
354 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
355 | "peer: %s num %u\n", | ||
356 | GNUNET_i2s (peer), | ||
357 | num); | ||
358 | us = GNUNET_TESTING_get_pub_key (cs->num, cs->tl_system); | ||
359 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
360 | "us: %s cs->num %d\n", | ||
361 | GNUNET_i2s (us), | ||
362 | cs->num); | ||
363 | |||
364 | GNUNET_asprintf (&peer_id, | ||
365 | "%s", | ||
366 | GNUNET_i2s (peer)); | ||
367 | GNUNET_asprintf (&us_id, | ||
368 | "%s", | ||
369 | GNUNET_i2s (us)); | ||
370 | |||
371 | if (0 < GNUNET_asprintf (&buf, | ||
372 | "%s%s%s%s%s", | ||
373 | part_one, | ||
374 | us_id, | ||
375 | part_two, | ||
376 | peer_id, | ||
377 | part_three)) | ||
378 | { | ||
379 | GNUNET_array_append (cs->search_string, | ||
380 | cs->con_num, | ||
381 | buf); | ||
382 | /*LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
383 | "con_num: %u search: %s %p\n", | ||
384 | cs->con_num, | ||
385 | cs->search_string[cs->con_num - 1], | ||
386 | cs->search_string);*/ | ||
387 | } | ||
388 | else | ||
389 | GNUNET_assert (0); | ||
390 | } | ||
391 | |||
392 | |||
393 | /** | ||
394 | * The run method of this cmd will connect to peers. | ||
395 | * | ||
396 | */ | ||
397 | static void | ||
398 | backchannel_check_run (void *cls, | ||
399 | const struct GNUNET_TESTING_Command *cmd, | ||
400 | struct GNUNET_TESTING_Interpreter *is) | ||
401 | { | ||
402 | struct CheckState *cs = cls; | ||
403 | // char *buf; | ||
404 | // char *part_one = "Delivering backchannel message from "; | ||
405 | // char *part_two = " of type 1460 to udp"; | ||
406 | const struct GNUNET_TESTING_Command *system_cmd; | ||
407 | struct GNUNET_TESTING_System *tl_system; | ||
408 | const struct GNUNET_TESTING_Command *peer1_cmd; | ||
409 | struct GNUNET_TRANSPORT_ApplicationHandle *ah; | ||
410 | // struct GNUNET_PeerIdentity *peer; | ||
411 | // uint32_t num; | ||
412 | // struct GNUNET_TESTING_NodeConnection *pos_connection; | ||
413 | // unsigned int con_num = 0; | ||
414 | struct GNUNET_CONTAINER_MultiShortmapIterator *node_it; | ||
415 | struct GNUNET_CONTAINER_MultiShortmapIterator *namespace_it; | ||
416 | struct GNUNET_ShortHashCode node_key; | ||
417 | struct GNUNET_ShortHashCode namespace_key; | ||
418 | const struct GNUNET_TESTING_NetjailNode *node; | ||
419 | const struct GNUNET_TESTING_NetjailNamespace *namespace; | ||
420 | |||
421 | peer1_cmd = GNUNET_TESTING_interpreter_lookup_command ( | ||
422 | cs->start_peer_label); | ||
423 | GNUNET_TRANSPORT_get_trait_application_handle_v2 (peer1_cmd, | ||
424 | &ah); | ||
425 | |||
426 | system_cmd = GNUNET_TESTING_interpreter_lookup_command (cs->create_label); | ||
427 | GNUNET_TESTING_get_trait_test_system (system_cmd, | ||
428 | &tl_system); | ||
429 | |||
430 | cs->tl_system = tl_system; | ||
431 | |||
432 | cs->node_connections_head = GNUNET_TESTING_get_connections (cs->num, | ||
433 | cs->topology); | ||
434 | |||
435 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
436 | "check run\n"); | ||
437 | |||
438 | |||
439 | node_it = GNUNET_CONTAINER_multishortmap_iterator_create ( | ||
440 | cs->topology->map_globals); | ||
441 | |||
442 | while (GNUNET_YES == GNUNET_CONTAINER_multishortmap_iterator_next (node_it, | ||
443 | &node_key, | ||
444 | (const | ||
445 | void**) & | ||
446 | node)) | ||
447 | { | ||
448 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
449 | "namespace_n %u node_n %u\n", | ||
450 | node->namespace_n, | ||
451 | node->node_n); | ||
452 | if (GNUNET_YES == will_the_other_node_connect_via_udp (cs, node)) | ||
453 | { | ||
454 | add_search_string (cs, node); | ||
455 | } | ||
456 | } | ||
457 | namespace_it = GNUNET_CONTAINER_multishortmap_iterator_create ( | ||
458 | cs->topology->map_namespaces); | ||
459 | while (GNUNET_YES == GNUNET_CONTAINER_multishortmap_iterator_next ( | ||
460 | namespace_it, | ||
461 | &namespace_key, | ||
462 | (const | ||
463 | void**) &namespace)) | ||
464 | { | ||
465 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
466 | "namespace_n %u\n", | ||
467 | node->namespace_n); | ||
468 | node_it = GNUNET_CONTAINER_multishortmap_iterator_create ( | ||
469 | namespace->nodes); | ||
470 | while (GNUNET_YES == GNUNET_CONTAINER_multishortmap_iterator_next (node_it, | ||
471 | &node_key, | ||
472 | (const | ||
473 | void**) | ||
474 | &node)) | ||
475 | { | ||
476 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
477 | "namespace_n %u node_n %u\n", | ||
478 | node->namespace_n, | ||
479 | node->node_n); | ||
480 | if (GNUNET_YES == will_the_other_node_connect_via_udp (cs, node)) | ||
481 | { | ||
482 | add_search_string (cs, node); | ||
483 | } | ||
484 | } | ||
485 | } | ||
486 | /* for (pos_connection = cs->node_connections_head; NULL != pos_connection; */ | ||
487 | /* pos_connection = pos_connection->next) */ | ||
488 | /* { */ | ||
489 | |||
490 | /* if (GNUNET_YES == will_the_other_node_connect_via_udp (cs, node)) */ | ||
491 | /* { */ | ||
492 | /* num = GNUNET_TESTING_calculate_num (pos_connection, cs->topology); */ | ||
493 | /* peer = GNUNET_TESTING_get_pub_key (num, tl_system); */ | ||
494 | /* LOG (GNUNET_ERROR_TYPE_DEBUG, */ | ||
495 | /* "peer: %s\n", */ | ||
496 | /* GNUNET_i2s (peer)); */ | ||
497 | |||
498 | /* if (0 < GNUNET_asprintf (&buf, */ | ||
499 | /* "%s%s%s", */ | ||
500 | /* part_one, */ | ||
501 | /* GNUNET_i2s (peer), */ | ||
502 | /* part_two)) */ | ||
503 | /* { */ | ||
504 | /* GNUNET_array_append (cs->search_string, */ | ||
505 | /* con_num, */ | ||
506 | /* buf); */ | ||
507 | /* /\*LOG (GNUNET_ERROR_TYPE_DEBUG, */ | ||
508 | /* "con_num: %u search: %s %p\n", */ | ||
509 | /* con_num, */ | ||
510 | /* cs->search_string[con_num - 1], */ | ||
511 | /* cs->search_string);*\/ */ | ||
512 | /* } */ | ||
513 | /* else */ | ||
514 | /* GNUNET_assert (0); */ | ||
515 | /* } */ | ||
516 | |||
517 | |||
518 | /* } */ | ||
519 | // cs->con_num = con_num; | ||
520 | if (0 != cs->con_num) | ||
521 | { | ||
522 | cs->task = | ||
523 | GNUNET_SCHEDULER_add_now (&read_from_log, | ||
524 | cs); | ||
525 | } | ||
526 | else | ||
527 | cs->finished = GNUNET_YES; | ||
528 | |||
529 | } | ||
530 | |||
531 | |||
532 | /** | ||
533 | * The finish function of this cmd will check if the peers we are trying to | ||
534 | * connect to are in the connected peers map of the start peer cmd for this peer. | ||
535 | * | ||
536 | */ | ||
537 | static int | ||
538 | backchannel_check_finish (void *cls, | ||
539 | GNUNET_SCHEDULER_TaskCallback cont, | ||
540 | void *cont_cls) | ||
541 | { | ||
542 | struct CheckState *cs = cls; | ||
543 | |||
544 | if (cs->finished) | ||
545 | { | ||
546 | cont (cont_cls); | ||
547 | } | ||
548 | return cs->finished; | ||
549 | } | ||
550 | |||
551 | |||
552 | /** | ||
553 | * Trait function of this cmd does nothing. | ||
554 | * | ||
555 | */ | ||
556 | static int | ||
557 | backchannel_check_traits (void *cls, | ||
558 | const void **ret, | ||
559 | const char *trait, | ||
560 | unsigned int index) | ||
561 | { | ||
562 | return GNUNET_OK; | ||
563 | } | ||
564 | |||
565 | |||
566 | /** | ||
567 | * The cleanup function of this cmd frees resources the cmd allocated. | ||
568 | * | ||
569 | */ | ||
570 | static void | ||
571 | backchannel_check_cleanup (void *cls, | ||
572 | const struct GNUNET_TESTING_Command *cmd) | ||
573 | { | ||
574 | struct ConnectPeersState *cs = cls; | ||
575 | |||
576 | GNUNET_free (cs); | ||
577 | } | ||
578 | |||
579 | |||
580 | /** | ||
581 | * Create command. | ||
582 | * | ||
583 | * @param label name for command. | ||
584 | * @param start_peer_label Label of the cmd to start a peer. | ||
585 | * @param create_label Label of the cmd to create the testing system. | ||
586 | * @param num Number globally identifying the node. | ||
587 | * @param node_n The number of the node in a network namespace. | ||
588 | * @param namespace_n The number of the network namespace. | ||
589 | * @param The topology for the test setup. | ||
590 | * @return command. | ||
591 | */ | ||
592 | struct GNUNET_TESTING_Command | ||
593 | GNUNET_TRANSPORT_cmd_backchannel_check (const char *label, | ||
594 | const char *start_peer_label, | ||
595 | const char *create_label, | ||
596 | uint32_t num, | ||
597 | unsigned int node_n, | ||
598 | unsigned int namespace_n, | ||
599 | struct GNUNET_TESTING_NetjailTopology * | ||
600 | topology) | ||
601 | { | ||
602 | struct CheckState *cs; | ||
603 | |||
604 | cs = GNUNET_new (struct CheckState); | ||
605 | cs->start_peer_label = start_peer_label; | ||
606 | cs->num = num; | ||
607 | cs->create_label = create_label; | ||
608 | cs->topology = topology; | ||
609 | cs->node_n = node_n; | ||
610 | cs->namespace_n = namespace_n; | ||
611 | |||
612 | struct GNUNET_TESTING_Command cmd = { | ||
613 | .cls = cs, | ||
614 | .label = label, | ||
615 | .run = &backchannel_check_run, | ||
616 | .finish = &backchannel_check_finish, | ||
617 | .cleanup = &backchannel_check_cleanup, | ||
618 | .traits = &backchannel_check_traits | ||
619 | }; | ||
620 | |||
621 | return cmd; | ||
622 | } | ||
diff --git a/src/transport/transport_api_cmd_send_simple_v3.c b/src/transport/transport_api_cmd_send_simple_v3.c new file mode 100644 index 000000000..a4ce2c4e9 --- /dev/null +++ b/src/transport/transport_api_cmd_send_simple_v3.c | |||
@@ -0,0 +1,194 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2021 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file testing_api_cmd_start_peer.c | ||
23 | * @brief cmd to start a peer. | ||
24 | * @author t3sserakt | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_util_lib.h" | ||
28 | #include "gnunet_testing_ng_lib.h" | ||
29 | #include "transport-testing2.h" | ||
30 | #include "transport-testing-cmds.h" | ||
31 | |||
32 | /** | ||
33 | * Struct to hold information for callbacks. | ||
34 | * | ||
35 | */ | ||
36 | struct SendSimpleState | ||
37 | { | ||
38 | /** | ||
39 | * Number globally identifying the node. | ||
40 | * | ||
41 | */ | ||
42 | uint32_t num; | ||
43 | |||
44 | /** | ||
45 | * Label of the cmd to start a peer. | ||
46 | * | ||
47 | */ | ||
48 | const char *start_peer_label; | ||
49 | |||
50 | /** | ||
51 | * Label of the cmd which started the test system. | ||
52 | * | ||
53 | */ | ||
54 | const char *create_label; | ||
55 | |||
56 | /** | ||
57 | * The topology we get the connected nodes from. | ||
58 | */ | ||
59 | struct GNUNET_TESTING_NetjailTopology *topology; | ||
60 | }; | ||
61 | |||
62 | |||
63 | /** | ||
64 | * Trait function of this cmd does nothing. | ||
65 | * | ||
66 | */ | ||
67 | static int | ||
68 | send_simple_traits (void *cls, | ||
69 | const void **ret, | ||
70 | const char *trait, | ||
71 | unsigned int index) | ||
72 | { | ||
73 | return GNUNET_OK; | ||
74 | } | ||
75 | |||
76 | |||
77 | /** | ||
78 | * The cleanup function of this cmd frees resources the cmd allocated. | ||
79 | * | ||
80 | */ | ||
81 | static void | ||
82 | send_simple_cleanup (void *cls, | ||
83 | const struct GNUNET_TESTING_Command *cmd) | ||
84 | { | ||
85 | struct SendSimpleState *sss = cls; | ||
86 | |||
87 | GNUNET_free (sss); | ||
88 | } | ||
89 | |||
90 | |||
91 | /** | ||
92 | * The run method of this cmd will send a simple message to the connected peers. | ||
93 | * | ||
94 | */ | ||
95 | static void | ||
96 | send_simple_run (void *cls, | ||
97 | const struct GNUNET_TESTING_Command *cmd, | ||
98 | struct GNUNET_TESTING_Interpreter *is) | ||
99 | { | ||
100 | struct SendSimpleState *sss = cls; | ||
101 | struct GNUNET_MQ_Envelope *env; | ||
102 | struct GNUNET_TRANSPORT_TESTING_TestMessage *test; | ||
103 | struct GNUNET_MQ_Handle *mq; | ||
104 | struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map; | ||
105 | const struct GNUNET_TESTING_Command *peer1_cmd; | ||
106 | struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode); | ||
107 | struct GNUNET_HashCode hc; | ||
108 | struct GNUNET_TESTING_NodeConnection *node_connections_head; | ||
109 | struct GNUNET_PeerIdentity *peer; | ||
110 | struct GNUNET_CRYPTO_EddsaPublicKey public_key; | ||
111 | uint32_t num; | ||
112 | struct GNUNET_TESTING_NodeConnection *pos_connection; | ||
113 | const struct GNUNET_TESTING_Command *system_cmd; | ||
114 | struct GNUNET_TESTING_System *tl_system; | ||
115 | |||
116 | peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (sss->start_peer_label); | ||
117 | GNUNET_TRANSPORT_get_trait_connected_peers_map (peer1_cmd, | ||
118 | &connected_peers_map); | ||
119 | |||
120 | system_cmd = GNUNET_TESTING_interpreter_lookup_command (sss->create_label); | ||
121 | GNUNET_TESTING_get_trait_test_system (system_cmd, | ||
122 | &tl_system); | ||
123 | |||
124 | node_connections_head = GNUNET_TESTING_get_connections (sss->num, | ||
125 | sss->topology); | ||
126 | |||
127 | for (int i = 0; i < 1; i++) | ||
128 | { | ||
129 | for (pos_connection = node_connections_head; NULL != pos_connection; | ||
130 | pos_connection = pos_connection->next) | ||
131 | { | ||
132 | num = GNUNET_TESTING_calculate_num (pos_connection, sss->topology); | ||
133 | peer = GNUNET_TESTING_get_pub_key (num, tl_system); | ||
134 | public_key = peer->public_key; | ||
135 | GNUNET_CRYPTO_hash (&public_key, sizeof(public_key), &hc); | ||
136 | |||
137 | memcpy (key, | ||
138 | &hc, | ||
139 | sizeof (*key)); | ||
140 | mq = GNUNET_CONTAINER_multishortmap_get (connected_peers_map, | ||
141 | key); | ||
142 | env = GNUNET_MQ_msg_extra (test, | ||
143 | 1000 - sizeof(*test), | ||
144 | GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE); | ||
145 | test->num = htonl (sss->num); | ||
146 | memset (&test[1], | ||
147 | sss->num, | ||
148 | 1000 - sizeof(*test)); | ||
149 | GNUNET_MQ_send (mq, | ||
150 | env); | ||
151 | } | ||
152 | } | ||
153 | |||
154 | GNUNET_free (key); | ||
155 | |||
156 | } | ||
157 | |||
158 | |||
159 | /** | ||
160 | * Create command. | ||
161 | * | ||
162 | * @param label name for command. | ||
163 | * @param start_peer_label Label of the cmd to start a peer. | ||
164 | * @param start_peer_label Label of the cmd which started the test system. | ||
165 | * @param num Number globally identifying the node. | ||
166 | * @param The topology for the test setup. | ||
167 | * @return command. | ||
168 | */ | ||
169 | struct GNUNET_TESTING_Command | ||
170 | GNUNET_TRANSPORT_cmd_send_simple_v3 (const char *label, | ||
171 | const char *start_peer_label, | ||
172 | const char *create_label, | ||
173 | uint32_t num, | ||
174 | struct GNUNET_TESTING_NetjailTopology * | ||
175 | topology) | ||
176 | { | ||
177 | struct SendSimpleState *sss; | ||
178 | |||
179 | sss = GNUNET_new (struct SendSimpleState); | ||
180 | sss->num = num; | ||
181 | sss->start_peer_label = start_peer_label; | ||
182 | sss->create_label = create_label; | ||
183 | sss->topology = topology; | ||
184 | |||
185 | struct GNUNET_TESTING_Command cmd = { | ||
186 | .cls = sss, | ||
187 | .label = label, | ||
188 | .run = &send_simple_run, | ||
189 | .cleanup = &send_simple_cleanup, | ||
190 | .traits = &send_simple_traits | ||
191 | }; | ||
192 | |||
193 | return cmd; | ||
194 | } | ||
diff --git a/src/util/helper.c b/src/util/helper.c index dcb55d8c7..0809c1f17 100644 --- a/src/util/helper.c +++ b/src/util/helper.c | |||
@@ -407,6 +407,8 @@ start_helper (struct GNUNET_HELPER_Handle *h) | |||
407 | if ((h->helper_in == NULL) || (h->helper_out == NULL)) | 407 | if ((h->helper_in == NULL) || (h->helper_out == NULL)) |
408 | { | 408 | { |
409 | /* out of file descriptors? try again later... */ | 409 | /* out of file descriptors? try again later... */ |
410 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
411 | "out of file descriptors? try again later\n"); | ||
410 | stop_helper (h, GNUNET_NO); | 412 | stop_helper (h, GNUNET_NO); |
411 | h->restart_task = GNUNET_SCHEDULER_add_delayed ( | 413 | h->restart_task = GNUNET_SCHEDULER_add_delayed ( |
412 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, | 414 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, |
@@ -434,6 +436,8 @@ start_helper (struct GNUNET_HELPER_Handle *h) | |||
434 | if (NULL == h->helper_proc) | 436 | if (NULL == h->helper_proc) |
435 | { | 437 | { |
436 | /* failed to start process? try again later... */ | 438 | /* failed to start process? try again later... */ |
439 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
440 | "failed to start process? try again later\n"); | ||
437 | stop_helper (h, GNUNET_NO); | 441 | stop_helper (h, GNUNET_NO); |
438 | h->restart_task = GNUNET_SCHEDULER_add_delayed ( | 442 | h->restart_task = GNUNET_SCHEDULER_add_delayed ( |
439 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, | 443 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, |