Socket state change in net/ipv4/tcp_input.c:tcp_fin()

Trond Myklebust (trond.myklebust@fys.uio.no)
Thu, 11 Nov 1999 21:41:23 +0100 (CET)


Hi,

I'm having problems with the SunRPC code over TCP due to a 'bug' in
the TCP layer. In function tcp_fin(), the code is calling the
state_change() method on the socket BEFORE the state is actually
changed.

Since the SunRPC code hooks the state_change() method in order to
keep track of the state of the socket, this is a problem. It may or
may not also give an SMP race in Linux-2.3.x if somebody is sleeping
on the socket, and the kernel lock is not being held.

Would it therefore be possible to apply the following patch on both
linux-2.2.x and linux-2.3.x. It moves the call to state_change() and
the associated socket wakeup to immediately after the change of state
in tcp_fin().

Cheers,
Trond

--- net/ipv4/tcp_input.c.orig Thu Aug 26 02:29:53 1999
+++ net/ipv4/tcp_input.c Thu Nov 11 21:18:04 1999
@@ -1129,11 +1129,6 @@

tcp_send_ack(sk);

- if (!sk->dead) {
- sk->state_change(sk);
- sock_wake_async(sk->socket, 1);
- }
-
switch(sk->state) {
case TCP_SYN_RECV:
case TCP_ESTABLISHED:
@@ -1177,6 +1172,10 @@
printk("tcp_fin: Impossible, sk->state=%d\n", sk->state);
break;
};
+ if (!sk->dead) {
+ sk->state_change(sk);
+ sock_wake_async(sk->socket, 1);
+ }
}

/* These routines update the SACK block as out-of-order packets arrive or

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/