diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-03-08 14:33:42 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-03-08 14:33:42 +0000 |
commit | 023cf4e2f6a6d50c40e6717fcc67bb598f0f54a9 (patch) | |
tree | 34a324c1ff70f23245863f30bca3212571cb2efb /src/core | |
parent | 247e63b4eb4db92cc0cfb2df9ca66632cc6c90b1 (diff) | |
download | gnunet-023cf4e2f6a6d50c40e6717fcc67bb598f0f54a9.tar.gz gnunet-023cf4e2f6a6d50c40e6717fcc67bb598f0f54a9.zip |
-always assume at least MIN bandwidth, even if we got no quota or a quota lower than min
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/gnunet-service-core_kx.c | 105 | ||||
-rw-r--r-- | src/core/gnunet-service-core_neighbours.c | 8 |
2 files changed, 74 insertions, 39 deletions
diff --git a/src/core/gnunet-service-core_kx.c b/src/core/gnunet-service-core_kx.c index 6608725a5..4983dab0e 100644 --- a/src/core/gnunet-service-core_kx.c +++ b/src/core/gnunet-service-core_kx.c | |||
@@ -716,7 +716,8 @@ GSC_KX_start (const struct GNUNET_PeerIdentity *pid) | |||
716 | "Initiating key exchange with `%s'\n", | 716 | "Initiating key exchange with `%s'\n", |
717 | GNUNET_i2s (pid)); | 717 | GNUNET_i2s (pid)); |
718 | GNUNET_STATISTICS_update (GSC_stats, | 718 | GNUNET_STATISTICS_update (GSC_stats, |
719 | gettext_noop ("# key exchanges initiated"), 1, | 719 | gettext_noop ("# key exchanges initiated"), |
720 | 1, | ||
720 | GNUNET_NO); | 721 | GNUNET_NO); |
721 | kx = GNUNET_new (struct GSC_KeyExchangeInfo); | 722 | kx = GNUNET_new (struct GSC_KeyExchangeInfo); |
722 | kx->peer = *pid; | 723 | kx->peer = *pid; |
@@ -745,7 +746,8 @@ GSC_KX_start (const struct GNUNET_PeerIdentity *pid) | |||
745 | /* peer with "higher" identity starts a delayed KX, if the "lower" peer | 746 | /* peer with "higher" identity starts a delayed KX, if the "lower" peer |
746 | * does not start a KX since he sees no reasons to do so */ | 747 | * does not start a KX since he sees no reasons to do so */ |
747 | kx->retry_set_key_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | 748 | kx->retry_set_key_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, |
748 | &set_key_retry_task, kx); | 749 | &set_key_retry_task, |
750 | kx); | ||
749 | } | 751 | } |
750 | return kx; | 752 | return kx; |
751 | } | 753 | } |
@@ -795,7 +797,7 @@ send_ping (struct GSC_KeyExchangeInfo *kx) | |||
795 | GNUNET_NO); | 797 | GNUNET_NO); |
796 | GSC_NEIGHBOURS_transmit (&kx->peer, | 798 | GSC_NEIGHBOURS_transmit (&kx->peer, |
797 | &kx->ping.header, | 799 | &kx->ping.header, |
798 | MIN_PING_FREQUENCY); | 800 | kx->set_key_retry_frequency); |
799 | } | 801 | } |
800 | 802 | ||
801 | 803 | ||
@@ -1024,7 +1026,8 @@ GSC_KX_handle_ping (struct GSC_KeyExchangeInfo *kx, | |||
1024 | return; | 1026 | return; |
1025 | } | 1027 | } |
1026 | GNUNET_STATISTICS_update (GSC_stats, | 1028 | GNUNET_STATISTICS_update (GSC_stats, |
1027 | gettext_noop ("# PING messages received"), 1, | 1029 | gettext_noop ("# PING messages received"), |
1030 | 1, | ||
1028 | GNUNET_NO); | 1031 | GNUNET_NO); |
1029 | if ( (kx->status != GNUNET_CORE_KX_STATE_KEY_RECEIVED) && | 1032 | if ( (kx->status != GNUNET_CORE_KX_STATE_KEY_RECEIVED) && |
1030 | (kx->status != GNUNET_CORE_KX_STATE_UP) && | 1033 | (kx->status != GNUNET_CORE_KX_STATE_UP) && |
@@ -1032,7 +1035,8 @@ GSC_KX_handle_ping (struct GSC_KeyExchangeInfo *kx, | |||
1032 | { | 1035 | { |
1033 | /* ignore */ | 1036 | /* ignore */ |
1034 | GNUNET_STATISTICS_update (GSC_stats, | 1037 | GNUNET_STATISTICS_update (GSC_stats, |
1035 | gettext_noop ("# PING messages dropped (out of order)"), 1, | 1038 | gettext_noop ("# PING messages dropped (out of order)"), |
1039 | 1, | ||
1036 | GNUNET_NO); | 1040 | GNUNET_NO); |
1037 | return; | 1041 | return; |
1038 | } | 1042 | } |
@@ -1166,12 +1170,14 @@ update_timeout (struct GSC_KeyExchangeInfo *kx) | |||
1166 | are bigger than the threshold (5s) */ | 1170 | are bigger than the threshold (5s) */ |
1167 | monitor_notify_all (kx); | 1171 | monitor_notify_all (kx); |
1168 | } | 1172 | } |
1169 | if (kx->keep_alive_task != NULL) | 1173 | if (NULL != kx->keep_alive_task) |
1170 | GNUNET_SCHEDULER_cancel (kx->keep_alive_task); | 1174 | GNUNET_SCHEDULER_cancel (kx->keep_alive_task); |
1171 | kx->keep_alive_task = | 1175 | kx->keep_alive_task = |
1172 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide | 1176 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide |
1173 | (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, | 1177 | (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, |
1174 | 2), &send_keep_alive, kx); | 1178 | 2), |
1179 | &send_keep_alive, | ||
1180 | kx); | ||
1175 | } | 1181 | } |
1176 | 1182 | ||
1177 | 1183 | ||
@@ -1197,7 +1203,8 @@ GSC_KX_handle_pong (struct GSC_KeyExchangeInfo *kx, | |||
1197 | return; | 1203 | return; |
1198 | } | 1204 | } |
1199 | GNUNET_STATISTICS_update (GSC_stats, | 1205 | GNUNET_STATISTICS_update (GSC_stats, |
1200 | gettext_noop ("# PONG messages received"), 1, | 1206 | gettext_noop ("# PONG messages received"), |
1207 | 1, | ||
1201 | GNUNET_NO); | 1208 | GNUNET_NO); |
1202 | switch (kx->status) | 1209 | switch (kx->status) |
1203 | { | 1210 | { |
@@ -1227,10 +1234,16 @@ GSC_KX_handle_pong (struct GSC_KeyExchangeInfo *kx, | |||
1227 | GNUNET_i2s (&kx->peer)); | 1234 | GNUNET_i2s (&kx->peer)); |
1228 | /* mark as garbage, just to be sure */ | 1235 | /* mark as garbage, just to be sure */ |
1229 | memset (&t, 255, sizeof (t)); | 1236 | memset (&t, 255, sizeof (t)); |
1230 | derive_pong_iv (&iv, &kx->decrypt_key, m->iv_seed, kx->ping_challenge, | 1237 | derive_pong_iv (&iv, |
1238 | &kx->decrypt_key, | ||
1239 | m->iv_seed, | ||
1240 | kx->ping_challenge, | ||
1231 | &GSC_my_identity); | 1241 | &GSC_my_identity); |
1232 | if (GNUNET_OK != | 1242 | if (GNUNET_OK != |
1233 | do_decrypt (kx, &iv, &m->challenge, &t.challenge, | 1243 | do_decrypt (kx, |
1244 | &iv, | ||
1245 | &m->challenge, | ||
1246 | &t.challenge, | ||
1234 | sizeof (struct PongMessage) - ((void *) &m->challenge - | 1247 | sizeof (struct PongMessage) - ((void *) &m->challenge - |
1235 | (void *) m))) | 1248 | (void *) m))) |
1236 | { | 1249 | { |
@@ -1238,19 +1251,23 @@ GSC_KX_handle_pong (struct GSC_KeyExchangeInfo *kx, | |||
1238 | return; | 1251 | return; |
1239 | } | 1252 | } |
1240 | GNUNET_STATISTICS_update (GSC_stats, | 1253 | GNUNET_STATISTICS_update (GSC_stats, |
1241 | gettext_noop ("# PONG messages decrypted"), 1, | 1254 | gettext_noop ("# PONG messages decrypted"), |
1255 | 1, | ||
1242 | GNUNET_NO); | 1256 | GNUNET_NO); |
1243 | if ((0 != memcmp (&t.target, &kx->peer, sizeof (struct GNUNET_PeerIdentity))) | 1257 | if ((0 != memcmp (&t.target, |
1244 | || (kx->ping_challenge != t.challenge)) | 1258 | &kx->peer, |
1259 | sizeof (struct GNUNET_PeerIdentity))) || | ||
1260 | (kx->ping_challenge != t.challenge)) | ||
1245 | { | 1261 | { |
1246 | /* PONG malformed */ | 1262 | /* PONG malformed */ |
1247 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1263 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1248 | "Received malformed `%s' wanted sender `%s' with challenge %u\n", | 1264 | "Received malformed PONG wanted sender `%s' with challenge %u\n", |
1249 | "PONG", GNUNET_i2s (&kx->peer), | 1265 | GNUNET_i2s (&kx->peer), |
1250 | (unsigned int) kx->ping_challenge); | 1266 | (unsigned int) kx->ping_challenge); |
1251 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1267 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1252 | "Received malformed `%s' received from `%s' with challenge %u\n", | 1268 | "Received malformed PONG received from `%s' with challenge %u\n", |
1253 | "PONG", GNUNET_i2s (&t.target), (unsigned int) t.challenge); | 1269 | GNUNET_i2s (&t.target), |
1270 | (unsigned int) t.challenge); | ||
1254 | return; | 1271 | return; |
1255 | } | 1272 | } |
1256 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1273 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1272,8 +1289,8 @@ GSC_KX_handle_pong (struct GSC_KeyExchangeInfo *kx, | |||
1272 | return; | 1289 | return; |
1273 | case GNUNET_CORE_KX_STATE_KEY_RECEIVED: | 1290 | case GNUNET_CORE_KX_STATE_KEY_RECEIVED: |
1274 | GNUNET_STATISTICS_update (GSC_stats, | 1291 | GNUNET_STATISTICS_update (GSC_stats, |
1275 | gettext_noop | 1292 | gettext_noop ("# session keys confirmed via PONG"), |
1276 | ("# session keys confirmed via PONG"), 1, | 1293 | 1, |
1277 | GNUNET_NO); | 1294 | GNUNET_NO); |
1278 | kx->status = GNUNET_CORE_KX_STATE_UP; | 1295 | kx->status = GNUNET_CORE_KX_STATE_UP; |
1279 | monitor_notify_all (kx); | 1296 | monitor_notify_all (kx); |
@@ -1283,15 +1300,15 @@ GSC_KX_handle_pong (struct GSC_KeyExchangeInfo *kx, | |||
1283 | break; | 1300 | break; |
1284 | case GNUNET_CORE_KX_STATE_UP: | 1301 | case GNUNET_CORE_KX_STATE_UP: |
1285 | GNUNET_STATISTICS_update (GSC_stats, | 1302 | GNUNET_STATISTICS_update (GSC_stats, |
1286 | gettext_noop | 1303 | gettext_noop ("# timeouts prevented via PONG"), |
1287 | ("# timeouts prevented via PONG"), 1, | 1304 | 1, |
1288 | GNUNET_NO); | 1305 | GNUNET_NO); |
1289 | update_timeout (kx); | 1306 | update_timeout (kx); |
1290 | break; | 1307 | break; |
1291 | case GNUNET_CORE_KX_STATE_REKEY_SENT: | 1308 | case GNUNET_CORE_KX_STATE_REKEY_SENT: |
1292 | GNUNET_STATISTICS_update (GSC_stats, | 1309 | GNUNET_STATISTICS_update (GSC_stats, |
1293 | gettext_noop | 1310 | gettext_noop ("# rekey operations confirmed via PONG"), |
1294 | ("# rekey operations confirmed via PONG"), 1, | 1311 | 1, |
1295 | GNUNET_NO); | 1312 | GNUNET_NO); |
1296 | kx->status = GNUNET_CORE_KX_STATE_UP; | 1313 | kx->status = GNUNET_CORE_KX_STATE_UP; |
1297 | monitor_notify_all (kx); | 1314 | monitor_notify_all (kx); |
@@ -1331,7 +1348,8 @@ send_key (struct GSC_KeyExchangeInfo *kx) | |||
1331 | send_ping (kx); | 1348 | send_ping (kx); |
1332 | kx->retry_set_key_task = | 1349 | kx->retry_set_key_task = |
1333 | GNUNET_SCHEDULER_add_delayed (kx->set_key_retry_frequency, | 1350 | GNUNET_SCHEDULER_add_delayed (kx->set_key_retry_frequency, |
1334 | &set_key_retry_task, kx); | 1351 | &set_key_retry_task, |
1352 | kx); | ||
1335 | } | 1353 | } |
1336 | 1354 | ||
1337 | 1355 | ||
@@ -1434,9 +1452,9 @@ GSC_KX_handle_encrypted_message (struct GSC_KeyExchangeInfo *kx, | |||
1434 | if (GNUNET_CORE_KX_STATE_UP != kx->status) | 1452 | if (GNUNET_CORE_KX_STATE_UP != kx->status) |
1435 | { | 1453 | { |
1436 | GNUNET_STATISTICS_update (GSC_stats, | 1454 | GNUNET_STATISTICS_update (GSC_stats, |
1437 | gettext_noop | 1455 | gettext_noop ("# DATA message dropped (out of order)"), |
1438 | ("# DATA message dropped (out of order)"), | 1456 | 1, |
1439 | 1, GNUNET_NO); | 1457 | GNUNET_NO); |
1440 | return; | 1458 | return; |
1441 | } | 1459 | } |
1442 | if (0 == GNUNET_TIME_absolute_get_remaining (kx->foreign_key_expires).rel_value_us) | 1460 | if (0 == GNUNET_TIME_absolute_get_remaining (kx->foreign_key_expires).rel_value_us) |
@@ -1460,10 +1478,16 @@ GSC_KX_handle_encrypted_message (struct GSC_KeyExchangeInfo *kx, | |||
1460 | } | 1478 | } |
1461 | 1479 | ||
1462 | /* validate hash */ | 1480 | /* validate hash */ |
1463 | derive_auth_key (&auth_key, &kx->decrypt_key, m->iv_seed); | 1481 | derive_auth_key (&auth_key, |
1464 | GNUNET_CRYPTO_hmac (&auth_key, &m->sequence_number, | 1482 | &kx->decrypt_key, |
1465 | size - ENCRYPTED_HEADER_SIZE, &ph); | 1483 | m->iv_seed); |
1466 | if (0 != memcmp (&ph, &m->hmac, sizeof (struct GNUNET_HashCode))) | 1484 | GNUNET_CRYPTO_hmac (&auth_key, |
1485 | &m->sequence_number, | ||
1486 | size - ENCRYPTED_HEADER_SIZE, | ||
1487 | &ph); | ||
1488 | if (0 != memcmp (&ph, | ||
1489 | &m->hmac, | ||
1490 | sizeof (struct GNUNET_HashCode))) | ||
1467 | { | 1491 | { |
1468 | /* checksum failed */ | 1492 | /* checksum failed */ |
1469 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1493 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1471,10 +1495,16 @@ GSC_KX_handle_encrypted_message (struct GSC_KeyExchangeInfo *kx, | |||
1471 | GNUNET_i2s (&kx->peer)); | 1495 | GNUNET_i2s (&kx->peer)); |
1472 | return; | 1496 | return; |
1473 | } | 1497 | } |
1474 | derive_iv (&iv, &kx->decrypt_key, m->iv_seed, &GSC_my_identity); | 1498 | derive_iv (&iv, |
1499 | &kx->decrypt_key, | ||
1500 | m->iv_seed, | ||
1501 | &GSC_my_identity); | ||
1475 | /* decrypt */ | 1502 | /* decrypt */ |
1476 | if (GNUNET_OK != | 1503 | if (GNUNET_OK != |
1477 | do_decrypt (kx, &iv, &m->sequence_number, &buf[ENCRYPTED_HEADER_SIZE], | 1504 | do_decrypt (kx, |
1505 | &iv, | ||
1506 | &m->sequence_number, | ||
1507 | &buf[ENCRYPTED_HEADER_SIZE], | ||
1478 | size - ENCRYPTED_HEADER_SIZE)) | 1508 | size - ENCRYPTED_HEADER_SIZE)) |
1479 | return; | 1509 | return; |
1480 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1510 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1492,7 +1522,8 @@ GSC_KX_handle_encrypted_message (struct GSC_KeyExchangeInfo *kx, | |||
1492 | /* duplicate, ignore */ | 1522 | /* duplicate, ignore */ |
1493 | GNUNET_STATISTICS_update (GSC_stats, | 1523 | GNUNET_STATISTICS_update (GSC_stats, |
1494 | gettext_noop ("# bytes dropped (duplicates)"), | 1524 | gettext_noop ("# bytes dropped (duplicates)"), |
1495 | size, GNUNET_NO); | 1525 | size, |
1526 | GNUNET_NO); | ||
1496 | return; | 1527 | return; |
1497 | } | 1528 | } |
1498 | if ((kx->last_sequence_number_received > snum) && | 1529 | if ((kx->last_sequence_number_received > snum) && |
@@ -1587,9 +1618,9 @@ deliver_message (void *cls, | |||
1587 | if (GNUNET_CORE_KX_STATE_UP != dmc->kx->status) | 1618 | if (GNUNET_CORE_KX_STATE_UP != dmc->kx->status) |
1588 | { | 1619 | { |
1589 | GNUNET_STATISTICS_update (GSC_stats, | 1620 | GNUNET_STATISTICS_update (GSC_stats, |
1590 | gettext_noop | 1621 | gettext_noop ("# PAYLOAD dropped (out of order)"), |
1591 | ("# PAYLOAD dropped (out of order)"), | 1622 | 1, |
1592 | 1, GNUNET_NO); | 1623 | GNUNET_NO); |
1593 | return GNUNET_OK; | 1624 | return GNUNET_OK; |
1594 | } | 1625 | } |
1595 | switch (ntohs (m->type)) | 1626 | switch (ntohs (m->type)) |
diff --git a/src/core/gnunet-service-core_neighbours.c b/src/core/gnunet-service-core_neighbours.c index 9fd9207e4..e3f4425e9 100644 --- a/src/core/gnunet-service-core_neighbours.c +++ b/src/core/gnunet-service-core_neighbours.c | |||
@@ -457,8 +457,12 @@ GSC_NEIGHBOURS_transmit (const struct GNUNET_PeerIdentity *target, | |||
457 | me = GNUNET_malloc (sizeof (struct NeighbourMessageEntry) + msize); | 457 | me = GNUNET_malloc (sizeof (struct NeighbourMessageEntry) + msize); |
458 | me->deadline = GNUNET_TIME_relative_to_absolute (timeout); | 458 | me->deadline = GNUNET_TIME_relative_to_absolute (timeout); |
459 | me->size = msize; | 459 | me->size = msize; |
460 | memcpy (&me[1], msg, msize); | 460 | memcpy (&me[1], |
461 | GNUNET_CONTAINER_DLL_insert_tail (n->message_head, n->message_tail, me); | 461 | msg, |
462 | msize); | ||
463 | GNUNET_CONTAINER_DLL_insert_tail (n->message_head, | ||
464 | n->message_tail, | ||
465 | me); | ||
462 | process_queue (n); | 466 | process_queue (n); |
463 | } | 467 | } |
464 | 468 | ||