From: Remi Gacogne Date: Sun, 12 Mar 2017 15:48:38 +0000 (+0100) Subject: auth: Add TCP Fast Open support X-Git-Tag: rec-4.1.0-alpha1~194^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F5137%2Fhead;p=thirdparty%2Fpdns.git auth: Add TCP Fast Open support --- diff --git a/docs/markdown/authoritative/settings.md b/docs/markdown/authoritative/settings.md index 642782b698..ca66118416 100644 --- a/docs/markdown/authoritative/settings.md +++ b/docs/markdown/authoritative/settings.md @@ -805,6 +805,14 @@ Limit TCP control to a specific client range. Password for TCP control. +## `tcp-fast-open` +* Integer +* Default: 0 (Disabled) +* Available since: 4.1 + +Enable TCP Fast Open support, if available, on the listening sockets. The numerical +value supplied is used as the queue size, 0 meaning disabled. + ## `tcp-idle-timeout` * Integer * Default: 5 diff --git a/pdns/common_startup.cc b/pdns/common_startup.cc index 4dd592b6bc..87bb65c223 100644 --- a/pdns/common_startup.cc +++ b/pdns/common_startup.cc @@ -195,6 +195,8 @@ void declareArguments() ::arg().setSwitch("8bit-dns", "Allow 8bit dns queries")="no"; ::arg().set("xfr-max-received-mbytes", "Maximum number of megabytes received from an incoming XFR")="100"; + + ::arg().set("tcp-fast-open", "Enable TCP Fast Open support on the listening sockets, using the supplied numerical value as the queue size")="0"; } static time_t s_start=time(0); diff --git a/pdns/tcpreceiver.cc b/pdns/tcpreceiver.cc index 03cf47ffe1..f16eda32d9 100644 --- a/pdns/tcpreceiver.cc +++ b/pdns/tcpreceiver.cc @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include "tcpreceiver.hh" @@ -1233,7 +1234,18 @@ TCPNameserver::TCPNameserver() L< 0) { +#ifdef TCP_FASTOPEN + int fastOpenQueueSize = ::arg().asNum("tcp-fast-open"); + if (setsockopt(s, IPPROTO_TCP, TCP_FASTOPEN, &fastOpenQueueSize, sizeof fastOpenQueueSize) < 0) { + L< 0) { +#ifdef TCP_FASTOPEN + int fastOpenQueueSize = ::arg().asNum("tcp-fast-open"); + if (setsockopt(s, IPPROTO_TCP, TCP_FASTOPEN, &fastOpenQueueSize, sizeof fastOpenQueueSize) < 0) { + L<