mirror of
https://github.com/facebookincubator/mvfst.git
synced 2025-08-06 22:22:38 +03:00
Folly SocketOptionMap with strings - separate cmsgs
Summary: Splitting cmgs from socket options. Reviewed By: mjoras Differential Revision: D49557451 fbshipit-source-id: fa3005170d049557d1c845fd14b0ada73b58b377
This commit is contained in:
committed by
Facebook GitHub Bot
parent
1626c53f1e
commit
c0e008c266
@@ -3826,11 +3826,11 @@ void QuicTransportBase::notifyAppRateLimited() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuicTransportBase::setCmsgs(const folly::SocketOptionMap& options) {
|
void QuicTransportBase::setCmsgs(const folly::SocketCmsgMap& options) {
|
||||||
socket_->setCmsgs(options);
|
socket_->setCmsgs(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuicTransportBase::appendCmsgs(const folly::SocketOptionMap& options) {
|
void QuicTransportBase::appendCmsgs(const folly::SocketCmsgMap& options) {
|
||||||
socket_->appendCmsgs(options);
|
socket_->appendCmsgs(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3904,7 +3904,7 @@ QuicTransportBase::setStreamGroupRetransmissionPolicy(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void QuicTransportBase::updatePacketProcessorsPrewriteRequests() {
|
void QuicTransportBase::updatePacketProcessorsPrewriteRequests() {
|
||||||
folly::SocketOptionMap cmsgs;
|
folly::SocketCmsgMap cmsgs;
|
||||||
for (const auto& pp : conn_->packetProcessors) {
|
for (const auto& pp : conn_->packetProcessors) {
|
||||||
// In case of overlapping cmsg keys, the priority is given to
|
// In case of overlapping cmsg keys, the priority is given to
|
||||||
// that were added to the QuicSocket first.
|
// that were added to the QuicSocket first.
|
||||||
@@ -3921,7 +3921,7 @@ void QuicTransportBase::updatePacketProcessorsPrewriteRequests() {
|
|||||||
conn_->socketCmsgsState.targetWriteCount = conn_->writeCount;
|
conn_->socketCmsgsState.targetWriteCount = conn_->writeCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
folly::Optional<folly::SocketOptionMap>
|
folly::Optional<folly::SocketCmsgMap>
|
||||||
QuicTransportBase::getAdditionalCmsgsForAsyncUDPSocket() {
|
QuicTransportBase::getAdditionalCmsgsForAsyncUDPSocket() {
|
||||||
if (conn_->socketCmsgsState.additionalCmsgs) {
|
if (conn_->socketCmsgsState.additionalCmsgs) {
|
||||||
// This callback should be happening for the target write
|
// This callback should be happening for the target write
|
||||||
|
@@ -660,9 +660,9 @@ class QuicTransportBase : public QuicSocket, QuicStreamPrioritiesObserver {
|
|||||||
* specific transport and does not change the other sockets sharing the same
|
* specific transport and does not change the other sockets sharing the same
|
||||||
* fd.
|
* fd.
|
||||||
*/
|
*/
|
||||||
void setCmsgs(const folly::SocketOptionMap& options);
|
void setCmsgs(const folly::SocketCmsgMap& options);
|
||||||
|
|
||||||
void appendCmsgs(const folly::SocketOptionMap& options);
|
void appendCmsgs(const folly::SocketCmsgMap& options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the policy per stream group id.
|
* Sets the policy per stream group id.
|
||||||
@@ -852,7 +852,7 @@ class QuicTransportBase : public QuicSocket, QuicStreamPrioritiesObserver {
|
|||||||
* The callback function for AsyncUDPSocket to provide the additional cmsgs
|
* The callback function for AsyncUDPSocket to provide the additional cmsgs
|
||||||
* required by this QuicSocket's packet processors.
|
* required by this QuicSocket's packet processors.
|
||||||
*/
|
*/
|
||||||
folly::Optional<folly::SocketOptionMap> getAdditionalCmsgsForAsyncUDPSocket();
|
folly::Optional<folly::SocketCmsgMap> getAdditionalCmsgsForAsyncUDPSocket();
|
||||||
|
|
||||||
std::atomic<QuicEventBase*> qEvbPtr_;
|
std::atomic<QuicEventBase*> qEvbPtr_;
|
||||||
std::unique_ptr<QuicAsyncUDPSocketWrapper> socket_;
|
std::unique_ptr<QuicAsyncUDPSocketWrapper> socket_;
|
||||||
|
@@ -4212,7 +4212,7 @@ TEST_P(QuicTransportImplTestBase, ZeroLengthDatagramBufs) {
|
|||||||
|
|
||||||
TEST_P(QuicTransportImplTestBase, Cmsgs) {
|
TEST_P(QuicTransportImplTestBase, Cmsgs) {
|
||||||
transport->setServerConnectionId();
|
transport->setServerConnectionId();
|
||||||
folly::SocketOptionMap cmsgs;
|
folly::SocketCmsgMap cmsgs;
|
||||||
cmsgs[{IPPROTO_IP, IP_TOS}] = 123;
|
cmsgs[{IPPROTO_IP, IP_TOS}] = 123;
|
||||||
EXPECT_CALL(*socketPtr, setCmsgs(_)).Times(1);
|
EXPECT_CALL(*socketPtr, setCmsgs(_)).Times(1);
|
||||||
transport->setCmsgs(cmsgs);
|
transport->setCmsgs(cmsgs);
|
||||||
|
@@ -975,7 +975,7 @@ TYPED_TEST(
|
|||||||
this->loopForWrites();
|
this->loopForWrites();
|
||||||
ASSERT_FALSE(this->getConn().outstandings.packets.empty());
|
ASSERT_FALSE(this->getConn().outstandings.packets.empty());
|
||||||
|
|
||||||
folly::SocketOptionMap expectedCmsgs;
|
folly::SocketCmsgMap expectedCmsgs;
|
||||||
expectedCmsgs[{IPPROTO_IPV6, IPV6_HOPLIMIT}] = 255;
|
expectedCmsgs[{IPPROTO_IPV6, IPV6_HOPLIMIT}] = 255;
|
||||||
expectedCmsgs[{IPPROTO_IPV6, IPV6_DONTFRAG}] = 1;
|
expectedCmsgs[{IPPROTO_IPV6, IPV6_DONTFRAG}] = 1;
|
||||||
auto pkt = this->getConn().outstandings.packets.rbegin();
|
auto pkt = this->getConn().outstandings.packets.rbegin();
|
||||||
@@ -1019,7 +1019,7 @@ TYPED_TEST(
|
|||||||
ASSERT_EQ(this->getConn().outstandings.packets.size(), packetsSent);
|
ASSERT_EQ(this->getConn().outstandings.packets.size(), packetsSent);
|
||||||
|
|
||||||
// Verify both packets are marked
|
// Verify both packets are marked
|
||||||
folly::SocketOptionMap expectedCmsgs;
|
folly::SocketCmsgMap expectedCmsgs;
|
||||||
expectedCmsgs[{IPPROTO_IPV6, IPV6_HOPLIMIT}] = 255;
|
expectedCmsgs[{IPPROTO_IPV6, IPV6_HOPLIMIT}] = 255;
|
||||||
auto pkt = this->getConn().outstandings.packets.rbegin();
|
auto pkt = this->getConn().outstandings.packets.rbegin();
|
||||||
ASSERT_TRUE(pkt->metadata.cmsgs);
|
ASSERT_TRUE(pkt->metadata.cmsgs);
|
||||||
@@ -1065,7 +1065,7 @@ TYPED_TEST(
|
|||||||
ASSERT_EQ(this->getConn().outstandings.packets.size(), packetsSent);
|
ASSERT_EQ(this->getConn().outstandings.packets.size(), packetsSent);
|
||||||
|
|
||||||
// Verify the last two packets are marked
|
// Verify the last two packets are marked
|
||||||
folly::SocketOptionMap expectedCmsgs;
|
folly::SocketCmsgMap expectedCmsgs;
|
||||||
expectedCmsgs[{IPPROTO_IPV6, IPV6_DONTFRAG}] = 1;
|
expectedCmsgs[{IPPROTO_IPV6, IPV6_DONTFRAG}] = 1;
|
||||||
auto pkt = this->getConn().outstandings.packets.rbegin();
|
auto pkt = this->getConn().outstandings.packets.rbegin();
|
||||||
ASSERT_TRUE(pkt->metadata.cmsgs);
|
ASSERT_TRUE(pkt->metadata.cmsgs);
|
||||||
|
@@ -112,7 +112,7 @@ int QuicAsyncUDPSocketImpl::writem(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void QuicAsyncUDPSocketImpl::setAdditionalCmsgsFunc(
|
void QuicAsyncUDPSocketImpl::setAdditionalCmsgsFunc(
|
||||||
folly::Function<folly::Optional<folly::SocketOptionMap>()>&&
|
folly::Function<folly::Optional<folly::SocketCmsgMap>()>&&
|
||||||
/* additionalCmsgsFunc */) {
|
/* additionalCmsgsFunc */) {
|
||||||
LOG(WARNING)
|
LOG(WARNING)
|
||||||
<< "Setting an additional cmsgs function is not implemented for QuicAsyncUDPSocketImpl";
|
<< "Setting an additional cmsgs function is not implemented for QuicAsyncUDPSocketImpl";
|
||||||
@@ -157,12 +157,12 @@ void QuicAsyncUDPSocketImpl::detachEventBase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void QuicAsyncUDPSocketImpl::setCmsgs(
|
void QuicAsyncUDPSocketImpl::setCmsgs(
|
||||||
const folly::SocketOptionMap& /* cmsgs */) {
|
const folly::SocketCmsgMap& /* cmsgs */) {
|
||||||
throw std::runtime_error("setCmsgs is not implemented.");
|
throw std::runtime_error("setCmsgs is not implemented.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuicAsyncUDPSocketImpl::appendCmsgs(
|
void QuicAsyncUDPSocketImpl::appendCmsgs(
|
||||||
const folly::SocketOptionMap& /* cmsgs */) {
|
const folly::SocketCmsgMap& /* cmsgs */) {
|
||||||
throw std::runtime_error("appendCmsgs is not implemented.");
|
throw std::runtime_error("appendCmsgs is not implemented.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -185,10 +185,10 @@ class QuicAsyncUDPSocketImpl {
|
|||||||
/**
|
/**
|
||||||
* Set extra control messages to send
|
* Set extra control messages to send
|
||||||
*/
|
*/
|
||||||
void setCmsgs(const folly::SocketOptionMap& /* cmsgs */);
|
void setCmsgs(const folly::SocketCmsgMap& /* cmsgs */);
|
||||||
void appendCmsgs(const folly::SocketOptionMap& /* cmsgs */);
|
void appendCmsgs(const folly::SocketCmsgMap& /* cmsgs */);
|
||||||
void setAdditionalCmsgsFunc(
|
void setAdditionalCmsgsFunc(
|
||||||
folly::Function<folly::Optional<folly::SocketOptionMap>()>&&
|
folly::Function<folly::Optional<folly::SocketCmsgMap>()>&&
|
||||||
/* additionalCmsgsFunc */);
|
/* additionalCmsgsFunc */);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -17,7 +17,7 @@ namespace quic {
|
|||||||
class PacketProcessor {
|
class PacketProcessor {
|
||||||
public:
|
public:
|
||||||
struct PrewriteRequest {
|
struct PrewriteRequest {
|
||||||
folly::Optional<folly::SocketOptionMap> cmsgs;
|
folly::Optional<folly::SocketCmsgMap> cmsgs;
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual ~PacketProcessor() = default;
|
virtual ~PacketProcessor() = default;
|
||||||
|
@@ -43,7 +43,7 @@ struct OutstandingPacketMetadata {
|
|||||||
// tracks the number of writes on this socket.
|
// tracks the number of writes on this socket.
|
||||||
uint64_t writeCount{0};
|
uint64_t writeCount{0};
|
||||||
// Cmsgs added by the QuicSocket when this packet was written
|
// Cmsgs added by the QuicSocket when this packet was written
|
||||||
folly::Optional<folly::SocketOptionMap> cmsgs;
|
folly::Optional<folly::SocketCmsgMap> cmsgs;
|
||||||
|
|
||||||
// Has value if the packet is lost by timeout. The value is the loss timeout
|
// Has value if the packet is lost by timeout. The value is the loss timeout
|
||||||
// dividend that was used to declare this packet.
|
// dividend that was used to declare this packet.
|
||||||
|
@@ -667,7 +667,7 @@ struct QuicConnectionStateBase : public folly::DelayedDestruction {
|
|||||||
retransmissionPolicies;
|
retransmissionPolicies;
|
||||||
|
|
||||||
struct SocketCmsgsState {
|
struct SocketCmsgsState {
|
||||||
folly::Optional<folly::SocketOptionMap> additionalCmsgs;
|
folly::Optional<folly::SocketCmsgMap> additionalCmsgs;
|
||||||
// The write count which this SocketCmsgs state is intended for.
|
// The write count which this SocketCmsgs state is intended for.
|
||||||
// This is used to make sure this cmsgs list does not end up used
|
// This is used to make sure this cmsgs list does not end up used
|
||||||
// for multiple writes.
|
// for multiple writes.
|
||||||
|
Reference in New Issue
Block a user