diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-12-03 03:11:42 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-12-03 03:11:42 +0000 |
commit | 03b10ac22fb7e80a02568af591e0ead6c76d8563 (patch) | |
tree | 42407bad847b7faa622070975d15cce29a7504d9 /src/fs/gnunet-service-fs.c | |
parent | b15e5e6fbee9941cd17218771e78412a3b50ed8b (diff) | |
download | gnunet-03b10ac22fb7e80a02568af591e0ead6c76d8563.tar.gz gnunet-03b10ac22fb7e80a02568af591e0ead6c76d8563.zip |
air plane hacking
Diffstat (limited to 'src/fs/gnunet-service-fs.c')
-rw-r--r-- | src/fs/gnunet-service-fs.c | 88 |
1 files changed, 85 insertions, 3 deletions
diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c index f02e85bba..08b01fbbf 100644 --- a/src/fs/gnunet-service-fs.c +++ b/src/fs/gnunet-service-fs.c | |||
@@ -85,6 +85,13 @@ | |||
85 | #define TRUST_FLUSH_FREQ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5) | 85 | #define TRUST_FLUSH_FREQ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5) |
86 | 86 | ||
87 | /** | 87 | /** |
88 | * How quickly do we age cover traffic? At the given | ||
89 | * time interval, remaining cover traffic counters are | ||
90 | * decremented by 1/16th. | ||
91 | */ | ||
92 | #define COVER_AGE_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) | ||
93 | |||
94 | /** | ||
88 | * How often do we at most PUT content into the DHT? | 95 | * How often do we at most PUT content into the DHT? |
89 | */ | 96 | */ |
90 | #define MAX_DHT_PUT_FREQ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) | 97 | #define MAX_DHT_PUT_FREQ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) |
@@ -495,9 +502,6 @@ struct UsedTargetEntry | |||
495 | }; | 502 | }; |
496 | 503 | ||
497 | 504 | ||
498 | |||
499 | |||
500 | |||
501 | /** | 505 | /** |
502 | * Doubly-linked list of messages we are performing | 506 | * Doubly-linked list of messages we are performing |
503 | * due to a pending request. | 507 | * due to a pending request. |
@@ -929,6 +933,34 @@ static struct GNUNET_LOAD_Value *datastore_put_load; | |||
929 | static struct GNUNET_LOAD_Value *rt_entry_lifetime; | 933 | static struct GNUNET_LOAD_Value *rt_entry_lifetime; |
930 | 934 | ||
931 | /** | 935 | /** |
936 | * How many query messages have we received 'recently' that | ||
937 | * have not yet been claimed as cover traffic? | ||
938 | */ | ||
939 | static unsigned int cover_query_count; | ||
940 | |||
941 | /** | ||
942 | * How many content messages have we received 'recently' that | ||
943 | * have not yet been claimed as cover traffic? | ||
944 | */ | ||
945 | static unsigned int cover_content_count; | ||
946 | |||
947 | /** | ||
948 | * ID of our task that we use to age the cover counters. | ||
949 | */ | ||
950 | static GNUNET_SCHEDULER_TaskIdentifier cover_age_task; | ||
951 | |||
952 | static void | ||
953 | age_cover_counters (void *cls, | ||
954 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
955 | { | ||
956 | cover_content_count = (cover_content_count * 15) / 16; | ||
957 | cover_query_count = (cover_query_count * 15) / 16; | ||
958 | cover_age_task = GNUNET_SCHEDULER_add_delayed (COVER_AGE_FREQUENCY, | ||
959 | &age_cover_counters, | ||
960 | NULL); | ||
961 | } | ||
962 | |||
963 | /** | ||
932 | * We've just now completed a datastore request. Update our | 964 | * We've just now completed a datastore request. Update our |
933 | * datastore load calculations. | 965 | * datastore load calculations. |
934 | * | 966 | * |
@@ -2084,6 +2116,8 @@ shutdown_task (void *cls, | |||
2084 | cfg = NULL; | 2116 | cfg = NULL; |
2085 | GNUNET_free_non_null (trustDirectory); | 2117 | GNUNET_free_non_null (trustDirectory); |
2086 | trustDirectory = NULL; | 2118 | trustDirectory = NULL; |
2119 | GNUNET_SCHEDULER_cancel (cover_age_task); | ||
2120 | cover_age_task = GNUNET_SCHEDULER_NO_TASK; | ||
2087 | } | 2121 | } |
2088 | 2122 | ||
2089 | 2123 | ||
@@ -3015,6 +3049,26 @@ forward_request_task (void *cls, | |||
3015 | &process_dht_reply, | 3049 | &process_dht_reply, |
3016 | pr); | 3050 | pr); |
3017 | } | 3051 | } |
3052 | |||
3053 | if ( (pr->anonymity_level > 1) && | ||
3054 | (cover_query_count < pr->anonymity_level - 1) ) | ||
3055 | { | ||
3056 | delay = get_processing_delay (); | ||
3057 | #if DEBUG_FS | ||
3058 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3059 | "Not enough cover traffic to forward query `%s', will try again in %llu ms!\n", | ||
3060 | GNUNET_h2s (&pr->query), | ||
3061 | delay.rel_value); | ||
3062 | #endif | ||
3063 | pr->task = GNUNET_SCHEDULER_add_delayed (delay, | ||
3064 | &forward_request_task, | ||
3065 | pr); | ||
3066 | return; | ||
3067 | } | ||
3068 | /* consume cover traffic */ | ||
3069 | if (pr->anonymity_level > 1) | ||
3070 | cover_query_count -= pr->anonymity_level - 1; | ||
3071 | |||
3018 | /* (1) select target */ | 3072 | /* (1) select target */ |
3019 | psc.pr = pr; | 3073 | psc.pr = pr; |
3020 | psc.target_score = -DBL_MAX; | 3074 | psc.target_score = -DBL_MAX; |
@@ -3221,6 +3275,11 @@ struct ProcessReplyClosure | |||
3221 | uint32_t priority; | 3275 | uint32_t priority; |
3222 | 3276 | ||
3223 | /** | 3277 | /** |
3278 | * Anonymity requirements for this reply. | ||
3279 | */ | ||
3280 | uint32_t anonymity_level; | ||
3281 | |||
3282 | /** | ||
3224 | * Evaluation result (returned). | 3283 | * Evaluation result (returned). |
3225 | */ | 3284 | */ |
3226 | enum GNUNET_BLOCK_EvaluationResult eval; | 3285 | enum GNUNET_BLOCK_EvaluationResult eval; |
@@ -3264,6 +3323,22 @@ struct GNUNET_TIME_Relative art_delay; | |||
3264 | size_t msize; | 3323 | size_t msize; |
3265 | unsigned int i; | 3324 | unsigned int i; |
3266 | 3325 | ||
3326 | if (NULL == pr->client_request_list) | ||
3327 | { | ||
3328 | /* reply will go over the network, check for cover traffic */ | ||
3329 | if ( (prq->anonymity_level > 1) && | ||
3330 | (cover_content_count < prq->anonymity_level - 1) ) | ||
3331 | { | ||
3332 | /* insufficient cover traffic, skip */ | ||
3333 | GNUNET_STATISTICS_update (stats, | ||
3334 | gettext_noop ("# replies suppressed due to lack of cover traffic"), | ||
3335 | 1, | ||
3336 | GNUNET_NO); | ||
3337 | return GNUNET_YES; | ||
3338 | } | ||
3339 | if (prq->anonymity_level > 1) | ||
3340 | cover_content_count -= prq->anonymity_level - 1; | ||
3341 | } | ||
3267 | #if DEBUG_FS | 3342 | #if DEBUG_FS |
3268 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3343 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3269 | "Matched result (type %u) for query `%s' with pending request\n", | 3344 | "Matched result (type %u) for query `%s' with pending request\n", |
@@ -3603,6 +3678,7 @@ handle_p2p_put (void *cls, | |||
3603 | GNUNET_break_op (0); | 3678 | GNUNET_break_op (0); |
3604 | return GNUNET_SYSERR; | 3679 | return GNUNET_SYSERR; |
3605 | } | 3680 | } |
3681 | cover_content_count++; | ||
3606 | #if DEBUG_FS | 3682 | #if DEBUG_FS |
3607 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3683 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3608 | "Received result for query `%s' from peer `%4s'\n", | 3684 | "Received result for query `%s' from peer `%4s'\n", |
@@ -3624,6 +3700,7 @@ handle_p2p_put (void *cls, | |||
3624 | prq.type = type; | 3700 | prq.type = type; |
3625 | prq.expiration = expiration; | 3701 | prq.expiration = expiration; |
3626 | prq.priority = 0; | 3702 | prq.priority = 0; |
3703 | prq.anonymity_level = 1; | ||
3627 | prq.finished = GNUNET_NO; | 3704 | prq.finished = GNUNET_NO; |
3628 | prq.request_found = GNUNET_NO; | 3705 | prq.request_found = GNUNET_NO; |
3629 | GNUNET_CONTAINER_multihashmap_get_multiple (query_request_map, | 3706 | GNUNET_CONTAINER_multihashmap_get_multiple (query_request_map, |
@@ -3905,6 +3982,7 @@ process_local_reply (void *cls, | |||
3905 | prq.priority = priority; | 3982 | prq.priority = priority; |
3906 | prq.finished = GNUNET_NO; | 3983 | prq.finished = GNUNET_NO; |
3907 | prq.request_found = GNUNET_NO; | 3984 | prq.request_found = GNUNET_NO; |
3985 | prq.anonymity_level = anonymity; | ||
3908 | if ( (old_rf == 0) && | 3986 | if ( (old_rf == 0) && |
3909 | (pr->results_found == 0) ) | 3987 | (pr->results_found == 0) ) |
3910 | update_datastore_delays (pr->start_time); | 3988 | update_datastore_delays (pr->start_time); |
@@ -4100,6 +4178,7 @@ handle_p2p_get (void *cls, | |||
4100 | GNUNET_break_op (0); | 4178 | GNUNET_break_op (0); |
4101 | return GNUNET_SYSERR; | 4179 | return GNUNET_SYSERR; |
4102 | } | 4180 | } |
4181 | cover_query_count++; | ||
4103 | bm = ntohl (gm->hash_bitmap); | 4182 | bm = ntohl (gm->hash_bitmap); |
4104 | bits = 0; | 4183 | bits = 0; |
4105 | cps = GNUNET_CONTAINER_multihashmap_get (connected_peers, | 4184 | cps = GNUNET_CONTAINER_multihashmap_get (connected_peers, |
@@ -4625,6 +4704,9 @@ main_init (struct GNUNET_SERVER_Handle *server, | |||
4625 | 4704 | ||
4626 | 4705 | ||
4627 | GNUNET_SERVER_add_handlers (server, handlers); | 4706 | GNUNET_SERVER_add_handlers (server, handlers); |
4707 | cover_age_task = GNUNET_SCHEDULER_add_delayed (COVER_AGE_FREQUENCY, | ||
4708 | &age_cover_counters, | ||
4709 | NULL); | ||
4628 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 4710 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, |
4629 | &shutdown_task, | 4711 | &shutdown_task, |
4630 | NULL); | 4712 | NULL); |