From: Christian Grothoff Date: Tue, 24 Apr 2018 21:28:24 +0000 (+0200) Subject: code cleanup, more diagnostics, more statistics X-Git-Tag: v0.11.0pre66~93^2~23 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=bdbb7c684f2c9711989d2543ecc08a95be23e6c4;p=oweals%2Fgnunet.git code cleanup, more diagnostics, more statistics --- diff --git a/src/gnsrecord/gnsrecord_crypto.c b/src/gnsrecord/gnsrecord_crypto.c index 0fab97f06..dd628ea76 100644 --- a/src/gnsrecord/gnsrecord_crypto.c +++ b/src/gnsrecord/gnsrecord_crypto.c @@ -85,7 +85,8 @@ GNUNET_GNSRECORD_block_create (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count) { - size_t payload_len = GNUNET_GNSRECORD_records_get_size (rd_count, rd); + size_t payload_len = GNUNET_GNSRECORD_records_get_size (rd_count, + rd); char payload[sizeof (uint32_t) + payload_len]; struct GNUNET_GNSRECORD_Block *block; struct GNUNET_CRYPTO_EcdsaPublicKey pkey; @@ -94,14 +95,13 @@ GNUNET_GNSRECORD_block_create (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, struct GNUNET_CRYPTO_SymmetricSessionKey skey; struct GNUNET_GNSRECORD_Data rdc[rd_count]; uint32_t rd_count_nbo; - unsigned int i; struct GNUNET_TIME_Absolute now; if (payload_len > GNUNET_GNSRECORD_MAX_BLOCK_SIZE) return NULL; /* convert relative to absolute times */ now = GNUNET_TIME_absolute_get (); - for (i=0;ipurpose.size = htonl (sizeof (uint32_t) + payload_len + + sizeof (uint32_t) + + payload_len); + block->purpose.size = htonl (sizeof (uint32_t) + + payload_len + sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) + sizeof (struct GNUNET_TIME_AbsoluteNBO)); block->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_GNS_RECORD_SIGN); @@ -132,18 +138,23 @@ GNUNET_GNSRECORD_block_create (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, label, "gns"); GNUNET_CRYPTO_ecdsa_key_get_public (dkey, - &block->derived_key); + &block->derived_key); GNUNET_CRYPTO_ecdsa_key_get_public (key, - &pkey); - derive_block_aes_key (&iv, &skey, label, &pkey); + &pkey); + derive_block_aes_key (&iv, + &skey, + label, + &pkey); GNUNET_break (payload_len + sizeof (uint32_t) == - GNUNET_CRYPTO_symmetric_encrypt (payload, payload_len + sizeof (uint32_t), - &skey, &iv, + GNUNET_CRYPTO_symmetric_encrypt (payload, + payload_len + sizeof (uint32_t), + &skey, + &iv, &block[1])); if (GNUNET_OK != GNUNET_CRYPTO_ecdsa_sign (dkey, - &block->purpose, - &block->signature)) + &block->purpose, + &block->signature)) { GNUNET_break (0); GNUNET_free (dkey); @@ -166,9 +177,9 @@ int GNUNET_GNSRECORD_block_verify (const struct GNUNET_GNSRECORD_Block *block) { return GNUNET_CRYPTO_ecdsa_verify (GNUNET_SIGNATURE_PURPOSE_GNS_RECORD_SIGN, - &block->purpose, - &block->signature, - &block->derived_key); + &block->purpose, + &block->signature, + &block->derived_key); } @@ -224,9 +235,7 @@ GNUNET_GNSRECORD_block_decrypt (const struct GNUNET_GNSRECORD_Block *block, } { struct GNUNET_GNSRECORD_Data rd[rd_count]; - unsigned int i; unsigned int j; - unsigned int k; struct GNUNET_TIME_Absolute now; if (GNUNET_OK != @@ -241,7 +250,7 @@ GNUNET_GNSRECORD_block_decrypt (const struct GNUNET_GNSRECORD_Block *block, /* hide expired records */ now = GNUNET_TIME_absolute_get (); j = 0; - for (i=0;imq, env); if (rd != res) @@ -707,6 +723,10 @@ refresh_block (struct NamestoreClient *nc, name, res_count, GNUNET_GNSRECORD_z2s (&pkey)); + GNUNET_STATISTICS_update (statistics, + "Namecache updates pushed", + 1, + GNUNET_NO); cop = GNUNET_new (struct CacheOperation); cop->nc = nc; cop->rid = rid; @@ -774,7 +794,8 @@ lookup_it (void *cls, unsigned int rdc_res; (void) private_key; - if (0 == strcmp (label, rlc->label)) + if (0 == strcmp (label, + rlc->label)) { rlc->found = GNUNET_YES; if (0 != rd_count) @@ -1332,7 +1353,8 @@ zone_iterate_proc (void *cls, struct ZoneIterationProcResult *proc = cls; int do_refresh_block; - if ((NULL == zone_key) && (NULL == name)) + if ( (NULL == zone_key) && + (NULL == name) ) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Iteration done\n"); @@ -1391,11 +1413,14 @@ run_zone_iteration_round (struct ZoneIteration *zi) { if (GNUNET_SYSERR == (ret = GSN_database->iterate_records (GSN_database->cls, - (0 == memcmp (&zi->zone, &zero, sizeof (zero))) + (0 == memcmp (&zi->zone, + &zero, + sizeof (zero))) ? NULL : &zi->zone, zi->offset, - &zone_iterate_proc, &proc))) + &zone_iterate_proc, + &proc))) { GNUNET_break (0); break; @@ -1503,6 +1528,10 @@ handle_iteration_next (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ZONE_ITERATION_NEXT message\n"); + GNUNET_STATISTICS_update (statistics, + "Iteration NEXT messages received", + 1, + GNUNET_NO); rid = ntohl (zis_msg->gns_header.r_id); for (zi = nc->op_head; NULL != zi; zi = zi->next) if (zi->request_id == rid) @@ -1569,6 +1598,10 @@ monitor_iterate_cb (void *cls, monitor_sync (zm); return; } + GNUNET_STATISTICS_update (statistics, + "Monitor notifications sent", + 1, + GNUNET_NO); send_lookup_response (zm->nc, 0, zone_key, @@ -1684,6 +1717,8 @@ run (void *cls, GSN_database = GNUNET_PLUGIN_load (db_lib_name, (void *) GSN_cfg); GNUNET_free (database); + statistics = GNUNET_STATISTICS_create ("namestore", + cfg); GNUNET_SCHEDULER_add_shutdown (&cleanup_task, NULL); if (NULL == GSN_database) diff --git a/src/zonemaster/gnunet-service-zonemaster.c b/src/zonemaster/gnunet-service-zonemaster.c index b3a2cb8b3..bf11f7d20 100644 --- a/src/zonemaster/gnunet-service-zonemaster.c +++ b/src/zonemaster/gnunet-service-zonemaster.c @@ -336,11 +336,10 @@ convert_records_for_export (const struct GNUNET_GNSRECORD_Data *rd, { struct GNUNET_TIME_Absolute now; unsigned int rd_public_count; - unsigned int i; rd_public_count = 0; now = GNUNET_TIME_absolute_get (); - for (i=0;i