Skip to contentSkip to conversation

: Withdrawal of passive-close patches

RFC Gerrit Renker 2 participants 4 messages Nov 22, 2007 – Nov 23, 2007

lore
Share & tools
lore
#0 lore raw

After fixing the issue with the leaked-skbs I spent nearly a day trying to provoke the problem that lead to the following two patches:

[DCCP]: Dedicated auxiliary states to support passive-close [DCCP]: Basic support for passive-close
[DCCP]: More informative state names

It is almost 8 months ago that I worked on these (my notes say 28th March) and I don't have the source code of the test program I used. I was sure that there was a problem since I was able to see the data on the wire but it didn't reach the application.

Really, I can't remember what the condition was. It may have been some kind of race condition, or something which can be dealt with at the application programming level rather than at the kernel level.

The case may be that ...
1. I misjudged the cause of the problem;
2. the problem may have disappeared during the 8 months of kernel changes;
3. the problem may re-appear later on.

The current solution is to enqueue the DCCP-Close and DCCP-Reset so that these come last in the receive buffer. I am actually hoping that I am wrong (case (1)), since the current solution is much simpler than the one I was suggesting and "simpler is better".

So I suggest to remove / not consider the following three patches:
[DCCP]: Dedicated auxiliary states to support passive-close [DCCP]: Basic support for passive-close
[DCCP]: More informative state names

If you or anyone on the list can create a condition which will lead to "application received data but didn't have a chance to read it", I'd like to hear about it.

For now, I will update the test tree (remove the above trio) and remove the online notes: they may at best be outdated and at worst plain wrong.

#1 lore raw
Quoted 3 lines

-----Original Message-----

...snip...

Quoted 3 lines

If you or anyone on the list can create a condition which will lead to "application received data but didn't have a chance to read it", I'd like to hear about it.

... snip ...

Quoted 1 line

---------------------------

If application first queries the message size in the receive buffer and only then issues a read command may have trouble if socket discards the data in the meantime. Scenario is possible if one is using select() call.

B.R.
Vladimir.

#2 lore raw
In reply to Gerrit Renker
| >If you or anyone on the list can create a condition which will 
| >lead to "application received data but didn't have a chance to 
| >read it", I'd like to hear about it.
| 
| ... snip ...
| 
| >---------------------------
| 
| 
| If application first queries the message size in the receive buffer  and
| only then issues a read command may have trouble if socket discards the
| data in the meantime. Scenario is possible if one is using select()
| call.
| 

Do you have a test program which can create this condition? That would be a great help.

From the description, this seems theoretically not possible: presumably the peek would return 0 if a Close/Reset is in the queue. Or, if the cause is something else, it may be the same thing I looked at in March.

However, I no longer have the test program and I am butchering my patches in favour of the older solution.

#3 lore raw
In reply to Gerrit Renker

The situation is clearer now: the passive-close patches are redundant, but the problem still exists. A description is below; the three passive-close patches have been taken out of the test tree and the updated test tree has been uploaded to

	git://eden-feed.erg.abdn.ac.uk/dccp_exp 

I have debugged the problem of mysteriously vanishing short-lived connections further and uploaded a test program to reproduce this behaviour on

http://www.erg.abdn.ac.uk/users/gerrit/dccp/short_connection_tests.tar.gz

(Any other program can also be used that writes a short string to a server and then terminates. )

The bug is that a short-lived connection resulted in ECONNABORTED at the client, while the complete transaction (initial handshake, data transfer, shutdown) could be seen on the wire with tcpdump or wireshark.

The problem can best be seen using loopback (127.0.0.1), when starting the server on a different host, a while loop can be used

while ./client <serverHost> ; do sleep 1; done

and then this behaviour will occur at some random time.

The events leading up to this are as follows:

1. ECONNABORTED is generated at the client before sys_connect() returns
2. tracing this back leads to inet_stream_connect(), where ECONNABORTED appears

    under the jump label sock_error, triggered by the following condition:
	if (sk->sk_state = TCP_CLOSE)
		goto sock_error;
 3. since TCP_CLOSE = DCCP_CLOSED, the DCCP_CLOSED state was assumed before
    inet_stream_connect returned
 4. one candidate is dccp_rcv_close, which changes the socket state within
    the backlog handler (so that userspace has no chance):

	static void dccp_rcv_close(struct sock *sk, struct sk_buff *skb)
	{
		// ...
		dccp_set_state(sk, DCCP_CLOSED);
		// ...
	}

However, simply taking out the dccp_set_state may not be the right thing to do, since then the socket remains in OPEN until the application closes it. The SOCK_DONE flag may be exploited for such tests instead. And there is the test for DCCP_CLOSED in dccp_close() -- without that, inet_destroy_sock() is not called.