sh->session_array_size * 2);
}
GNUNET_assert (f > 0);
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "ats-scheduling-api",
- "Session %p for peer `%s' stored in slot %u \n",
- session, GNUNET_i2s (peer), f);
sh->session_array[f].session = session;
sh->session_array[f].peer = *peer;
sh->session_array[f].slot_used = GNUNET_YES;
s = find_session_id (sh, session, &address->peer);
if (NOT_FOUND != s)
{
- /* Already existing */
- GNUNET_break (0);
+ /* Already existing, nothing todo */
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Adding duplicate address for peer `%s', plugin `%s', session %p id %u\n",
+ GNUNET_i2s (&address->peer),
+ address->transport_name, session, s);
return GNUNET_SYSERR;
}
s = find_empty_session_slot (sh, session, &address->peer);
{
s = find_session_id (sh, session, &address->peer);
if (NOT_FOUND == s)
- {
- /* new session without slot, find one */
- s = find_empty_session_slot (sh, session, &address->peer);
- GNUNET_break (NOT_FOUND != s);
+ GNUNET_break (0);
return;
- }
}
m->session_id = htonl (s);
return;
}
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Trying to set address to %s for peer `%s', plugin `%s', session %p\n",
GNUNET_i2s (&address->peer),
(GNUNET_NO == in_use) ? "NO" : "YES",
* Possible state of a neighbour. Initially, we are S_NOT_CONNECTED.
*
* Then, there are two main paths. If we receive a CONNECT message, we
- * first run a check against the blacklist and ask ATS for a
- * suggestion. (S_CONNECT_RECV_ATS). If the blacklist comes back
- * positive, we give the address to ATS. If ATS makes a suggestion,
- * we ALSO give that suggestion to the blacklist
+ * first run a check against the blacklist (S_CONNECT_RECV_BLACKLIST_INBOUND).
+ * If this check is successful, we give the inbound address to ATS.
+ * After the check we ask ATS for a suggestion (S_CONNECT_RECV_ATS).
+ * If ATS makes a suggestion, we ALSO give that suggestion to the blacklist
* (S_CONNECT_RECV_BLACKLIST). Once the blacklist approves the
* address we got from ATS, we send our CONNECT_ACK and go to
* S_CONNECT_RECV_ACK. If we receive a SESSION_ACK, we go to
*/
S_CONNECT_SENT,
+ /**
+ * Received a CONNECT, do a blacklist check for inbound address
+ */
+ S_CONNECT_RECV_BLACKLIST_INBOUND,
+
/**
* Received a CONNECT, asking ATS about address suggestions.
*/
case S_CONNECT_SENT:
return "S_CONNECT_SENT";
break;
+ case S_CONNECT_RECV_BLACKLIST_INBOUND:
+ return "S_CONNECT_RECV_BLACKLIST_INBOUND";
+ break;
case S_CONNECT_RECV_ATS:
return "S_CONNECT_RECV_ATS";
break;
if (GNUNET_YES == is_active)
{
/* Telling ATS about new session */
- GNUNET_ATS_address_add (GST_ats, na->address, na->session, NULL, 0);
GNUNET_ATS_address_in_use (GST_ats, na->address, na->session, GNUNET_YES);
GST_validation_set_address_use (na->address, na->session, GNUNET_YES, __LINE__);
"Connection to new address of peer `%s' based on blacklist is `%s'\n",
GNUNET_i2s (peer),
(GNUNET_OK == result) ? "allowed" : "FORBIDDEN");
- if (GNUNET_OK == result)
- {
- /* valid new address, let ATS know! */
- GNUNET_ATS_address_add (GST_ats,
- bcc->na.address,
- bcc->na.session,
- bcc->ats, bcc->ats_count);
- }
if (NULL == (n = lookup_neighbour (peer)))
goto cleanup; /* nobody left to care about new address */
switch (n->state)
n->connect_ack_timestamp);
}
break;
+ case S_CONNECT_RECV_BLACKLIST_INBOUND:
+ if (GNUNET_OK == result)
+ {
+ /* valid new address, let ATS know! */
+ GNUNET_ATS_address_add (GST_ats,
+ bcc->na.address,
+ bcc->na.session,
+ bcc->ats, bcc->ats_count);
+ }
+ n->state = S_CONNECT_RECV_ATS;
+ n->timeout = GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT);
+ GNUNET_ATS_reset_backoff (GST_ats, peer);
+ GNUNET_ATS_suggest_address (GST_ats, peer);
+ break;
case S_CONNECT_RECV_ATS:
/* still waiting on ATS suggestion, don't care about blacklist */
- break;
+ break;
case S_CONNECT_RECV_BLACKLIST:
if (GNUNET_YES != address_matches (&bcc->na, &n->primary_address))
break; /* result for an address we currently don't care about */
switch (n->state)
{
case S_NOT_CONNECTED:
- n->state = S_CONNECT_RECV_ATS;
- n->timeout = GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT);
- GNUNET_ATS_reset_backoff (GST_ats, peer);
- GNUNET_ATS_suggest_address (GST_ats, peer);
+ n->state = S_CONNECT_RECV_BLACKLIST_INBOUND;
+ /* Do a blacklist check for the new address */
check_blacklist (peer, ts, address, session, ats, ats_count);
break;
case S_INIT_ATS:
return;
}
break;
+ case S_CONNECT_RECV_BLACKLIST_INBOUND:
+ if (0 == delay.rel_value)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Connection to `%s' timed out waiting BLACKLIST to approve address to use for received CONNECT\n",
+ GNUNET_i2s (&n->id));
+ n->state = S_DISCONNECT_FINISHED;
+ free_neighbour (n, GNUNET_NO);
+ return;
+ }
+ break;
case S_CONNECT_RECV_ATS:
if (0 == delay.rel_value)
{