From c0e008c266ffde478619cc4b3699b12c80fff4b6 Mon Sep 17 00:00:00 2001 From: Andrii Vasylevskyi Date: Sun, 1 Oct 2023 11:33:09 -0700 Subject: [PATCH] Folly SocketOptionMap with strings - separate cmsgs Summary: Splitting cmgs from socket options. Reviewed By: mjoras Differential Revision: D49557451 fbshipit-source-id: fa3005170d049557d1c845fd14b0ada73b58b377 --- quic/api/QuicTransportBase.cpp | 8 ++++---- quic/api/QuicTransportBase.h | 6 +++--- quic/api/test/QuicTransportBaseTest.cpp | 2 +- quic/api/test/QuicTypedTransportTest.cpp | 6 +++--- quic/common/QuicAsyncUDPSocketImpl.cpp | 6 +++--- quic/common/QuicAsyncUDPSocketImpl.h | 6 +++--- quic/congestion_control/PacketProcessor.h | 2 +- quic/state/OutstandingPacket.h | 2 +- quic/state/StateData.h | 2 +- 9 files changed, 20 insertions(+), 20 deletions(-) diff --git a/quic/api/QuicTransportBase.cpp b/quic/api/QuicTransportBase.cpp index 04e231f6f..7f94b9561 100644 --- a/quic/api/QuicTransportBase.cpp +++ b/quic/api/QuicTransportBase.cpp @@ -3826,11 +3826,11 @@ void QuicTransportBase::notifyAppRateLimited() { } } -void QuicTransportBase::setCmsgs(const folly::SocketOptionMap& options) { +void QuicTransportBase::setCmsgs(const folly::SocketCmsgMap& options) { socket_->setCmsgs(options); } -void QuicTransportBase::appendCmsgs(const folly::SocketOptionMap& options) { +void QuicTransportBase::appendCmsgs(const folly::SocketCmsgMap& options) { socket_->appendCmsgs(options); } @@ -3904,7 +3904,7 @@ QuicTransportBase::setStreamGroupRetransmissionPolicy( } void QuicTransportBase::updatePacketProcessorsPrewriteRequests() { - folly::SocketOptionMap cmsgs; + folly::SocketCmsgMap cmsgs; for (const auto& pp : conn_->packetProcessors) { // In case of overlapping cmsg keys, the priority is given to // that were added to the QuicSocket first. @@ -3921,7 +3921,7 @@ void QuicTransportBase::updatePacketProcessorsPrewriteRequests() { conn_->socketCmsgsState.targetWriteCount = conn_->writeCount; } -folly::Optional +folly::Optional QuicTransportBase::getAdditionalCmsgsForAsyncUDPSocket() { if (conn_->socketCmsgsState.additionalCmsgs) { // This callback should be happening for the target write diff --git a/quic/api/QuicTransportBase.h b/quic/api/QuicTransportBase.h index 7200a3939..25bc8dcbb 100644 --- a/quic/api/QuicTransportBase.h +++ b/quic/api/QuicTransportBase.h @@ -660,9 +660,9 @@ class QuicTransportBase : public QuicSocket, QuicStreamPrioritiesObserver { * specific transport and does not change the other sockets sharing the same * 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. @@ -852,7 +852,7 @@ class QuicTransportBase : public QuicSocket, QuicStreamPrioritiesObserver { * The callback function for AsyncUDPSocket to provide the additional cmsgs * required by this QuicSocket's packet processors. */ - folly::Optional getAdditionalCmsgsForAsyncUDPSocket(); + folly::Optional getAdditionalCmsgsForAsyncUDPSocket(); std::atomic qEvbPtr_; std::unique_ptr socket_; diff --git a/quic/api/test/QuicTransportBaseTest.cpp b/quic/api/test/QuicTransportBaseTest.cpp index c6349f77a..819a6bd70 100644 --- a/quic/api/test/QuicTransportBaseTest.cpp +++ b/quic/api/test/QuicTransportBaseTest.cpp @@ -4212,7 +4212,7 @@ TEST_P(QuicTransportImplTestBase, ZeroLengthDatagramBufs) { TEST_P(QuicTransportImplTestBase, Cmsgs) { transport->setServerConnectionId(); - folly::SocketOptionMap cmsgs; + folly::SocketCmsgMap cmsgs; cmsgs[{IPPROTO_IP, IP_TOS}] = 123; EXPECT_CALL(*socketPtr, setCmsgs(_)).Times(1); transport->setCmsgs(cmsgs); diff --git a/quic/api/test/QuicTypedTransportTest.cpp b/quic/api/test/QuicTypedTransportTest.cpp index bdc5122d1..9456694a0 100644 --- a/quic/api/test/QuicTypedTransportTest.cpp +++ b/quic/api/test/QuicTypedTransportTest.cpp @@ -975,7 +975,7 @@ TYPED_TEST( this->loopForWrites(); ASSERT_FALSE(this->getConn().outstandings.packets.empty()); - folly::SocketOptionMap expectedCmsgs; + folly::SocketCmsgMap expectedCmsgs; expectedCmsgs[{IPPROTO_IPV6, IPV6_HOPLIMIT}] = 255; expectedCmsgs[{IPPROTO_IPV6, IPV6_DONTFRAG}] = 1; auto pkt = this->getConn().outstandings.packets.rbegin(); @@ -1019,7 +1019,7 @@ TYPED_TEST( ASSERT_EQ(this->getConn().outstandings.packets.size(), packetsSent); // Verify both packets are marked - folly::SocketOptionMap expectedCmsgs; + folly::SocketCmsgMap expectedCmsgs; expectedCmsgs[{IPPROTO_IPV6, IPV6_HOPLIMIT}] = 255; auto pkt = this->getConn().outstandings.packets.rbegin(); ASSERT_TRUE(pkt->metadata.cmsgs); @@ -1065,7 +1065,7 @@ TYPED_TEST( ASSERT_EQ(this->getConn().outstandings.packets.size(), packetsSent); // Verify the last two packets are marked - folly::SocketOptionMap expectedCmsgs; + folly::SocketCmsgMap expectedCmsgs; expectedCmsgs[{IPPROTO_IPV6, IPV6_DONTFRAG}] = 1; auto pkt = this->getConn().outstandings.packets.rbegin(); ASSERT_TRUE(pkt->metadata.cmsgs); diff --git a/quic/common/QuicAsyncUDPSocketImpl.cpp b/quic/common/QuicAsyncUDPSocketImpl.cpp index 7c32d2862..edf586db1 100644 --- a/quic/common/QuicAsyncUDPSocketImpl.cpp +++ b/quic/common/QuicAsyncUDPSocketImpl.cpp @@ -112,7 +112,7 @@ int QuicAsyncUDPSocketImpl::writem( } void QuicAsyncUDPSocketImpl::setAdditionalCmsgsFunc( - folly::Function()>&& + folly::Function()>&& /* additionalCmsgsFunc */) { LOG(WARNING) << "Setting an additional cmsgs function is not implemented for QuicAsyncUDPSocketImpl"; @@ -157,12 +157,12 @@ void QuicAsyncUDPSocketImpl::detachEventBase() { } void QuicAsyncUDPSocketImpl::setCmsgs( - const folly::SocketOptionMap& /* cmsgs */) { + const folly::SocketCmsgMap& /* cmsgs */) { throw std::runtime_error("setCmsgs is not implemented."); } void QuicAsyncUDPSocketImpl::appendCmsgs( - const folly::SocketOptionMap& /* cmsgs */) { + const folly::SocketCmsgMap& /* cmsgs */) { throw std::runtime_error("appendCmsgs is not implemented."); } diff --git a/quic/common/QuicAsyncUDPSocketImpl.h b/quic/common/QuicAsyncUDPSocketImpl.h index dafec1d93..f1ee6be31 100644 --- a/quic/common/QuicAsyncUDPSocketImpl.h +++ b/quic/common/QuicAsyncUDPSocketImpl.h @@ -185,10 +185,10 @@ class QuicAsyncUDPSocketImpl { /** * Set extra control messages to send */ - void setCmsgs(const folly::SocketOptionMap& /* cmsgs */); - void appendCmsgs(const folly::SocketOptionMap& /* cmsgs */); + void setCmsgs(const folly::SocketCmsgMap& /* cmsgs */); + void appendCmsgs(const folly::SocketCmsgMap& /* cmsgs */); void setAdditionalCmsgsFunc( - folly::Function()>&& + folly::Function()>&& /* additionalCmsgsFunc */); /* diff --git a/quic/congestion_control/PacketProcessor.h b/quic/congestion_control/PacketProcessor.h index 53752040c..c31f83792 100644 --- a/quic/congestion_control/PacketProcessor.h +++ b/quic/congestion_control/PacketProcessor.h @@ -17,7 +17,7 @@ namespace quic { class PacketProcessor { public: struct PrewriteRequest { - folly::Optional cmsgs; + folly::Optional cmsgs; }; virtual ~PacketProcessor() = default; diff --git a/quic/state/OutstandingPacket.h b/quic/state/OutstandingPacket.h index 63ecd9984..b6436159b 100644 --- a/quic/state/OutstandingPacket.h +++ b/quic/state/OutstandingPacket.h @@ -43,7 +43,7 @@ struct OutstandingPacketMetadata { // tracks the number of writes on this socket. uint64_t writeCount{0}; // Cmsgs added by the QuicSocket when this packet was written - folly::Optional cmsgs; + folly::Optional cmsgs; // Has value if the packet is lost by timeout. The value is the loss timeout // dividend that was used to declare this packet. diff --git a/quic/state/StateData.h b/quic/state/StateData.h index f289cf105..9a4ef58cd 100644 --- a/quic/state/StateData.h +++ b/quic/state/StateData.h @@ -667,7 +667,7 @@ struct QuicConnectionStateBase : public folly::DelayedDestruction { retransmissionPolicies; struct SocketCmsgsState { - folly::Optional additionalCmsgs; + folly::Optional additionalCmsgs; // The write count which this SocketCmsgs state is intended for. // This is used to make sure this cmsgs list does not end up used // for multiple writes.