Implemented link padding and receiver token buckets
Each socket reads at most 'bandwidth' bytes per second sustained, but
can handle bursts of up to 10*bandwidth bytes.
Cells are now sent out at evenly-spaced intervals, with padding sent
out otherwise. Set Linkpadding=0 in the rc file to send cells as soon
as they're available (and to never send padding cells).
Added license/copyrights statements at the top of most files.
router->min and router->max have been merged into a single 'bandwidth'
value. We should make the routerinfo_t reflect this (want to do that,
Mat?)
As the bandwidth increases, and we want to stop sleeping more and more
frequently to send a single cell, cpu usage goes up. At 128kB/s we're
pretty much calling poll with a timeout of 1ms or even 0ms. The current
code takes a timeout of 0-9ms and makes it 10ms. prepare_for_poll()
handles everything that should have happened in the past, so as long as
our buffers don't get too full in that 10ms, we're ok.
Speaking of too full, if you run three servers at 100kB/s with -l debug,
it spends too much time printing debugging messages to be able to keep
up with the cells. The outbuf ultimately fills up and it kills that
connection. If you run with -l err, it works fine up through 500kB/s and
probably beyond. Down the road we'll want to teach it to recognize when
an outbuf is getting full, and back off.
svn:r50
2002-07-16 03:12:15 +02:00
|
|
|
/* Copyright 2001,2002 Roger Dingledine, Matej Pfajfar. */
|
|
|
|
/* See LICENSE for licensing information */
|
|
|
|
/* $Id$ */
|
2002-06-27 00:45:49 +02:00
|
|
|
|
|
|
|
#include "or.h"
|
|
|
|
|
2002-11-23 09:49:03 +01:00
|
|
|
extern or_options_t options; /* command-line and config-file options */
|
|
|
|
|
2002-11-24 09:45:54 +01:00
|
|
|
void command_time_process_cell(cell_t *cell, connection_t *conn,
|
|
|
|
int *num, int *time,
|
|
|
|
void (*func)(cell_t *, connection_t *)) {
|
|
|
|
struct timeval start, end;
|
2003-04-17 01:21:44 +02:00
|
|
|
long time_passed;
|
2002-11-24 09:45:54 +01:00
|
|
|
|
|
|
|
*num += 1;
|
|
|
|
|
2003-04-16 19:04:58 +02:00
|
|
|
my_gettimeofday(&start);
|
2002-11-24 09:45:54 +01:00
|
|
|
|
|
|
|
(*func)(cell, conn);
|
|
|
|
|
2003-04-16 19:04:58 +02:00
|
|
|
my_gettimeofday(&end);
|
|
|
|
time_passed = tv_udiff(&start, &end) ;
|
2002-11-24 09:45:54 +01:00
|
|
|
|
2003-04-16 19:04:58 +02:00
|
|
|
if (time_passed > 5000) { /* more than 5ms */
|
2002-11-24 09:45:54 +01:00
|
|
|
log(LOG_INFO,"command_time_process_cell(): That call just took %d ms.",time_passed/1000);
|
|
|
|
}
|
|
|
|
*time += time_passed;
|
|
|
|
}
|
|
|
|
|
2002-06-27 00:45:49 +02:00
|
|
|
void command_process_cell(cell_t *cell, connection_t *conn) {
|
major overhaul: dns slave subsystem, topics
on startup, it forks off a master dns handler, which forks off dns
slaves (like the apache model). slaves as spawned as load increases,
and then reused. excess slaves are not ever killed, currently.
implemented topics. each topic has a receive window in each direction
at each edge of the circuit, and sends sendme's at the data level, as
per before. each circuit also has receive windows in each direction at
each hop; an edge sends a circuit-level sendme as soon as enough data
cells have arrived (regardless of whether the data cells were flushed
to the exit conns). removed the 'connected' cell type, since it's now
a topic command within data cells.
at the edge of the circuit, there can be multiple connections associated
with a single circuit. you find them via the linked list conn->next_topic.
currently each new ap connection starts its own circuit, so we ought
to see comparable performance to what we had before. but that's only
because i haven't written the code to reattach to old circuits. please
try to break it as-is, and then i'll make it reuse the same circuit and
we'll try to break that.
svn:r152
2003-01-26 10:02:24 +01:00
|
|
|
static int num_create=0, num_data=0, num_destroy=0, num_sendme=0;
|
|
|
|
static int create_time=0, data_time=0, destroy_time=0, sendme_time=0;
|
2002-11-24 09:45:54 +01:00
|
|
|
static long current_second = 0; /* from previous calls to gettimeofday */
|
|
|
|
struct timeval now;
|
|
|
|
|
2003-04-16 19:04:58 +02:00
|
|
|
my_gettimeofday(&now);
|
2002-11-24 09:45:54 +01:00
|
|
|
|
|
|
|
if(now.tv_sec > current_second) { /* the second has rolled over */
|
|
|
|
/* print stats */
|
|
|
|
log(LOG_INFO,"At end of second:");
|
|
|
|
log(LOG_INFO,"Create: %d (%d ms)", num_create, create_time/1000);
|
|
|
|
log(LOG_INFO,"Data: %d (%d ms)", num_data, data_time/1000);
|
|
|
|
log(LOG_INFO,"Destroy: %d (%d ms)", num_destroy, destroy_time/1000);
|
|
|
|
log(LOG_INFO,"Sendme: %d (%d ms)", num_sendme, sendme_time/1000);
|
|
|
|
|
|
|
|
/* zero out stats */
|
major overhaul: dns slave subsystem, topics
on startup, it forks off a master dns handler, which forks off dns
slaves (like the apache model). slaves as spawned as load increases,
and then reused. excess slaves are not ever killed, currently.
implemented topics. each topic has a receive window in each direction
at each edge of the circuit, and sends sendme's at the data level, as
per before. each circuit also has receive windows in each direction at
each hop; an edge sends a circuit-level sendme as soon as enough data
cells have arrived (regardless of whether the data cells were flushed
to the exit conns). removed the 'connected' cell type, since it's now
a topic command within data cells.
at the edge of the circuit, there can be multiple connections associated
with a single circuit. you find them via the linked list conn->next_topic.
currently each new ap connection starts its own circuit, so we ought
to see comparable performance to what we had before. but that's only
because i haven't written the code to reattach to old circuits. please
try to break it as-is, and then i'll make it reuse the same circuit and
we'll try to break that.
svn:r152
2003-01-26 10:02:24 +01:00
|
|
|
num_create = num_data = num_destroy = num_sendme = 0;
|
|
|
|
create_time = data_time = destroy_time = sendme_time = 0;
|
2002-11-24 09:45:54 +01:00
|
|
|
|
|
|
|
/* remember which second it is, for next time */
|
|
|
|
current_second = now.tv_sec;
|
|
|
|
}
|
2002-06-27 00:45:49 +02:00
|
|
|
|
|
|
|
switch(cell->command) {
|
|
|
|
case CELL_PADDING:
|
|
|
|
/* do nothing */
|
|
|
|
break;
|
|
|
|
case CELL_CREATE:
|
2002-11-24 09:45:54 +01:00
|
|
|
command_time_process_cell(cell, conn, &num_create, &create_time,
|
|
|
|
command_process_create_cell);
|
2002-06-27 00:45:49 +02:00
|
|
|
break;
|
|
|
|
case CELL_DATA:
|
2002-11-24 09:45:54 +01:00
|
|
|
command_time_process_cell(cell, conn, &num_data, &data_time,
|
|
|
|
command_process_data_cell);
|
2002-06-27 00:45:49 +02:00
|
|
|
break;
|
|
|
|
case CELL_DESTROY:
|
2002-11-24 09:45:54 +01:00
|
|
|
command_time_process_cell(cell, conn, &num_destroy, &destroy_time,
|
|
|
|
command_process_destroy_cell);
|
2002-06-27 00:45:49 +02:00
|
|
|
break;
|
2002-07-18 08:37:58 +02:00
|
|
|
case CELL_SENDME:
|
2002-11-24 09:45:54 +01:00
|
|
|
command_time_process_cell(cell, conn, &num_sendme, &sendme_time,
|
|
|
|
command_process_sendme_cell);
|
2002-07-18 08:37:58 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
log(LOG_DEBUG,"Cell of unknown type (%d) received. Dropping.", cell->command);
|
|
|
|
break;
|
2002-06-27 00:45:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void command_process_create_cell(cell_t *cell, connection_t *conn) {
|
|
|
|
circuit_t *circ;
|
|
|
|
|
|
|
|
circ = circuit_get_by_aci_conn(cell->aci, conn);
|
|
|
|
|
2002-11-27 05:08:20 +01:00
|
|
|
if(circ && circ->state != CIRCUIT_STATE_ONION_WAIT) {
|
|
|
|
log(LOG_DEBUG,"command_process_create_cell(): received CREATE cell, not in onion_wait. Dropping.");
|
2002-06-27 00:45:49 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!circ) { /* if it's not there, create it */
|
|
|
|
circ = circuit_new(cell->aci, conn);
|
2002-11-27 05:08:20 +01:00
|
|
|
circ->state = CIRCUIT_STATE_ONION_WAIT;
|
Implemented link padding and receiver token buckets
Each socket reads at most 'bandwidth' bytes per second sustained, but
can handle bursts of up to 10*bandwidth bytes.
Cells are now sent out at evenly-spaced intervals, with padding sent
out otherwise. Set Linkpadding=0 in the rc file to send cells as soon
as they're available (and to never send padding cells).
Added license/copyrights statements at the top of most files.
router->min and router->max have been merged into a single 'bandwidth'
value. We should make the routerinfo_t reflect this (want to do that,
Mat?)
As the bandwidth increases, and we want to stop sleeping more and more
frequently to send a single cell, cpu usage goes up. At 128kB/s we're
pretty much calling poll with a timeout of 1ms or even 0ms. The current
code takes a timeout of 0-9ms and makes it 10ms. prepare_for_poll()
handles everything that should have happened in the past, so as long as
our buffers don't get too full in that 10ms, we're ok.
Speaking of too full, if you run three servers at 100kB/s with -l debug,
it spends too much time printing debugging messages to be able to keep
up with the cells. The outbuf ultimately fills up and it kills that
connection. If you run with -l err, it works fine up through 500kB/s and
probably beyond. Down the road we'll want to teach it to recognize when
an outbuf is getting full, and back off.
svn:r50
2002-07-16 03:12:15 +02:00
|
|
|
circ->onionlen = ntohl(*(int*)cell->payload);
|
2002-06-27 00:45:49 +02:00
|
|
|
log(LOG_DEBUG,"command_process_create_cell(): Onion length is %u.",circ->onionlen);
|
Integrated onion proxy into or/
The 'or' process can now be told (by the global_role variable) what
roles this server should play -- connect to all ORs, listen for ORs,
listen for OPs, listen for APs, or any combination.
* everything in /src/op/ is now obsolete.
* connection_ap.c now handles all interactions with application proxies
* "port" is now or_port, op_port, ap_port. But routers are still always
referenced (say, in conn_get_by_addr_port()) by addr / or_port. We
should make routers.c actually read these new ports (currently I've
kludged it so op_port = or_port+10, ap_port=or_port+20)
* circuits currently know if they're at the beginning of the path because
circ->cpath is set. They use this instead for crypts (both ways),
if it's set.
* I still obey the "send a 0 back to the AP when you're ready" protocol,
but I think we should phase it out. I can simply not read from the AP
socket until I'm ready.
I need to do a lot of cleanup work here, but the code appears to work, so
now's a good time for a checkin.
svn:r22
2002-07-02 11:36:58 +02:00
|
|
|
if(circ->onionlen > 50000 || circ->onionlen < 1) { /* too big or too small */
|
2002-06-27 00:45:49 +02:00
|
|
|
log(LOG_DEBUG,"That's ludicrous. Closing.");
|
|
|
|
circuit_close(circ);
|
|
|
|
return;
|
|
|
|
}
|
major overhaul: dns slave subsystem, topics
on startup, it forks off a master dns handler, which forks off dns
slaves (like the apache model). slaves as spawned as load increases,
and then reused. excess slaves are not ever killed, currently.
implemented topics. each topic has a receive window in each direction
at each edge of the circuit, and sends sendme's at the data level, as
per before. each circuit also has receive windows in each direction at
each hop; an edge sends a circuit-level sendme as soon as enough data
cells have arrived (regardless of whether the data cells were flushed
to the exit conns). removed the 'connected' cell type, since it's now
a topic command within data cells.
at the edge of the circuit, there can be multiple connections associated
with a single circuit. you find them via the linked list conn->next_topic.
currently each new ap connection starts its own circuit, so we ought
to see comparable performance to what we had before. but that's only
because i haven't written the code to reattach to old circuits. please
try to break it as-is, and then i'll make it reuse the same circuit and
we'll try to break that.
svn:r152
2003-01-26 10:02:24 +01:00
|
|
|
circ->onion = malloc(circ->onionlen);
|
2002-06-27 00:45:49 +02:00
|
|
|
if(!circ->onion) {
|
|
|
|
log(LOG_DEBUG,"command_process_create_cell(): Out of memory. Closing.");
|
|
|
|
circuit_close(circ);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(circ->onionlen < cell->length-4) { /* protect from buffer overflow */
|
|
|
|
log(LOG_DEBUG,"command_process_create_cell(): Onion too small. Closing.");
|
|
|
|
circuit_close(circ);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
memcpy((void *)circ->onion,(void *)(cell->payload+4),cell->length-4);
|
|
|
|
circ->recvlen = cell->length-4;
|
|
|
|
log(LOG_DEBUG,"command_process_create_cell(): Primary create cell handled, have received %d of %d onion bytes.",
|
|
|
|
circ->recvlen,circ->onionlen);
|
|
|
|
|
|
|
|
} else { /* pull over as much of the onion as we can */
|
|
|
|
if(cell->length + circ->recvlen > circ->onionlen) { /* protect from buffer overflow */
|
|
|
|
log(LOG_DEBUG,"command_process_create_cell(): payload too big for onion. Closing.");
|
|
|
|
circuit_close(circ);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
memcpy((void *)(circ->onion+circ->recvlen),(void *)cell->payload,cell->length);
|
|
|
|
circ->recvlen += cell->length;
|
2003-02-18 02:35:55 +01:00
|
|
|
log(LOG_DEBUG,"command_process_create_cell(): Secondary create cell handled, have received %d of %d onion bytes (aci %d)",
|
|
|
|
circ->recvlen,circ->onionlen,circ->p_aci);
|
2002-06-27 00:45:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(circ->recvlen != circ->onionlen) {
|
|
|
|
log(LOG_DEBUG,"command_process_create_cell(): Onion not all here yet. Ok.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-11-27 05:08:20 +01:00
|
|
|
/* add it to the pending onions queue, and then return */
|
|
|
|
circ->state = CIRCUIT_STATE_ONION_PENDING;
|
|
|
|
|
|
|
|
if(onion_pending_add(circ) < 0) {
|
|
|
|
log(LOG_DEBUG,"command_process_create_cell(): Failed to queue onion. Closing.");
|
|
|
|
circuit_close(circ);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2002-06-27 00:45:49 +02:00
|
|
|
|
2002-07-18 08:37:58 +02:00
|
|
|
void command_process_sendme_cell(cell_t *cell, connection_t *conn) {
|
2002-06-27 00:45:49 +02:00
|
|
|
circuit_t *circ;
|
|
|
|
|
2002-07-18 08:37:58 +02:00
|
|
|
circ = circuit_get_by_aci_conn(cell->aci, conn);
|
|
|
|
|
|
|
|
if(!circ) {
|
|
|
|
log(LOG_DEBUG,"command_process_sendme_cell(): unknown circuit %d. Dropping.", cell->aci);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-11-27 05:08:20 +01:00
|
|
|
if(circ->state == CIRCUIT_STATE_ONION_WAIT) {
|
|
|
|
log(LOG_DEBUG,"command_process_sendme_cell(): circuit in onion_wait. Dropping.");
|
2002-07-18 08:37:58 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(circ->state == CIRCUIT_STATE_OR_WAIT) {
|
|
|
|
log(LOG_DEBUG,"command_process_sendme_cell(): circuit in or_wait. Dropping.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* at this point both circ->n_conn and circ->p_conn are guaranteed to be set */
|
|
|
|
|
major overhaul: dns slave subsystem, topics
on startup, it forks off a master dns handler, which forks off dns
slaves (like the apache model). slaves as spawned as load increases,
and then reused. excess slaves are not ever killed, currently.
implemented topics. each topic has a receive window in each direction
at each edge of the circuit, and sends sendme's at the data level, as
per before. each circuit also has receive windows in each direction at
each hop; an edge sends a circuit-level sendme as soon as enough data
cells have arrived (regardless of whether the data cells were flushed
to the exit conns). removed the 'connected' cell type, since it's now
a topic command within data cells.
at the edge of the circuit, there can be multiple connections associated
with a single circuit. you find them via the linked list conn->next_topic.
currently each new ap connection starts its own circuit, so we ought
to see comparable performance to what we had before. but that's only
because i haven't written the code to reattach to old circuits. please
try to break it as-is, and then i'll make it reuse the same circuit and
we'll try to break that.
svn:r152
2003-01-26 10:02:24 +01:00
|
|
|
if(cell->length != CIRCWINDOW_INCREMENT) {
|
2002-11-24 09:45:54 +01:00
|
|
|
log(LOG_WARNING,"command_process_sendme_cell(): non-standard sendme value %d.",cell->length);
|
|
|
|
}
|
2002-07-18 08:37:58 +02:00
|
|
|
|
|
|
|
if(cell->aci == circ->p_aci) { /* it's an outgoing cell */
|
major overhaul: dns slave subsystem, topics
on startup, it forks off a master dns handler, which forks off dns
slaves (like the apache model). slaves as spawned as load increases,
and then reused. excess slaves are not ever killed, currently.
implemented topics. each topic has a receive window in each direction
at each edge of the circuit, and sends sendme's at the data level, as
per before. each circuit also has receive windows in each direction at
each hop; an edge sends a circuit-level sendme as soon as enough data
cells have arrived (regardless of whether the data cells were flushed
to the exit conns). removed the 'connected' cell type, since it's now
a topic command within data cells.
at the edge of the circuit, there can be multiple connections associated
with a single circuit. you find them via the linked list conn->next_topic.
currently each new ap connection starts its own circuit, so we ought
to see comparable performance to what we had before. but that's only
because i haven't written the code to reattach to old circuits. please
try to break it as-is, and then i'll make it reuse the same circuit and
we'll try to break that.
svn:r152
2003-01-26 10:02:24 +01:00
|
|
|
circ->n_receive_circwindow += cell->length;
|
|
|
|
assert(circ->n_receive_circwindow <= CIRCWINDOW_START);
|
2003-03-10 23:30:05 +01:00
|
|
|
log(LOG_DEBUG,"command_process_sendme_cell(): n_receive_circwindow for aci %d is %d.",circ->n_aci,circ->n_receive_circwindow);
|
major overhaul: dns slave subsystem, topics
on startup, it forks off a master dns handler, which forks off dns
slaves (like the apache model). slaves as spawned as load increases,
and then reused. excess slaves are not ever killed, currently.
implemented topics. each topic has a receive window in each direction
at each edge of the circuit, and sends sendme's at the data level, as
per before. each circuit also has receive windows in each direction at
each hop; an edge sends a circuit-level sendme as soon as enough data
cells have arrived (regardless of whether the data cells were flushed
to the exit conns). removed the 'connected' cell type, since it's now
a topic command within data cells.
at the edge of the circuit, there can be multiple connections associated
with a single circuit. you find them via the linked list conn->next_topic.
currently each new ap connection starts its own circuit, so we ought
to see comparable performance to what we had before. but that's only
because i haven't written the code to reattach to old circuits. please
try to break it as-is, and then i'll make it reuse the same circuit and
we'll try to break that.
svn:r152
2003-01-26 10:02:24 +01:00
|
|
|
if(!circ->n_conn || circ->n_conn->type == CONN_TYPE_EXIT) {
|
|
|
|
circuit_resume_edge_reading(circ, EDGE_EXIT);
|
2002-07-18 08:37:58 +02:00
|
|
|
} else {
|
|
|
|
cell->aci = circ->n_aci; /* switch it */
|
2003-02-18 02:35:55 +01:00
|
|
|
if(connection_write_cell_to_buf(cell, circ->n_conn) < 0) {
|
2002-07-18 08:37:58 +02:00
|
|
|
circuit_close(circ);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else { /* it's an ingoing cell */
|
2003-02-18 02:35:55 +01:00
|
|
|
assert(cell->aci == circ->n_aci);
|
major overhaul: dns slave subsystem, topics
on startup, it forks off a master dns handler, which forks off dns
slaves (like the apache model). slaves as spawned as load increases,
and then reused. excess slaves are not ever killed, currently.
implemented topics. each topic has a receive window in each direction
at each edge of the circuit, and sends sendme's at the data level, as
per before. each circuit also has receive windows in each direction at
each hop; an edge sends a circuit-level sendme as soon as enough data
cells have arrived (regardless of whether the data cells were flushed
to the exit conns). removed the 'connected' cell type, since it's now
a topic command within data cells.
at the edge of the circuit, there can be multiple connections associated
with a single circuit. you find them via the linked list conn->next_topic.
currently each new ap connection starts its own circuit, so we ought
to see comparable performance to what we had before. but that's only
because i haven't written the code to reattach to old circuits. please
try to break it as-is, and then i'll make it reuse the same circuit and
we'll try to break that.
svn:r152
2003-01-26 10:02:24 +01:00
|
|
|
circ->p_receive_circwindow += cell->length;
|
2003-03-10 23:30:05 +01:00
|
|
|
log(LOG_DEBUG,"command_process_sendme_cell(): p_receive_circwindow for aci %d is %d.",circ->p_aci,circ->p_receive_circwindow);
|
major overhaul: dns slave subsystem, topics
on startup, it forks off a master dns handler, which forks off dns
slaves (like the apache model). slaves as spawned as load increases,
and then reused. excess slaves are not ever killed, currently.
implemented topics. each topic has a receive window in each direction
at each edge of the circuit, and sends sendme's at the data level, as
per before. each circuit also has receive windows in each direction at
each hop; an edge sends a circuit-level sendme as soon as enough data
cells have arrived (regardless of whether the data cells were flushed
to the exit conns). removed the 'connected' cell type, since it's now
a topic command within data cells.
at the edge of the circuit, there can be multiple connections associated
with a single circuit. you find them via the linked list conn->next_topic.
currently each new ap connection starts its own circuit, so we ought
to see comparable performance to what we had before. but that's only
because i haven't written the code to reattach to old circuits. please
try to break it as-is, and then i'll make it reuse the same circuit and
we'll try to break that.
svn:r152
2003-01-26 10:02:24 +01:00
|
|
|
assert(circ->p_receive_circwindow <= CIRCWINDOW_START);
|
|
|
|
if(!circ->p_conn || circ->p_conn->type == CONN_TYPE_AP) {
|
|
|
|
circuit_resume_edge_reading(circ, EDGE_AP);
|
2002-07-18 08:37:58 +02:00
|
|
|
} else {
|
|
|
|
cell->aci = circ->p_aci; /* switch it */
|
2003-02-18 02:35:55 +01:00
|
|
|
if(connection_write_cell_to_buf(cell, circ->p_conn) < 0) {
|
2002-07-18 08:37:58 +02:00
|
|
|
circuit_close(circ);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void command_process_data_cell(cell_t *cell, connection_t *conn) {
|
|
|
|
circuit_t *circ;
|
2002-06-27 00:45:49 +02:00
|
|
|
|
|
|
|
circ = circuit_get_by_aci_conn(cell->aci, conn);
|
|
|
|
|
|
|
|
if(!circ) {
|
2002-07-18 08:37:58 +02:00
|
|
|
log(LOG_DEBUG,"command_process_data_cell(): unknown circuit %d. Dropping.", cell->aci);
|
2002-06-27 00:45:49 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-11-27 05:08:20 +01:00
|
|
|
if(circ->state == CIRCUIT_STATE_ONION_PENDING) {
|
|
|
|
log(LOG_DEBUG,"command_process_data_cell(): circuit in create_wait. Queueing data cell.");
|
|
|
|
onion_pending_data_add(circ, cell);
|
|
|
|
return;
|
|
|
|
}
|
major overhaul: dns slave subsystem, topics
on startup, it forks off a master dns handler, which forks off dns
slaves (like the apache model). slaves as spawned as load increases,
and then reused. excess slaves are not ever killed, currently.
implemented topics. each topic has a receive window in each direction
at each edge of the circuit, and sends sendme's at the data level, as
per before. each circuit also has receive windows in each direction at
each hop; an edge sends a circuit-level sendme as soon as enough data
cells have arrived (regardless of whether the data cells were flushed
to the exit conns). removed the 'connected' cell type, since it's now
a topic command within data cells.
at the edge of the circuit, there can be multiple connections associated
with a single circuit. you find them via the linked list conn->next_topic.
currently each new ap connection starts its own circuit, so we ought
to see comparable performance to what we had before. but that's only
because i haven't written the code to reattach to old circuits. please
try to break it as-is, and then i'll make it reuse the same circuit and
we'll try to break that.
svn:r152
2003-01-26 10:02:24 +01:00
|
|
|
|
2002-06-27 00:45:49 +02:00
|
|
|
if(cell->aci == circ->p_aci) { /* it's an outgoing cell */
|
major overhaul: dns slave subsystem, topics
on startup, it forks off a master dns handler, which forks off dns
slaves (like the apache model). slaves as spawned as load increases,
and then reused. excess slaves are not ever killed, currently.
implemented topics. each topic has a receive window in each direction
at each edge of the circuit, and sends sendme's at the data level, as
per before. each circuit also has receive windows in each direction at
each hop; an edge sends a circuit-level sendme as soon as enough data
cells have arrived (regardless of whether the data cells were flushed
to the exit conns). removed the 'connected' cell type, since it's now
a topic command within data cells.
at the edge of the circuit, there can be multiple connections associated
with a single circuit. you find them via the linked list conn->next_topic.
currently each new ap connection starts its own circuit, so we ought
to see comparable performance to what we had before. but that's only
because i haven't written the code to reattach to old circuits. please
try to break it as-is, and then i'll make it reuse the same circuit and
we'll try to break that.
svn:r152
2003-01-26 10:02:24 +01:00
|
|
|
if(--circ->p_receive_circwindow < 0) { /* is it less than 0 after decrement? */
|
2003-02-18 02:35:55 +01:00
|
|
|
log(LOG_INFO,"connection_process_data_cell(): Too many data cells for out circuit (aci %d). Closing.", circ->p_aci);
|
2002-07-18 08:37:58 +02:00
|
|
|
circuit_close(circ);
|
|
|
|
return;
|
|
|
|
}
|
major overhaul: dns slave subsystem, topics
on startup, it forks off a master dns handler, which forks off dns
slaves (like the apache model). slaves as spawned as load increases,
and then reused. excess slaves are not ever killed, currently.
implemented topics. each topic has a receive window in each direction
at each edge of the circuit, and sends sendme's at the data level, as
per before. each circuit also has receive windows in each direction at
each hop; an edge sends a circuit-level sendme as soon as enough data
cells have arrived (regardless of whether the data cells were flushed
to the exit conns). removed the 'connected' cell type, since it's now
a topic command within data cells.
at the edge of the circuit, there can be multiple connections associated
with a single circuit. you find them via the linked list conn->next_topic.
currently each new ap connection starts its own circuit, so we ought
to see comparable performance to what we had before. but that's only
because i haven't written the code to reattach to old circuits. please
try to break it as-is, and then i'll make it reuse the same circuit and
we'll try to break that.
svn:r152
2003-01-26 10:02:24 +01:00
|
|
|
log(LOG_DEBUG,"connection_process_data_cell(): p_receive_circwindow for aci %d is %d.",circ->p_aci,circ->p_receive_circwindow);
|
2003-02-18 02:35:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(cell->aci == circ->n_aci) { /* it's an ingoing cell */
|
|
|
|
if(--circ->n_receive_circwindow < 0) { /* is it less than 0 after decrement? */
|
|
|
|
log(LOG_INFO,"connection_process_data_cell(): Too many data cells for in circuit (aci %d). Closing.", circ->n_aci);
|
|
|
|
circuit_close(circ);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
log(LOG_DEBUG,"connection_process_data_cell(): n_receive_circwindow for aci %d is %d.",circ->n_aci,circ->n_receive_circwindow);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(circ->state == CIRCUIT_STATE_ONION_WAIT) {
|
|
|
|
log(LOG_WARNING,"command_process_data_cell(): circuit in onion_wait. Dropping data cell.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(circ->state == CIRCUIT_STATE_OR_WAIT) {
|
|
|
|
log(LOG_WARNING,"command_process_data_cell(): circuit in or_wait. Dropping data cell.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* circ->p_conn and n_conn are only null if we're at an edge point with no connections yet */
|
|
|
|
|
|
|
|
if(cell->aci == circ->p_aci) { /* it's an outgoing cell */
|
|
|
|
cell->aci = circ->n_aci; /* switch it */
|
major overhaul: dns slave subsystem, topics
on startup, it forks off a master dns handler, which forks off dns
slaves (like the apache model). slaves as spawned as load increases,
and then reused. excess slaves are not ever killed, currently.
implemented topics. each topic has a receive window in each direction
at each edge of the circuit, and sends sendme's at the data level, as
per before. each circuit also has receive windows in each direction at
each hop; an edge sends a circuit-level sendme as soon as enough data
cells have arrived (regardless of whether the data cells were flushed
to the exit conns). removed the 'connected' cell type, since it's now
a topic command within data cells.
at the edge of the circuit, there can be multiple connections associated
with a single circuit. you find them via the linked list conn->next_topic.
currently each new ap connection starts its own circuit, so we ought
to see comparable performance to what we had before. but that's only
because i haven't written the code to reattach to old circuits. please
try to break it as-is, and then i'll make it reuse the same circuit and
we'll try to break that.
svn:r152
2003-01-26 10:02:24 +01:00
|
|
|
if(circuit_deliver_data_cell(cell, circ, CELL_DIRECTION_OUT) < 0) {
|
|
|
|
log(LOG_INFO,"command_process_data_cell(): circuit_deliver_data_cell (forward) failed. Closing.");
|
2002-06-27 00:45:49 +02:00
|
|
|
circuit_close(circ);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else { /* it's an ingoing cell */
|
|
|
|
cell->aci = circ->p_aci; /* switch it */
|
major overhaul: dns slave subsystem, topics
on startup, it forks off a master dns handler, which forks off dns
slaves (like the apache model). slaves as spawned as load increases,
and then reused. excess slaves are not ever killed, currently.
implemented topics. each topic has a receive window in each direction
at each edge of the circuit, and sends sendme's at the data level, as
per before. each circuit also has receive windows in each direction at
each hop; an edge sends a circuit-level sendme as soon as enough data
cells have arrived (regardless of whether the data cells were flushed
to the exit conns). removed the 'connected' cell type, since it's now
a topic command within data cells.
at the edge of the circuit, there can be multiple connections associated
with a single circuit. you find them via the linked list conn->next_topic.
currently each new ap connection starts its own circuit, so we ought
to see comparable performance to what we had before. but that's only
because i haven't written the code to reattach to old circuits. please
try to break it as-is, and then i'll make it reuse the same circuit and
we'll try to break that.
svn:r152
2003-01-26 10:02:24 +01:00
|
|
|
if(circuit_deliver_data_cell(cell, circ, CELL_DIRECTION_IN) < 0) {
|
2003-02-18 02:35:55 +01:00
|
|
|
log(LOG_DEBUG,"command_process_data_cell(): circuit_deliver_data_cell (backward) failed. Closing.");
|
major overhaul: dns slave subsystem, topics
on startup, it forks off a master dns handler, which forks off dns
slaves (like the apache model). slaves as spawned as load increases,
and then reused. excess slaves are not ever killed, currently.
implemented topics. each topic has a receive window in each direction
at each edge of the circuit, and sends sendme's at the data level, as
per before. each circuit also has receive windows in each direction at
each hop; an edge sends a circuit-level sendme as soon as enough data
cells have arrived (regardless of whether the data cells were flushed
to the exit conns). removed the 'connected' cell type, since it's now
a topic command within data cells.
at the edge of the circuit, there can be multiple connections associated
with a single circuit. you find them via the linked list conn->next_topic.
currently each new ap connection starts its own circuit, so we ought
to see comparable performance to what we had before. but that's only
because i haven't written the code to reattach to old circuits. please
try to break it as-is, and then i'll make it reuse the same circuit and
we'll try to break that.
svn:r152
2003-01-26 10:02:24 +01:00
|
|
|
circuit_close(circ);
|
|
|
|
return;
|
2002-06-27 00:45:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void command_process_destroy_cell(cell_t *cell, connection_t *conn) {
|
|
|
|
circuit_t *circ;
|
major overhaul: dns slave subsystem, topics
on startup, it forks off a master dns handler, which forks off dns
slaves (like the apache model). slaves as spawned as load increases,
and then reused. excess slaves are not ever killed, currently.
implemented topics. each topic has a receive window in each direction
at each edge of the circuit, and sends sendme's at the data level, as
per before. each circuit also has receive windows in each direction at
each hop; an edge sends a circuit-level sendme as soon as enough data
cells have arrived (regardless of whether the data cells were flushed
to the exit conns). removed the 'connected' cell type, since it's now
a topic command within data cells.
at the edge of the circuit, there can be multiple connections associated
with a single circuit. you find them via the linked list conn->next_topic.
currently each new ap connection starts its own circuit, so we ought
to see comparable performance to what we had before. but that's only
because i haven't written the code to reattach to old circuits. please
try to break it as-is, and then i'll make it reuse the same circuit and
we'll try to break that.
svn:r152
2003-01-26 10:02:24 +01:00
|
|
|
connection_t *tmpconn;
|
2002-06-27 00:45:49 +02:00
|
|
|
|
|
|
|
circ = circuit_get_by_aci_conn(cell->aci, conn);
|
|
|
|
|
|
|
|
if(!circ) {
|
2002-07-18 08:37:58 +02:00
|
|
|
log(LOG_DEBUG,"command_process_destroy_cell(): unknown circuit %d. Dropping.", cell->aci);
|
2002-06-27 00:45:49 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
log(LOG_DEBUG,"command_process_destroy_cell(): Received for aci %d.",cell->aci);
|
2002-11-27 05:08:20 +01:00
|
|
|
if(circ->state == CIRCUIT_STATE_ONION_PENDING) {
|
|
|
|
onion_pending_remove(circ);
|
|
|
|
}
|
major overhaul: dns slave subsystem, topics
on startup, it forks off a master dns handler, which forks off dns
slaves (like the apache model). slaves as spawned as load increases,
and then reused. excess slaves are not ever killed, currently.
implemented topics. each topic has a receive window in each direction
at each edge of the circuit, and sends sendme's at the data level, as
per before. each circuit also has receive windows in each direction at
each hop; an edge sends a circuit-level sendme as soon as enough data
cells have arrived (regardless of whether the data cells were flushed
to the exit conns). removed the 'connected' cell type, since it's now
a topic command within data cells.
at the edge of the circuit, there can be multiple connections associated
with a single circuit. you find them via the linked list conn->next_topic.
currently each new ap connection starts its own circuit, so we ought
to see comparable performance to what we had before. but that's only
because i haven't written the code to reattach to old circuits. please
try to break it as-is, and then i'll make it reuse the same circuit and
we'll try to break that.
svn:r152
2003-01-26 10:02:24 +01:00
|
|
|
|
2002-06-27 00:45:49 +02:00
|
|
|
circuit_remove(circ);
|
major overhaul: dns slave subsystem, topics
on startup, it forks off a master dns handler, which forks off dns
slaves (like the apache model). slaves as spawned as load increases,
and then reused. excess slaves are not ever killed, currently.
implemented topics. each topic has a receive window in each direction
at each edge of the circuit, and sends sendme's at the data level, as
per before. each circuit also has receive windows in each direction at
each hop; an edge sends a circuit-level sendme as soon as enough data
cells have arrived (regardless of whether the data cells were flushed
to the exit conns). removed the 'connected' cell type, since it's now
a topic command within data cells.
at the edge of the circuit, there can be multiple connections associated
with a single circuit. you find them via the linked list conn->next_topic.
currently each new ap connection starts its own circuit, so we ought
to see comparable performance to what we had before. but that's only
because i haven't written the code to reattach to old circuits. please
try to break it as-is, and then i'll make it reuse the same circuit and
we'll try to break that.
svn:r152
2003-01-26 10:02:24 +01:00
|
|
|
|
2002-12-23 07:48:14 +01:00
|
|
|
if(cell->aci == circ->p_aci) { /* the destroy came from behind */
|
major overhaul: dns slave subsystem, topics
on startup, it forks off a master dns handler, which forks off dns
slaves (like the apache model). slaves as spawned as load increases,
and then reused. excess slaves are not ever killed, currently.
implemented topics. each topic has a receive window in each direction
at each edge of the circuit, and sends sendme's at the data level, as
per before. each circuit also has receive windows in each direction at
each hop; an edge sends a circuit-level sendme as soon as enough data
cells have arrived (regardless of whether the data cells were flushed
to the exit conns). removed the 'connected' cell type, since it's now
a topic command within data cells.
at the edge of the circuit, there can be multiple connections associated
with a single circuit. you find them via the linked list conn->next_topic.
currently each new ap connection starts its own circuit, so we ought
to see comparable performance to what we had before. but that's only
because i haven't written the code to reattach to old circuits. please
try to break it as-is, and then i'll make it reuse the same circuit and
we'll try to break that.
svn:r152
2003-01-26 10:02:24 +01:00
|
|
|
for(tmpconn = circ->n_conn; tmpconn; tmpconn=tmpconn->next_topic) {
|
|
|
|
connection_send_destroy(circ->n_aci, tmpconn);
|
|
|
|
}
|
2002-12-23 07:48:14 +01:00
|
|
|
}
|
|
|
|
if(cell->aci == circ->n_aci) { /* the destroy came from ahead */
|
major overhaul: dns slave subsystem, topics
on startup, it forks off a master dns handler, which forks off dns
slaves (like the apache model). slaves as spawned as load increases,
and then reused. excess slaves are not ever killed, currently.
implemented topics. each topic has a receive window in each direction
at each edge of the circuit, and sends sendme's at the data level, as
per before. each circuit also has receive windows in each direction at
each hop; an edge sends a circuit-level sendme as soon as enough data
cells have arrived (regardless of whether the data cells were flushed
to the exit conns). removed the 'connected' cell type, since it's now
a topic command within data cells.
at the edge of the circuit, there can be multiple connections associated
with a single circuit. you find them via the linked list conn->next_topic.
currently each new ap connection starts its own circuit, so we ought
to see comparable performance to what we had before. but that's only
because i haven't written the code to reattach to old circuits. please
try to break it as-is, and then i'll make it reuse the same circuit and
we'll try to break that.
svn:r152
2003-01-26 10:02:24 +01:00
|
|
|
for(tmpconn = circ->p_conn; tmpconn; tmpconn=tmpconn->next_topic) {
|
|
|
|
connection_send_destroy(circ->p_aci, tmpconn);
|
|
|
|
}
|
2002-12-23 07:48:14 +01:00
|
|
|
}
|
2002-06-27 00:45:49 +02:00
|
|
|
circuit_free(circ);
|
|
|
|
}
|
|
|
|
|
2003-04-07 04:12:02 +02:00
|
|
|
/*
|
|
|
|
Local Variables:
|
|
|
|
mode:c
|
|
|
|
indent-tabs-mode:nil
|
|
|
|
c-basic-offset:2
|
|
|
|
End:
|
|
|
|
*/
|