mirror of
https://github.com/torvalds/linux.git
synced 2026-06-07 22:14:04 +02:00
BACKPORT: tcp/dccp: drop SYN packets if accept queue is full
Per listen(fd, backlog) rules, there is really no point accepting a SYN,
sending a SYNACK, and dropping the following ACK packet if accept queue
is full, because application is not draining accept queue fast enough.
This behavior is fooling TCP clients that believe they established a
flow, while there is nothing at server side. They might then send about
10 MSS (if using IW10) that will be dropped anyway while server is under
stress.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Acked-by: Neal Cardwell <ncardwell@google.com>
Acked-by: Yuchung Cheng <ycheng@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit 5ea8ea2cb7)
Backport for pass Android CTS CtsLibcoreTestCases:
libcore.javax.net.ServerSocketFactoryTest#testCreateServerSocketWithPortNoBacklog
Refer the comments on libcore/luni/src/test/java/libcore/javax/net/ServerSocketFactoryTest.java
// This test may fail on kernel versions between 4.4 and 4.9, due to a kernel implementation
// detail change. Backporting the following kernel change will fix the behavior.
// http://b/31960002
// https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=5ea8ea2cb7f1d0db15762c9b0bb9e7330425a071
public void testCreateServerSocketWithPortNoBacklog() throws IOException {
ServerSocket serverSocket = ServerSocketFactory.getDefault().createServerSocket(0, 1);
testSocket(serverSocket, 1);
}
Change-Id: I9bb3531480f4942447d8d4eded110aa31bc7c031
Signed-off-by: Tao Huang <huangtao@rock-chips.com>
This commit is contained in:
parent
5eb7acedd4
commit
702d673e9e
|
|
@ -289,11 +289,6 @@ static inline int inet_csk_reqsk_queue_len(const struct sock *sk)
|
|||
return reqsk_queue_len(&inet_csk(sk)->icsk_accept_queue);
|
||||
}
|
||||
|
||||
static inline int inet_csk_reqsk_queue_young(const struct sock *sk)
|
||||
{
|
||||
return reqsk_queue_len_young(&inet_csk(sk)->icsk_accept_queue);
|
||||
}
|
||||
|
||||
static inline int inet_csk_reqsk_queue_is_full(const struct sock *sk)
|
||||
{
|
||||
return inet_csk_reqsk_queue_len(sk) >= sk->sk_max_ack_backlog;
|
||||
|
|
|
|||
|
|
@ -592,13 +592,7 @@ int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
|
|||
if (inet_csk_reqsk_queue_is_full(sk))
|
||||
goto drop;
|
||||
|
||||
/*
|
||||
* Accept backlog is full. If we have already queued enough
|
||||
* of warm entries in syn queue, drop request. It is better than
|
||||
* clogging syn queue with openreqs with exponentially increasing
|
||||
* timeout.
|
||||
*/
|
||||
if (sk_acceptq_is_full(sk) && inet_csk_reqsk_queue_young(sk) > 1)
|
||||
if (sk_acceptq_is_full(sk))
|
||||
goto drop;
|
||||
|
||||
req = inet_reqsk_alloc(&dccp_request_sock_ops, sk, true);
|
||||
|
|
|
|||
|
|
@ -324,7 +324,7 @@ static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
|
|||
if (inet_csk_reqsk_queue_is_full(sk))
|
||||
goto drop;
|
||||
|
||||
if (sk_acceptq_is_full(sk) && inet_csk_reqsk_queue_young(sk) > 1)
|
||||
if (sk_acceptq_is_full(sk))
|
||||
goto drop;
|
||||
|
||||
req = inet_reqsk_alloc(&dccp6_request_sock_ops, sk, true);
|
||||
|
|
|
|||
|
|
@ -6188,13 +6188,7 @@ int tcp_conn_request(struct request_sock_ops *rsk_ops,
|
|||
goto drop;
|
||||
}
|
||||
|
||||
|
||||
/* Accept backlog is full. If we have already queued enough
|
||||
* of warm entries in syn queue, drop request. It is better than
|
||||
* clogging syn queue with openreqs with exponentially increasing
|
||||
* timeout.
|
||||
*/
|
||||
if (sk_acceptq_is_full(sk) && inet_csk_reqsk_queue_young(sk) > 1) {
|
||||
if (sk_acceptq_is_full(sk)) {
|
||||
NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_LISTENOVERFLOWS);
|
||||
goto drop;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user