From: weidong <weid@np.css.fujitsu.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net
Subject: Fix bugs in "Whether sock accept queue is full" checking
Date: Wed, 14 Feb 2007 11:30:57 -0500 [thread overview]
Message-ID: <1171470657.7414.15.camel@LINE> (raw)
Hi, All
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. The following patch can fix this
problem.
signed-off-by: Wei Dong <weid@np.css.fujitsu.com>
diff -ruN old/include/net/sock.h new/include/net/sock.h
--- old/include/net/sock.h 2007-02-03 08:38:21.000000000 -0500
+++ new/include/net/sock.h 2007-02-03 08:38:30.000000000 -0500
@@ -426,7 +426,7 @@
static inline int sk_acceptq_is_full(struct sock *sk)
{
- return sk->sk_ack_backlog > sk->sk_max_ack_backlog;
+ return sk->sk_ack_backlog >= sk->sk_max_ack_backlog;
}
/*
next reply other threads:[~2007-02-15 2:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-14 16:30 weidong [this message]
2007-02-22 11:13 ` Fix bugs in "Whether sock accept queue is full" checking David Miller
2007-02-22 18:09 ` Vlad Yasevich
2007-03-02 20:51 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1171470657.7414.15.camel@LINE \
--to=weid@np.css.fujitsu.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).