route.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. #include <pthread.h>
  2. #include "Enclave_t.h"
  3. #include "config.hpp"
  4. #include "utils.hpp"
  5. #include "sort.hpp"
  6. #include "comms.hpp"
  7. #include "obliv.hpp"
  8. #include "route.hpp"
  9. #define PROFILE_ROUTING
  10. struct MsgBuffer {
  11. pthread_mutex_t mutex;
  12. uint8_t *buf;
  13. // The number of messages (not bytes) in, or on their way into, the
  14. // buffer
  15. uint32_t reserved;
  16. // The number of messages definitely in the buffer
  17. uint32_t inserted;
  18. // The number of messages that can fit in buf
  19. uint32_t bufsize;
  20. // The number of nodes we've heard from
  21. nodenum_t nodes_received;
  22. MsgBuffer() : buf(NULL), reserved(0), inserted(0), bufsize(0),
  23. nodes_received(0) {
  24. pthread_mutex_init(&mutex, NULL);
  25. }
  26. ~MsgBuffer() {
  27. delete[] buf;
  28. }
  29. // The number passed is messages, not bytes
  30. void alloc(uint32_t msgs) {
  31. delete[] buf;
  32. buf = NULL;
  33. reserved = 0;
  34. inserted = 0;
  35. // This may throw bad_alloc, but we'll catch it higher up
  36. buf = new uint8_t[size_t(msgs) * g_teems_config.msg_size];
  37. memset(buf, 0, size_t(msgs) * g_teems_config.msg_size);
  38. bufsize = msgs;
  39. nodes_received = 0;
  40. }
  41. // Reset the contents of the buffer
  42. void reset() {
  43. memset(buf, 0, bufsize * g_teems_config.msg_size);
  44. reserved = 0;
  45. inserted = 0;
  46. nodes_received = 0;
  47. }
  48. // You can't copy a MsgBuffer
  49. MsgBuffer(const MsgBuffer&) = delete;
  50. MsgBuffer &operator=(const MsgBuffer&) = delete;
  51. };
  52. enum RouteStep {
  53. ROUTE_NOT_STARTED,
  54. ROUTE_ROUND_1,
  55. ROUTE_ROUND_2
  56. };
  57. // The ingbuf MsgBuffer stores messages an ingestion node ingests while
  58. // waiting for round 1 to start, which will be sorted and sent out in
  59. // round 1. The round1 MsgBuffer stores messages a routing node
  60. // receives in round 1, which will be padded, sorted, and sent out in
  61. // round 2. The round2 MsgBuffer stores messages a storage node
  62. // receives in round 2.
  63. static struct RouteState {
  64. MsgBuffer ingbuf;
  65. MsgBuffer round1;
  66. MsgBuffer round2;
  67. RouteStep step;
  68. uint32_t tot_msg_per_ing;
  69. uint32_t max_msg_to_each_stg;
  70. uint32_t max_round2_msgs;
  71. void *cbpointer;
  72. } route_state;
  73. // Computes ceil(x/y) where x and y are integers, x>=0, y>0.
  74. #define CEILDIV(x,y) (((x)+(y)-1)/(y))
  75. // Call this near the end of ecall_config_load, but before
  76. // comms_init_nodestate. Returns true on success, false on failure.
  77. bool route_init()
  78. {
  79. // Compute the maximum number of messages we could receive by direct
  80. // ingestion
  81. // Each ingestion node will have at most
  82. // ceil(user_count/num_ingestion_nodes) users, and each user will
  83. // send at most m_priv_out messages.
  84. uint32_t users_per_ing = CEILDIV(g_teems_config.user_count,
  85. g_teems_config.num_ingestion_nodes);
  86. uint32_t tot_msg_per_ing = users_per_ing * g_teems_config.m_priv_out;
  87. // Compute the maximum number of messages we could receive in round 1
  88. // Each ingestion node will send us an our_weight/tot_weight
  89. // fraction of the messages they hold
  90. uint32_t max_msg_from_each_ing = CEILDIV(tot_msg_per_ing,
  91. g_teems_config.tot_weight) * g_teems_config.my_weight;
  92. // And the maximum number we can receive in total is that times the
  93. // number of ingestion nodes
  94. uint32_t max_round1_msgs = max_msg_from_each_ing *
  95. g_teems_config.num_ingestion_nodes;
  96. // Compute the maximum number of messages we could send in round 2
  97. // Each storage node has at most this many users
  98. uint32_t users_per_stg = CEILDIV(g_teems_config.user_count,
  99. g_teems_config.num_storage_nodes);
  100. // And so can receive at most this many messages
  101. uint32_t tot_msg_per_stg = users_per_stg *
  102. g_teems_config.m_priv_in;
  103. // Which will be at most this many from us
  104. uint32_t max_msg_to_each_stg = CEILDIV(tot_msg_per_stg,
  105. g_teems_config.tot_weight) * g_teems_config.my_weight;
  106. // But we can't send more messages to each storage server than we
  107. // could receive in total
  108. if (max_msg_to_each_stg > max_round1_msgs) {
  109. max_msg_to_each_stg = max_round1_msgs;
  110. }
  111. // And the max total number of outgoing messages in round 2 is then
  112. uint32_t max_round2_msgs = max_msg_to_each_stg *
  113. g_teems_config.num_storage_nodes;
  114. // In case we have a weird configuration where users can send more
  115. // messages per epoch than they can receive, ensure the round 2
  116. // buffer is large enough to hold the incoming messages as well
  117. if (max_round2_msgs < max_round1_msgs) {
  118. max_round2_msgs = max_round1_msgs;
  119. }
  120. /*
  121. printf("round1_msgs = %u, round2_msgs = %u\n",
  122. max_round1_msgs, max_round2_msgs);
  123. */
  124. // Create the route state
  125. uint8_t my_roles = g_teems_config.roles[g_teems_config.my_node_num];
  126. try {
  127. if (my_roles & ROLE_INGESTION) {
  128. route_state.ingbuf.alloc(tot_msg_per_ing);
  129. }
  130. if (my_roles & ROLE_ROUTING) {
  131. route_state.round1.alloc(max_round2_msgs);
  132. }
  133. if (my_roles & ROLE_STORAGE) {
  134. route_state.round2.alloc(tot_msg_per_stg +
  135. g_teems_config.tot_weight);
  136. }
  137. } catch (std::bad_alloc&) {
  138. printf("Memory allocation failed in route_init\n");
  139. return false;
  140. }
  141. route_state.step = ROUTE_NOT_STARTED;
  142. route_state.tot_msg_per_ing = tot_msg_per_ing;
  143. route_state.max_msg_to_each_stg = max_msg_to_each_stg;
  144. route_state.max_round2_msgs = max_round2_msgs;
  145. route_state.cbpointer = NULL;
  146. threadid_t nthreads = g_teems_config.nthreads;
  147. #ifdef PROFILE_ROUTING
  148. unsigned long start = printf_with_rtclock("begin precompute evalplans (%u,%hu) (%u,%hu)\n", tot_msg_per_ing, nthreads, max_round2_msgs, nthreads);
  149. #endif
  150. sort_precompute_evalplan(tot_msg_per_ing, nthreads);
  151. sort_precompute_evalplan(max_round2_msgs, nthreads);
  152. #ifdef PROFILE_ROUTING
  153. printf_with_rtclock_diff(start, "end precompute evalplans\n");
  154. #endif
  155. return true;
  156. }
  157. // Precompute the WaksmanNetworks needed for the sorts. If you pass -1,
  158. // it will return the number of different sizes it needs. If you pass
  159. // [0,sizes-1], it will compute one WaksmanNetwork with that size index
  160. // and return the number of available WaksmanNetworks of that size.
  161. size_t ecall_precompute_sort(int sizeidx)
  162. {
  163. size_t ret = 0;
  164. switch(sizeidx) {
  165. case 0:
  166. #ifdef PROFILE_ROUTING
  167. {unsigned long start = printf_with_rtclock("begin precompute WaksmanNetwork (%u)\n", route_state.tot_msg_per_ing);
  168. #endif
  169. ret = sort_precompute(route_state.tot_msg_per_ing);
  170. #ifdef PROFILE_ROUTING
  171. printf_with_rtclock_diff(start, "end precompute Waksman Network (%u)\n", route_state.tot_msg_per_ing);}
  172. #endif
  173. break;
  174. case 1:
  175. #ifdef PROFILE_ROUTING
  176. {unsigned long start = printf_with_rtclock("begin precompute WaksmanNetwork (%u)\n", route_state.max_round2_msgs);
  177. #endif
  178. ret = sort_precompute(route_state.max_round2_msgs);
  179. #ifdef PROFILE_ROUTING
  180. printf_with_rtclock_diff(start, "end precompute Waksman Network (%u)\n", route_state.max_round2_msgs);}
  181. #endif
  182. break;
  183. default:
  184. ret = 2;
  185. break;
  186. }
  187. return ret;
  188. }
  189. static uint8_t* msgbuffer_get_buf(MsgBuffer &msgbuf,
  190. NodeCommState &, uint32_t tot_enc_chunk_size)
  191. {
  192. uint16_t msg_size = g_teems_config.msg_size;
  193. // Chunks will be encrypted and have a MAC tag attached which will
  194. // not correspond to plaintext bytes, so we can trim them.
  195. // The minimum number of chunks needed to transmit this message
  196. uint32_t min_num_chunks =
  197. (tot_enc_chunk_size + (FRAME_SIZE-1)) / FRAME_SIZE;
  198. // The number of plaintext bytes this message could contain
  199. uint32_t plaintext_bytes = tot_enc_chunk_size -
  200. SGX_AESGCM_MAC_SIZE * min_num_chunks;
  201. assert ((plaintext_bytes % uint32_t(msg_size)) == 0);
  202. uint32_t num_msgs = plaintext_bytes/uint32_t(msg_size);
  203. pthread_mutex_lock(&msgbuf.mutex);
  204. uint32_t start = msgbuf.reserved;
  205. if (start + num_msgs > msgbuf.bufsize) {
  206. pthread_mutex_unlock(&msgbuf.mutex);
  207. printf("Max %u messages exceeded\n", msgbuf.bufsize);
  208. return NULL;
  209. }
  210. msgbuf.reserved += num_msgs;
  211. pthread_mutex_unlock(&msgbuf.mutex);
  212. return msgbuf.buf + start * msg_size;
  213. }
  214. // A round 1 message was received by a routing node from an ingestion
  215. // node; we put it into the round 2 buffer for processing in round 2
  216. static void round1_received(NodeCommState &nodest,
  217. uint8_t *data, uint32_t plaintext_len, uint32_t)
  218. {
  219. uint16_t msg_size = g_teems_config.msg_size;
  220. assert((plaintext_len % uint32_t(msg_size)) == 0);
  221. uint32_t num_msgs = plaintext_len / uint32_t(msg_size);
  222. pthread_mutex_lock(&route_state.round1.mutex);
  223. route_state.round1.inserted += num_msgs;
  224. route_state.round1.nodes_received += 1;
  225. nodenum_t nodes_received = route_state.round1.nodes_received;
  226. pthread_mutex_unlock(&route_state.round1.mutex);
  227. if (nodes_received == g_teems_config.num_ingestion_nodes) {
  228. route_state.step = ROUTE_ROUND_1;
  229. void *cbpointer = route_state.cbpointer;
  230. route_state.cbpointer = NULL;
  231. ocall_routing_round_complete(cbpointer, 1);
  232. }
  233. }
  234. // A round 2 message was received by a storage node from a routing node
  235. static void round2_received(NodeCommState &nodest,
  236. uint8_t *data, uint32_t plaintext_len, uint32_t)
  237. {
  238. uint16_t msg_size = g_teems_config.msg_size;
  239. assert((plaintext_len % uint32_t(msg_size)) == 0);
  240. }
  241. // For a given other node, set the received message handler to the first
  242. // message we would expect from them, given their roles and our roles.
  243. void route_init_msg_handler(nodenum_t node_num)
  244. {
  245. // Our roles and their roles
  246. uint8_t our_roles = g_teems_config.roles[g_teems_config.my_node_num];
  247. uint8_t their_roles = g_teems_config.roles[node_num];
  248. // The node communication state
  249. NodeCommState &nodest = g_commstates[node_num];
  250. // If we are a routing node (possibly among other roles) and they
  251. // are an ingestion node (possibly among other roles), a round 1
  252. // routing message is the first thing we expect from them. We put
  253. // these messages into the round1 buffer for processing.
  254. if ((our_roles & ROLE_ROUTING) && (their_roles & ROLE_INGESTION)) {
  255. nodest.in_msg_get_buf = [&](NodeCommState &commst,
  256. uint32_t tot_enc_chunk_size) {
  257. return msgbuffer_get_buf(route_state.round1, commst,
  258. tot_enc_chunk_size);
  259. };
  260. nodest.in_msg_received = round1_received;
  261. }
  262. // Otherwise, if we are a storage node (possibly among other roles)
  263. // and they are a routing node (possibly among other roles), a round
  264. // 2 routing message is the first thing we expect from them
  265. else if ((our_roles & ROLE_STORAGE) && (their_roles & ROLE_ROUTING)) {
  266. nodest.in_msg_get_buf = default_in_msg_get_buf;
  267. nodest.in_msg_received = round2_received;
  268. }
  269. // Otherwise, we don't expect a message from this node. Set the
  270. // unknown message handler.
  271. else {
  272. nodest.in_msg_get_buf = default_in_msg_get_buf;
  273. nodest.in_msg_received = unknown_in_msg_received;
  274. }
  275. }
  276. // Directly ingest a buffer of num_msgs messages into the ingbuf buffer.
  277. // Return true on success, false on failure.
  278. bool ecall_ingest_raw(uint8_t *msgs, uint32_t num_msgs)
  279. {
  280. uint16_t msg_size = g_teems_config.msg_size;
  281. MsgBuffer &ingbuf = route_state.ingbuf;
  282. pthread_mutex_lock(&ingbuf.mutex);
  283. uint32_t start = ingbuf.reserved;
  284. if (start + num_msgs > route_state.tot_msg_per_ing) {
  285. pthread_mutex_unlock(&ingbuf.mutex);
  286. printf("Max %u messages exceeded\n",
  287. route_state.tot_msg_per_ing);
  288. return false;
  289. }
  290. ingbuf.reserved += num_msgs;
  291. pthread_mutex_unlock(&ingbuf.mutex);
  292. memmove(ingbuf.buf + start * msg_size,
  293. msgs, num_msgs * msg_size);
  294. pthread_mutex_lock(&ingbuf.mutex);
  295. ingbuf.inserted += num_msgs;
  296. pthread_mutex_unlock(&ingbuf.mutex);
  297. return true;
  298. }
  299. // Send the round 1 messages. Note that N here is not private.
  300. static void send_round1_msgs(const uint8_t *msgs, const uint64_t *indices,
  301. uint32_t N)
  302. {
  303. uint16_t msg_size = g_teems_config.msg_size;
  304. uint16_t tot_weight = g_teems_config.tot_weight;
  305. nodenum_t my_node_num = g_teems_config.my_node_num;
  306. uint32_t full_rows = N / uint32_t(tot_weight);
  307. uint32_t last_row = N % uint32_t(tot_weight);
  308. for (auto &routing_node: g_teems_config.routing_nodes) {
  309. uint8_t weight =
  310. g_teems_config.weights[routing_node].weight;
  311. if (weight == 0) {
  312. // This shouldn't happen, but just in case
  313. continue;
  314. }
  315. uint16_t start_weight =
  316. g_teems_config.weights[routing_node].startweight;
  317. // The number of messages headed for this routing node from the
  318. // full rows
  319. uint32_t num_msgs_full_rows = full_rows * uint32_t(weight);
  320. // The number of messages headed for this routing node from the
  321. // incomplete last row is:
  322. // 0 if last_row < start_weight
  323. // last_row-start_weight if start_weight <= last_row < start_weight + weight
  324. // weight if start_weight + weight <= last_row
  325. uint32_t num_msgs_last_row = 0;
  326. if (start_weight <= last_row && last_row < start_weight + weight) {
  327. num_msgs_last_row = last_row-start_weight;
  328. } else if (start_weight + weight <= last_row) {
  329. num_msgs_last_row = weight;
  330. }
  331. // The total number of messages headed for this routing node
  332. uint32_t num_msgs = num_msgs_full_rows + num_msgs_last_row;
  333. if (routing_node == my_node_num) {
  334. // Special case: we're sending to ourselves; just put the
  335. // messages in our own round1 buffer
  336. MsgBuffer &round1 = route_state.round1;
  337. pthread_mutex_lock(&round1.mutex);
  338. uint32_t start = round1.reserved;
  339. if (start + num_msgs > round1.bufsize) {
  340. pthread_mutex_unlock(&round1.mutex);
  341. printf("Max %u messages exceeded\n", round1.bufsize);
  342. return;
  343. }
  344. round1.reserved += num_msgs;
  345. pthread_mutex_unlock(&round1.mutex);
  346. uint8_t *buf = round1.buf + start * msg_size;
  347. for (uint32_t i=0; i<full_rows; ++i) {
  348. const uint64_t *idxp = indices + i*tot_weight + start_weight;
  349. for (uint32_t j=0; j<weight; ++j) {
  350. memmove(buf, msgs + idxp[j]*msg_size, msg_size);
  351. buf += msg_size;
  352. }
  353. }
  354. const uint64_t *idxp = indices + full_rows*tot_weight + start_weight;
  355. for (uint32_t j=0; j<num_msgs_last_row; ++j) {
  356. memmove(buf, msgs + idxp[j]*msg_size, msg_size);
  357. buf += msg_size;
  358. }
  359. pthread_mutex_lock(&round1.mutex);
  360. round1.inserted += num_msgs;
  361. round1.nodes_received += 1;
  362. nodenum_t nodes_received = round1.nodes_received;
  363. pthread_mutex_unlock(&round1.mutex);
  364. if (nodes_received == g_teems_config.num_ingestion_nodes) {
  365. route_state.step = ROUTE_ROUND_1;
  366. void *cbpointer = route_state.cbpointer;
  367. route_state.cbpointer = NULL;
  368. ocall_routing_round_complete(cbpointer, 1);
  369. }
  370. } else {
  371. NodeCommState &nodecom = g_commstates[routing_node];
  372. nodecom.message_start(num_msgs * msg_size);
  373. for (uint32_t i=0; i<full_rows; ++i) {
  374. const uint64_t *idxp = indices + i*tot_weight + start_weight;
  375. for (uint32_t j=0; j<weight; ++j) {
  376. nodecom.message_data(msgs + idxp[j]*msg_size, msg_size);
  377. }
  378. }
  379. const uint64_t *idxp = indices + full_rows*tot_weight + start_weight;
  380. for (uint32_t j=0; j<num_msgs_last_row; ++j) {
  381. nodecom.message_data(msgs + idxp[j]*msg_size, msg_size);
  382. }
  383. }
  384. }
  385. }
  386. // Perform the next round of routing. The callback pointer will be
  387. // passed to ocall_routing_round_complete when the round is complete.
  388. void ecall_routing_proceed(void *cbpointer)
  389. {
  390. uint8_t my_roles = g_teems_config.roles[g_teems_config.my_node_num];
  391. if (route_state.step == ROUTE_NOT_STARTED) {
  392. if (my_roles & ROLE_INGESTION) {
  393. route_state.cbpointer = cbpointer;
  394. MsgBuffer &ingbuf = route_state.ingbuf;
  395. pthread_mutex_lock(&ingbuf.mutex);
  396. // Ensure there are no pending messages currently being inserted
  397. // into the buffer
  398. while (ingbuf.reserved != ingbuf.inserted) {
  399. pthread_mutex_unlock(&ingbuf.mutex);
  400. pthread_mutex_lock(&ingbuf.mutex);
  401. }
  402. // Sort the messages we've received
  403. #ifdef PROFILE_ROUTING
  404. uint32_t inserted = ingbuf.inserted;
  405. unsigned long start = printf_with_rtclock("begin oblivious sort (%u,%u)\n", inserted, route_state.tot_msg_per_ing);
  406. #endif
  407. sort_mtobliv(g_teems_config.nthreads, ingbuf.buf,
  408. g_teems_config.msg_size, ingbuf.inserted,
  409. route_state.tot_msg_per_ing, send_round1_msgs);
  410. #ifdef PROFILE_ROUTING
  411. printf_with_rtclock_diff(start, "end oblivious sort (%u,%u)\n", inserted, route_state.tot_msg_per_ing);
  412. #endif
  413. ingbuf.reset();
  414. pthread_mutex_unlock(&ingbuf.mutex);
  415. } else {
  416. route_state.step = ROUTE_ROUND_1;
  417. ocall_routing_round_complete(cbpointer, 1);
  418. }
  419. } else if (route_state.step == ROUTE_ROUND_1) {
  420. if (my_roles & ROLE_ROUTING) {
  421. route_state.cbpointer = cbpointer;
  422. MsgBuffer &round1 = route_state.round1;
  423. pthread_mutex_lock(&round1.mutex);
  424. // Ensure there are no pending messages currently being inserted
  425. // into the buffer
  426. while (round1.reserved != round1.inserted) {
  427. pthread_mutex_unlock(&round1.mutex);
  428. pthread_mutex_lock(&round1.mutex);
  429. }
  430. // If the _total_ number of messages we received in round 1
  431. // is less than the max number of messages we could send to
  432. // _each_ storage node, then cap the number of messages we
  433. // will send to each storage node to that number.
  434. uint32_t msgs_per_stg = route_state.max_msg_to_each_stg;
  435. if (round1.inserted < msgs_per_stg) {
  436. msgs_per_stg = round1.inserted;
  437. }
  438. // Note: at this point, it is required that each message in
  439. // the round1 buffer have a _valid_ storage node id field.
  440. // Obliviously tally the number of messages we received in
  441. // round1 destined for each storage node
  442. uint32_t msg_size = g_teems_config.msg_size;
  443. nodenum_t num_storage_nodes = g_teems_config.num_storage_nodes;
  444. std::vector<uint32_t> tally = obliv_tally_stg(
  445. round1.buf, msg_size, round1.inserted, num_storage_nodes);
  446. // Note: tally contains private values! It's OK to
  447. // non-obliviously check for an error condition, though.
  448. // While we're at it, obliviously change the tally of
  449. // messages received to a tally of padding messages
  450. // required.
  451. uint32_t tot_padding = 0;
  452. for (nodenum_t i=0; i<num_storage_nodes; ++i) {
  453. if (tally[i] > msgs_per_stg) {
  454. printf("Received too many messages for storage node %u\n", i);
  455. assert(tally[i] <= msgs_per_stg);
  456. }
  457. tally[i] = msgs_per_stg - tally[i];
  458. tot_padding += tally[i];
  459. }
  460. round1.reserved += tot_padding;
  461. assert(round1.reserved <= round1.bufsize);
  462. // Obliviously add padding for each storage node according
  463. // to the (private) padding tally.
  464. obliv_pad_stg(round1.buf + round1.inserted * msg_size,
  465. msg_size, tally, tot_padding);
  466. round1.inserted += tot_padding;
  467. // Obliviously shuffle the messages
  468. uint32_t num_shuffled = shuffle_mtobliv(g_teems_config.nthreads,
  469. round1.buf, msg_size, round1.inserted, round1.bufsize);
  470. // Now we can handle the messages non-obliviously, since we
  471. // know there will be exactly msgs_per_stg messages to each
  472. // storage node, and the oblivious shuffle broke the
  473. // connection between where each message came from and where
  474. // it's going.
  475. for(uint32_t i=0;i<num_shuffled;++i) {
  476. uint32_t destaddr = *(uint32_t*)(round1.buf+i*msg_size);
  477. printf("%08x\n", destaddr);
  478. }
  479. round1.reset();
  480. pthread_mutex_unlock(&round1.mutex);
  481. } else {
  482. // We're done
  483. route_state.step = ROUTE_NOT_STARTED;
  484. ocall_routing_round_complete(cbpointer, 2);
  485. }
  486. }
  487. }