Browse code

tcp: remember which connections were accepted

Use a new flag to remember which connection were passively opened
(accept()) and which were locally initiated (connect).

Andrei Pelinescu-Onciul authored on 21/09/2009 16:39:41
Showing 2 changed files
... ...
@@ -75,6 +75,7 @@
75 75
 #define F_CONN_WR_ERROR  2048 /* write error on the fd */
76 76
 #define F_CONN_WANTS_RD  4096  /* conn. should be watched for READ */
77 77
 #define F_CONN_WANTS_WR  8192  /* conn. should be watched for WRITE */
78
+#define F_CONN_PASSIVE  16384 /* conn. created via accept() and not connect()*/
78 79
 
79 80
 
80 81
 enum tcp_req_errors {	TCP_REQ_INIT, TCP_REQ_OK, TCP_READ_ERROR,
... ...
@@ -3433,6 +3433,7 @@ static inline int handle_new_connect(struct socket_info* si)
3433 3433
 	/* add socket to list */
3434 3434
 	tcpconn=tcpconn_new(new_sock, &su, dst_su, si, si->proto, S_CONN_ACCEPT);
3435 3435
 	if (likely(tcpconn)){
3436
+		tcpconn->flags|=F_CONN_PASSIVE;
3436 3437
 #ifdef TCP_PASS_NEW_CONNECTION_ON_DATA
3437 3438
 		atomic_set(&tcpconn->refcnt, 1); /* safe, not yet available to the
3438 3439
 											outside world */