Skip to contentSkip to conversation

sk->state_chage is not called for listening sockets

PATCH Applied Pete Zaitcev 2 participants 2 messages Apr 13, 2001 – Apr 19, 2001

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hello:

Suppose for a moment, that I have an in-kernel daemon, listening on a TCP socket, and that the said daemon is interested to know when connection becomes established. To that end it puts something into sk->state_change. However, when connection is established, state_chenge is not called (in 2.4.3).

With that in mind, would the following chage have any ill effects? It does not seem to break anything obvious, but I am worried about a performance degradation for some retarded benchmark.

net/ipv4/tcp_input.c +1 -1
diff -u -U 4 linux-2.4.3/net/ipv4/tcp_input.c linux-2.4.3-nfs/net/ipv4/tcp_input.c
@@ -3712,16 +3712,16 @@
 			if (acceptable) {
 				tp->copied_seq = tp->rcv_nxt;
 				mb();
 				tcp_set_state(sk, TCP_ESTABLISHED);
+				sk->state_change(sk);
 
 				/* Note, that this wakeup is only for marginal
 				 * crossed SYN case. Passively open sockets
 				 * are not waked up, because sk->sleep == NULL
 				 * and sk->socket == NULL.
 				 */
 				if (sk->socket) {
-					sk->state_change(sk);
 					sk_wake_async(sk,0,POLL_OUT);
 				}
 
 				tp->snd_una = TCP_SKB_CB(skb)->ack_seq;

Thanks,
-- Pete

#1 lore raw

net/ipv4/tcp_input.c

Quoted 7 lines · Pete Zaitcev

With that in mind, would the following chage have any ill effects? It does not seem to break anything obvious, but I am worried about a performance degradation for some retarded benchmark.

diff -u -U 4 linux-2.4.3/net/ipv4/tcp_input.c linux-2.4.3-nfs/net/ipv4/tcp_input.c

net/ipv4/tcp_input.c +0 -0

I've applied this patch, thanks.

Later,
David S. Miller
[email protected]