diff options
author | Wei Dong <weid@np.css.fujitsu.com> | 2007-03-02 15:37:26 -0500 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-03-02 23:37:33 -0500 |
commit | 8488df894d05d6fa41c2bd298c335f944bb0e401 (patch) | |
tree | 2d79c5c57a71833a1c55f1d39e6628f486ed2539 | |
parent | bb648a0d22908116b4ef168935a160d7f17c4e6d (diff) |
[NET]: Fix bugs in "Whether sock accept queue is full" checking
when I use linux TCP socket, and find there is a bug in function
sk_acceptq_is_full().
When a new SYN comes, TCP module first checks its validation. If valid,
send SYN,ACK to the client and add the sock to the syn hash table. Next
time if received the valid ACK for SYN,ACK from the client. server will
accept this connection and increase the sk->sk_ack_backlog -- which is
done in function tcp_check_req().We check wether acceptq is full in
function tcp_v4_syn_recv_sock().
Consider an example:
After listen(sockfd, 1) system call, sk->sk_max_ack_backlog is set to
1. As we know, sk->sk_ack_backlog is initialized to 0. Assuming accept()
system call is not invoked now.
1. 1st connection comes. invoke sk_acceptq_is_full(). sk-
>sk_ack_backlog=0 sk->sk_max_ack_backlog=1, function return 0 accept
this connection. Increase the sk->sk_ack_backlog
2. 2nd connection comes. invoke sk_acceptq_is_full(). sk-
>sk_ack_backlog=1 sk->sk_max_ack_backlog=1, function return 0 accept
this connection. Increase the sk->sk_ack_backlog
3. 3rd connection comes. invoke sk_acceptq_is_full(). sk-
>sk_ack_backlog=2 sk->sk_max_ack_backlog=1, function return 1. Refuse
this connection.
I think it has bugs. after listen system call. sk->sk_max_ack_backlog=1
but now it can accept 2 connections.
Signed-off-by: Wei Dong <weid@np.css.fujitsu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/net/sock.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/include/net/sock.h b/include/net/sock.h index 2c7d60ca3548..849c7df23181 100644 --- a/include/net/sock.h +++ b/include/net/sock.h | |||
@@ -426,7 +426,7 @@ static inline void sk_acceptq_added(struct sock *sk) | |||
426 | 426 | ||
427 | static inline int sk_acceptq_is_full(struct sock *sk) | 427 | static inline int sk_acceptq_is_full(struct sock *sk) |
428 | { | 428 | { |
429 | return sk->sk_ack_backlog > sk->sk_max_ack_backlog; | 429 | return sk->sk_ack_backlog >= sk->sk_max_ack_backlog; |
430 | } | 430 | } |
431 | 431 | ||
432 | /* | 432 | /* |