Commit 9074a5ba authored by Prabhakaran Ganesan's avatar Prabhakaran Ganesan Committed by Facebook Github Bot

Perform TOS reflection only if the TOS value in SYN is non-zero

Summary:
TOS reflected is implemented in the AsyncServerSocket layer. The way it works is by extracting the TOS value from cached SYN packet and applying a setsockopt() on the accepted socket. But if the TOS value in the cached SYN packet is ZERO, this results in TOS=0 for the accepted socket, resulting in problems.

Made changes to limit TOS reflection only if SYN carries non-zero TOS.

Reviewed By: yfeldblum

Differential Revision: D15633518

fbshipit-source-id: 856ba2059145e37fdab580b094349632677a40ba
parent 6829ab70
...@@ -872,16 +872,21 @@ void AsyncServerSocket::handlerReady( ...@@ -872,16 +872,21 @@ void AsyncServerSocket::handlerReady(
uint32_t tosWord = folly::Endian::big(buffer[0]); uint32_t tosWord = folly::Endian::big(buffer[0]);
if (addressFamily == AF_INET6) { if (addressFamily == AF_INET6) {
tosWord = (tosWord & 0x0FC00000) >> 20; tosWord = (tosWord & 0x0FC00000) >> 20;
ret = netops::setsockopt( // Set the TOS on the return socket only if it is non-zero
clientSocket, if (tosWord) {
IPPROTO_IPV6, ret = netops::setsockopt(
IPV6_TCLASS, clientSocket,
&tosWord, IPPROTO_IPV6,
sizeof(tosWord)); IPV6_TCLASS,
&tosWord,
sizeof(tosWord));
}
} else if (addressFamily == AF_INET) { } else if (addressFamily == AF_INET) {
tosWord = (tosWord & 0x00FC0000) >> 16; tosWord = (tosWord & 0x00FC0000) >> 16;
ret = netops::setsockopt( if (tosWord) {
clientSocket, IPPROTO_IP, IP_TOS, &tosWord, sizeof(tosWord)); ret = netops::setsockopt(
clientSocket, IPPROTO_IP, IP_TOS, &tosWord, sizeof(tosWord));
}
} }
if (ret != 0) { if (ret != 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment