patch-2.1.68 linux/net/ipv4/tcp.c

Next file: linux/net/ipv4/tcp_input.c
Previous file: linux/net/ipv4/sysctl_net_ipv4.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.67/linux/net/ipv4/tcp.c linux/net/ipv4/tcp.c
@@ -5,7 +5,7 @@
  *
  *		Implementation of the Transmission Control Protocol(TCP).
  *
- * Version:	$Id: tcp.c,v 1.71 1997/09/06 05:11:45 davem Exp $
+ * Version:	$Id: tcp.c,v 1.75 1997/10/16 02:57:34 davem Exp $
  *
  * Authors:	Ross Biro, <bir7@leland.Stanford.Edu>
  *		Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
@@ -437,8 +437,8 @@
 	struct open_request *prev = (struct open_request *)&tp->syn_wait_queue; 
 	while(req) {
 		if (req->sk && 
-		    (req->sk->state == TCP_ESTABLISHED ||
-		     req->sk->state >= TCP_FIN_WAIT1))
+		    ((1 << req->sk->state) &
+		     ~(TCPF_SYN_SENT|TCPF_SYN_RECV)))
 			break;
 		prev = req; 
 		req = req->dl_next;
@@ -603,7 +603,7 @@
 	if (sk->err)
 		mask = POLLERR;
 	/* Connected? */
-	if (sk->state != TCP_SYN_SENT && sk->state != TCP_SYN_RECV) {
+	if ((1 << sk->state) & ~(TCPF_SYN_SENT|TCPF_SYN_RECV)) {
 		if (sk->shutdown & RCV_SHUTDOWN)
 			mask |= POLLHUP;
 
@@ -653,7 +653,8 @@
 		{
 			unsigned long amount;
 
-			if (sk->state == TCP_LISTEN) return(-EINVAL);
+			if (sk->state == TCP_LISTEN)
+				return(-EINVAL);
 			amount = sock_wspace(sk);
 			return put_user(amount, (int *)arg);
 		}
@@ -701,7 +702,8 @@
 {
 	release_sock(sk);
 	cli();
-	if (sk->state != TCP_ESTABLISHED && sk->state != TCP_CLOSE_WAIT && sk->err == 0)
+	if (((1 << sk->state) & ~(TCPF_ESTABLISHED|TCPF_CLOSE_WAIT)) &&
+	    sk->err == 0)
 		interruptible_sleep_on(sk->sleep);
 	sti();
 	lock_sock(sk);
@@ -779,11 +781,11 @@
 	struct tcp_opt *tp=&(sk->tp_pinfo.af_tcp);
 
 	/* Wait for a connection to finish. */
-	while (sk->state != TCP_ESTABLISHED && sk->state != TCP_CLOSE_WAIT) {
+	while ((1 << sk->state) & ~(TCPF_ESTABLISHED | TCPF_CLOSE_WAIT)) {
 		if (sk->err)
 			return sock_error(sk);
 
-		if (sk->state != TCP_SYN_SENT && sk->state != TCP_SYN_RECV) {
+		if ((1 << sk->state) & ~(TCPF_SYN_SENT | TCPF_SYN_RECV)) {
 			if (sk->keepopen)
 				send_sig(SIGPIPE, current, 0);
 			return -EPIPE;
@@ -982,7 +984,7 @@
 	/* If we're closed, don't send an ack, or we'll get a RST
 	 * from the closed destination.
 	 */
-	if ((sk->state == TCP_CLOSE) || (sk->state == TCP_TIME_WAIT))
+	if ((1 << sk->state) & (TCPF_CLOSE|TCPF_TIME_WAIT))
 		return;
 
 	tcp_send_ack(sk);
@@ -1400,10 +1402,8 @@
 		return;
 
 	/* If we've already sent a FIN, or it's a closed state, skip this. */
-	if (sk->state == TCP_ESTABLISHED	||
-	    sk->state == TCP_SYN_SENT		||
-	    sk->state == TCP_SYN_RECV		||
-	    sk->state == TCP_CLOSE_WAIT) {
+	if ((1 << sk->state) &
+	    (TCPF_ESTABLISHED|TCPF_SYN_SENT|TCPF_SYN_RECV|TCPF_CLOSE_WAIT)) {
 		lock_sock(sk);
 
 		/* Flag that the sender has shutdown. */
@@ -1424,9 +1424,7 @@
 
 static inline int closing(struct sock * sk)
 {
-	return ((1 << sk->state) & ((1 << TCP_FIN_WAIT1)|
-				    (1 << TCP_CLOSING)|
-				    (1 << TCP_LAST_ACK)));
+	return ((1 << sk->state) & (TCPF_FIN_WAIT1|TCPF_CLOSING|TCPF_LAST_ACK));
 }
 
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov