diff options
author | Florian Dold <florian.dold@gmail.com> | 2015-12-12 01:19:33 +0000 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2015-12-12 01:19:33 +0000 |
commit | 0f90ccc7e083596607a0cee58173d9578642447f (patch) | |
tree | 4f78de5c5c25460652c8eaf1598e2e3a7d211614 /src/set | |
parent | 6735421b5aa576407844e37ce40da0e6583a7ab4 (diff) | |
download | gnunet-0f90ccc7e083596607a0cee58173d9578642447f.tar.gz gnunet-0f90ccc7e083596607a0cee58173d9578642447f.zip |
Handle larger IBFs correctly.
Diffstat (limited to 'src/set')
-rw-r--r-- | src/set/gnunet-service-set_protocol.h | 9 | ||||
-rw-r--r-- | src/set/gnunet-service-set_union.c | 27 |
2 files changed, 27 insertions, 9 deletions
diff --git a/src/set/gnunet-service-set_protocol.h b/src/set/gnunet-service-set_protocol.h index b96ea0889..263d4b367 100644 --- a/src/set/gnunet-service-set_protocol.h +++ b/src/set/gnunet-service-set_protocol.h | |||
@@ -80,12 +80,17 @@ struct IBFMessage | |||
80 | /** | 80 | /** |
81 | * Padding, must be 0. | 81 | * Padding, must be 0. |
82 | */ | 82 | */ |
83 | uint8_t reserved; | 83 | uint8_t reserved1; |
84 | |||
85 | /** | ||
86 | * Padding, must be 0. | ||
87 | */ | ||
88 | uint16_t reserved2 GNUNET_PACKED; | ||
84 | 89 | ||
85 | /** | 90 | /** |
86 | * Offset of the strata in the rest of the message | 91 | * Offset of the strata in the rest of the message |
87 | */ | 92 | */ |
88 | uint16_t offset GNUNET_PACKED; | 93 | uint32_t offset GNUNET_PACKED; |
89 | 94 | ||
90 | /** | 95 | /** |
91 | * Salt used when hashing elements for this IBF. | 96 | * Salt used when hashing elements for this IBF. |
diff --git a/src/set/gnunet-service-set_union.c b/src/set/gnunet-service-set_union.c index af1aaeb81..0a8826fb4 100644 --- a/src/set/gnunet-service-set_union.c +++ b/src/set/gnunet-service-set_union.c | |||
@@ -61,7 +61,7 @@ | |||
61 | * Choose this value so that computing the IBF is still cheaper | 61 | * Choose this value so that computing the IBF is still cheaper |
62 | * than transmitting all values. | 62 | * than transmitting all values. |
63 | */ | 63 | */ |
64 | #define MAX_IBF_ORDER (18) | 64 | #define MAX_IBF_ORDER (20) |
65 | 65 | ||
66 | /** | 66 | /** |
67 | * Number of buckets used in the ibf per estimated | 67 | * Number of buckets used in the ibf per estimated |
@@ -614,9 +614,10 @@ send_ibf (struct Operation *op, | |||
614 | ev = GNUNET_MQ_msg_extra (msg, | 614 | ev = GNUNET_MQ_msg_extra (msg, |
615 | buckets_in_message * IBF_BUCKET_SIZE, | 615 | buckets_in_message * IBF_BUCKET_SIZE, |
616 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_IBF); | 616 | GNUNET_MESSAGE_TYPE_SET_UNION_P2P_IBF); |
617 | msg->reserved = 0; | 617 | msg->reserved1 = 0; |
618 | msg->reserved2 = 0; | ||
618 | msg->order = ibf_order; | 619 | msg->order = ibf_order; |
619 | msg->offset = htons (buckets_sent); | 620 | msg->offset = htonl (buckets_sent); |
620 | msg->salt = htonl (op->state->salt_send); | 621 | msg->salt = htonl (op->state->salt_send); |
621 | ibf_write_slice (ibf, buckets_sent, | 622 | ibf_write_slice (ibf, buckets_sent, |
622 | buckets_in_message, &msg[1]); | 623 | buckets_in_message, &msg[1]); |
@@ -855,6 +856,7 @@ decode_and_send (struct Operation *op) | |||
855 | if (GNUNET_OK != | 856 | if (GNUNET_OK != |
856 | prepare_ibf (op, op->state->remote_ibf->size)) | 857 | prepare_ibf (op, op->state->remote_ibf->size)) |
857 | { | 858 | { |
859 | GNUNET_break (0); | ||
858 | /* allocation failed */ | 860 | /* allocation failed */ |
859 | return GNUNET_SYSERR; | 861 | return GNUNET_SYSERR; |
860 | } | 862 | } |
@@ -1023,6 +1025,7 @@ handle_p2p_ibf (void *cls, | |||
1023 | 1 << msg->order); | 1025 | 1 << msg->order); |
1024 | op->state->remote_ibf = ibf_create (1<<msg->order, SE_IBF_HASH_NUM); | 1026 | op->state->remote_ibf = ibf_create (1<<msg->order, SE_IBF_HASH_NUM); |
1025 | op->state->salt_receive = ntohl (msg->salt); | 1027 | op->state->salt_receive = ntohl (msg->salt); |
1028 | LOG (GNUNET_ERROR_TYPE_INFO, "Receiving new IBF with salt %u\n", op->state->salt_receive); | ||
1026 | if (NULL == op->state->remote_ibf) | 1029 | if (NULL == op->state->remote_ibf) |
1027 | { | 1030 | { |
1028 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1031 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -1031,7 +1034,7 @@ handle_p2p_ibf (void *cls, | |||
1031 | return GNUNET_SYSERR; | 1034 | return GNUNET_SYSERR; |
1032 | } | 1035 | } |
1033 | op->state->ibf_buckets_received = 0; | 1036 | op->state->ibf_buckets_received = 0; |
1034 | if (0 != ntohs (msg->offset)) | 1037 | if (0 != ntohl (msg->offset)) |
1035 | { | 1038 | { |
1036 | GNUNET_break_op (0); | 1039 | GNUNET_break_op (0); |
1037 | fail_union_operation (op); | 1040 | fail_union_operation (op); |
@@ -1040,9 +1043,19 @@ handle_p2p_ibf (void *cls, | |||
1040 | } | 1043 | } |
1041 | else if (op->state->phase == PHASE_EXPECT_IBF_CONT) | 1044 | else if (op->state->phase == PHASE_EXPECT_IBF_CONT) |
1042 | { | 1045 | { |
1043 | if ( (ntohs (msg->offset) != op->state->ibf_buckets_received) || | 1046 | if (ntohl (msg->offset) != op->state->ibf_buckets_received) |
1044 | (1<<msg->order != op->state->remote_ibf->size) || | 1047 | { |
1045 | (ntohl (msg->salt) != op->state->salt_receive)) | 1048 | GNUNET_break_op (0); |
1049 | fail_union_operation (op); | ||
1050 | return GNUNET_SYSERR; | ||
1051 | } | ||
1052 | if (1<<msg->order != op->state->remote_ibf->size) | ||
1053 | { | ||
1054 | GNUNET_break_op (0); | ||
1055 | fail_union_operation (op); | ||
1056 | return GNUNET_SYSERR; | ||
1057 | } | ||
1058 | if (ntohl (msg->salt) != op->state->salt_receive) | ||
1046 | { | 1059 | { |
1047 | GNUNET_break_op (0); | 1060 | GNUNET_break_op (0); |
1048 | fail_union_operation (op); | 1061 | fail_union_operation (op); |