Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 78767
b: refs/heads/master
c: 490d504
h: refs/heads/master
i:
  78765: f20540a
  78763: c2cbda8
  78759: 267db22
  78751: a4ac478
v: v3
  • Loading branch information
Ilpo Järvinen authored and David S. Miller committed Jan 28, 2008
1 parent f5b8245 commit 004e49d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 35 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 389f661224cdbdf178553fb09a52dc6c8bf86890
refs/heads/master: 490d5046930276aae50dd16942649bfc626056f7
35 changes: 1 addition & 34 deletions trunk/include/net/tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -926,40 +926,7 @@ static const char *statename[]={
"Close Wait","Last ACK","Listen","Closing"
};
#endif

static inline void tcp_set_state(struct sock *sk, int state)
{
int oldstate = sk->sk_state;

switch (state) {
case TCP_ESTABLISHED:
if (oldstate != TCP_ESTABLISHED)
TCP_INC_STATS(TCP_MIB_CURRESTAB);
break;

case TCP_CLOSE:
if (oldstate == TCP_CLOSE_WAIT || oldstate == TCP_ESTABLISHED)
TCP_INC_STATS(TCP_MIB_ESTABRESETS);

sk->sk_prot->unhash(sk);
if (inet_csk(sk)->icsk_bind_hash &&
!(sk->sk_userlocks & SOCK_BINDPORT_LOCK))
inet_put_port(&tcp_hashinfo, sk);
/* fall through */
default:
if (oldstate==TCP_ESTABLISHED)
TCP_DEC_STATS(TCP_MIB_CURRESTAB);
}

/* Change state AFTER socket is unhashed to avoid closed
* socket sitting in hash tables.
*/
sk->sk_state = state;

#ifdef STATE_TRACE
SOCK_DEBUG(sk, "TCP sk=%p, State %s -> %s\n",sk, statename[oldstate],statename[state]);
#endif
}
extern void tcp_set_state(struct sock *sk, int state);

extern void tcp_done(struct sock *sk);

Expand Down
35 changes: 35 additions & 0 deletions trunk/net/ipv4/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1652,6 +1652,41 @@ int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
goto out;
}

void tcp_set_state(struct sock *sk, int state)
{
int oldstate = sk->sk_state;

switch (state) {
case TCP_ESTABLISHED:
if (oldstate != TCP_ESTABLISHED)
TCP_INC_STATS(TCP_MIB_CURRESTAB);
break;

case TCP_CLOSE:
if (oldstate == TCP_CLOSE_WAIT || oldstate == TCP_ESTABLISHED)
TCP_INC_STATS(TCP_MIB_ESTABRESETS);

sk->sk_prot->unhash(sk);
if (inet_csk(sk)->icsk_bind_hash &&
!(sk->sk_userlocks & SOCK_BINDPORT_LOCK))
inet_put_port(&tcp_hashinfo, sk);
/* fall through */
default:
if (oldstate==TCP_ESTABLISHED)
TCP_DEC_STATS(TCP_MIB_CURRESTAB);
}

/* Change state AFTER socket is unhashed to avoid closed
* socket sitting in hash tables.
*/
sk->sk_state = state;

#ifdef STATE_TRACE
SOCK_DEBUG(sk, "TCP sk=%p, State %s -> %s\n",sk, statename[oldstate],statename[state]);
#endif
}
EXPORT_SYMBOL_GPL(tcp_set_state);

/*
* State processing on a close. This implements the state shift for
* sending our FIN frame. Note that we only send a FIN for some
Expand Down

0 comments on commit 004e49d

Please sign in to comment.