[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r35359 - in gnunet/src: core include transport util
From: |
gnunet |
Subject: |
[GNUnet-SVN] r35359 - in gnunet/src: core include transport util |
Date: |
Sun, 8 Mar 2015 15:33:43 +0100 |
Author: grothoff
Date: 2015-03-08 15:33:42 +0100 (Sun, 08 Mar 2015)
New Revision: 35359
Modified:
gnunet/src/core/gnunet-service-core_kx.c
gnunet/src/core/gnunet-service-core_neighbours.c
gnunet/src/include/gnunet_bandwidth_lib.h
gnunet/src/transport/gnunet-service-transport_neighbours.c
gnunet/src/transport/gnunet-service-transport_validation.c
gnunet/src/util/bandwidth.c
Log:
-always assume at least MIN bandwidth, even if we got no quota or a quota lower
than min
Modified: gnunet/src/core/gnunet-service-core_kx.c
===================================================================
--- gnunet/src/core/gnunet-service-core_kx.c 2015-03-08 13:11:48 UTC (rev
35358)
+++ gnunet/src/core/gnunet-service-core_kx.c 2015-03-08 14:33:42 UTC (rev
35359)
@@ -716,7 +716,8 @@
"Initiating key exchange with `%s'\n",
GNUNET_i2s (pid));
GNUNET_STATISTICS_update (GSC_stats,
- gettext_noop ("# key exchanges initiated"), 1,
+ gettext_noop ("# key exchanges initiated"),
+ 1,
GNUNET_NO);
kx = GNUNET_new (struct GSC_KeyExchangeInfo);
kx->peer = *pid;
@@ -745,7 +746,8 @@
/* peer with "higher" identity starts a delayed KX, if the "lower" peer
* does not start a KX since he sees no reasons to do so */
kx->retry_set_key_task = GNUNET_SCHEDULER_add_delayed
(GNUNET_TIME_UNIT_SECONDS,
-
&set_key_retry_task, kx);
+ &set_key_retry_task,
+ kx);
}
return kx;
}
@@ -795,7 +797,7 @@
GNUNET_NO);
GSC_NEIGHBOURS_transmit (&kx->peer,
&kx->ping.header,
- MIN_PING_FREQUENCY);
+ kx->set_key_retry_frequency);
}
@@ -1024,7 +1026,8 @@
return;
}
GNUNET_STATISTICS_update (GSC_stats,
- gettext_noop ("# PING messages received"), 1,
+ gettext_noop ("# PING messages received"),
+ 1,
GNUNET_NO);
if ( (kx->status != GNUNET_CORE_KX_STATE_KEY_RECEIVED) &&
(kx->status != GNUNET_CORE_KX_STATE_UP) &&
@@ -1032,7 +1035,8 @@
{
/* ignore */
GNUNET_STATISTICS_update (GSC_stats,
- gettext_noop ("# PING messages dropped (out of
order)"), 1,
+ gettext_noop ("# PING messages dropped (out of
order)"),
+ 1,
GNUNET_NO);
return;
}
@@ -1166,12 +1170,14 @@
are bigger than the threshold (5s) */
monitor_notify_all (kx);
}
- if (kx->keep_alive_task != NULL)
+ if (NULL != kx->keep_alive_task)
GNUNET_SCHEDULER_cancel (kx->keep_alive_task);
kx->keep_alive_task =
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide
(GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
- 2), &send_keep_alive, kx);
+ 2),
+ &send_keep_alive,
+ kx);
}
@@ -1197,7 +1203,8 @@
return;
}
GNUNET_STATISTICS_update (GSC_stats,
- gettext_noop ("# PONG messages received"), 1,
+ gettext_noop ("# PONG messages received"),
+ 1,
GNUNET_NO);
switch (kx->status)
{
@@ -1227,10 +1234,16 @@
GNUNET_i2s (&kx->peer));
/* mark as garbage, just to be sure */
memset (&t, 255, sizeof (t));
- derive_pong_iv (&iv, &kx->decrypt_key, m->iv_seed, kx->ping_challenge,
+ derive_pong_iv (&iv,
+ &kx->decrypt_key,
+ m->iv_seed,
+ kx->ping_challenge,
&GSC_my_identity);
if (GNUNET_OK !=
- do_decrypt (kx, &iv, &m->challenge, &t.challenge,
+ do_decrypt (kx,
+ &iv,
+ &m->challenge,
+ &t.challenge,
sizeof (struct PongMessage) - ((void *) &m->challenge -
(void *) m)))
{
@@ -1238,19 +1251,23 @@
return;
}
GNUNET_STATISTICS_update (GSC_stats,
- gettext_noop ("# PONG messages decrypted"), 1,
+ gettext_noop ("# PONG messages decrypted"),
+ 1,
GNUNET_NO);
- if ((0 != memcmp (&t.target, &kx->peer, sizeof (struct GNUNET_PeerIdentity)))
- || (kx->ping_challenge != t.challenge))
+ if ((0 != memcmp (&t.target,
+ &kx->peer,
+ sizeof (struct GNUNET_PeerIdentity))) ||
+ (kx->ping_challenge != t.challenge))
{
/* PONG malformed */
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received malformed `%s' wanted sender `%s' with challenge
%u\n",
- "PONG", GNUNET_i2s (&kx->peer),
+ "Received malformed PONG wanted sender `%s' with challenge
%u\n",
+ GNUNET_i2s (&kx->peer),
(unsigned int) kx->ping_challenge);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received malformed `%s' received from `%s' with challenge
%u\n",
- "PONG", GNUNET_i2s (&t.target), (unsigned int) t.challenge);
+ "Received malformed PONG received from `%s' with challenge
%u\n",
+ GNUNET_i2s (&t.target),
+ (unsigned int) t.challenge);
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1272,8 +1289,8 @@
return;
case GNUNET_CORE_KX_STATE_KEY_RECEIVED:
GNUNET_STATISTICS_update (GSC_stats,
- gettext_noop
- ("# session keys confirmed via PONG"), 1,
+ gettext_noop ("# session keys confirmed via
PONG"),
+ 1,
GNUNET_NO);
kx->status = GNUNET_CORE_KX_STATE_UP;
monitor_notify_all (kx);
@@ -1283,15 +1300,15 @@
break;
case GNUNET_CORE_KX_STATE_UP:
GNUNET_STATISTICS_update (GSC_stats,
- gettext_noop
- ("# timeouts prevented via PONG"), 1,
+ gettext_noop ("# timeouts prevented via PONG"),
+ 1,
GNUNET_NO);
update_timeout (kx);
break;
case GNUNET_CORE_KX_STATE_REKEY_SENT:
GNUNET_STATISTICS_update (GSC_stats,
- gettext_noop
- ("# rekey operations confirmed via PONG"), 1,
+ gettext_noop ("# rekey operations confirmed via
PONG"),
+ 1,
GNUNET_NO);
kx->status = GNUNET_CORE_KX_STATE_UP;
monitor_notify_all (kx);
@@ -1331,7 +1348,8 @@
send_ping (kx);
kx->retry_set_key_task =
GNUNET_SCHEDULER_add_delayed (kx->set_key_retry_frequency,
- &set_key_retry_task, kx);
+ &set_key_retry_task,
+ kx);
}
@@ -1434,9 +1452,9 @@
if (GNUNET_CORE_KX_STATE_UP != kx->status)
{
GNUNET_STATISTICS_update (GSC_stats,
- gettext_noop
- ("# DATA message dropped (out of order)"),
- 1, GNUNET_NO);
+ gettext_noop ("# DATA message dropped (out of
order)"),
+ 1,
+ GNUNET_NO);
return;
}
if (0 == GNUNET_TIME_absolute_get_remaining
(kx->foreign_key_expires).rel_value_us)
@@ -1460,10 +1478,16 @@
}
/* validate hash */
- derive_auth_key (&auth_key, &kx->decrypt_key, m->iv_seed);
- GNUNET_CRYPTO_hmac (&auth_key, &m->sequence_number,
- size - ENCRYPTED_HEADER_SIZE, &ph);
- if (0 != memcmp (&ph, &m->hmac, sizeof (struct GNUNET_HashCode)))
+ derive_auth_key (&auth_key,
+ &kx->decrypt_key,
+ m->iv_seed);
+ GNUNET_CRYPTO_hmac (&auth_key,
+ &m->sequence_number,
+ size - ENCRYPTED_HEADER_SIZE,
+ &ph);
+ if (0 != memcmp (&ph,
+ &m->hmac,
+ sizeof (struct GNUNET_HashCode)))
{
/* checksum failed */
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1471,10 +1495,16 @@
GNUNET_i2s (&kx->peer));
return;
}
- derive_iv (&iv, &kx->decrypt_key, m->iv_seed, &GSC_my_identity);
+ derive_iv (&iv,
+ &kx->decrypt_key,
+ m->iv_seed,
+ &GSC_my_identity);
/* decrypt */
if (GNUNET_OK !=
- do_decrypt (kx, &iv, &m->sequence_number, &buf[ENCRYPTED_HEADER_SIZE],
+ do_decrypt (kx,
+ &iv,
+ &m->sequence_number,
+ &buf[ENCRYPTED_HEADER_SIZE],
size - ENCRYPTED_HEADER_SIZE))
return;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1492,7 +1522,8 @@
/* duplicate, ignore */
GNUNET_STATISTICS_update (GSC_stats,
gettext_noop ("# bytes dropped (duplicates)"),
- size, GNUNET_NO);
+ size,
+ GNUNET_NO);
return;
}
if ((kx->last_sequence_number_received > snum) &&
@@ -1587,9 +1618,9 @@
if (GNUNET_CORE_KX_STATE_UP != dmc->kx->status)
{
GNUNET_STATISTICS_update (GSC_stats,
- gettext_noop
- ("# PAYLOAD dropped (out of order)"),
- 1, GNUNET_NO);
+ gettext_noop ("# PAYLOAD dropped (out of
order)"),
+ 1,
+ GNUNET_NO);
return GNUNET_OK;
}
switch (ntohs (m->type))
Modified: gnunet/src/core/gnunet-service-core_neighbours.c
===================================================================
--- gnunet/src/core/gnunet-service-core_neighbours.c 2015-03-08 13:11:48 UTC
(rev 35358)
+++ gnunet/src/core/gnunet-service-core_neighbours.c 2015-03-08 14:33:42 UTC
(rev 35359)
@@ -457,8 +457,12 @@
me = GNUNET_malloc (sizeof (struct NeighbourMessageEntry) + msize);
me->deadline = GNUNET_TIME_relative_to_absolute (timeout);
me->size = msize;
- memcpy (&me[1], msg, msize);
- GNUNET_CONTAINER_DLL_insert_tail (n->message_head, n->message_tail, me);
+ memcpy (&me[1],
+ msg,
+ msize);
+ GNUNET_CONTAINER_DLL_insert_tail (n->message_head,
+ n->message_tail,
+ me);
process_queue (n);
}
Modified: gnunet/src/include/gnunet_bandwidth_lib.h
===================================================================
--- gnunet/src/include/gnunet_bandwidth_lib.h 2015-03-08 13:11:48 UTC (rev
35358)
+++ gnunet/src/include/gnunet_bandwidth_lib.h 2015-03-08 14:33:42 UTC (rev
35359)
@@ -195,17 +195,29 @@
/**
+ * Compute the MAX of two bandwidth values.
+ *
+ * @param b1 first value
+ * @param b2 second value
+ * @return the min of b1 and b2
+ */
+struct GNUNET_BANDWIDTH_Value32NBO
+GNUNET_BANDWIDTH_value_max (struct GNUNET_BANDWIDTH_Value32NBO b1,
+ struct GNUNET_BANDWIDTH_Value32NBO b2);
+
+
+/**
* Initialize bandwidth tracker. Note that in addition to the
* 'max_carry_s' limit, we also always allow at least
- * GNUNET_SERVER_MAX_MESSAGE_SIZE to accumulate. So if the
+ * #GNUNET_SERVER_MAX_MESSAGE_SIZE to accumulate. So if the
* bytes-per-second limit is so small that within 'max_carry_s' not
- * even GNUNET_SERVER_MAX_MESSAGE_SIZE is allowed to accumulate, it is
- * ignored and replaced by GNUNET_SERVER_MAX_MESSAGE_SIZE (which is in
+ * even #GNUNET_SERVER_MAX_MESSAGE_SIZE is allowed to accumulate, it is
+ * ignored and replaced by #GNUNET_SERVER_MAX_MESSAGE_SIZE (which is in
* bytes).
*
* @param av tracker to initialize
* @param update_cb callback to notify a client about the tracker being updated
- * @param update_cb_cls cls for the callback
+ * @param update_cb_cls cls for the @a update_cb callback
* @param bytes_per_second_limit initial limit to assume
* @param max_carry_s maximum number of seconds unused bandwidth
* may accumulate before it expires
Modified: gnunet/src/transport/gnunet-service-transport_neighbours.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_neighbours.c 2015-03-08
13:11:48 UTC (rev 35358)
+++ gnunet/src/transport/gnunet-service-transport_neighbours.c 2015-03-08
14:33:42 UTC (rev 35359)
@@ -2140,6 +2140,7 @@
n->id = *peer;
n->ack_state = ACK_UNDEFINED;
n->last_util_transmission = GNUNET_TIME_absolute_get();
+ n->neighbour_receive_quota = GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT;
GNUNET_BANDWIDTH_tracker_init (&n->in_tracker,
&inbound_bw_tracker_update,
n,
@@ -3661,7 +3662,9 @@
/* gone already */
return;
}
- n->neighbour_receive_quota = GNUNET_BANDWIDTH_value_init (ntohl
(sqm->quota));
+ n->neighbour_receive_quota
+ = GNUNET_BANDWIDTH_value_max (GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT,
+ GNUNET_BANDWIDTH_value_init (ntohl
(sqm->quota)));
bandwidth_min = GNUNET_BANDWIDTH_value_min (n->primary_address.bandwidth_out,
n->neighbour_receive_quota);
Modified: gnunet/src/transport/gnunet-service-transport_validation.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_validation.c 2015-03-08
13:11:48 UTC (rev 35358)
+++ gnunet/src/transport/gnunet-service-transport_validation.c 2015-03-08
14:33:42 UTC (rev 35359)
@@ -1524,10 +1524,10 @@
/* build HELLO to store in PEERINFO */
ve->copied = GNUNET_NO;
hello = GNUNET_HELLO_create (&ve->address->peer.public_key,
- &add_valid_peer_address,
+ &add_valid_peer_address,
ve,
GNUNET_NO);
- GNUNET_PEERINFO_add_peer (GST_peerinfo,
+ GNUNET_PEERINFO_add_peer (GST_peerinfo,
hello,
NULL,
NULL);
@@ -1549,7 +1549,6 @@
const struct GNUNET_HELLO_Message *hm =
(const struct GNUNET_HELLO_Message *) hello;
struct GNUNET_PeerIdentity pid;
- struct GNUNET_HELLO_Message *h;
int friend;
friend = GNUNET_HELLO_is_friend_only (hm);
Modified: gnunet/src/util/bandwidth.c
===================================================================
--- gnunet/src/util/bandwidth.c 2015-03-08 13:11:48 UTC (rev 35358)
+++ gnunet/src/util/bandwidth.c 2015-03-08 14:33:42 UTC (rev 35359)
@@ -61,11 +61,30 @@
{
return
GNUNET_BANDWIDTH_value_init (GNUNET_MIN
- (ntohl (b1.value__), ntohl (b2.value__)));
+ (ntohl (b1.value__),
+ ntohl (b2.value__)));
}
/**
+ * Compute the MAX of two bandwidth values.
+ *
+ * @param b1 first value
+ * @param b2 second value
+ * @return the min of b1 and b2
+ */
+struct GNUNET_BANDWIDTH_Value32NBO
+GNUNET_BANDWIDTH_value_max (struct GNUNET_BANDWIDTH_Value32NBO b1,
+ struct GNUNET_BANDWIDTH_Value32NBO b2)
+{
+ return
+ GNUNET_BANDWIDTH_value_init (GNUNET_MAX
+ (ntohl (b1.value__),
+ ntohl (b2.value__)));
+}
+
+
+/**
* At the given bandwidth, calculate how much traffic will be
* available until the given deadline.
*
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r35359 - in gnunet/src: core include transport util,
gnunet <=