diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-02-17 19:54:04 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-02-17 19:54:04 +0100 |
commit | 6d5dfc645805f2fc7b24ea72f84c3c3c5a0124cb (patch) | |
tree | af904e0ec738ebfde19a31ddfef4ae3d75054abd | |
parent | e4867f6ec0b9d0e57d8448f08d96a349dde0886c (diff) | |
parent | 08adc88b441694e02c3e440836e4ff9585cf3f88 (diff) | |
download | gnunet-6d5dfc645805f2fc7b24ea72f84c3c3c5a0124cb.tar.gz gnunet-6d5dfc645805f2fc7b24ea72f84c3c3c5a0124cb.zip |
Merge branch 'master' of git+ssh://gnunet.org/gnunet
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | src/setu/gnunet-service-setu.c | 60 |
2 files changed, 40 insertions, 23 deletions
diff --git a/.gitignore b/.gitignore index b076501bc..d51248502 100644 --- a/.gitignore +++ b/.gitignore | |||
@@ -73,3 +73,6 @@ cmake/ | |||
73 | build | 73 | build |
74 | CMakeLists.txt | 74 | CMakeLists.txt |
75 | CMakeFiles.txt | 75 | CMakeFiles.txt |
76 | |||
77 | # Prevent cache files from IDEA from being commited | ||
78 | .idea/ | ||
diff --git a/src/setu/gnunet-service-setu.c b/src/setu/gnunet-service-setu.c index e5d8751f2..9ec482559 100644 --- a/src/setu/gnunet-service-setu.c +++ b/src/setu/gnunet-service-setu.c | |||
@@ -103,17 +103,17 @@ enum UnionOperationPhase | |||
103 | /** | 103 | /** |
104 | * Continuation for multi part IBFs. | 104 | * Continuation for multi part IBFs. |
105 | */ | 105 | */ |
106 | PHASE_EXPECT_IBF_CONT, | 106 | PHASE_EXPECT_IBF_LAST, |
107 | 107 | ||
108 | /** | 108 | /** |
109 | * We are decoding an IBF. | 109 | * We are decoding an IBF. |
110 | */ | 110 | */ |
111 | PHASE_INVENTORY_ACTIVE, | 111 | PHASE_ACTIVE_DECODING, |
112 | 112 | ||
113 | /** | 113 | /** |
114 | * The other peer is decoding the IBF we just sent. | 114 | * The other peer is decoding the IBF we just sent. |
115 | */ | 115 | */ |
116 | PHASE_INVENTORY_PASSIVE, | 116 | PHASE_PASSIVE_DECODING, |
117 | 117 | ||
118 | /** | 118 | /** |
119 | * The protocol is almost finished, but we still have to flush our message | 119 | * The protocol is almost finished, but we still have to flush our message |
@@ -131,13 +131,19 @@ enum UnionOperationPhase | |||
131 | * In the ultimate phase, we wait until our demands are satisfied and then | 131 | * In the ultimate phase, we wait until our demands are satisfied and then |
132 | * quit (sending another DONE message). | 132 | * quit (sending another DONE message). |
133 | */ | 133 | */ |
134 | PHASE_DONE, | 134 | PHASE_FINISHED, |
135 | 135 | ||
136 | /** | 136 | /** |
137 | * After sending the full set, wait for responses with the elements | 137 | * After sending the full set, wait for responses with the elements |
138 | * that the local peer is missing. | 138 | * that the local peer is missing. |
139 | */ | 139 | */ |
140 | PHASE_FULL_SENDING, | 140 | PHASE_FULL_SENDING, |
141 | |||
142 | /** | ||
143 | * Phase that receives full set first and then sends elements that are | ||
144 | * the local peer missing | ||
145 | */ | ||
146 | PHASE_FULL_RECEIVING | ||
141 | }; | 147 | }; |
142 | 148 | ||
143 | 149 | ||
@@ -657,7 +663,7 @@ send_client_done (void *cls) | |||
657 | 663 | ||
658 | if (GNUNET_YES == op->client_done_sent) | 664 | if (GNUNET_YES == op->client_done_sent) |
659 | return; | 665 | return; |
660 | if (PHASE_DONE != op->phase) | 666 | if (PHASE_FINISHED != op->phase) |
661 | { | 667 | { |
662 | LOG (GNUNET_ERROR_TYPE_WARNING, | 668 | LOG (GNUNET_ERROR_TYPE_WARNING, |
663 | "Union operation failed\n"); | 669 | "Union operation failed\n"); |
@@ -1225,7 +1231,7 @@ send_ibf (struct Operation *op, | |||
1225 | 1231 | ||
1226 | /* The other peer must decode the IBF, so | 1232 | /* The other peer must decode the IBF, so |
1227 | * we're passive. */ | 1233 | * we're passive. */ |
1228 | op->phase = PHASE_INVENTORY_PASSIVE; | 1234 | op->phase = PHASE_PASSIVE_DECODING; |
1229 | return GNUNET_OK; | 1235 | return GNUNET_OK; |
1230 | } | 1236 | } |
1231 | 1237 | ||
@@ -1448,7 +1454,7 @@ handle_union_p2p_strata_estimator (void *cls, | |||
1448 | 1454 | ||
1449 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1455 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1450 | "Telling other peer that we expect its full set\n"); | 1456 | "Telling other peer that we expect its full set\n"); |
1451 | op->phase = PHASE_EXPECT_IBF; | 1457 | op->phase = PHASE_FULL_RECEIVING; |
1452 | ev = GNUNET_MQ_msg_header ( | 1458 | ev = GNUNET_MQ_msg_header ( |
1453 | GNUNET_MESSAGE_TYPE_SETU_P2P_REQUEST_FULL); | 1459 | GNUNET_MESSAGE_TYPE_SETU_P2P_REQUEST_FULL); |
1454 | GNUNET_MQ_send (op->mq, | 1460 | GNUNET_MQ_send (op->mq, |
@@ -1552,7 +1558,7 @@ decode_and_send (struct Operation *op) | |||
1552 | unsigned int num_decoded; | 1558 | unsigned int num_decoded; |
1553 | struct InvertibleBloomFilter *diff_ibf; | 1559 | struct InvertibleBloomFilter *diff_ibf; |
1554 | 1560 | ||
1555 | GNUNET_assert (PHASE_INVENTORY_ACTIVE == op->phase); | 1561 | GNUNET_assert (PHASE_ACTIVE_DECODING == op->phase); |
1556 | 1562 | ||
1557 | if (GNUNET_OK != | 1563 | if (GNUNET_OK != |
1558 | prepare_ibf (op, | 1564 | prepare_ibf (op, |
@@ -1729,7 +1735,7 @@ check_union_p2p_ibf (void *cls, | |||
1729 | GNUNET_break_op (0); | 1735 | GNUNET_break_op (0); |
1730 | return GNUNET_SYSERR; | 1736 | return GNUNET_SYSERR; |
1731 | } | 1737 | } |
1732 | if (op->phase == PHASE_EXPECT_IBF_CONT) | 1738 | if (op->phase == PHASE_EXPECT_IBF_LAST) |
1733 | { | 1739 | { |
1734 | if (ntohl (msg->offset) != op->ibf_buckets_received) | 1740 | if (ntohl (msg->offset) != op->ibf_buckets_received) |
1735 | { | 1741 | { |
@@ -1747,7 +1753,7 @@ check_union_p2p_ibf (void *cls, | |||
1747 | return GNUNET_SYSERR; | 1753 | return GNUNET_SYSERR; |
1748 | } | 1754 | } |
1749 | } | 1755 | } |
1750 | else if ((op->phase != PHASE_INVENTORY_PASSIVE) && | 1756 | else if ((op->phase != PHASE_PASSIVE_DECODING) && |
1751 | (op->phase != PHASE_EXPECT_IBF)) | 1757 | (op->phase != PHASE_EXPECT_IBF)) |
1752 | { | 1758 | { |
1753 | GNUNET_break_op (0); | 1759 | GNUNET_break_op (0); |
@@ -1776,10 +1782,10 @@ handle_union_p2p_ibf (void *cls, | |||
1776 | 1782 | ||
1777 | buckets_in_message = (ntohs (msg->header.size) - sizeof *msg) | 1783 | buckets_in_message = (ntohs (msg->header.size) - sizeof *msg) |
1778 | / IBF_BUCKET_SIZE; | 1784 | / IBF_BUCKET_SIZE; |
1779 | if ((op->phase == PHASE_INVENTORY_PASSIVE) || | 1785 | if ((op->phase == PHASE_PASSIVE_DECODING) || |
1780 | (op->phase == PHASE_EXPECT_IBF)) | 1786 | (op->phase == PHASE_EXPECT_IBF)) |
1781 | { | 1787 | { |
1782 | op->phase = PHASE_EXPECT_IBF_CONT; | 1788 | op->phase = PHASE_EXPECT_IBF_LAST; |
1783 | GNUNET_assert (NULL == op->remote_ibf); | 1789 | GNUNET_assert (NULL == op->remote_ibf); |
1784 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1790 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1785 | "Creating new ibf of size %u\n", | 1791 | "Creating new ibf of size %u\n", |
@@ -1806,7 +1812,7 @@ handle_union_p2p_ibf (void *cls, | |||
1806 | } | 1812 | } |
1807 | else | 1813 | else |
1808 | { | 1814 | { |
1809 | GNUNET_assert (op->phase == PHASE_EXPECT_IBF_CONT); | 1815 | GNUNET_assert (op->phase == PHASE_EXPECT_IBF_LAST); |
1810 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1816 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1811 | "Received more of IBF\n"); | 1817 | "Received more of IBF\n"); |
1812 | } | 1818 | } |
@@ -1822,7 +1828,7 @@ handle_union_p2p_ibf (void *cls, | |||
1822 | { | 1828 | { |
1823 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1829 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1824 | "received full ibf\n"); | 1830 | "received full ibf\n"); |
1825 | op->phase = PHASE_INVENTORY_ACTIVE; | 1831 | op->phase = PHASE_ACTIVE_DECODING; |
1826 | if (GNUNET_OK != | 1832 | if (GNUNET_OK != |
1827 | decode_and_send (op)) | 1833 | decode_and_send (op)) |
1828 | { | 1834 | { |
@@ -1901,7 +1907,7 @@ maybe_finish (struct Operation *op) | |||
1901 | { | 1907 | { |
1902 | struct GNUNET_MQ_Envelope *ev; | 1908 | struct GNUNET_MQ_Envelope *ev; |
1903 | 1909 | ||
1904 | op->phase = PHASE_DONE; | 1910 | op->phase = PHASE_FINISHED; |
1905 | ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SETU_P2P_DONE); | 1911 | ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SETU_P2P_DONE); |
1906 | GNUNET_MQ_send (op->mq, | 1912 | GNUNET_MQ_send (op->mq, |
1907 | ev); | 1913 | ev); |
@@ -1916,7 +1922,7 @@ maybe_finish (struct Operation *op) | |||
1916 | num_demanded); | 1922 | num_demanded); |
1917 | if (0 == num_demanded) | 1923 | if (0 == num_demanded) |
1918 | { | 1924 | { |
1919 | op->phase = PHASE_DONE; | 1925 | op->phase = PHASE_FINISHED; |
1920 | send_client_done (op); | 1926 | send_client_done (op); |
1921 | _GSS_operation_destroy2 (op); | 1927 | _GSS_operation_destroy2 (op); |
1922 | } | 1928 | } |
@@ -2051,6 +2057,12 @@ check_union_p2p_full_element (void *cls, | |||
2051 | { | 2057 | { |
2052 | struct Operation *op = cls; | 2058 | struct Operation *op = cls; |
2053 | 2059 | ||
2060 | // Allow only receiving of full element message if in expect IBF or in PHASE_FULL_RECEIVING state | ||
2061 | if ( op->phase != PHASE_EXPECT_IBF && op->phase != PHASE_FULL_RECEIVING ) { | ||
2062 | GNUNET_break_op (0); | ||
2063 | return GNUNET_SYSERR; | ||
2064 | } | ||
2065 | |||
2054 | (void) op; | 2066 | (void) op; |
2055 | // FIXME: check that we expect full elements here? | 2067 | // FIXME: check that we expect full elements here? |
2056 | return GNUNET_OK; | 2068 | return GNUNET_OK; |
@@ -2072,6 +2084,8 @@ handle_union_p2p_full_element (void *cls, | |||
2072 | struct KeyEntry *ke; | 2084 | struct KeyEntry *ke; |
2073 | uint16_t element_size; | 2085 | uint16_t element_size; |
2074 | 2086 | ||
2087 | op->phase = PHASE_FULL_RECEIVING; | ||
2088 | |||
2075 | element_size = ntohs (emsg->header.size) | 2089 | element_size = ntohs (emsg->header.size) |
2076 | - sizeof(struct GNUNET_SETU_ElementMessage); | 2090 | - sizeof(struct GNUNET_SETU_ElementMessage); |
2077 | ee = GNUNET_malloc (sizeof(struct ElementEntry) + element_size); | 2091 | ee = GNUNET_malloc (sizeof(struct ElementEntry) + element_size); |
@@ -2154,7 +2168,7 @@ check_union_p2p_inquiry (void *cls, | |||
2154 | struct Operation *op = cls; | 2168 | struct Operation *op = cls; |
2155 | unsigned int num_keys; | 2169 | unsigned int num_keys; |
2156 | 2170 | ||
2157 | if (op->phase != PHASE_INVENTORY_PASSIVE) | 2171 | if (op->phase != PHASE_PASSIVE_DECODING) |
2158 | { | 2172 | { |
2159 | GNUNET_break_op (0); | 2173 | GNUNET_break_op (0); |
2160 | return GNUNET_SYSERR; | 2174 | return GNUNET_SYSERR; |
@@ -2297,7 +2311,7 @@ handle_union_p2p_full_done (void *cls, | |||
2297 | ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SETU_P2P_FULL_DONE); | 2311 | ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SETU_P2P_FULL_DONE); |
2298 | GNUNET_MQ_send (op->mq, | 2312 | GNUNET_MQ_send (op->mq, |
2299 | ev); | 2313 | ev); |
2300 | op->phase = PHASE_DONE; | 2314 | op->phase = PHASE_FINISHED; |
2301 | /* we now wait until the other peer sends us the OVER message*/ | 2315 | /* we now wait until the other peer sends us the OVER message*/ |
2302 | } | 2316 | } |
2303 | break; | 2317 | break; |
@@ -2307,7 +2321,7 @@ handle_union_p2p_full_done (void *cls, | |||
2307 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2321 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2308 | "got FULL DONE, finishing\n"); | 2322 | "got FULL DONE, finishing\n"); |
2309 | /* We sent the full set, and got the response for that. We're done. */ | 2323 | /* We sent the full set, and got the response for that. We're done. */ |
2310 | op->phase = PHASE_DONE; | 2324 | op->phase = PHASE_FINISHED; |
2311 | GNUNET_CADET_receive_done (op->channel); | 2325 | GNUNET_CADET_receive_done (op->channel); |
2312 | send_client_done (op); | 2326 | send_client_done (op); |
2313 | _GSS_operation_destroy2 (op); | 2327 | _GSS_operation_destroy2 (op); |
@@ -2437,8 +2451,8 @@ check_union_p2p_offer (void *cls, | |||
2437 | unsigned int num_hashes; | 2451 | unsigned int num_hashes; |
2438 | 2452 | ||
2439 | /* look up elements and send them */ | 2453 | /* look up elements and send them */ |
2440 | if ((op->phase != PHASE_INVENTORY_PASSIVE) && | 2454 | if ((op->phase != PHASE_PASSIVE_DECODING) && |
2441 | (op->phase != PHASE_INVENTORY_ACTIVE)) | 2455 | (op->phase != PHASE_ACTIVE_DECODING)) |
2442 | { | 2456 | { |
2443 | GNUNET_break_op (0); | 2457 | GNUNET_break_op (0); |
2444 | return GNUNET_SYSERR; | 2458 | return GNUNET_SYSERR; |
@@ -2531,7 +2545,7 @@ handle_union_p2p_done (void *cls, | |||
2531 | 2545 | ||
2532 | switch (op->phase) | 2546 | switch (op->phase) |
2533 | { | 2547 | { |
2534 | case PHASE_INVENTORY_PASSIVE: | 2548 | case PHASE_PASSIVE_DECODING: |
2535 | /* We got all requests, but still have to send our elements in response. */ | 2549 | /* We got all requests, but still have to send our elements in response. */ |
2536 | op->phase = PHASE_FINISH_WAITING; | 2550 | op->phase = PHASE_FINISH_WAITING; |
2537 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2551 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -2547,7 +2561,7 @@ handle_union_p2p_done (void *cls, | |||
2547 | */GNUNET_CADET_receive_done (op->channel); | 2561 | */GNUNET_CADET_receive_done (op->channel); |
2548 | maybe_finish (op); | 2562 | maybe_finish (op); |
2549 | return; | 2563 | return; |
2550 | case PHASE_INVENTORY_ACTIVE: | 2564 | case PHASE_ACTIVE_DECODING: |
2551 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2565 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2552 | "got DONE (as active partner), waiting to finish\n"); | 2566 | "got DONE (as active partner), waiting to finish\n"); |
2553 | /* All demands of the other peer are satisfied, | 2567 | /* All demands of the other peer are satisfied, |