Skip to content

Commit

Permalink
Folly SocketOptionMap with strings - separate cmsgs
Browse files Browse the repository at this point in the history
Summary: Splitting cmgs from socket options.

Reviewed By: mjoras

Differential Revision: D49557451

fbshipit-source-id: fa3005170d049557d1c845fd14b0ada73b58b377
  • Loading branch information
avasylev authored and facebook-github-bot committed Oct 1, 2023
1 parent 1626c53 commit c0e008c
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 20 deletions.
8 changes: 4 additions & 4 deletions quic/api/QuicTransportBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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.
Expand All @@ -3921,7 +3921,7 @@ void QuicTransportBase::updatePacketProcessorsPrewriteRequests() {
conn_->socketCmsgsState.targetWriteCount = conn_->writeCount;
}

folly::Optional<folly::SocketOptionMap>
folly::Optional<folly::SocketCmsgMap>
QuicTransportBase::getAdditionalCmsgsForAsyncUDPSocket() {
if (conn_->socketCmsgsState.additionalCmsgs) {
// This callback should be happening for the target write
Expand Down
6 changes: 3 additions & 3 deletions quic/api/QuicTransportBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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<folly::SocketOptionMap> getAdditionalCmsgsForAsyncUDPSocket();
folly::Optional<folly::SocketCmsgMap> getAdditionalCmsgsForAsyncUDPSocket();

std::atomic<QuicEventBase*> qEvbPtr_;
std::unique_ptr<QuicAsyncUDPSocketWrapper> socket_;
Expand Down
2 changes: 1 addition & 1 deletion quic/api/test/QuicTransportBaseTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions quic/api/test/QuicTypedTransportTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions quic/common/QuicAsyncUDPSocketImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ int QuicAsyncUDPSocketImpl::writem(
}

void QuicAsyncUDPSocketImpl::setAdditionalCmsgsFunc(
folly::Function<folly::Optional<folly::SocketOptionMap>()>&&
folly::Function<folly::Optional<folly::SocketCmsgMap>()>&&
/* additionalCmsgsFunc */) {
LOG(WARNING)
<< "Setting an additional cmsgs function is not implemented for QuicAsyncUDPSocketImpl";
Expand Down Expand Up @@ -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.");
}

Expand Down
6 changes: 3 additions & 3 deletions quic/common/QuicAsyncUDPSocketImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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::Optional<folly::SocketOptionMap>()>&&
folly::Function<folly::Optional<folly::SocketCmsgMap>()>&&
/* additionalCmsgsFunc */);

/*
Expand Down
2 changes: 1 addition & 1 deletion quic/congestion_control/PacketProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace quic {
class PacketProcessor {
public:
struct PrewriteRequest {
folly::Optional<folly::SocketOptionMap> cmsgs;
folly::Optional<folly::SocketCmsgMap> cmsgs;
};

virtual ~PacketProcessor() = default;
Expand Down
2 changes: 1 addition & 1 deletion quic/state/OutstandingPacket.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<folly::SocketOptionMap> cmsgs;
folly::Optional<folly::SocketCmsgMap> cmsgs;

// Has value if the packet is lost by timeout. The value is the loss timeout
// dividend that was used to declare this packet.
Expand Down
2 changes: 1 addition & 1 deletion quic/state/StateData.h
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ struct QuicConnectionStateBase : public folly::DelayedDestruction {
retransmissionPolicies;

struct SocketCmsgsState {
folly::Optional<folly::SocketOptionMap> additionalCmsgs;
folly::Optional<folly::SocketCmsgMap> 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.
Expand Down

0 comments on commit c0e008c

Please sign in to comment.