Skip to contentSkip to conversation

connect() does not return ETIMEDOUT

DISCUSSION Andi Kleen 2 participants 2 messages Aug 13, 2001 – Aug 15, 2001 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 20010813140049.28744.qmail@optushome.com.au.suse.lists.linux.kernel

Andi Kleen

author
#1 lore raw
Quoted 3 lines · Manfred Bartz

When a TCP client opens multiple connections beyond the server's backlog capacity, the call to connect() returns a value of zero (success) after 9 seconds. Toggling SYN-cookies makes no difference.

It works correct here (2.4.7-something)

# ipchains -A input -j DENY -p tcp --dport 10000
# strace -e connect telnet localhost 10000
...
connect(3, {sin_family=AF_INET, sin_port=htons(10000), sin_addr=inet_addr("127.0.0.1")}}, 16) = -1 ETIMEDOUT (Connection timed out)

If you think something is wrong you should probably send a strace that shows it.

-Andi

#2 lore raw
In reply to a message not in the archive
Quoted 1 line · Andi Kleen

It works correct here (2.4.7-something)

Ok, after running tcpdump, it now looks the problem is not with connect() but elsewhere. Linux 2.4.8, same results on 2.4.2

The programs which demonstrate the problem, pcap file and other files are at <http://logi.cc/linux/tcp2a/>.

My experimental server will accept() two connections and the backlog is set to 1 (one) in the call to listen().

My experimental client will open up to 100 connections to the server. The first 6 connections succeed immediately. Subsequent connections succeed at a rate of 2 connections every 9 seconds.

Under Solaris, the client succeeds with 4 connections, the 5th connect() gives ETIMEDOUT after about 4 minutes.

server side:
/* tcp socket bound to port 7000 */ listen(listen_fd, 1); /* backlog set to 1 */ accept() called twice only.

commented and compacted tcpdump:

The server has now accept()ed 2 connections and does no further calls to accept().

--------------------------------------------------
Connection 3, backlog, ok
10:22:01.258195 192.168.1.1.51834 > 192.168.1.11.7000: S 10:22:01.258283 192.168.1.11.7000 > 192.168.1.1.51834: S ack 10:22:01.258970 192.168.1.1.51834 > 192.168.1.11.7000: . ack

10:22:01.024577 Connection[3] established. connect()==0

--------------------------------------------------
Connection 4, ?
10:22:01.265549 192.168.1.1.51835 > 192.168.1.11.7000: S 10:22:01.265634 192.168.1.11.7000 > 192.168.1.1.51835: S ack 10:22:01.266324 192.168.1.1.51835 > 192.168.1.11.7000: . ack

10:22:01.031926 Connection[4] established. connect()==0

The backlog was set to one, but it completes and queues two connections. Is that because the kernel maintains two queues (one each for incomplete and complete connections)?

--------------------------------------------------
Connection 5, ? should fail
10:22:01.272881 192.168.1.1.51836 > 192.168.1.11.7000: S 10:22:01.272958 192.168.1.11.7000 > 192.168.1.1.51836: S ack 10:22:01.273650 192.168.1.1.51836 > 192.168.1.11.7000: . ack

10:22:01.039251 Connection[5] established. connect()==0

10:22:04.866558 192.168.1.11.7000 > 192.168.1.1.51836: S ack 10:22:10.866629 192.168.1.11.7000 > 192.168.1.1.51836: S ack 10:22:22.866793 192.168.1.11.7000 > 192.168.1.1.51836: S ack

--------------------------------------------------
Connection 6, ? should fail
10:22:01.280139 192.168.1.1.51837 > 192.168.1.11.7000: S 10:22:01.280223 192.168.1.11.7000 > 192.168.1.1.51837: S ack 10:22:01.280917 192.168.1.1.51837 > 192.168.1.11.7000: . ack

10:22:01.046514 Connection[6] established. connect()==0

10:22:05.666558 192.168.1.11.7000 > 192.168.1.1.51837: S ack 10:22:11.666637 192.168.1.11.7000 > 192.168.1.1.51837: S ack 10:22:23.666789 192.168.1.11.7000 > 192.168.1.1.51837: S ack

etc. etc...

connect() keeps returning 0 (success) because the client side sees the full 3-way handshake.

Questions:

Once the backlog is exhausted, shouldn't the server side TCP stop sending SYNs and either be quiet or perhaps send an appropriate ICMP response?

Why does the server side keep sending SYNs after the connection handshake was apparently completed?

Signature · 1 line
Manfred