diff options
author | Bart Polot <bart@net.in.tum.de> | 2014-06-17 12:13:46 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2014-06-17 12:13:46 +0000 |
commit | 73313b83e7916396ffb2e11cef1e022dd3f20ab6 (patch) | |
tree | 2951674479fa36f1961ba76b3a6e47329fc9474e | |
parent | a36ddba19527ed61dd7d8d6f0a5c30092190f267 (diff) | |
download | gnunet-73313b83e7916396ffb2e11cef1e022dd3f20ab6.tar.gz gnunet-73313b83e7916396ffb2e11cef1e022dd3f20ab6.zip |
- fix KX for very short rekey periods (seconds)
-rw-r--r-- | src/cadet/gnunet-service-cadet_tunnel.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/cadet/gnunet-service-cadet_tunnel.c b/src/cadet/gnunet-service-cadet_tunnel.c index d8feb4688..2b7307456 100644 --- a/src/cadet/gnunet-service-cadet_tunnel.c +++ b/src/cadet/gnunet-service-cadet_tunnel.c | |||
@@ -1331,7 +1331,7 @@ rekey_tunnel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1331 | 1331 | ||
1332 | t->rekey_task = GNUNET_SCHEDULER_NO_TASK; | 1332 | t->rekey_task = GNUNET_SCHEDULER_NO_TASK; |
1333 | 1333 | ||
1334 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Re-key Tunnel %s\n", GCT_2s (t)); | 1334 | LOG (GNUNET_ERROR_TYPE_INFO, "Re-key Tunnel %s\n", GCT_2s (t)); |
1335 | if (NULL != tc && 0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) | 1335 | if (NULL != tc && 0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) |
1336 | return; | 1336 | return; |
1337 | 1337 | ||
@@ -1377,9 +1377,13 @@ rekey_tunnel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1377 | } | 1377 | } |
1378 | 1378 | ||
1379 | // FIXME exponential backoff | 1379 | // FIXME exponential backoff |
1380 | struct GNUNET_TIME_Relative delay; | ||
1381 | |||
1382 | delay = GNUNET_TIME_relative_divide (rekey_period, 16); | ||
1383 | delay = GNUNET_TIME_relative_min (delay, REKEY_WAIT); | ||
1380 | LOG (GNUNET_ERROR_TYPE_DEBUG, " next call in %s\n", | 1384 | LOG (GNUNET_ERROR_TYPE_DEBUG, " next call in %s\n", |
1381 | GNUNET_STRINGS_relative_time_to_string (REKEY_WAIT, GNUNET_YES)); | 1385 | GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES)); |
1382 | t->rekey_task = GNUNET_SCHEDULER_add_delayed (REKEY_WAIT, &rekey_tunnel, t); | 1386 | t->rekey_task = GNUNET_SCHEDULER_add_delayed (delay, &rekey_tunnel, t); |
1383 | } | 1387 | } |
1384 | 1388 | ||
1385 | 1389 | ||
@@ -1815,8 +1819,10 @@ handle_ping (struct CadetTunnel *t, | |||
1815 | 1819 | ||
1816 | send_pong (t, res.nonce); | 1820 | send_pong (t, res.nonce); |
1817 | } | 1821 | } |
1822 | |||
1823 | |||
1818 | /** | 1824 | /** |
1819 | * @brief Finish the Key eXchange and destory the old keys. | 1825 | * @brief Finish the Key eXchange and destroy the old keys. |
1820 | * | 1826 | * |
1821 | * @param cls Closure (Tunnel for which to finish the KX). | 1827 | * @param cls Closure (Tunnel for which to finish the KX). |
1822 | * @param tc Task context. | 1828 | * @param tc Task context. |
@@ -1829,6 +1835,8 @@ finish_kx (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1829 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 1835 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
1830 | return; | 1836 | return; |
1831 | 1837 | ||
1838 | LOG (GNUNET_ERROR_TYPE_INFO, "finish KX for %s\n", GCT_2s (t)); | ||
1839 | |||
1832 | GNUNET_free (t->kx_ctx); | 1840 | GNUNET_free (t->kx_ctx); |
1833 | t->kx_ctx = NULL; | 1841 | t->kx_ctx = NULL; |
1834 | } | 1842 | } |