From: Otto Moerbeek Date: Wed, 20 Jan 2021 10:04:50 +0000 (+0100) Subject: sdig now works with fastopen X-Git-Tag: rec-4.5.0-beta1^2~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9ef45e517be735c589972c5b272152aa4d3f845a;p=thirdparty%2Fpdns.git sdig now works with fastopen --- diff --git a/pdns/lwres.cc b/pdns/lwres.cc index 4ff3809f11..96f353b487 100644 --- a/pdns/lwres.cc +++ b/pdns/lwres.cc @@ -329,7 +329,7 @@ LWResult::Result asyncresolve(const ComboAddress& ip, const DNSName& domain, int s.setNonBlocking(); ComboAddress local = pdns::getQueryLocalAddress(ip.sin4.sin_family, 0); if (SyncRes::s_tcp_fast_open > 0) { - s.setFastOpen(SyncRes::s_tcp_fast_open); + s.setFastOpenConnect(); } s.bind(local); diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index d9ec1ad229..58546cd921 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -3292,7 +3292,7 @@ static void makeTCPServerSockets(deferredAdd_t& deferredAdds, std::set& tcp if (SyncRes::s_tcp_fast_open > 0) { #ifdef TCP_FASTOPEN - if (setsockopt(fd, IPPROTO_TCP, TCP_FASTOPEN, &SyncRes::tcp_fast_open, sizeof SyncRes::tcp_fast_open) < 0) { + if (setsockopt(fd, IPPROTO_TCP, TCP_FASTOPEN, &SyncRes::s_tcp_fast_open, sizeof SyncRes::s_tcp_fast_open) < 0) { int err = errno; g_log<>>>>>> 5b8fccd32 (sdig now works with fastopen) "[proxy UDP(0)/TCP(1) SOURCE-IP-ADDRESS-AND-PORT DESTINATION-IP-ADDRESS-AND-PORT]" "dumpluaraw" << endl; @@ -212,6 +217,7 @@ try { bool dnssec = false; bool recurse = false; bool tcp = false; + bool fastopen = false; bool showflags = false; bool hidesoadetails = false; bool doh = false; @@ -262,6 +268,7 @@ try { hidettl = true; else if (strcmp(argv[i], "tcp") == 0) tcp = true; +<<<<<<< HEAD else if (strcmp(argv[i], "dot") == 0) dot = true; else if (strcmp(argv[i], "insecure") == 0) @@ -269,6 +276,11 @@ try { else if (strcmp(argv[i], "fastOpen") == 0) fastOpen = true; else if (strcmp(argv[i], "ednssubnet") == 0) { +======= + if (strcmp(argv[i], "fastopen") == 0) + fastopen = true; + if (strcmp(argv[i], "ednssubnet") == 0) { +>>>>>>> 5b8fccd32 (sdig now works with fastopen) if (argc < i + 2) { cerr << "ednssubnet needs an argument" << endl; exit(EXIT_FAILURE); diff --git a/pdns/sstuff.hh b/pdns/sstuff.hh index 548e0d0729..31f3d007b8 100644 --- a/pdns/sstuff.hh +++ b/pdns/sstuff.hh @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -127,10 +128,12 @@ public: } } - void setFastOpen(int fastOpenQueueSize) + void setFastOpenConnect() { #ifdef TCP_FASTOPEN_CONNECT - setsockopt(d_socket, IPPROTO_TCP, TCP_FASTOPEN_CONNECT, &fastOpenQueueSize, sizeof fastOpenQueueSize); + int on = 1; + if (setsockopt(d_socket, IPPROTO_TCP, TCP_FASTOPEN_CONNECT, &on, sizeof(on)) < 0) + throw NetworkError("While setting TCP_FASTOPEN_CONNECT: " + stringerror()); #endif }