diff options
author | Christian Grothoff <christian@grothoff.org> | 2018-06-03 20:21:08 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2018-06-03 20:21:08 +0200 |
commit | fdf5283f5d5d603217748232941bafb60728aeb2 (patch) | |
tree | e5330e4e0f56b397637abf77f7f4010e330631cb /src/core | |
parent | 2a789993747f7c74b331e38e4562772270bde3c0 (diff) | |
download | gnunet-fdf5283f5d5d603217748232941bafb60728aeb2.tar.gz gnunet-fdf5283f5d5d603217748232941bafb60728aeb2.zip |
more logging
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/gnunet-service-core_kx.c | 88 |
1 files changed, 60 insertions, 28 deletions
diff --git a/src/core/gnunet-service-core_kx.c b/src/core/gnunet-service-core_kx.c index 2250f59e6..c29e46997 100644 --- a/src/core/gnunet-service-core_kx.c +++ b/src/core/gnunet-service-core_kx.c | |||
@@ -970,15 +970,26 @@ handle_ephemeral_key (void *cls, | |||
970 | { | 970 | { |
971 | GNUNET_STATISTICS_update (GSC_stats, | 971 | GNUNET_STATISTICS_update (GSC_stats, |
972 | gettext_noop ("# old ephemeral keys ignored"), | 972 | gettext_noop ("# old ephemeral keys ignored"), |
973 | 1, GNUNET_NO); | 973 | 1, |
974 | GNUNET_NO); | ||
975 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
976 | "Received expired EPHEMERAL_KEY from %s\n", | ||
977 | GNUNET_i2s (&m->origin_identity)); | ||
978 | return; | ||
979 | } | ||
980 | if (0 == memcmp (&m->ephemeral_key, | ||
981 | &kx->other_ephemeral_key, | ||
982 | sizeof (m->ephemeral_key))) | ||
983 | { | ||
984 | GNUNET_STATISTICS_update (GSC_stats, | ||
985 | gettext_noop ("# duplicate ephemeral keys ignored"), | ||
986 | 1, | ||
987 | GNUNET_NO); | ||
988 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
989 | "Ignoring duplicate EPHEMERAL_KEY from %s\n", | ||
990 | GNUNET_i2s (&m->origin_identity)); | ||
974 | return; | 991 | return; |
975 | } | 992 | } |
976 | start_t = GNUNET_TIME_absolute_ntoh (m->creation_time); | ||
977 | |||
978 | GNUNET_STATISTICS_update (GSC_stats, | ||
979 | gettext_noop ("# ephemeral keys received"), | ||
980 | 1, GNUNET_NO); | ||
981 | |||
982 | if (0 != | 993 | if (0 != |
983 | memcmp (&m->origin_identity, | 994 | memcmp (&m->origin_identity, |
984 | kx->peer, | 995 | kx->peer, |
@@ -991,18 +1002,6 @@ handle_ephemeral_key (void *cls, | |||
991 | GNUNET_break_op (0); | 1002 | GNUNET_break_op (0); |
992 | return; | 1003 | return; |
993 | } | 1004 | } |
994 | { | ||
995 | struct GNUNET_HashCode eh; | ||
996 | |||
997 | GNUNET_CRYPTO_hash (¤t_ekm.ephemeral_key, | ||
998 | sizeof (current_ekm.ephemeral_key), | ||
999 | &eh); | ||
1000 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1001 | "Core service receives EPHEMERAL_KEY `%s' from `%s'.\n", | ||
1002 | GNUNET_h2s (&eh), | ||
1003 | GNUNET_i2s (kx->peer)); | ||
1004 | } | ||
1005 | |||
1006 | if ((ntohl (m->purpose.size) != | 1005 | if ((ntohl (m->purpose.size) != |
1007 | sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) + | 1006 | sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) + |
1008 | sizeof (struct GNUNET_TIME_AbsoluteNBO) + | 1007 | sizeof (struct GNUNET_TIME_AbsoluteNBO) + |
@@ -1017,26 +1016,51 @@ handle_ephemeral_key (void *cls, | |||
1017 | { | 1016 | { |
1018 | /* invalid signature */ | 1017 | /* invalid signature */ |
1019 | GNUNET_break_op (0); | 1018 | GNUNET_break_op (0); |
1019 | GNUNET_STATISTICS_update (GSC_stats, | ||
1020 | gettext_noop ("# EPHEMERAL_KEYs rejected (bad signature)"), | ||
1021 | 1, | ||
1022 | GNUNET_NO); | ||
1023 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1024 | "Received EPHEMERAL_KEY from %s with bad signature\n", | ||
1025 | GNUNET_i2s (&m->origin_identity)); | ||
1020 | return; | 1026 | return; |
1021 | } | 1027 | } |
1022 | now = GNUNET_TIME_absolute_get (); | 1028 | now = GNUNET_TIME_absolute_get (); |
1029 | start_t = GNUNET_TIME_absolute_ntoh (m->creation_time); | ||
1023 | if ( (end_t.abs_value_us < GNUNET_TIME_absolute_subtract (now, REKEY_TOLERANCE).abs_value_us) || | 1030 | if ( (end_t.abs_value_us < GNUNET_TIME_absolute_subtract (now, REKEY_TOLERANCE).abs_value_us) || |
1024 | (start_t.abs_value_us > GNUNET_TIME_absolute_add (now, REKEY_TOLERANCE).abs_value_us) ) | 1031 | (start_t.abs_value_us > GNUNET_TIME_absolute_add (now, REKEY_TOLERANCE).abs_value_us) ) |
1025 | { | 1032 | { |
1026 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1033 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1027 | _("Ephemeral key message from peer `%s' rejected as its validity range does not match our system time (%llu not in [%llu,%llu]).\n"), | 1034 | _("EPHERMAL_KEY from peer `%s' rejected as its validity range does not match our system time (%llu not in [%llu,%llu]).\n"), |
1028 | GNUNET_i2s (kx->peer), | 1035 | GNUNET_i2s (kx->peer), |
1029 | (unsigned long long) now.abs_value_us, | 1036 | (unsigned long long) now.abs_value_us, |
1030 | (unsigned long long) start_t.abs_value_us, | 1037 | (unsigned long long) start_t.abs_value_us, |
1031 | (unsigned long long) end_t.abs_value_us); | 1038 | (unsigned long long) end_t.abs_value_us); |
1039 | GNUNET_STATISTICS_update (GSC_stats, | ||
1040 | gettext_noop ("# EPHEMERAL_KEY messages rejected due to time"), | ||
1041 | 1, | ||
1042 | GNUNET_NO); | ||
1032 | return; | 1043 | return; |
1033 | } | 1044 | } |
1045 | { | ||
1046 | struct GNUNET_HashCode eh; | ||
1047 | |||
1048 | GNUNET_CRYPTO_hash (&m->ephemeral_key, | ||
1049 | sizeof (m->ephemeral_key), | ||
1050 | &eh); | ||
1051 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1052 | "Received valid EPHEMERAL_KEY `%s' from `%s' in state %d.\n", | ||
1053 | GNUNET_h2s (&eh), | ||
1054 | GNUNET_i2s (kx->peer), | ||
1055 | kx->status); | ||
1056 | } | ||
1057 | GNUNET_STATISTICS_update (GSC_stats, | ||
1058 | gettext_noop ("# valid ephemeral keys received"), | ||
1059 | 1, | ||
1060 | GNUNET_NO); | ||
1034 | kx->other_ephemeral_key = m->ephemeral_key; | 1061 | kx->other_ephemeral_key = m->ephemeral_key; |
1035 | kx->foreign_key_expires = end_t; | 1062 | kx->foreign_key_expires = end_t; |
1036 | derive_session_keys (kx); | 1063 | derive_session_keys (kx); |
1037 | GNUNET_STATISTICS_update (GSC_stats, | ||
1038 | gettext_noop ("# EPHEMERAL_KEY messages received"), 1, | ||
1039 | GNUNET_NO); | ||
1040 | 1064 | ||
1041 | /* check if we still need to send the sender our key */ | 1065 | /* check if we still need to send the sender our key */ |
1042 | sender_status = (enum GNUNET_CORE_KxState) ntohl (m->sender_status); | 1066 | sender_status = (enum GNUNET_CORE_KxState) ntohl (m->sender_status); |
@@ -1369,7 +1393,7 @@ handle_pong (void *cls, | |||
1369 | return; | 1393 | return; |
1370 | } | 1394 | } |
1371 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1395 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1372 | "Received PONG from `%s'\n", | 1396 | "Received valid PONG from `%s'\n", |
1373 | GNUNET_i2s (kx->peer)); | 1397 | GNUNET_i2s (kx->peer)); |
1374 | /* no need to resend key any longer */ | 1398 | /* no need to resend key any longer */ |
1375 | if (NULL != kx->retry_set_key_task) | 1399 | if (NULL != kx->retry_set_key_task) |
@@ -1436,10 +1460,18 @@ send_key (struct GSC_KeyExchangeInfo *kx) | |||
1436 | kx->retry_set_key_task = NULL; | 1460 | kx->retry_set_key_task = NULL; |
1437 | } | 1461 | } |
1438 | /* always update sender status in SET KEY message */ | 1462 | /* always update sender status in SET KEY message */ |
1439 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1463 | { |
1440 | "Sending key to `%s' (my status: %d)\n", | 1464 | struct GNUNET_HashCode hc; |
1441 | GNUNET_i2s (kx->peer), | 1465 | |
1442 | kx->status); | 1466 | GNUNET_CRYPTO_hash (¤t_ekm.ephemeral_key, |
1467 | sizeof (current_ekm.ephemeral_key), | ||
1468 | &hc); | ||
1469 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1470 | "Sending EPHERMERAL_KEY %s to `%s' (my status: %d)\n", | ||
1471 | GNUNET_h2s (&hc), | ||
1472 | GNUNET_i2s (kx->peer), | ||
1473 | kx->status); | ||
1474 | } | ||
1443 | current_ekm.sender_status = htonl ((int32_t) (kx->status)); | 1475 | current_ekm.sender_status = htonl ((int32_t) (kx->status)); |
1444 | env = GNUNET_MQ_msg_copy (¤t_ekm.header); | 1476 | env = GNUNET_MQ_msg_copy (¤t_ekm.header); |
1445 | GNUNET_MQ_send (kx->mq, | 1477 | GNUNET_MQ_send (kx->mq, |