Commit ae4ddebe authored by Cristian Lumezanu's avatar Cristian Lumezanu Committed by Facebook GitHub Bot

Update TcpInfo namespaces

Summary: We update the TcpInfo namespace to `folly` (previosuly `folly::tcpinfo`) to avoid introducing unnecessary namespaces and to make it slightly easier to refer to. We also move the structs in the `TcpInfoTypes.h` file to the `folly::detail` namespace and move `LookupOptions` to the `TcpInfo` class, following comments in D22134355 (https://github.com/facebook/folly/commit/68a78d99d10743b54d38a550b2f0ebdc5c872f76).

Reviewed By: bschlinker

Differential Revision: D30159429

fbshipit-source-id: 7260fc80c2e76b3439c539b65cc188b2e5517b24
parent 416d85c5
......@@ -24,7 +24,6 @@
#endif
namespace folly {
namespace tcpinfo {
namespace {
constexpr std::array<
......@@ -52,7 +51,6 @@ static_assert(
using ms = std::chrono::milliseconds;
using us = std::chrono::microseconds;
using namespace tcpinfo;
TcpInfo::IoctlDispatcher* TcpInfo::IoctlDispatcher::getDefaultInstance() {
static TcpInfo::IoctlDispatcher dispatcher = {};
......@@ -69,7 +67,7 @@ int TcpInfo::IoctlDispatcher::ioctl(int fd, unsigned long request, void* argp) {
Expected<TcpInfo, std::errc> TcpInfo::initFromFd(
const NetworkSocket& fd,
const LookupOptions& options,
const TcpInfo::LookupOptions& options,
netops::Dispatcher& netopsDispatcher,
IoctlDispatcher& ioctlDispatcher) {
#ifndef FOLLY_HAVE_TCP_INFO
......@@ -85,7 +83,7 @@ Expected<TcpInfo, std::errc> TcpInfo::initFromFd(
auto ret = netopsDispatcher.getsockopt(
fd,
IPPROTO_TCP,
folly::tcpinfo::tcp_info_sock_opt,
folly::detail::tcp_info_sock_opt,
(void*)&info.tcpInfo,
&len);
if (ret < 0) {
......@@ -411,8 +409,10 @@ Optional<uint64_t> TcpInfo::bbrBwBytesPerSecond() const {
#ifndef FOLLY_HAVE_TCP_CC_INFO
return folly::none;
#elif defined(__linux__)
auto bbrBwLoOpt = getFieldAsOptUInt64(&tcp_bbr_info::bbr_bw_lo);
auto bbrBwHiOpt = getFieldAsOptUInt64(&tcp_bbr_info::bbr_bw_hi);
auto bbrBwLoOpt =
getFieldAsOptUInt64(&folly::TcpInfo::tcp_bbr_info::bbr_bw_lo);
auto bbrBwHiOpt =
getFieldAsOptUInt64(&folly::TcpInfo::tcp_bbr_info::bbr_bw_hi);
if (bbrBwLoOpt && bbrBwHiOpt) {
return ((int64_t)*bbrBwHiOpt << 32) + *bbrBwLoOpt;
}
......@@ -428,7 +428,7 @@ Optional<std::chrono::microseconds> TcpInfo::bbrMinrtt() const {
#ifndef FOLLY_HAVE_TCP_CC_INFO
return folly::none;
#elif defined(__linux__)
auto opt = getFieldAsOptUInt64(&tcp_bbr_info::bbr_min_rtt);
auto opt = getFieldAsOptUInt64(&folly::TcpInfo::tcp_bbr_info::bbr_min_rtt);
return (opt) ? us(*opt) : folly::Optional<us>();
#elif defined(__APPLE__)
return folly::none;
......@@ -441,7 +441,7 @@ Optional<uint64_t> TcpInfo::bbrPacingGain() const {
#ifndef FOLLY_HAVE_TCP_CC_INFO
return folly::none;
#elif defined(__linux__)
return getFieldAsOptUInt64(&tcp_bbr_info::bbr_pacing_gain);
return getFieldAsOptUInt64(&folly::TcpInfo::tcp_bbr_info::bbr_pacing_gain);
#elif defined(__APPLE__)
return folly::none;
#else
......@@ -453,7 +453,7 @@ Optional<uint64_t> TcpInfo::bbrCwndGain() const {
#ifndef FOLLY_HAVE_TCP_CC_INFO
return folly::none;
#elif defined(__linux__)
return getFieldAsOptUInt64(&tcp_bbr_info::bbr_cwnd_gain);
return getFieldAsOptUInt64(&folly::TcpInfo::tcp_bbr_info::bbr_cwnd_gain);
#elif defined(__APPLE__)
return folly::none;
#else
......@@ -539,8 +539,8 @@ void TcpInfo::initCcInfoFromFd(
LOG(FATAL) << "CongestionControlName::NumCcTypes is not a valid CC type";
}
tcpinfo::tcp_cc_info ccInfo = {};
socklen_t len = sizeof(tcpinfo::tcp_cc_info);
tcp_cc_info ccInfo = {};
socklen_t len = sizeof(tcp_cc_info);
const int ret = netopsDispatcher.getsockopt(
fd, IPPROTO_TCP, TCP_CC_INFO, (void*)&ccInfo, &len);
if (ret < 0) {
......@@ -574,5 +574,4 @@ void TcpInfo::initMemInfoFromFd(
#endif
}
} // namespace tcpinfo
} // namespace folly
......@@ -27,19 +27,6 @@
#include <folly/net/TcpInfoTypes.h>
namespace folly {
namespace tcpinfo {
/**
* Structure specifying options for TcpInfo::initFromFd.
*/
struct LookupOptions {
// On supported platforms, whether to fetch the name of the congestion
// control algorithm and any information exposed via TCP_CC_INFO.
bool getCcInfo{false};
// On supported platforms, whether to fetch socket buffer utilization.
bool getMemInfo{false};
};
/**
* Abstraction layer for capturing current TCP and congestion control state.
......@@ -112,6 +99,20 @@ struct TcpInfo {
NumCcTypes,
};
/**
* Structure specifying options for TcpInfo::initFromFd.
*/
struct LookupOptions {
// On supported platforms, whether to fetch the name of the congestion
// control algorithm and any information exposed via TCP_CC_INFO.
bool getCcInfo{false};
// On supported platforms, whether to fetch socket buffer utilization.
bool getMemInfo{false};
LookupOptions() {}
};
/**
* Dispatcher that enables calls to ioctl to be intercepted for tests.
*
......@@ -139,7 +140,7 @@ struct TcpInfo {
*/
static Expected<TcpInfo, std::errc> initFromFd(
const NetworkSocket& fd,
const LookupOptions& options = LookupOptions(),
const TcpInfo::LookupOptions& options = TcpInfo::LookupOptions(),
netops::Dispatcher& netopsDispatcher =
*netops::Dispatcher::getDefaultInstance(),
IoctlDispatcher& ioctlDispatcher =
......@@ -268,7 +269,7 @@ struct TcpInfo {
#if defined(FOLLY_HAVE_TCP_INFO)
public:
using tcp_info = folly::tcpinfo::tcp_info;
using tcp_info = folly::detail::tcp_info;
/**
* Returns pointer containing requested field from tcp_info struct.
......@@ -311,7 +312,10 @@ struct TcpInfo {
#if defined(FOLLY_HAVE_TCP_CC_INFO)
public:
using tcp_cc_info = folly::tcpinfo::tcp_cc_info;
using tcp_cc_info = folly::detail::tcp_cc_info;
using tcp_bbr_info = folly::detail::tcp_bbr_info;
using tcpvegas_info = folly::detail::tcpvegas_info;
using tcp_dctcp_info = folly::detail::tcp_dctcp_info;
// TCP_CA_NAME_MAX from <net/tcp.h> (Linux) or <netinet/tcp.h> (FreeBSD)
static constexpr socklen_t kLinuxTcpCaNameMax = 16;
......@@ -326,8 +330,7 @@ struct TcpInfo {
* specifics, use accessors such as bbrBwBitsPerSecond().
*/
template <typename T1>
folly::Optional<uint64_t> getFieldAsOptUInt64(
T1 tcpinfo::tcp_bbr_info::*field) const {
folly::Optional<uint64_t> getFieldAsOptUInt64(T1 tcp_bbr_info::*field) const {
if (maybeCcInfo.has_value() && ccNameEnum() == CongestionControlName::BBR) {
return getFieldAsOptUInt64(maybeCcInfo.value().bbr, field);
}
......@@ -342,7 +345,7 @@ struct TcpInfo {
*/
template <typename T1>
folly::Optional<uint64_t> getFieldAsOptUInt64(
T1 tcpinfo::tcpvegas_info::*field) const {
T1 tcpvegas_info::*field) const {
if (maybeCcInfo.hasValue() &&
ccNameEnum() == CongestionControlName::VEGAS) {
return getFieldAsOptUInt64(maybeCcInfo.value().vegas, field);
......@@ -358,7 +361,7 @@ struct TcpInfo {
*/
template <typename T1>
const folly::Optional<uint64_t> getFieldAsOptUInt64(
T1 tcpinfo::tcp_dctcp_info::*field) const {
T1 tcp_dctcp_info::*field) const {
if (maybeCcInfo.has_value() &&
(ccNameEnum() == CongestionControlName::DCTCP ||
ccNameEnum() == CongestionControlName::DCTCP_CUBIC ||
......@@ -410,5 +413,4 @@ struct TcpInfo {
folly::Optional<size_t> maybeRecvBufInUseBytes;
};
} // namespace tcpinfo
} // namespace folly
......@@ -27,7 +27,7 @@
#endif
namespace folly {
namespace tcpinfo {
namespace detail {
/**
*
......@@ -222,5 +222,5 @@ union tcp_cc_info {
};
#endif
} // namespace tcpinfo
} // namespace detail
} // namespace folly
......@@ -23,8 +23,7 @@
using namespace folly;
using namespace testing;
using namespace folly::tcpinfo;
using namespace folly::tcpinfo::test;
using namespace folly::test;
using us = std::chrono::microseconds;
......@@ -49,7 +48,7 @@ class TcpInfoTest : public Test {
}
void setupExpectCallCcInfo(
NetworkSocket& s, const folly::tcpinfo::tcp_cc_info& ccInfo) {
NetworkSocket& s, const folly::TcpInfo::tcp_cc_info& ccInfo) {
TcpInfoTestUtil::setupExpectCallCcInfo(mockNetOpsDispatcher_, s, ccInfo);
}
......@@ -74,8 +73,8 @@ class TcpInfoTest : public Test {
})));
}
static folly::tcpinfo::tcp_info getTestLatestTcpInfo() {
folly::tcpinfo::tcp_info tInfo = {};
static folly::TcpInfo::tcp_info getTestLatestTcpInfo() {
folly::TcpInfo::tcp_info tInfo = {};
tInfo.tcpi_state = 1;
tInfo.tcpi_ca_state = 2;
tInfo.tcpi_retransmits = 3;
......@@ -134,8 +133,8 @@ class TcpInfoTest : public Test {
return tInfo;
}
static folly::tcpinfo::tcp_info_legacy getTestLegacyTcpInfo() {
folly::tcpinfo::tcp_info_legacy tInfo = {};
static folly::detail::tcp_info_legacy getTestLegacyTcpInfo() {
folly::detail::tcp_info_legacy tInfo = {};
tInfo.tcpi_state = 1;
tInfo.tcpi_ca_state = 2;
tInfo.tcpi_retransmits = 3;
......@@ -171,8 +170,8 @@ class TcpInfoTest : public Test {
return tInfo;
}
static folly::tcpinfo::tcp_cc_info getTestBbrInfo() {
folly::tcpinfo::tcp_cc_info ccInfo = {};
static folly::TcpInfo::tcp_cc_info getTestBbrInfo() {
folly::TcpInfo::tcp_cc_info ccInfo = {};
ccInfo.bbr.bbr_bw_lo = 1;
ccInfo.bbr.bbr_bw_hi = 2;
ccInfo.bbr.bbr_min_rtt = 3;
......@@ -181,8 +180,8 @@ class TcpInfoTest : public Test {
return ccInfo;
}
static folly::tcpinfo::tcp_cc_info getTestVegasInfo() {
folly::tcpinfo::tcp_cc_info ccInfo = {};
static folly::TcpInfo::tcp_cc_info getTestVegasInfo() {
folly::TcpInfo::tcp_cc_info ccInfo = {};
ccInfo.vegas.tcpv_enabled = 6;
ccInfo.vegas.tcpv_rttcnt = 7;
ccInfo.vegas.tcpv_rtt = 8;
......@@ -190,8 +189,8 @@ class TcpInfoTest : public Test {
return ccInfo;
}
static folly::tcpinfo::tcp_cc_info getTestDctcpInfo() {
folly::tcpinfo::tcp_cc_info ccInfo = {};
static folly::TcpInfo::tcp_cc_info getTestDctcpInfo() {
folly::TcpInfo::tcp_cc_info ccInfo = {};
ccInfo.dctcp.dctcp_enabled = 10;
ccInfo.dctcp.dctcp_ce_state = 11;
ccInfo.dctcp.dctcp_alpha = 12;
......@@ -209,11 +208,11 @@ class TcpInfoTest : public Test {
EXPECT_FALSE(wrappedTcpInfo.cwndInPackets().has_value());
EXPECT_FALSE(
wrappedTcpInfo
.getFieldAsOptUInt64(&folly::tcpinfo::tcp_info::tcpi_total_retrans)
.getFieldAsOptUInt64(&folly::TcpInfo::tcp_info::tcpi_total_retrans)
.has_value());
EXPECT_FALSE(
wrappedTcpInfo
.getFieldAsOptUInt64(&folly::tcpinfo::tcp_info::tcpi_snd_cwnd)
.getFieldAsOptUInt64(&folly::TcpInfo::tcp_info::tcpi_snd_cwnd)
.has_value());
}
......@@ -257,13 +256,13 @@ class TcpInfoTest : public Test {
EXPECT_EQ(
controlTcpInfo.tcpi_snd_cwnd,
wrappedTcpInfo.getFieldAsOptUInt64(
&folly::tcpinfo::tcp_info::tcpi_snd_cwnd));
&folly::TcpInfo::tcp_info::tcpi_snd_cwnd));
// try using getTcpInfoFieldAsOpt to get one of the newer fields
// this field should _not_ be available in legacy
EXPECT_FALSE(
wrappedTcpInfo
.getFieldAsOptUInt64(&folly::tcpinfo::tcp_info::tcpi_delivery_rate)
.getFieldAsOptUInt64(&folly::TcpInfo::tcp_info::tcpi_delivery_rate)
.hasValue());
}
......@@ -318,7 +317,7 @@ class TcpInfoTest : public Test {
EXPECT_EQ(
controlTcpInfo.tcpi_delivery_rate,
wrappedTcpInfo.getFieldAsOptUInt64(
&folly::tcpinfo::tcp_info::tcpi_delivery_rate));
&folly::TcpInfo::tcp_info::tcpi_delivery_rate));
}
static void checkNoCcNameType(const TcpInfo& wrappedTcpInfo) {
......@@ -331,12 +330,16 @@ class TcpInfoTest : public Test {
// should get false for all three types
EXPECT_FALSE(wrappedTcpInfo.bbrCwndGain().has_value());
EXPECT_FALSE(
wrappedTcpInfo.getFieldAsOptUInt64(&tcp_bbr_info::bbr_pacing_gain)
wrappedTcpInfo
.getFieldAsOptUInt64(&folly::TcpInfo::tcp_bbr_info::bbr_pacing_gain)
.has_value());
EXPECT_FALSE(wrappedTcpInfo.getFieldAsOptUInt64(&tcpvegas_info::tcpv_rtt)
.has_value());
EXPECT_FALSE(
wrappedTcpInfo.getFieldAsOptUInt64(&tcp_dctcp_info::dctcp_alpha)
wrappedTcpInfo
.getFieldAsOptUInt64(&folly::TcpInfo::tcpvegas_info::tcpv_rtt)
.has_value());
EXPECT_FALSE(
wrappedTcpInfo
.getFieldAsOptUInt64(&folly::TcpInfo::tcp_dctcp_info::dctcp_alpha)
.has_value());
}
......@@ -347,7 +350,8 @@ class TcpInfoTest : public Test {
const auto controlCcInfo = getTestBbrInfo().bbr;
EXPECT_EQ(
controlCcInfo.bbr_pacing_gain,
wrappedTcpInfo.getFieldAsOptUInt64(&tcp_bbr_info::bbr_pacing_gain));
wrappedTcpInfo.getFieldAsOptUInt64(
&folly::TcpInfo::tcp_bbr_info::bbr_pacing_gain));
const uint64_t bbrBwBytesPerSecond =
(uint64_t(controlCcInfo.bbr_bw_hi) << 32) + controlCcInfo.bbr_bw_lo;
EXPECT_EQ(bbrBwBytesPerSecond, wrappedTcpInfo.bbrBwBytesPerSecond());
......@@ -359,12 +363,14 @@ class TcpInfoTest : public Test {
// try using getFieldAsOptUInt64 directly to get one of the BBR fields
EXPECT_EQ(
controlCcInfo.bbr_pacing_gain,
wrappedTcpInfo.getFieldAsOptUInt64(&tcp_bbr_info::bbr_pacing_gain));
wrappedTcpInfo.getFieldAsOptUInt64(
&folly::TcpInfo::tcp_bbr_info::bbr_pacing_gain));
// no CC info for the other types
EXPECT_FALSE(wrappedTcpInfo.getFieldAsOptUInt64(&tcpvegas_info::tcpv_rtt));
EXPECT_FALSE(
wrappedTcpInfo.getFieldAsOptUInt64(&tcp_dctcp_info::dctcp_alpha));
EXPECT_FALSE(wrappedTcpInfo.getFieldAsOptUInt64(
&folly::TcpInfo::tcpvegas_info::tcpv_rtt));
EXPECT_FALSE(wrappedTcpInfo.getFieldAsOptUInt64(
&folly::TcpInfo::tcp_dctcp_info::dctcp_alpha));
}
static void checkCcFieldsAgainstVegas(const TcpInfo& wrappedTcpInfo) {
......@@ -375,15 +381,18 @@ class TcpInfoTest : public Test {
const auto controlCcInfo = getTestVegasInfo().vegas;
EXPECT_EQ(
controlCcInfo.tcpv_rtt,
wrappedTcpInfo.getFieldAsOptUInt64(&tcpvegas_info::tcpv_rtt));
wrappedTcpInfo.getFieldAsOptUInt64(
&folly::TcpInfo::tcpvegas_info::tcpv_rtt));
// no CC info for the other types
EXPECT_FALSE(wrappedTcpInfo.bbrCwndGain().has_value());
EXPECT_FALSE(
wrappedTcpInfo.getFieldAsOptUInt64(&tcp_bbr_info::bbr_pacing_gain)
wrappedTcpInfo
.getFieldAsOptUInt64(&folly::TcpInfo::tcp_bbr_info::bbr_pacing_gain)
.has_value());
EXPECT_FALSE(
wrappedTcpInfo.getFieldAsOptUInt64(&tcp_dctcp_info::dctcp_alpha)
wrappedTcpInfo
.getFieldAsOptUInt64(&folly::TcpInfo::tcp_dctcp_info::dctcp_alpha)
.has_value());
}
......@@ -415,18 +424,23 @@ class TcpInfoTest : public Test {
const auto controlCcInfo = getTestDctcpInfo().dctcp;
EXPECT_EQ(
controlCcInfo.dctcp_alpha,
wrappedTcpInfo.getFieldAsOptUInt64(&tcp_dctcp_info::dctcp_alpha));
wrappedTcpInfo.getFieldAsOptUInt64(
&folly::TcpInfo::tcp_dctcp_info::dctcp_alpha));
EXPECT_EQ(
controlCcInfo.dctcp_enabled,
wrappedTcpInfo.getFieldAsOptUInt64(&tcp_dctcp_info::dctcp_enabled));
wrappedTcpInfo.getFieldAsOptUInt64(
&folly::TcpInfo::tcp_dctcp_info::dctcp_enabled));
// no CC info for the other types
EXPECT_FALSE(wrappedTcpInfo.bbrCwndGain().has_value());
EXPECT_FALSE(
wrappedTcpInfo.getFieldAsOptUInt64(&tcp_bbr_info::bbr_pacing_gain)
wrappedTcpInfo
.getFieldAsOptUInt64(&folly::TcpInfo::tcp_bbr_info::bbr_pacing_gain)
.has_value());
EXPECT_FALSE(
wrappedTcpInfo
.getFieldAsOptUInt64(&folly::TcpInfo::tcpvegas_info::tcpv_rtt)
.has_value());
EXPECT_FALSE(wrappedTcpInfo.getFieldAsOptUInt64(&tcpvegas_info::tcpv_rtt)
.has_value());
}
static void checkNoMemoryInfo(const TcpInfo& wrappedTcpInfo) {
......@@ -443,7 +457,7 @@ TEST_F(TcpInfoTest, LegacyStruct) {
NetworkSocket s(0);
setupExpectCallTcpInfo(s, getTestLegacyTcpInfo());
LookupOptions options = {};
TcpInfo::LookupOptions options = {};
options.getCcInfo = false;
options.getMemInfo = false;
auto wrappedTcpInfoExpect =
......@@ -463,7 +477,7 @@ TEST_F(TcpInfoTest, LatestStruct) {
NetworkSocket s(0);
setupExpectCallTcpInfo(s, getTestLatestTcpInfo());
LookupOptions options = {};
TcpInfo::LookupOptions options = {};
options.getCcInfo = false;
options.getMemInfo = false;
auto wrappedTcpInfoExpect =
......@@ -485,7 +499,7 @@ TEST_F(TcpInfoTest, LatestStructWithCcInfo) {
setupExpectCallCcName(s, "bbr");
setupExpectCallCcInfo(s, getTestBbrInfo());
LookupOptions options = {};
TcpInfo::LookupOptions options = {};
options.getCcInfo = true;
options.getMemInfo = false;
auto wrappedTcpInfoExpect = TcpInfo::initFromFd(
......@@ -508,7 +522,7 @@ TEST_F(TcpInfoTest, LatestStructWithMemInfo) {
ExpectCallMemInfoConfig{
.siocoutq = kTestSiocoutqVal, .siocinq = kTestSiocinqVal});
LookupOptions options = {};
TcpInfo::LookupOptions options = {};
options.getCcInfo = false;
options.getMemInfo = true;
auto wrappedTcpInfoExpect = TcpInfo::initFromFd(
......@@ -535,7 +549,7 @@ TEST_F(TcpInfoTest, LatestStructWithCcInfoAndMemInfo) {
ExpectCallMemInfoConfig{
.siocoutq = kTestSiocoutqVal, .siocinq = kTestSiocinqVal});
LookupOptions options = {};
TcpInfo::LookupOptions options = {};
options.getCcInfo = true;
options.getMemInfo = true;
auto wrappedTcpInfoExpect = TcpInfo::initFromFd(
......@@ -558,7 +572,7 @@ TEST_F(TcpInfoTest, LatestStructWithCcInfoAndMemInfoUnknownCc) {
ExpectCallMemInfoConfig{
.siocoutq = kTestSiocoutqVal, .siocinq = kTestSiocinqVal});
LookupOptions options = {};
TcpInfo::LookupOptions options = {};
options.getCcInfo = true;
options.getMemInfo = true;
auto wrappedTcpInfoExpect = TcpInfo::initFromFd(
......@@ -581,7 +595,7 @@ TEST_F(TcpInfoTest, LatestStructWithCcInfoAndMemInfoUnknownCc) {
TEST_F(TcpInfoTest, FailUninitializedSocket) {
NetworkSocket s;
LookupOptions options = {};
TcpInfo::LookupOptions options = {};
options.getCcInfo = true;
options.getMemInfo = true;
auto wrappedTcpInfoExpect = TcpInfo::initFromFd(
......@@ -592,7 +606,7 @@ TEST_F(TcpInfoTest, FailUninitializedSocket) {
TEST_F(TcpInfoTest, FailTcpInfo) {
NetworkSocket s(0);
LookupOptions options = {};
TcpInfo::LookupOptions options = {};
options.getCcInfo = true;
options.getMemInfo = true;
EXPECT_CALL(mockNetOpsDispatcher_, getsockopt(s, IPPROTO_TCP, TCP_INFO, _, _))
......@@ -622,7 +636,7 @@ TEST_F(TcpInfoTest, FailCcName) {
Pointee(Eq(TcpInfo::kLinuxTcpCaNameMax))))
.WillOnce(Return(-1));
LookupOptions options = {};
TcpInfo::LookupOptions options = {};
options.getCcInfo = true;
options.getMemInfo = true;
auto wrappedTcpInfoExpect = TcpInfo::initFromFd(
......@@ -660,7 +674,7 @@ TEST_F(TcpInfoTest, FailCcInfo) {
Pointee(Eq(sizeof(TcpInfo::tcp_cc_info)))))
.WillOnce(Return(-1));
LookupOptions options = {};
TcpInfo::LookupOptions options = {};
options.getCcInfo = true;
options.getMemInfo = true;
auto wrappedTcpInfoExpect = TcpInfo::initFromFd(
......@@ -695,7 +709,7 @@ TEST_F(TcpInfoTest, FailSiocoutq) {
return 0;
})));
LookupOptions options = {};
TcpInfo::LookupOptions options = {};
options.getCcInfo = true;
options.getMemInfo = true;
auto wrappedTcpInfoExpect = TcpInfo::initFromFd(
......@@ -726,7 +740,7 @@ TEST_F(TcpInfoTest, FailSiocinq) {
EXPECT_CALL(mockIoctlDispatcher_, ioctl(s.toFd(), SIOCINQ, testing::_))
.WillOnce(Return(-1));
LookupOptions options = {};
TcpInfo::LookupOptions options = {};
options.getCcInfo = true;
options.getMemInfo = true;
auto wrappedTcpInfoExpect = TcpInfo::initFromFd(
......@@ -806,7 +820,7 @@ TEST_P(TcpInfoTestCcParam, FetchAllAndCheck) {
FAIL();
}
LookupOptions options = {};
TcpInfo::LookupOptions options = {};
options.getCcInfo = true;
options.getMemInfo = true;
auto wrappedTcpInfoExpect = TcpInfo::initFromFd(
......
......@@ -24,7 +24,6 @@
#include <folly/portability/GTest.h>
namespace folly {
namespace tcpinfo {
namespace test {
class TcpInfoTestUtil {
......@@ -32,7 +31,7 @@ class TcpInfoTestUtil {
/**
* Mock to enable testing of socket buffer lookups.
*/
class MockIoctlDispatcher : public folly::tcpinfo::TcpInfo::IoctlDispatcher {
class MockIoctlDispatcher : public folly::TcpInfo::IoctlDispatcher {
public:
MockIoctlDispatcher() = default;
virtual ~MockIoctlDispatcher() = default;
......@@ -79,8 +78,7 @@ class TcpInfoTestUtil {
IPPROTO_TCP,
TCP_CONGESTION,
testing::NotNull(),
testing::Pointee(
testing::Eq(folly::tcpinfo::TcpInfo::kLinuxTcpCaNameMax))))
testing::Pointee(testing::Eq(folly::TcpInfo::kLinuxTcpCaNameMax))))
.WillOnce(testing::WithArgs<3, 4>(
testing::Invoke([ccName](void* optval, socklen_t* optlen) {
EXPECT_THAT(optlen, testing::Pointee(testing::Ge(ccName.size())));
......@@ -89,8 +87,8 @@ class TcpInfoTestUtil {
ccName.end(),
((std::array<
char,
(unsigned int)
folly::tcpinfo::TcpInfo::kLinuxTcpCaNameMax>*)optval)
(unsigned int)folly::TcpInfo::kLinuxTcpCaNameMax>*)
optval)
->data());
*optlen = std::min<socklen_t>(ccName.size(), *optlen);
return 0;
......@@ -100,7 +98,7 @@ class TcpInfoTestUtil {
static void setupExpectCallCcInfo(
folly::netops::test::MockDispatcher& mockDispatcher,
const NetworkSocket& s,
const folly::tcpinfo::tcp_cc_info& ccInfo) {
const folly::TcpInfo::tcp_cc_info& ccInfo) {
EXPECT_CALL(
mockDispatcher,
getsockopt(
......@@ -108,7 +106,7 @@ class TcpInfoTestUtil {
IPPROTO_TCP,
TCP_CC_INFO,
testing::NotNull(),
testing::Pointee(testing::Eq(sizeof(folly::tcpinfo::tcp_cc_info)))))
testing::Pointee(testing::Eq(sizeof(folly::TcpInfo::tcp_cc_info)))))
.WillOnce(testing::WithArgs<3, 4>(
testing::Invoke([ccInfo](void* optval, socklen_t* optlen) {
auto copied = std::min((unsigned int)sizeof ccInfo, *optlen);
......@@ -120,5 +118,4 @@ class TcpInfoTestUtil {
};
} // namespace test
} // namespace tcpinfo
} // namespace folly
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