summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brown2007-01-09 06:01:22 +0100
committerMichael Brown2007-01-09 06:01:22 +0100
commit2eeb7c4fe7959a2a7507375e231e86ae74c0629d (patch)
treee91f54ab19026d171b4c0c7204361e0b1a917d04
parentReset character attributes before start of welcome banner, in case (diff)
downloadipxe-2eeb7c4fe7959a2a7507375e231e86ae74c0629d.tar.gz
ipxe-2eeb7c4fe7959a2a7507375e231e86ae74c0629d.tar.xz
ipxe-2eeb7c4fe7959a2a7507375e231e86ae74c0629d.zip
Define "connected" as
"when SYN is ACKed and we have already received SYN", or "when SYN is received and we have already had SYN ACKed" rather than just "when SYN is ACKed" This avoids spuriously calling the connected() method when we receive a RST,ACK in response to a SYN.
-rw-r--r--src/net/tcp.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/net/tcp.c b/src/net/tcp.c
index cc5562849..8df01f3ea 100644
--- a/src/net/tcp.c
+++ b/src/net/tcp.c
@@ -492,6 +492,7 @@ static struct tcp_connection * tcp_demux ( uint16_t local_port ) {
* @ret rc Return status code
*/
static int tcp_rx_syn ( struct tcp_connection *conn, uint32_t seq ) {
+ struct tcp_application *app = conn->app;
/* Synchronise sequence numbers on first SYN */
if ( ! ( conn->tcp_state & TCP_STATE_RCVD ( TCP_SYN ) ) )
@@ -508,6 +509,11 @@ static int tcp_rx_syn ( struct tcp_connection *conn, uint32_t seq ) {
/* Acknowledge SYN */
conn->rcv_ack++;
+ /* Notify application of established connection, if applicable */
+ if ( ( conn->tcp_state & TCP_STATE_ACKED ( TCP_SYN ) ) &&
+ app && app->tcp_op->connected )
+ app->tcp_op->connected ( app );
+
return 0;
}
@@ -565,7 +571,9 @@ static int tcp_rx_ack ( struct tcp_connection *conn, uint32_t ack,
conn->tcp_state |= TCP_STATE_ACKED ( acked_flags );
/* Notify application of established connection, if applicable */
- if ( ( acked_flags & TCP_SYN ) && app && app->tcp_op->connected )
+ if ( ( acked_flags & TCP_SYN ) &&
+ ( conn->tcp_state & TCP_STATE_RCVD ( TCP_SYN ) ) &&
+ app && app->tcp_op->connected )
app->tcp_op->connected ( app );
return 0;