View | Details | Raw Unified | Return to bug 1417 | Differences between
and this patch

Collapse All | Expand All

(-)b/daemon/remote.c (+18 lines)
 Lines 825-830   print_mem(SSL* ssl, struct worker* worker, struct daemon* daemon) Link Here 
825
#ifdef USE_IPSECMOD
825
#ifdef USE_IPSECMOD
826
	size_t ipsecmod = 0;
826
	size_t ipsecmod = 0;
827
#endif /* USE_IPSECMOD */
827
#endif /* USE_IPSECMOD */
828
#ifdef USE_DNSCRYPT
829
	size_t dnscrypt_shared_secret = 0;
830
#endif /* USE_DNSCRYPT */
828
	msg = slabhash_get_mem(daemon->env->msg_cache);
831
	msg = slabhash_get_mem(daemon->env->msg_cache);
829
	rrset = slabhash_get_mem(&daemon->env->rrset_cache->table);
832
	rrset = slabhash_get_mem(&daemon->env->rrset_cache->table);
830
	val = mod_get_mem(&worker->env, "validator");
833
	val = mod_get_mem(&worker->env, "validator");
 Lines 836-841   print_mem(SSL* ssl, struct worker* worker, struct daemon* daemon) Link Here 
836
#ifdef USE_IPSECMOD
839
#ifdef USE_IPSECMOD
837
	ipsecmod = mod_get_mem(&worker->env, "ipsecmod");
840
	ipsecmod = mod_get_mem(&worker->env, "ipsecmod");
838
#endif /* USE_IPSECMOD */
841
#endif /* USE_IPSECMOD */
842
#ifdef USE_DNSCRYPT
843
	dnscrypt_shared_secret = slabhash_get_mem(
844
		daemon->dnscenv->shared_secrets_cache);
845
#endif /* USE_DNSCRYPT */
839
846
840
	if(!print_longnum(ssl, "mem.cache.rrset"SQ, rrset))
847
	if(!print_longnum(ssl, "mem.cache.rrset"SQ, rrset))
841
		return 0;
848
		return 0;
 Lines 855-860   print_mem(SSL* ssl, struct worker* worker, struct daemon* daemon) Link Here 
855
	if(!print_longnum(ssl, "mem.mod.ipsecmod"SQ, ipsecmod))
862
	if(!print_longnum(ssl, "mem.mod.ipsecmod"SQ, ipsecmod))
856
		return 0;
863
		return 0;
857
#endif /* USE_IPSECMOD */
864
#endif /* USE_IPSECMOD */
865
#ifdef USE_DNSCRYPT
866
	if(!print_longnum(ssl, "mem.cache.dnscrypt_shared_secret"SQ,
867
			dnscrypt_shared_secret))
868
		return 0;
869
#endif /* USE_DNSCRYPT */
858
	return 1;
870
	return 1;
859
}
871
}
860
872
 Lines 1041-1046   print_ext(SSL* ssl, struct ub_stats_info* s) Link Here 
1041
		(unsigned)s->svr.infra_cache_count)) return 0;
1053
		(unsigned)s->svr.infra_cache_count)) return 0;
1042
	if(!ssl_printf(ssl, "key.cache.count"SQ"%u\n",
1054
	if(!ssl_printf(ssl, "key.cache.count"SQ"%u\n",
1043
		(unsigned)s->svr.key_cache_count)) return 0;
1055
		(unsigned)s->svr.key_cache_count)) return 0;
1056
#ifdef USE_DNSCRYPT
1057
	if(!ssl_printf(ssl, "dnscrypt_shared_secret.cache.count"SQ"%u\n",
1058
		(unsigned)s->svr.shared_secret_cache_count)) return 0;
1059
	if(!ssl_printf(ssl, "num.query.dnscrypt.shared_secret.cachemiss"SQ"%lu\n",
1060
		(unsigned long)s->svr.num_query_dnscrypt_secret_missed_cache)) return 0;
1061
#endif /* USE_DNSCRYPT */
1044
	return 1;
1062
	return 1;
1045
}
1063
}
1046
1064
(-)b/daemon/stats.c (-1 / +25 lines)
 Lines 158-163   get_queries_ratelimit(struct worker* worker, int reset) Link Here 
158
	return r;
158
	return r;
159
}
159
}
160
160
161
#ifdef USE_DNSCRYPT
162
/** get the number of shared secret cache miss */
163
static size_t
164
get_dnscrypt_cache_miss(struct worker* worker, int reset)
165
{
166
	size_t r;
167
	struct dnsc_env* de = worker->daemon->dnscenv;
168
169
	lock_basic_lock(&de->shared_secrets_cache_lock);
170
	r = de->num_query_dnscrypt_secret_missed_cache;
171
	if(reset && !worker->env.cfg->stat_cumulative)
172
		de->num_query_dnscrypt_secret_missed_cache = 0;
173
	lock_basic_unlock(&de->shared_secrets_cache_lock);
174
	return r;
175
}
176
#endif /* USE_DNSCRYPT */
177
161
void
178
void
162
server_stats_compile(struct worker* worker, struct ub_stats_info* s, int reset)
179
server_stats_compile(struct worker* worker, struct ub_stats_info* s, int reset)
163
{
180
{
 Lines 201-206   server_stats_compile(struct worker* worker, struct ub_stats_info* s, int reset) Link Here 
201
		s->svr.key_cache_count = (long long)count_slabhash_entries(worker->env.key_cache->slab);
218
		s->svr.key_cache_count = (long long)count_slabhash_entries(worker->env.key_cache->slab);
202
	else	s->svr.key_cache_count = 0;
219
	else	s->svr.key_cache_count = 0;
203
220
221
#ifdef USE_DNSCRYPT
222
	s->svr.num_query_dnscrypt_secret_missed_cache =
223
		(long long)get_dnscrypt_cache_miss(worker, reset);
224
	s->svr.shared_secret_cache_count = (long long)count_slabhash_entries(
225
		worker->daemon->dnscenv->shared_secrets_cache);
226
#endif /* USE_DNSCRYPT */
227
204
	/* get tcp accept usage */
228
	/* get tcp accept usage */
205
	s->svr.tcp_accept_usage = 0;
229
	s->svr.tcp_accept_usage = 0;
206
	for(lp = worker->front->cps; lp; lp = lp->next) {
230
	for(lp = worker->front->cps; lp; lp = lp->next) {
 Lines 262-268   void server_stats_add(struct ub_stats_info* total, struct ub_stats_info* a) Link Here 
262
		a->svr.num_query_dnscrypt_cleartext;
286
		a->svr.num_query_dnscrypt_cleartext;
263
	total->svr.num_query_dnscrypt_crypted_malformed += \
287
	total->svr.num_query_dnscrypt_crypted_malformed += \
264
		a->svr.num_query_dnscrypt_crypted_malformed;
288
		a->svr.num_query_dnscrypt_crypted_malformed;
265
#endif
289
#endif /* USE_DNSCRYPT */
266
	/* the max size reached is upped to higher of both */
290
	/* the max size reached is upped to higher of both */
267
	if(a->svr.max_query_list_size > total->svr.max_query_list_size)
291
	if(a->svr.max_query_list_size > total->svr.max_query_list_size)
268
		total->svr.max_query_list_size = a->svr.max_query_list_size;
292
		total->svr.max_query_list_size = a->svr.max_query_list_size;
(-)b/dnscrypt/dnscrypt.c (+8 lines)
 Lines 177-182   dnscrypt_server_uncurve(struct dnsc_env* env, Link Here 
177
                                       hash);
177
                                       hash);
178
178
179
    if(!entry) {
179
    if(!entry) {
180
        lock_basic_lock(&env->shared_secrets_cache_lock);
181
        env->num_query_dnscrypt_secret_missed_cache++;
182
        lock_basic_unlock(&env->shared_secrets_cache_lock);
180
        if(cert->es_version[1] == 2) {
183
        if(cert->es_version[1] == 2) {
181
#ifdef USE_DNSCRYPT_XCHACHA20
184
#ifdef USE_DNSCRYPT_XCHACHA20
182
            if (crypto_box_curve25519xchacha20poly1305_beforenm(
185
            if (crypto_box_curve25519xchacha20poly1305_beforenm(
 Lines 765-770   dnsc_create(void) Link Here 
765
		fatal_exit("dnsc_create: could not initialize libsodium.");
768
		fatal_exit("dnsc_create: could not initialize libsodium.");
766
	}
769
	}
767
	env = (struct dnsc_env *) calloc(1, sizeof(struct dnsc_env));
770
	env = (struct dnsc_env *) calloc(1, sizeof(struct dnsc_env));
771
	lock_basic_init(&env->shared_secrets_cache_lock);
772
	lock_protect(&env->shared_secrets_cache_lock,
773
				 &env->num_query_dnscrypt_secret_missed_cache,
774
				 sizeof(env->num_query_dnscrypt_secret_missed_cache));
768
	return env;
775
	return env;
769
}
776
}
770
777
 Lines 810-815   dnsc_delete(struct dnsc_env *env) Link Here 
810
	sodium_free(env->certs);
817
	sodium_free(env->certs);
811
	sodium_free(env->keypairs);
818
	sodium_free(env->keypairs);
812
	slabhash_delete(env->shared_secrets_cache);
819
	slabhash_delete(env->shared_secrets_cache);
820
	lock_basic_destroy(&env->shared_secrets_cache_lock);
813
	free(env);
821
	free(env);
814
}
822
}
815
823
(-)b/dnscrypt/dnscrypt.h (+5 lines)
 Lines 26-31    Link Here 
26
26
27
#include "config.h"
27
#include "config.h"
28
#include "dnscrypt/cert.h"
28
#include "dnscrypt/cert.h"
29
#include "util/locks.h"
29
30
30
#define DNSCRYPT_QUERY_HEADER_SIZE \
31
#define DNSCRYPT_QUERY_HEADER_SIZE \
31
    (DNSCRYPT_MAGIC_HEADER_LEN + crypto_box_PUBLICKEYBYTES + crypto_box_HALF_NONCEBYTES + crypto_box_MACBYTES)
32
    (DNSCRYPT_MAGIC_HEADER_LEN + crypto_box_PUBLICKEYBYTES + crypto_box_HALF_NONCEBYTES + crypto_box_MACBYTES)
 Lines 63-68   struct dnsc_env { Link Here 
63
	unsigned char hash_key[crypto_shorthash_KEYBYTES];
64
	unsigned char hash_key[crypto_shorthash_KEYBYTES];
64
	char * provider_name;
65
	char * provider_name;
65
	struct slabhash *shared_secrets_cache;
66
	struct slabhash *shared_secrets_cache;
67
	/** lock on shared secret cache counters */
68
	lock_basic_type shared_secrets_cache_lock;
69
	/** number of misses from shared_secrets_cache */
70
	size_t num_query_dnscrypt_secret_missed_cache;
66
};
71
};
67
72
68
struct dnscrypt_query_header {
73
struct dnscrypt_query_header {
(-)b/libunbound/unbound.h (+5 lines)
 Lines 622-627   struct ub_shm_stat_info { Link Here 
622
		long long subnet;
622
		long long subnet;
623
		long long ipsecmod;
623
		long long ipsecmod;
624
		long long respip;
624
		long long respip;
625
		long long dnscrypt_shared_secret;
625
	} mem;
626
	} mem;
626
};
627
};
627
628
 Lines 737-742   struct ub_server_stats { Link Here 
737
	long long num_query_dnscrypt_cleartext;
738
	long long num_query_dnscrypt_cleartext;
738
	/** number of malformed encrypted queries */
739
	/** number of malformed encrypted queries */
739
	long long num_query_dnscrypt_crypted_malformed;
740
	long long num_query_dnscrypt_crypted_malformed;
741
	/** number of queries which did not have a shared secret in cache */
742
	long long num_query_dnscrypt_secret_missed_cache;
743
	/** number of dnscrypt shared secret cache entries */
744
	long long shared_secret_cache_count;
740
};
745
};
741
746
742
/** 
747
/** 
(-)b/smallapp/unbound-control.c (-1 / +11 lines)
 Lines 207-213   static void pr_stats(const char* nm, struct ub_stats_info* s) Link Here 
207
    PR_UL_NM("num.dnscrypt.cleartext", s->svr.num_query_dnscrypt_cleartext);
207
    PR_UL_NM("num.dnscrypt.cleartext", s->svr.num_query_dnscrypt_cleartext);
208
    PR_UL_NM("num.dnscrypt.malformed",
208
    PR_UL_NM("num.dnscrypt.malformed",
209
             s->svr.num_query_dnscrypt_crypted_malformed);
209
             s->svr.num_query_dnscrypt_crypted_malformed);
210
#endif
210
#endif /* USE_DNSCRYPT */
211
	printf("%s.requestlist.avg"SQ"%g\n", nm,
211
	printf("%s.requestlist.avg"SQ"%g\n", nm,
212
		(s->svr.num_queries_missed_cache+s->svr.num_queries_prefetch)?
212
		(s->svr.num_queries_missed_cache+s->svr.num_queries_prefetch)?
213
			(double)s->svr.sum_query_list_size/
213
			(double)s->svr.sum_query_list_size/
 Lines 251-256   static void print_mem(struct ub_shm_stat_info* shm_stat) Link Here 
251
#ifdef USE_IPSECMOD
251
#ifdef USE_IPSECMOD
252
	PR_LL("mem.mod.ipsecmod", shm_stat->mem.ipsecmod);
252
	PR_LL("mem.mod.ipsecmod", shm_stat->mem.ipsecmod);
253
#endif
253
#endif
254
#ifdef USE_DNSCRYPT
255
	PR_LL("mem.cache.dnscrypt_shared_secret",
256
		shm_stat->mem.dnscrypt_shared_secret);
257
#endif
254
}
258
}
255
259
256
/** print histogram */
260
/** print histogram */
 Lines 351-356   static void print_extended(struct ub_stats_info* s) Link Here 
351
	PR_UL("rrset.cache.count", s->svr.rrset_cache_count);
355
	PR_UL("rrset.cache.count", s->svr.rrset_cache_count);
352
	PR_UL("infra.cache.count", s->svr.infra_cache_count);
356
	PR_UL("infra.cache.count", s->svr.infra_cache_count);
353
	PR_UL("key.cache.count", s->svr.key_cache_count);
357
	PR_UL("key.cache.count", s->svr.key_cache_count);
358
#ifdef USE_DNSCRYPT
359
	PR_UL("dnscrypt_shared_secret.cache.count",
360
			 s->svr.shared_secret_cache_count);
361
	PR_UL("num.query.dnscrypt.shared_secret.cachemiss",
362
			 s->svr.num_query_dnscrypt_secret_missed_cache);
363
#endif /* USE_DNSCRYPT */
354
}
364
}
355
365
356
/** print statistics out of memory structures */
366
/** print statistics out of memory structures */
(-)b/util/shm_side/shm_main.c (+4 lines)
 Lines 249-254   void shm_main_run(struct worker *worker) Link Here 
249
249
250
		shm_stat->mem.msg = (long long)slabhash_get_mem(worker->env.msg_cache);
250
		shm_stat->mem.msg = (long long)slabhash_get_mem(worker->env.msg_cache);
251
		shm_stat->mem.rrset = (long long)slabhash_get_mem(&worker->env.rrset_cache->table);
251
		shm_stat->mem.rrset = (long long)slabhash_get_mem(&worker->env.rrset_cache->table);
252
#ifdef USE_DNSCRYPT
253
		shm_stat->mem.dnscrypt_shared_secret = (long long)slabhash_get_mem(
254
			worker->daemon->dnscenv->shared_secrets_cache);
255
#endif
252
		shm_stat->mem.val = (long long)mod_get_mem(&worker->env,
256
		shm_stat->mem.val = (long long)mod_get_mem(&worker->env,
253
			"validator");
257
			"validator");
254
		shm_stat->mem.iter = (long long)mod_get_mem(&worker->env,
258
		shm_stat->mem.iter = (long long)mod_get_mem(&worker->env,

Return to bug 1417