From 940d78115931e93a665643ca5467d2995d5993ec Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Sun, 12 Mar 2017 16:48:38 +0100 Subject: [PATCH] auth: Add TCP Fast Open support --- docs/markdown/authoritative/settings.md | 8 ++++++++ pdns/common_startup.cc | 2 ++ pdns/tcpreceiver.cc | 26 ++++++++++++++++++++++++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/docs/markdown/authoritative/settings.md b/docs/markdown/authoritative/settings.md index 642782b69..ca6611841 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 4dd592b6b..87bb65c22 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 03cf47ffe..f16eda32d 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<