Skip to contentSkip to conversation

gdbstub: set listen backlog to 1

PATCH Applied Peter Wu 2 participants 2 messages May 4, 2016 – May 29, 2016

lore
Share & tools
lore

Peter Wu

author
#0 lore raw

PATCH 1/1 gdbstub: set listen backlog to 1

Avoid possible connection drops on Linux (when tcp_syncookies is disabled) or fallbacks to SYN cookies with the following kernel warning:

TCP: request_sock_TCP: Possible SYN flooding on port 1234. Sending cookies. Check SNMP counters.

Since Linux 4.4 (ef547f2ac16b "tcp: remove max_qlen_log"), a backlog of zero is really treated as the "queue length for completely established sockets waiting to be accepted" (listen(2)). This is apparently a valid interpretation of an "implementation-defined minimum value" for a backlog value of 0 (listen(3p)). Previous kernels would use 8 as minimum value, but that is no longer the case.

---
Hi,

This was also reported at Linux, but the author of that patch argued that it is intended behavior[1].

Kind regards,
Peter

[1]: https://lkml.kernel.org/r/[email protected]

---
 gdbstub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
gdbstub.c +1 -1
index b126bf5..f181dc3 100644
@@ -1630,7 +1630,7 @@ static int gdbserver_open(int port)
         close(fd);
         return -1;
     }
-    ret = listen(fd, 0);
+    ret = listen(fd, 1);
     if (ret < 0) {
         perror("listen");
         close(fd);
Signature · 1 line
2.8.0
#1 lore raw
Quoted 11 lines · Peter Wu

Avoid possible connection drops on Linux (when tcp_syncookies is disabled) or fallbacks to SYN cookies with the following kernel warning:

TCP: request_sock_TCP: Possible SYN flooding on port 1234. Sending cookies. Check SNMP counters.

Since Linux 4.4 (ef547f2ac16b "tcp: remove max_qlen_log"), a backlog of zero is really treated as the "queue length for completely established sockets waiting to be accepted" (listen(2)). This is apparently a valid interpretation of an "implementation-defined minimum value" for a backlog value of 0 (listen(3p)). Previous kernels would use 8 as minimum value, but that is no longer the case.

Applied to -trivial, thanks!

/mjt