catch (const std::exception& e) {
warnlog(e.what());
}
+ } else {
+ try {
+ auto result = raiseSocketSendBufferToMax(socket);
+ if (result > 0) {
+ infolog("Raised send buffer to %u for local address '%s'", result, addr.toStringWithPort());
+ }
+ } catch (const std::exception& e) {
+ warnlog(e.what());
+ }
}
if (g_socketUDPRecvBuffer > 0) {
catch (const std::exception& e) {
warnlog(e.what());
}
+ } else {
+ try {
+ auto result = raiseSocketReceiveBufferToMax(socket);
+ if (result > 0) {
+ infolog("Raised receive buffer to %u for local address '%s'", result, addr.toStringWithPort());
+ }
+ } catch (const std::exception& e) {
+ warnlog(e.what());
+ }
}
}
#include "iputils.hh"
+#include <fstream>
#include <sys/socket.h>
#include <boost/format.hpp>
setSocketBuffer(fd, SO_SNDBUF, size);
}
+static uint32_t raiseSocketBufferToMax(int fd, int optname, const std::string& readMaxFromFile)
+{
+ std::ifstream ifs(readMaxFromFile);
+ if (ifs) {
+ std::string line;
+ if (getline(ifs, line)) {
+ auto max = pdns::checked_stoi<uint32_t>(line);
+ setSocketBuffer(fd, optname, max);
+ return max;
+ }
+ }
+ return 0;
+}
+
+uint32_t raiseSocketReceiveBufferToMax(int fd)
+{
+#ifdef __linux__
+ return raiseSocketBufferToMax(fd, SO_RCVBUF, "/proc/sys/net/core/rmem_max");
+#else
+ return 0;
+#endif
+}
+
+uint32_t raiseSocketSendBufferToMax(int fd)
+{
+#ifdef __linux__
+ return raiseSocketBufferToMax(fd, SO_SNDBUF, "/proc/sys/net/core/wmem_max");
+#else
+ return 0;
+#endif
+}
+
std::set<std::string> getListOfNetworkInterfaces()
{
std::set<std::string> result;
void setSocketBuffer(int fd, int optname, uint32_t size);
void setSocketReceiveBuffer(int fd, uint32_t size);
void setSocketSendBuffer(int fd, uint32_t size);
+uint32_t raiseSocketReceiveBufferToMax(int fd);
+uint32_t raiseSocketSendBufferToMax(int fd);