aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2015-12-12 01:19:33 +0000
committerFlorian Dold <florian.dold@gmail.com>2015-12-12 01:19:33 +0000
commit0f90ccc7e083596607a0cee58173d9578642447f (patch)
tree4f78de5c5c25460652c8eaf1598e2e3a7d211614 /src
parent6735421b5aa576407844e37ce40da0e6583a7ab4 (diff)
Handle larger IBFs correctly.
Diffstat (limited to 'src')
-rw-r--r--src/set/gnunet-service-set_protocol.h9
-rw-r--r--src/set/gnunet-service-set_union.c27
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 b96ea08899..263d4b367a 100644
--- a/src/set/gnunet-service-set_protocol.h
+++ b/src/set/gnunet-service-set_protocol.h
@@ -80,12 +80,17 @@ struct IBFMessage
/**
* Padding, must be 0.
*/
- uint8_t reserved;
+ uint8_t reserved1;
+
+ /**
+ * Padding, must be 0.
+ */
+ uint16_t reserved2 GNUNET_PACKED;
/**
* Offset of the strata in the rest of the message
*/
- uint16_t offset GNUNET_PACKED;
+ uint32_t offset GNUNET_PACKED;
/**
* 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 af1aaeb81b..0a8826fb45 100644
--- a/src/set/gnunet-service-set_union.c
+++ b/src/set/gnunet-service-set_union.c
@@ -61,7 +61,7 @@
* Choose this value so that computing the IBF is still cheaper
* than transmitting all values.
*/
-#define MAX_IBF_ORDER (18)
+#define MAX_IBF_ORDER (20)
/**
* Number of buckets used in the ibf per estimated
@@ -614,9 +614,10 @@ send_ibf (struct Operation *op,
ev = GNUNET_MQ_msg_extra (msg,
buckets_in_message * IBF_BUCKET_SIZE,
GNUNET_MESSAGE_TYPE_SET_UNION_P2P_IBF);
- msg->reserved = 0;
+ msg->reserved1 = 0;
+ msg->reserved2 = 0;
msg->order = ibf_order;
- msg->offset = htons (buckets_sent);
+ msg->offset = htonl (buckets_sent);
msg->salt = htonl (op->state->salt_send);
ibf_write_slice (ibf, buckets_sent,
buckets_in_message, &msg[1]);
@@ -855,6 +856,7 @@ decode_and_send (struct Operation *op)
if (GNUNET_OK !=
prepare_ibf (op, op->state->remote_ibf->size))
{
+ GNUNET_break (0);
/* allocation failed */
return GNUNET_SYSERR;
}
@@ -1023,6 +1025,7 @@ handle_p2p_ibf (void *cls,
1 << msg->order);
op->state->remote_ibf = ibf_create (1<<msg->order, SE_IBF_HASH_NUM);
op->state->salt_receive = ntohl (msg->salt);
+ LOG (GNUNET_ERROR_TYPE_INFO, "Receiving new IBF with salt %u\n", op->state->salt_receive);
if (NULL == op->state->remote_ibf)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -1031,7 +1034,7 @@ handle_p2p_ibf (void *cls,
return GNUNET_SYSERR;
}
op->state->ibf_buckets_received = 0;
- if (0 != ntohs (msg->offset))
+ if (0 != ntohl (msg->offset))
{
GNUNET_break_op (0);
fail_union_operation (op);
@@ -1040,9 +1043,19 @@ handle_p2p_ibf (void *cls,
}
else if (op->state->phase == PHASE_EXPECT_IBF_CONT)
{
- if ( (ntohs (msg->offset) != op->state->ibf_buckets_received) ||
- (1<<msg->order != op->state->remote_ibf->size) ||
- (ntohl (msg->salt) != op->state->salt_receive))
+ if (ntohl (msg->offset) != op->state->ibf_buckets_received)
+ {
+ GNUNET_break_op (0);
+ fail_union_operation (op);
+ return GNUNET_SYSERR;
+ }
+ if (1<<msg->order != op->state->remote_ibf->size)
+ {
+ GNUNET_break_op (0);
+ fail_union_operation (op);
+ return GNUNET_SYSERR;
+ }
+ if (ntohl (msg->salt) != op->state->salt_receive)
{
GNUNET_break_op (0);
fail_union_operation (op);