aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-02-13 10:46:26 +0000
committerChristian Grothoff <christian@grothoff.org>2013-02-13 10:46:26 +0000
commit26ea58eb2ef9a90d31e57e054ba26c5968dcb00a (patch)
tree34a1b59f785490c1c4aa9ad0c4ad0181c71dab09 /src/core
parentd32fe8eefb630ffa6ffd50684b0a59add13cf02f (diff)
downloadgnunet-26ea58eb2ef9a90d31e57e054ba26c5968dcb00a.tar.gz
gnunet-26ea58eb2ef9a90d31e57e054ba26c5968dcb00a.zip
-trying to fix #2794
Diffstat (limited to 'src/core')
-rw-r--r--src/core/gnunet-service-core_kx.c27
-rw-r--r--src/core/gnunet-service-core_sessions.c24
2 files changed, 37 insertions, 14 deletions
diff --git a/src/core/gnunet-service-core_kx.c b/src/core/gnunet-service-core_kx.c
index b8b58bc83..5a70b62ad 100644
--- a/src/core/gnunet-service-core_kx.c
+++ b/src/core/gnunet-service-core_kx.c
@@ -270,8 +270,11 @@ enum KxStateMachine
270 KX_STATE_UP, 270 KX_STATE_UP,
271 271
272 /** 272 /**
273 * We're rekeying, so we have sent the other peer our new ephemeral 273 * We're rekeying (or had a timeout), so we have sent the other peer
274 * key, but we did not get a matching PONG yet. 274 * our new ephemeral key, but we did not get a matching PONG yet.
275 * This is equivalent to being 'KX_STATE_KEY_RECEIVED', except that
276 * the session is marked as 'up' with sessions (as we don't want to
277 * drop and re-establish P2P connections simply due to rekeying).
275 */ 278 */
276 KX_STATE_REKEY_SENT 279 KX_STATE_REKEY_SENT
277 280
@@ -1222,6 +1225,11 @@ struct DeliverMessageContext
1222 const struct GNUNET_ATS_Information *atsi; 1225 const struct GNUNET_ATS_Information *atsi;
1223 1226
1224 /** 1227 /**
1228 * Key exchange context.
1229 */
1230 struct GSC_KeyExchangeInfo *kx;
1231
1232 /**
1225 * Sender of the message. 1233 * Sender of the message.
1226 */ 1234 */
1227 const struct GNUNET_PeerIdentity *peer; 1235 const struct GNUNET_PeerIdentity *peer;
@@ -1276,11 +1284,11 @@ GSC_KX_handle_encrypted_message (struct GSC_KeyExchangeInfo *kx,
1276 } 1284 }
1277 if (0 == GNUNET_TIME_absolute_get_remaining (kx->foreign_key_expires).rel_value) 1285 if (0 == GNUNET_TIME_absolute_get_remaining (kx->foreign_key_expires).rel_value)
1278 { 1286 {
1279 kx->status = KX_STATE_KEY_SENT;
1280 GNUNET_STATISTICS_update (GSC_stats, 1287 GNUNET_STATISTICS_update (GSC_stats,
1281 gettext_noop 1288 gettext_noop ("# sessions terminated by key expiration"),
1282 ("# DATA message dropped (session key expired)"),
1283 1, GNUNET_NO); 1289 1, GNUNET_NO);
1290 GSC_SESSIONS_end (&kx->peer);
1291 kx->status = KX_STATE_KEY_SENT;
1284 send_key (kx); 1292 send_key (kx);
1285 return; 1293 return;
1286 } 1294 }
@@ -1379,6 +1387,7 @@ GSC_KX_handle_encrypted_message (struct GSC_KeyExchangeInfo *kx,
1379 gettext_noop ("# bytes of payload decrypted"), 1387 gettext_noop ("# bytes of payload decrypted"),
1380 size - sizeof (struct EncryptedMessage), GNUNET_NO); 1388 size - sizeof (struct EncryptedMessage), GNUNET_NO);
1381 dmc.atsi = atsi; 1389 dmc.atsi = atsi;
1390 dmc.kx = kx;
1382 dmc.atsi_count = atsi_count; 1391 dmc.atsi_count = atsi_count;
1383 dmc.peer = &kx->peer; 1392 dmc.peer = &kx->peer;
1384 if (GNUNET_OK != 1393 if (GNUNET_OK !=
@@ -1404,6 +1413,14 @@ deliver_message (void *cls, void *client, const struct GNUNET_MessageHeader *m)
1404{ 1413{
1405 struct DeliverMessageContext *dmc = client; 1414 struct DeliverMessageContext *dmc = client;
1406 1415
1416 if (KX_STATE_UP != dmc->kx->status)
1417 {
1418 GNUNET_STATISTICS_update (GSC_stats,
1419 gettext_noop
1420 ("# PAYLOAD dropped (out of order)"),
1421 1, GNUNET_NO);
1422 return GNUNET_OK;
1423 }
1407 switch (ntohs (m->type)) 1424 switch (ntohs (m->type))
1408 { 1425 {
1409 case GNUNET_MESSAGE_TYPE_CORE_BINARY_TYPE_MAP: 1426 case GNUNET_MESSAGE_TYPE_CORE_BINARY_TYPE_MAP:
diff --git a/src/core/gnunet-service-core_sessions.c b/src/core/gnunet-service-core_sessions.c
index 3a603bc81..bea4aad56 100644
--- a/src/core/gnunet-service-core_sessions.c
+++ b/src/core/gnunet-service-core_sessions.c
@@ -115,13 +115,6 @@ struct Session
115 struct GSC_TypeMap *tmap; 115 struct GSC_TypeMap *tmap;
116 116
117 /** 117 /**
118 * At what time did we initially establish this session?
119 * (currently unused, should be integrated with ATS in the
120 * future...).
121 */
122 struct GNUNET_TIME_Absolute time_established;
123
124 /**
125 * Task to transmit corked messages with a delay. 118 * Task to transmit corked messages with a delay.
126 */ 119 */
127 GNUNET_SCHEDULER_TaskIdentifier cork_task; 120 GNUNET_SCHEDULER_TaskIdentifier cork_task;
@@ -137,6 +130,12 @@ struct Session
137 */ 130 */
138 int ready_to_transmit; 131 int ready_to_transmit;
139 132
133 /**
134 * Is this the first time we're sending the typemap? If so,
135 * we want to send it a bit faster the second time. 0 if
136 * we are sending for the first time, 1 if not.
137 */
138 int first_typemap;
140}; 139};
141 140
142 141
@@ -226,7 +225,15 @@ transmit_typemap_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
226 struct GNUNET_MessageHeader *hdr; 225 struct GNUNET_MessageHeader *hdr;
227 struct GNUNET_TIME_Relative delay; 226 struct GNUNET_TIME_Relative delay;
228 227
229 delay = TYPEMAP_FREQUENCY; 228 if (0 == session->first_typemap)
229 {
230 delay = GNUNET_TIME_UNIT_ZERO;
231 session->first_typemap = 1;
232 }
233 else
234 {
235 delay = TYPEMAP_FREQUENCY;
236 }
230 /* randomize a bit to avoid spont. sync */ 237 /* randomize a bit to avoid spont. sync */
231 delay.rel_value += 238 delay.rel_value +=
232 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 1000); 239 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 1000);
@@ -259,7 +266,6 @@ GSC_SESSIONS_create (const struct GNUNET_PeerIdentity *peer,
259 session->tmap = GSC_TYPEMAP_create (); 266 session->tmap = GSC_TYPEMAP_create ();
260 session->peer = *peer; 267 session->peer = *peer;
261 session->kxinfo = kx; 268 session->kxinfo = kx;
262 session->time_established = GNUNET_TIME_absolute_get ();
263 session->typemap_task = 269 session->typemap_task =
264 GNUNET_SCHEDULER_add_now (&transmit_typemap_task, session); 270 GNUNET_SCHEDULER_add_now (&transmit_typemap_task, session);
265 GNUNET_assert (GNUNET_OK == 271 GNUNET_assert (GNUNET_OK ==