diff --git a/src/event/ServerSocket.cxx b/src/event/ServerSocket.cxx index 77557db1d..e75d13560 100644 --- a/src/event/ServerSocket.cxx +++ b/src/event/ServerSocket.cxx @@ -182,12 +182,18 @@ ServerSocket::OneServerSocket::Open() address, 5); #ifdef HAVE_TCP - if (parent.ip_tos >= 0 && address.GetFamily() == AF_INET && - !_fd.SetIntOption(IPPROTO_IP, IP_TOS, parent.ip_tos)) { - const SocketErrorMessage msg; - FmtError(server_socket_domain, - "Could not set TOS option: {}", - (const char *)msg); + if (parent.dscp_class >= 0) { + const int family = address.GetFamily(); + if ((family == AF_INET && + !_fd.SetIntOption(IPPROTO_IP, IP_TOS, parent.dscp_class)) || + (family == AF_INET6 && + !_fd.SetIntOption(IPPROTO_IPV6, IPV6_TCLASS, + parent.dscp_class))) { + const SocketErrorMessage msg; + FmtError(server_socket_domain, + "Could not set DSCP class: {}", + (const char *)msg); + } } #endif diff --git a/src/event/ServerSocket.hxx b/src/event/ServerSocket.hxx index 56bdf40d7..6af6261a4 100644 --- a/src/event/ServerSocket.hxx +++ b/src/event/ServerSocket.hxx @@ -43,10 +43,10 @@ class ServerSocket { #ifdef HAVE_TCP /** - * A non-negative value sets the IPPROTO_IP/IP_TOS socket - * option. + * A non-negative value sets the IPPROTO_IP/IP_TOS or + * IPPROTO_IPV6/IPV6_TCLASS socket option. */ - int ip_tos = -1; + int dscp_class = -1; #endif unsigned next_serial = 1; @@ -60,10 +60,10 @@ public: } #ifdef HAVE_TCP - void SetIpTos(int _ip_tos) noexcept { + void SetDscpClass(int _dscp_class) noexcept { assert(sockets.empty()); - ip_tos = _ip_tos; + dscp_class = _dscp_class; } #endif