aboutsummaryrefslogtreecommitdiff
path: root/src/dht/gnunet-service-dht_datacache.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-03-08 19:11:46 +0000
committerChristian Grothoff <christian@grothoff.org>2015-03-08 19:11:46 +0000
commit5105deda52a78e0aa44b4f86feba98b60a59208b (patch)
tree036eecedd83875132e1d23e76e33c6e9c4d3736c /src/dht/gnunet-service-dht_datacache.c
parent226ee707da1f1d38570fc4fa2afe7c0cdf6851e9 (diff)
downloadgnunet-5105deda52a78e0aa44b4f86feba98b60a59208b.tar.gz
gnunet-5105deda52a78e0aa44b4f86feba98b60a59208b.zip
do not do cryptographic verification for results from datacache
Diffstat (limited to 'src/dht/gnunet-service-dht_datacache.c')
-rw-r--r--src/dht/gnunet-service-dht_datacache.c84
1 files changed, 51 insertions, 33 deletions
diff --git a/src/dht/gnunet-service-dht_datacache.c b/src/dht/gnunet-service-dht_datacache.c
index 48ce941c1..0b067dca4 100644
--- a/src/dht/gnunet-service-dht_datacache.c
+++ b/src/dht/gnunet-service-dht_datacache.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2009, 2010, 2011 Christian Grothoff (and other contributing authors) 3 Copyright (C) 2009, 2010, 2011, 2015 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -31,7 +31,7 @@
31#include "gnunet-service-dht_routing.h" 31#include "gnunet-service-dht_routing.h"
32#include "gnunet-service-dht.h" 32#include "gnunet-service-dht.h"
33 33
34#define LOG(kind,...) GNUNET_log_from (kind, "dht-dtcache",__VA_ARGS__) 34#define LOG(kind,...) GNUNET_log_from (kind, "dht-dhtcache",__VA_ARGS__)
35 35
36 36
37/** 37/**
@@ -46,18 +46,19 @@ static struct GNUNET_DATACACHE_Handle *datacache;
46 * 46 *
47 * @param expiration when will the reply expire 47 * @param expiration when will the reply expire
48 * @param key the query this reply is for 48 * @param key the query this reply is for
49 * @param put_path_length number of peers in 'put_path' 49 * @param put_path_length number of peers in @a put_path
50 * @param put_path path the reply took on put 50 * @param put_path path the reply took on put
51 * @param type type of the reply 51 * @param type type of the reply
52 * @param data_size number of bytes in 'data' 52 * @param data_size number of bytes in @a data
53 * @param data application payload data 53 * @param data application payload data
54 */ 54 */
55void 55void
56GDS_DATACACHE_handle_put (struct GNUNET_TIME_Absolute expiration, 56GDS_DATACACHE_handle_put (struct GNUNET_TIME_Absolute expiration,
57 const struct GNUNET_HashCode * key, 57 const struct GNUNET_HashCode *key,
58 unsigned int put_path_length, 58 unsigned int put_path_length,
59 const struct GNUNET_PeerIdentity *put_path, 59 const struct GNUNET_PeerIdentity *put_path,
60 enum GNUNET_BLOCK_Type type, size_t data_size, 60 enum GNUNET_BLOCK_Type type,
61 size_t data_size,
61 const void *data) 62 const void *data)
62{ 63{
63 int r; 64 int r;
@@ -130,16 +131,18 @@ struct GetRequestContext
130 * @param key the key this data is stored under 131 * @param key the key this data is stored under
131 * @param size the size of the data identified by key 132 * @param size the size of the data identified by key
132 * @param data the actual data 133 * @param data the actual data
133 * @param type the type of the data 134 * @param type the type of the @a data
134 * @param put_path_length number of peers in 'put_path' 135 * @param put_path_length number of peers in @a put_path
135 * @param put_path path the reply took on put 136 * @param put_path path the reply took on put
136 * @return GNUNET_OK to continue iteration, anything else 137 * @return #GNUNET_OK to continue iteration, anything else
137 * to stop iteration. 138 * to stop iteration.
138 */ 139 */
139static int 140static int
140datacache_get_iterator (void *cls, 141datacache_get_iterator (void *cls,
141 const struct GNUNET_HashCode * key, size_t size, 142 const struct GNUNET_HashCode *key,
142 const char *data, enum GNUNET_BLOCK_Type type, 143 size_t size,
144 const char *data,
145 enum GNUNET_BLOCK_Type type,
143 struct GNUNET_TIME_Absolute exp, 146 struct GNUNET_TIME_Absolute exp,
144 unsigned int put_path_length, 147 unsigned int put_path_length,
145 const struct GNUNET_PeerIdentity *put_path) 148 const struct GNUNET_PeerIdentity *put_path)
@@ -150,7 +153,7 @@ datacache_get_iterator (void *cls,
150 eval = 153 eval =
151 GNUNET_BLOCK_evaluate (GDS_block_context, 154 GNUNET_BLOCK_evaluate (GDS_block_context,
152 type, 155 type,
153 GNUNET_BLOCK_EO_NONE, 156 GNUNET_BLOCK_EO_LOCAL_SKIP_CRYPTO,
154 key, 157 key,
155 ctx->reply_bf, 158 ctx->reply_bf,
156 ctx->reply_bf_mutator, 159 ctx->reply_bf_mutator,
@@ -172,28 +175,35 @@ datacache_get_iterator (void *cls,
172 gettext_noop 175 gettext_noop
173 ("# Good RESULTS found in datacache"), 1, 176 ("# Good RESULTS found in datacache"), 1,
174 GNUNET_NO); 177 GNUNET_NO);
175 GDS_CLIENTS_handle_reply (exp, key, 0, NULL, put_path_length, put_path, 178 GDS_CLIENTS_handle_reply (exp, key,
176 type, size, data); 179 0, NULL,
180 put_path_length, put_path,
181 type,
182 size, data);
177 /* forward to other peers */ 183 /* forward to other peers */
178 GDS_ROUTING_process (type, exp, key, put_path_length, put_path, 0, NULL, 184 GDS_ROUTING_process (type,
185 exp,
186 key,
187 put_path_length, put_path,
188 0, NULL,
179 data, size); 189 data, size);
180 break; 190 break;
181 case GNUNET_BLOCK_EVALUATION_OK_DUPLICATE: 191 case GNUNET_BLOCK_EVALUATION_OK_DUPLICATE:
182 GNUNET_STATISTICS_update (GDS_stats, 192 GNUNET_STATISTICS_update (GDS_stats,
183 gettext_noop 193 gettext_noop ("# Duplicate RESULTS found in datacache"),
184 ("# Duplicate RESULTS found in datacache"), 1, 194 1,
185 GNUNET_NO); 195 GNUNET_NO);
186 break; 196 break;
187 case GNUNET_BLOCK_EVALUATION_RESULT_INVALID: 197 case GNUNET_BLOCK_EVALUATION_RESULT_INVALID:
188 GNUNET_STATISTICS_update (GDS_stats, 198 GNUNET_STATISTICS_update (GDS_stats,
189 gettext_noop 199 gettext_noop ("# Invalid RESULTS found in datacache"),
190 ("# Invalid RESULTS found in datacache"), 1, 200 1,
191 GNUNET_NO); 201 GNUNET_NO);
192 break; 202 break;
193 case GNUNET_BLOCK_EVALUATION_RESULT_IRRELEVANT: 203 case GNUNET_BLOCK_EVALUATION_RESULT_IRRELEVANT:
194 GNUNET_STATISTICS_update (GDS_stats, 204 GNUNET_STATISTICS_update (GDS_stats,
195 gettext_noop 205 gettext_noop ("# Irrelevant RESULTS found in datacache"),
196 ("# Irrelevant RESULTS found in datacache"), 1, 206 1,
197 GNUNET_NO); 207 GNUNET_NO);
198 break; 208 break;
199 case GNUNET_BLOCK_EVALUATION_REQUEST_VALID: 209 case GNUNET_BLOCK_EVALUATION_REQUEST_VALID:
@@ -204,11 +214,12 @@ datacache_get_iterator (void *cls,
204 return GNUNET_SYSERR; 214 return GNUNET_SYSERR;
205 case GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED: 215 case GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED:
206 GNUNET_STATISTICS_update (GDS_stats, 216 GNUNET_STATISTICS_update (GDS_stats,
207 gettext_noop 217 gettext_noop ("# Unsupported RESULTS found in datacache"),
208 ("# Unsupported RESULTS found in datacache"), 1, 218 1,
209 GNUNET_NO); 219 GNUNET_NO);
210 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 220 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
211 _("Unsupported block type (%u) in local response!\n"), type); 221 _("Unsupported block type (%u) in local response!\n"),
222 type);
212 break; 223 break;
213 } 224 }
214 return (eval == GNUNET_BLOCK_EVALUATION_OK_LAST) ? GNUNET_NO : GNUNET_OK; 225 return (eval == GNUNET_BLOCK_EVALUATION_OK_LAST) ? GNUNET_NO : GNUNET_OK;
@@ -221,14 +232,15 @@ datacache_get_iterator (void *cls,
221 * @param key the query 232 * @param key the query
222 * @param type requested data type 233 * @param type requested data type
223 * @param xquery extended query 234 * @param xquery extended query
224 * @param xquery_size number of bytes in xquery 235 * @param xquery_size number of bytes in @a xquery
225 * @param reply_bf where the reply bf is (to be) stored, possibly updated, can be NULL 236 * @param reply_bf where the reply bf is (to be) stored, possibly updated, can be NULL
226 * @param reply_bf_mutator mutation value for reply_bf 237 * @param reply_bf_mutator mutation value for @a reply_bf
227 * @return evaluation result for the local replies 238 * @return evaluation result for the local replies
228 */ 239 */
229enum GNUNET_BLOCK_EvaluationResult 240enum GNUNET_BLOCK_EvaluationResult
230GDS_DATACACHE_handle_get (const struct GNUNET_HashCode * key, 241GDS_DATACACHE_handle_get (const struct GNUNET_HashCode *key,
231 enum GNUNET_BLOCK_Type type, const void *xquery, 242 enum GNUNET_BLOCK_Type type,
243 const void *xquery,
232 size_t xquery_size, 244 size_t xquery_size,
233 struct GNUNET_CONTAINER_BloomFilter **reply_bf, 245 struct GNUNET_CONTAINER_BloomFilter **reply_bf,
234 uint32_t reply_bf_mutator) 246 uint32_t reply_bf_mutator)
@@ -236,22 +248,28 @@ GDS_DATACACHE_handle_get (const struct GNUNET_HashCode * key,
236 struct GetRequestContext ctx; 248 struct GetRequestContext ctx;
237 unsigned int r; 249 unsigned int r;
238 250
239 if (datacache == NULL) 251 if (NULL == datacache)
240 return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; 252 return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
241 GNUNET_STATISTICS_update (GDS_stats, 253 GNUNET_STATISTICS_update (GDS_stats,
242 gettext_noop ("# GET requests given to datacache"), 254 gettext_noop ("# GET requests given to datacache"),
243 1, GNUNET_NO); 255 1,
256 GNUNET_NO);
244 ctx.eval = GNUNET_BLOCK_EVALUATION_REQUEST_VALID; 257 ctx.eval = GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
245 ctx.key = *key; 258 ctx.key = *key;
246 ctx.xquery = xquery; 259 ctx.xquery = xquery;
247 ctx.xquery_size = xquery_size; 260 ctx.xquery_size = xquery_size;
248 ctx.reply_bf = reply_bf; 261 ctx.reply_bf = reply_bf;
249 ctx.reply_bf_mutator = reply_bf_mutator; 262 ctx.reply_bf_mutator = reply_bf_mutator;
250 r = GNUNET_DATACACHE_get (datacache, key, type, &datacache_get_iterator, 263 r = GNUNET_DATACACHE_get (datacache,
264 key,
265 type,
266 &datacache_get_iterator,
251 &ctx); 267 &ctx);
252 LOG (GNUNET_ERROR_TYPE_DEBUG, 268 LOG (GNUNET_ERROR_TYPE_DEBUG,
253 "DATACACHE GET for key %s completed (%d). %u results found.\n", 269 "DATACACHE GET for key %s completed (%d). %u results found.\n",
254 GNUNET_h2s (key), ctx.eval, r); 270 GNUNET_h2s (key),
271 ctx.eval,
272 r);
255 return ctx.eval; 273 return ctx.eval;
256} 274}
257 275
@@ -272,7 +290,7 @@ GDS_DATACACHE_init ()
272void 290void
273GDS_DATACACHE_done () 291GDS_DATACACHE_done ()
274{ 292{
275 if (datacache != NULL) 293 if (NULL != datacache)
276 { 294 {
277 GNUNET_DATACACHE_destroy (datacache); 295 GNUNET_DATACACHE_destroy (datacache);
278 datacache = NULL; 296 datacache = NULL;