diff --git a/.azure/azure-pipelines.ci.yml b/.azure/azure-pipelines.ci.yml index c01288e6f..fb562aa40 100644 --- a/.azure/azure-pipelines.ci.yml +++ b/.azure/azure-pipelines.ci.yml @@ -612,7 +612,8 @@ stages: logProfile: Full.Light extraArtifactDir: '_Xdp' extraPrepareArgs: -InstallDuoNic -InstallXdpDriver - extraTestArgs: -DuoNic -Filter -*ValidateConfiguration:*ValidAlpnLengths:*ResumeRejection*:*ClientCertificate*:*LoadBalanced*:*Tcp* -ExtraArtifactDir Xdp + # TODO: reenable these testcases: *RebindAddr*:*RebindPort*:*Unreachable*:*DrillInitialPacket*:*WithHandshakeArgs*:CredValidation.ConnectValidServerCertificate + extraTestArgs: -DuoNic -Filter -*ValidateConfiguration:*ValidAlpnLengths:*ResumeRejection*:*ClientCertificate*:*LoadBalanced*:*Tcp*:*RebindAddr*:*RebindPort*:*Unreachable*:*DrillInitialPacket*:*WithHandshakeArgs*:CredValidation.ConnectValidServerCertificate -ExtraArtifactDir Xdp - template: ./templates/run-bvt.yml parameters: image: windows-2019 diff --git a/scripts/test.ps1 b/scripts/test.ps1 index 47a282634..c4dfc460f 100644 --- a/scripts/test.ps1 +++ b/scripts/test.ps1 @@ -323,10 +323,7 @@ if (!$Kernel -and !$SkipUnitTests) { Invoke-Expression ($RunTest + " -Path $MsQuicCoreTest " + $TestArguments) Invoke-Expression ($RunTest + " -Path $MsQuicPlatTest " + $TestArguments) } -# TODO: fix main tests to run with XDP. -if (!$DuoNic) { - Invoke-Expression ($RunTest + " -Path $MsQuicTest " + $TestArguments) -} +Invoke-Expression ($RunTest + " -Path $MsQuicTest " + $TestArguments) if ($CodeCoverage) { # Merge code coverage results diff --git a/src/generated/linux/datapath_raw_socket.c.clog.h b/src/generated/linux/datapath_raw_socket.c.clog.h index 2d93934d9..ab07529fb 100644 --- a/src/generated/linux/datapath_raw_socket.c.clog.h +++ b/src/generated/linux/datapath_raw_socket.c.clog.h @@ -106,10 +106,10 @@ tracepoint(CLOG_DATAPATH_RAW_SOCKET_C, LibraryErrorStatus , arg2, arg3);\ DatapathErrorStatus, "[data][%p] ERROR, %u, %s.", Socket, - Error, + WsaError, "socket"); // arg2 = arg2 = Socket = arg2 -// arg3 = arg3 = Error = arg3 +// arg3 = arg3 = WsaError = arg3 // arg4 = arg4 = "socket" = arg4 ----------------------------------------------------------*/ #ifndef _clog_5_ARGS_TRACE_DatapathErrorStatus diff --git a/src/generated/linux/datapath_raw_socket.c.clog.h.lttng.h b/src/generated/linux/datapath_raw_socket.c.clog.h.lttng.h index a6f52c9bb..593b040eb 100644 --- a/src/generated/linux/datapath_raw_socket.c.clog.h.lttng.h +++ b/src/generated/linux/datapath_raw_socket.c.clog.h.lttng.h @@ -105,10 +105,10 @@ TRACEPOINT_EVENT(CLOG_DATAPATH_RAW_SOCKET_C, LibraryErrorStatus, DatapathErrorStatus, "[data][%p] ERROR, %u, %s.", Socket, - Error, + WsaError, "socket"); // arg2 = arg2 = Socket = arg2 -// arg3 = arg3 = Error = arg3 +// arg3 = arg3 = WsaError = arg3 // arg4 = arg4 = "socket" = arg4 ----------------------------------------------------------*/ TRACEPOINT_EVENT(CLOG_DATAPATH_RAW_SOCKET_C, DatapathErrorStatus, diff --git a/src/inc/msquic.hpp b/src/inc/msquic.hpp index f883e76f9..15b8da070 100644 --- a/src/inc/msquic.hpp +++ b/src/inc/msquic.hpp @@ -798,14 +798,6 @@ struct MsQuicConnection { return MsQuic->ConnectionStart(Handle, Config, Family, ServerName, ServerPort); } - QUIC_STATUS - StartLocalhost( - _In_ const MsQuicConfiguration& Config, - _In_ const QuicAddr& LocalhostAddr - ) noexcept { - return MsQuic->ConnectionStart(Handle, Config, LocalhostAddr.GetFamily(), QUIC_LOCALHOST_FOR_AF(LocalhostAddr.GetFamily()), LocalhostAddr.GetPort()); - } - QUIC_STATUS SetConfiguration( _In_ const MsQuicConfiguration& Config diff --git a/src/platform/datapath_raw.c b/src/platform/datapath_raw.c index 6129f98a9..c0dc16a2e 100644 --- a/src/platform/datapath_raw.c +++ b/src/platform/datapath_raw.c @@ -312,8 +312,8 @@ CxPlatSocketCreateUdp( CXPLAT_FRE_ASSERT((*NewSocket)->Wildcard ^ (*NewSocket)->Connected); // Assumes either a pure wildcard listener or a // connected socket; not both. - if (!CxPlatTryAddSocket(&Datapath->SocketPool, *NewSocket)) { - Status = QUIC_STATUS_ADDRESS_IN_USE; + Status = CxPlatTryAddSocket(&Datapath->SocketPool, *NewSocket); + if (QUIC_FAILED(Status)) { goto Error; } diff --git a/src/platform/datapath_raw.h b/src/platform/datapath_raw.h index d4c6f993a..258c9a1ff 100644 --- a/src/platform/datapath_raw.h +++ b/src/platform/datapath_raw.h @@ -304,7 +304,7 @@ CxPlatGetSocket( _In_ const QUIC_ADDR* RemoteAddress ); -BOOLEAN +QUIC_STATUS CxPlatTryAddSocket( _In_ CXPLAT_SOCKET_POOL* Pool, _In_ CXPLAT_SOCKET* Socket diff --git a/src/platform/datapath_raw_socket.c b/src/platform/datapath_raw_socket.c index cc9cf989e..1a8830d80 100644 --- a/src/platform/datapath_raw_socket.c +++ b/src/platform/datapath_raw_socket.c @@ -92,14 +92,14 @@ CxPlatGetSocket( return Socket; } -BOOLEAN +QUIC_STATUS CxPlatTryAddSocket( _In_ CXPLAT_SOCKET_POOL* Pool, _In_ CXPLAT_SOCKET* Socket ) { + QUIC_STATUS Status = QUIC_STATUS_SUCCESS; int Result; - BOOLEAN Success = FALSE; CXPLAT_HASHTABLE_LOOKUP_CONTEXT Context; CXPLAT_HASHTABLE_ENTRY* Entry; QUIC_ADDR MappedAddress = {0}; @@ -115,13 +115,14 @@ CxPlatTryAddSocket( SOCK_DGRAM, IPPROTO_UDP); if (Socket->AuxSocket == INVALID_SOCKET) { - int Error = SocketError(); + int WsaError = SocketError(); QuicTraceEvent( DatapathErrorStatus, "[data][%p] ERROR, %u, %s.", Socket, - Error, + WsaError, "socket"); + Status = HRESULT_FROM_WIN32(WsaError); goto Error; } @@ -134,13 +135,14 @@ CxPlatTryAddSocket( (char*)&Option, sizeof(Option)); if (Result == SOCKET_ERROR) { - int Error = SocketError(); + int WsaError = SocketError(); QuicTraceEvent( DatapathErrorStatus, "[data][%p] ERROR, %u, %s.", Socket, - Error, + WsaError, "Set IPV6_V6ONLY"); + Status = HRESULT_FROM_WIN32(WsaError); goto Error; } @@ -154,13 +156,14 @@ CxPlatTryAddSocket( (char*)&Option, sizeof(Option)); if (Result == SOCKET_ERROR) { - int Error = SocketError(); + int WsaError = SocketError(); QuicTraceEvent( DatapathErrorStatus, "[data][%p] ERROR, %u, %s.", Socket, - Error, + WsaError, "Set SO_REUSEADDR"); + Status = HRESULT_FROM_WIN32(WsaError); goto Error; } } @@ -180,14 +183,15 @@ CxPlatTryAddSocket( (struct sockaddr*)&MappedAddress, sizeof(MappedAddress)); if (Result == SOCKET_ERROR) { - int Error = SocketError(); + int WsaError = SocketError(); QuicTraceEvent( DatapathErrorStatus, "[data][%p] ERROR, %u, %s.", Socket, - Error, + WsaError, "bind"); CxPlatRwLockReleaseExclusive(&Pool->Lock); + Status = HRESULT_FROM_WIN32(WsaError); goto Error; } @@ -207,14 +211,15 @@ CxPlatTryAddSocket( (struct sockaddr*)&MappedAddress, sizeof(MappedAddress)); if (Result == SOCKET_ERROR) { - int Error = SocketError(); + int WsaError = SocketError(); QuicTraceEvent( DatapathErrorStatus, "[data][%p] ERROR, %u, %s.", Socket, - Error, + WsaError, "connect failed"); CxPlatRwLockReleaseExclusive(&Pool->Lock); + Status = HRESULT_FROM_WIN32(WsaError); goto Error; } } @@ -226,30 +231,30 @@ CxPlatTryAddSocket( (struct sockaddr*)&Socket->LocalAddress, &AssignedLocalAddressLength); if (Result == SOCKET_ERROR) { - int Error = SocketError(); + int WsaError = SocketError(); QuicTraceEvent( DatapathErrorStatus, "[data][%p] ERROR, %u, %s.", Socket, - Error, + WsaError, "getsockname"); CxPlatRwLockReleaseExclusive(&Pool->Lock); + Status = HRESULT_FROM_WIN32(WsaError); goto Error; } CxPlatConvertFromMappedV6(&Socket->LocalAddress, &Socket->LocalAddress); - Success = TRUE; Entry = CxPlatHashtableLookup(&Pool->Sockets, Socket->LocalAddress.Ipv4.sin_port, &Context); while (Entry != NULL) { CXPLAT_SOCKET* Temp = CONTAINING_RECORD(Entry, CXPLAT_SOCKET, Entry); if (CxPlatSocketCompare(Temp, &Socket->LocalAddress, &Socket->RemoteAddress)) { - Success = FALSE; + Status = QUIC_STATUS_ADDRESS_IN_USE; break; } Entry = CxPlatHashtableLookupNext(&Pool->Sockets, &Context); } - if (Success) { + if (QUIC_SUCCEEDED(Status)) { CxPlatHashtableInsert(&Pool->Sockets, &Socket->Entry, Socket->LocalAddress.Ipv4.sin_port, &Context); } @@ -257,11 +262,11 @@ CxPlatTryAddSocket( Error: - if (!Success && Socket->AuxSocket != INVALID_SOCKET) { + if (QUIC_FAILED(Status) && Socket->AuxSocket != INVALID_SOCKET) { closesocket(Socket->AuxSocket); } - return Success; + return Status; } void diff --git a/src/platform/unittest/DataPathTest.cpp b/src/platform/unittest/DataPathTest.cpp index affda43eb..f9021ec91 100644 --- a/src/platform/unittest/DataPathTest.cpp +++ b/src/platform/unittest/DataPathTest.cpp @@ -19,6 +19,11 @@ Abstract: extern bool UseDuoNic; +// +// Connect to the duonic address (if using duonic) or localhost (if not). +// +#define QUIC_TEST_LOOPBACK_FOR_AF(Af) (UseDuoNic ? ((Af == QUIC_ADDRESS_FAMILY_INET) ? "192.168.1.11" : "fc00::1:11") : QUIC_LOCALHOST_FOR_AF(Af)) + const uint32_t ExpectedDataSize = 1 * 1024; char* ExpectedData; @@ -233,13 +238,8 @@ protected: // NextPort = 50000 + (CxPlatCurThreadID() % 10000) + (rand() % 5000); - if (UseDuoNic) { - LocalIPv4.Resolve(QUIC_ADDRESS_FAMILY_INET, "192.168.1.11"); - LocalIPv6.Resolve(QUIC_ADDRESS_FAMILY_INET6, "fc00::1:11"); - } else { - LocalIPv4.Resolve(QUIC_ADDRESS_FAMILY_INET, QUIC_LOCALHOST_FOR_AF(QUIC_ADDRESS_FAMILY_INET)); - LocalIPv6.Resolve(QUIC_ADDRESS_FAMILY_INET6, QUIC_LOCALHOST_FOR_AF(QUIC_ADDRESS_FAMILY_INET6)); - } + LocalIPv4.Resolve(QUIC_ADDRESS_FAMILY_INET, QUIC_TEST_LOOPBACK_FOR_AF(QUIC_ADDRESS_FAMILY_INET)); + LocalIPv6.Resolve(QUIC_ADDRESS_FAMILY_INET6, QUIC_TEST_LOOPBACK_FOR_AF(QUIC_ADDRESS_FAMILY_INET6)); UnspecIPv4.Resolve(QUIC_ADDRESS_FAMILY_INET, "0.0.0.0"); UnspecIPv6.Resolve(QUIC_ADDRESS_FAMILY_INET6, "::"); diff --git a/src/test/bin/quic_gtest.cpp b/src/test/bin/quic_gtest.cpp index 7892ac5cc..eabd93d33 100644 --- a/src/test/bin/quic_gtest.cpp +++ b/src/test/bin/quic_gtest.cpp @@ -12,6 +12,7 @@ bool TestingKernelMode = false; bool PrivateTestLibrary = false; +bool UseDuoNic = false; const MsQuicApi* MsQuic; QUIC_CREDENTIAL_CONFIG ServerSelfSignedCredConfig; QUIC_CREDENTIAL_CONFIG ServerSelfSignedCredConfigClientAuth; @@ -1860,6 +1861,8 @@ int main(int argc, char** argv) { if (strcmp("--kernelPriv", argv[i]) == 0) { PrivateTestLibrary = true; } + } else if (strcmp("--duoNic", argv[i]) == 0) { + UseDuoNic = true; } } ::testing::AddGlobalTestEnvironment(new QuicTestEnvironment); diff --git a/src/test/bin/winkernel/control.cpp b/src/test/bin/winkernel/control.cpp index 366fa39b1..4f2eefe7d 100644 --- a/src/test/bin/winkernel/control.cpp +++ b/src/test/bin/winkernel/control.cpp @@ -24,6 +24,7 @@ QUIC_CREDENTIAL_CONFIG ServerSelfSignedCredConfigClientAuth; QUIC_CREDENTIAL_CONFIG ClientCertCredConfig; QUIC_CERTIFICATE_HASH SelfSignedCertHash; QUIC_CERTIFICATE_HASH ClientCertHash; +bool UseDuoNic = false; #ifdef PRIVATE_LIBRARY DECLARE_CONST_UNICODE_STRING(QuicTestCtlDeviceName, L"\\Device\\" QUIC_DRIVER_NAME_PRIVATE); diff --git a/src/test/lib/ApiTest.cpp b/src/test/lib/ApiTest.cpp index d2cd965dc..3aaeeda3d 100644 --- a/src/test/lib/ApiTest.cpp +++ b/src/test/lib/ApiTest.cpp @@ -1023,7 +1023,7 @@ void QuicTestValidateConnection() TestScopeLogger logScope("SendResumption in Listener callback"); MsQuicConnection Connection(Registration); TEST_QUIC_SUCCEEDED(Connection.GetInitStatus()); - TEST_QUIC_SUCCEEDED(Connection.StartLocalhost(ClientConfiguration, ServerLocalAddr)); + TEST_QUIC_SUCCEEDED(Connection.Start(ClientConfiguration, ServerLocalAddr.GetFamily(), QUIC_TEST_LOOPBACK_FOR_AF(ServerLocalAddr.GetFamily()), ServerLocalAddr.GetPort())); TEST_TRUE(ListenerContext.ListenerAcceptEvent.WaitTimeout(2000)); } @@ -1035,7 +1035,7 @@ void QuicTestValidateConnection() TestScopeLogger logScope("SendResumption with resumption disabled"); MsQuicConnection Connection(Registration); TEST_QUIC_SUCCEEDED(Connection.GetInitStatus()); - TEST_QUIC_SUCCEEDED(Connection.StartLocalhost(ClientConfiguration, ServerLocalAddr)); + TEST_QUIC_SUCCEEDED(Connection.Start(ClientConfiguration, ServerLocalAddr.GetFamily(), QUIC_TEST_LOOPBACK_FOR_AF(ServerLocalAddr.GetFamily()), ServerLocalAddr.GetPort())); TEST_TRUE(ListenerContext.ListenerAcceptEvent.WaitTimeout(2000)); TEST_TRUE(ListenerContext.HandshakeCompleteEvent.WaitTimeout(2000)); // Wait for server to get connected } @@ -1048,7 +1048,7 @@ void QuicTestValidateConnection() TestScopeLogger logScope("SendResumption handshake not complete"); MsQuicConnection Connection(Registration); TEST_QUIC_SUCCEEDED(Connection.GetInitStatus()); - TEST_QUIC_SUCCEEDED(Connection.StartLocalhost(ClientConfiguration, ServerLocalAddr)); + TEST_QUIC_SUCCEEDED(Connection.Start(ClientConfiguration, ServerLocalAddr.GetFamily(), QUIC_TEST_LOOPBACK_FOR_AF(ServerLocalAddr.GetFamily()), ServerLocalAddr.GetPort())); TEST_TRUE(ListenerContext.ListenerAcceptEvent.WaitTimeout(2000)); TEST_TRUE(Connection.HandshakeCompleteEvent.WaitTimeout(2000)); // Wait for client to get connected @@ -1246,7 +1246,7 @@ void QuicTestValidateStream(bool Connect) Client.Start( ClientConfiguration, QuicAddrGetFamily(&ServerLocalAddr.SockAddr), - QUIC_LOCALHOST_FOR_AF( + QUIC_TEST_LOOPBACK_FOR_AF( QuicAddrGetFamily(&ServerLocalAddr.SockAddr)), ServerLocalAddr.GetPort())); @@ -2104,7 +2104,7 @@ QuicTestConnectionRejection( MsQuicConnection Connection(Registration); TEST_QUIC_SUCCEEDED(Connection.GetInitStatus()); - TEST_QUIC_SUCCEEDED(Connection.StartLocalhost(ClientConfiguration, ServerLocalAddr)); + TEST_QUIC_SUCCEEDED(Connection.Start(ClientConfiguration, ServerLocalAddr.GetFamily(), QUIC_TEST_LOOPBACK_FOR_AF(ServerLocalAddr.GetFamily()), ServerLocalAddr.GetPort())); if (RejectByClosing) { TEST_TRUE(ShutdownEvent.WaitTimeout(TestWaitTimeout)); diff --git a/src/test/lib/BasicTest.cpp b/src/test/lib/BasicTest.cpp index 00f8586fe..546323060 100644 --- a/src/test/lib/BasicTest.cpp +++ b/src/test/lib/BasicTest.cpp @@ -211,6 +211,9 @@ void QuicTestStartListenerExplicit(_In_ int Family) QUIC_ADDRESS_FAMILY QuicAddrFamily = (Family == 4) ? QUIC_ADDRESS_FAMILY_INET : QUIC_ADDRESS_FAMILY_INET6; QuicAddr LocalAddress(QuicAddr(QuicAddrFamily, true), TestUdpPortBase); + if (UseDuoNic) { + QuicAddrSetToDuoNic(&LocalAddress.SockAddr); + } QUIC_STATUS Status = QUIC_STATUS_ADDRESS_IN_USE; while (Status == QUIC_STATUS_ADDRESS_IN_USE) { LocalAddress.IncrementPort(); @@ -256,6 +259,9 @@ void QuicTestBindConnectionExplicit(_In_ int Family) QUIC_ADDRESS_FAMILY QuicAddrFamily = (Family == 4) ? QUIC_ADDRESS_FAMILY_INET : QUIC_ADDRESS_FAMILY_INET6; QuicAddr LocalAddress(QuicAddr(QuicAddrFamily, true), TestUdpPortBase); + if (UseDuoNic) { + QuicAddrSetToDuoNic(&LocalAddress.SockAddr); + } QUIC_STATUS Status = QUIC_STATUS_ADDRESS_IN_USE; while (Status == QUIC_STATUS_ADDRESS_IN_USE) { LocalAddress.IncrementPort(); diff --git a/src/test/lib/DataTest.cpp b/src/test/lib/DataTest.cpp index fd6bfad35..ac05e4110 100644 --- a/src/test/lib/DataTest.cpp +++ b/src/test/lib/DataTest.cpp @@ -451,6 +451,9 @@ QuicTestConnectAndPing( if (j == 0) { QuicAddr RemoteAddr(QuicAddrFamily, true); + if (UseDuoNic) { + QuicAddrSetToDuoNic(&RemoteAddr.SockAddr); + } TEST_QUIC_SUCCEEDED(Connections.get()[i]->SetRemoteAddr(RemoteAddr)); if (i != 0) { @@ -460,7 +463,7 @@ QuicTestConnectAndPing( Connections.get()[i]->Start( ClientConfiguration, QuicAddrFamily, - ClientZeroRtt ? QUIC_LOCALHOST_FOR_AF(QuicAddrFamily) : nullptr, + ClientZeroRtt ? QUIC_TEST_LOOPBACK_FOR_AF(QuicAddrFamily) : nullptr, ServerLocalAddr.GetPort())); if (i == 0) { Connections.get()[i]->GetLocalAddr(LocalAddr); @@ -528,7 +531,7 @@ QuicTestServerDisconnect( Client->Start( ClientConfiguration, QuicAddrGetFamily(&ServerLocalAddr.SockAddr), - QUIC_LOCALHOST_FOR_AF( + QUIC_TEST_LOOPBACK_FOR_AF( QuicAddrGetFamily(&ServerLocalAddr.SockAddr)), ServerLocalAddr.GetPort())); @@ -659,7 +662,7 @@ QuicTestClientDisconnect( Client->Start( ClientConfiguration, QUIC_ADDRESS_FAMILY_INET, - QUIC_LOCALHOST_FOR_AF(QUIC_ADDRESS_FAMILY_INET), + QUIC_TEST_LOOPBACK_FOR_AF(QUIC_ADDRESS_FAMILY_INET), ServerLocalAddr.GetPort())); if (!Client->WaitForConnectionComplete()) { @@ -982,7 +985,7 @@ QuicAbortiveTransfers( ClientContext.Conn.Handle, ClientConfiguration, QuicAddrFamily, - QUIC_LOCALHOST_FOR_AF(QuicAddrFamily), + QUIC_TEST_LOOPBACK_FOR_AF(QuicAddrFamily), ServerLocalAddr.GetPort()); if (QUIC_FAILED(Status)) { TEST_FAILURE("MsQuic->ConnectionStart failed, 0x%x.", Status); @@ -1443,7 +1446,7 @@ QuicTestReceiveResume( ClientContext.Conn.Handle, ClientConfiguration, QuicAddrFamily, - QUIC_LOCALHOST_FOR_AF(QuicAddrFamily), + QUIC_TEST_LOOPBACK_FOR_AF(QuicAddrFamily), ServerLocalAddr.GetPort()); if (QUIC_FAILED(Status)) { TEST_FAILURE("MsQuic->ConnectionStart failed, 0x%x.", Status); @@ -1669,7 +1672,7 @@ QuicTestReceiveResumeNoData( ClientContext.Conn.Handle, ClientConfiguration, QuicAddrFamily, - QUIC_LOCALHOST_FOR_AF(QuicAddrFamily), + QUIC_TEST_LOOPBACK_FOR_AF(QuicAddrFamily), ServerLocalAddr.GetPort()); if (QUIC_FAILED(Status)) { TEST_FAILURE("MsQuic->ConnectionStart failed, 0x%x.", Status); @@ -1995,7 +1998,7 @@ QuicTestAckSendDelay( TestContext.ClientConnection.Handle, ClientConfiguration, QuicAddrFamily, - QUIC_LOCALHOST_FOR_AF(QuicAddrFamily), + QUIC_TEST_LOOPBACK_FOR_AF(QuicAddrFamily), ServerLocalAddr.GetPort()); if (QUIC_FAILED(Status)) { TEST_FAILURE("MsQuic->ConnectionStart failed, 0x%x.", Status); @@ -2125,7 +2128,7 @@ QuicTestAbortReceive( MsQuicConnection Connection(Registration); TEST_QUIC_SUCCEEDED(Connection.GetInitStatus()); - TEST_QUIC_SUCCEEDED(Connection.StartLocalhost(ClientConfiguration, ServerLocalAddr)); + TEST_QUIC_SUCCEEDED(Connection.Start(ClientConfiguration, ServerLocalAddr.GetFamily(), QUIC_TEST_LOOPBACK_FOR_AF(ServerLocalAddr.GetFamily()), ServerLocalAddr.GetPort())); MsQuicStream Stream(Connection, QUIC_STREAM_OPEN_FLAG_UNIDIRECTIONAL); TEST_QUIC_SUCCEEDED(Stream.GetInitStatus()); @@ -2194,7 +2197,7 @@ QuicTestSlowReceive( MsQuicConnection Connection(Registration); TEST_QUIC_SUCCEEDED(Connection.GetInitStatus()); - TEST_QUIC_SUCCEEDED(Connection.StartLocalhost(ClientConfiguration, ServerLocalAddr)); + TEST_QUIC_SUCCEEDED(Connection.Start(ClientConfiguration, ServerLocalAddr.GetFamily(), QUIC_TEST_LOOPBACK_FOR_AF(ServerLocalAddr.GetFamily()), ServerLocalAddr.GetPort())); MsQuicStream Stream(Connection, QUIC_STREAM_OPEN_FLAG_UNIDIRECTIONAL); TEST_QUIC_SUCCEEDED(Stream.GetInitStatus()); @@ -2312,7 +2315,7 @@ QuicTestNthAllocFail( MsQuicConnection Connection(Registration); CONTINUE_ON_FAIL(Connection.GetInitStatus()); - CONTINUE_ON_FAIL(Connection.StartLocalhost(ClientConfiguration, ServerLocalAddr)); + CONTINUE_ON_FAIL(Connection.Start(ClientConfiguration, ServerLocalAddr.GetFamily(), QUIC_TEST_LOOPBACK_FOR_AF(ServerLocalAddr.GetFamily()), ServerLocalAddr.GetPort())); MsQuicStream Stream(Connection, QUIC_STREAM_OPEN_FLAG_UNIDIRECTIONAL); CONTINUE_ON_FAIL(Stream.GetInitStatus()); @@ -2396,7 +2399,7 @@ QuicTestStreamPriority( TEST_QUIC_SUCCEEDED(Stream1.SetPriority(0)); // Change to lowest priority - TEST_QUIC_SUCCEEDED(Connection.StartLocalhost(ClientConfiguration, ServerLocalAddr)); + TEST_QUIC_SUCCEEDED(Connection.Start(ClientConfiguration, ServerLocalAddr.GetFamily(), QUIC_TEST_LOOPBACK_FOR_AF(ServerLocalAddr.GetFamily()), ServerLocalAddr.GetPort())); TEST_TRUE(Connection.HandshakeCompleteEvent.WaitTimeout(TestWaitTimeout)); TEST_TRUE(Connection.HandshakeComplete); @@ -2449,7 +2452,7 @@ QuicTestStreamPriorityInfiniteLoop( TEST_QUIC_SUCCEEDED(Stream3.GetInitStatus()); TEST_QUIC_SUCCEEDED(Stream3.Send(&Buffer, 1, QUIC_SEND_FLAG_START | QUIC_SEND_FLAG_FIN)); - TEST_QUIC_SUCCEEDED(Connection.StartLocalhost(ClientConfiguration, ServerLocalAddr)); + TEST_QUIC_SUCCEEDED(Connection.Start(ClientConfiguration, ServerLocalAddr.GetFamily(), QUIC_TEST_LOOPBACK_FOR_AF(ServerLocalAddr.GetFamily()), ServerLocalAddr.GetPort())); TEST_TRUE(Connection.HandshakeCompleteEvent.WaitTimeout(TestWaitTimeout)); TEST_TRUE(Connection.HandshakeComplete); @@ -2516,7 +2519,7 @@ QuicTestStreamDifferentAbortErrors( TEST_QUIC_SUCCEEDED(Stream.Shutdown(RecvShutdownErrorCode, QUIC_STREAM_SHUTDOWN_FLAG_ABORT_RECEIVE)); TEST_QUIC_SUCCEEDED(Stream.Shutdown(SendShutdownErrorCode, QUIC_STREAM_SHUTDOWN_FLAG_ABORT_SEND)); - TEST_QUIC_SUCCEEDED(Connection.StartLocalhost(ClientConfiguration, ServerLocalAddr)); + TEST_QUIC_SUCCEEDED(Connection.Start(ClientConfiguration, ServerLocalAddr.GetFamily(), QUIC_TEST_LOOPBACK_FOR_AF(ServerLocalAddr.GetFamily()), ServerLocalAddr.GetPort())); TEST_TRUE(Connection.HandshakeCompleteEvent.WaitTimeout(TestWaitTimeout)); TEST_TRUE(Connection.HandshakeComplete); @@ -2581,7 +2584,7 @@ QuicTestStreamAbortRecvFinRace( TEST_QUIC_SUCCEEDED(Stream.Start()); TEST_QUIC_SUCCEEDED(Stream.Shutdown(0, QUIC_STREAM_SHUTDOWN_FLAG_GRACEFUL)); - TEST_QUIC_SUCCEEDED(Connection.StartLocalhost(ClientConfiguration, ServerLocalAddr)); + TEST_QUIC_SUCCEEDED(Connection.Start(ClientConfiguration, ServerLocalAddr.GetFamily(), QUIC_TEST_LOOPBACK_FOR_AF(ServerLocalAddr.GetFamily()), ServerLocalAddr.GetPort())); TEST_TRUE(Connection.HandshakeCompleteEvent.WaitTimeout(TestWaitTimeout)); TEST_TRUE(Connection.HandshakeComplete); @@ -2651,7 +2654,7 @@ QuicTestStreamAbortConnFlowControl( TEST_QUIC_SUCCEEDED(Stream2.GetInitStatus()); TEST_QUIC_SUCCEEDED(Stream2.Send(&Buffer, 1, QUIC_SEND_FLAG_START | QUIC_SEND_FLAG_FIN)); - TEST_QUIC_SUCCEEDED(Connection.StartLocalhost(ClientConfiguration, ServerLocalAddr)); + TEST_QUIC_SUCCEEDED(Connection.Start(ClientConfiguration, ServerLocalAddr.GetFamily(), QUIC_TEST_LOOPBACK_FOR_AF(ServerLocalAddr.GetFamily()), ServerLocalAddr.GetPort())); TEST_TRUE(Connection.HandshakeCompleteEvent.WaitTimeout(TestWaitTimeout)); TEST_TRUE(Connection.HandshakeComplete); diff --git a/src/test/lib/DatagramTest.cpp b/src/test/lib/DatagramTest.cpp index 5e0567dfa..6f4dbe979 100644 --- a/src/test/lib/DatagramTest.cpp +++ b/src/test/lib/DatagramTest.cpp @@ -92,7 +92,7 @@ QuicTestDatagramNegotiation( Client.Start( ClientConfiguration, QuicAddrFamily, - QUIC_LOCALHOST_FOR_AF(QuicAddrFamily), + QUIC_TEST_LOOPBACK_FOR_AF(QuicAddrFamily), ServerLocalAddr.GetPort())); if (!Client.WaitForConnectionComplete()) { @@ -184,7 +184,7 @@ QuicTestDatagramSend( Client.Start( ClientConfiguration, QuicAddrFamily, - QUIC_LOCALHOST_FOR_AF(QuicAddrFamily), + QUIC_TEST_LOOPBACK_FOR_AF(QuicAddrFamily), ServerLocalAddr.GetPort())); if (!Client.WaitForConnectionComplete()) { diff --git a/src/test/lib/EventTest.cpp b/src/test/lib/EventTest.cpp index 100c0c873..6d26f8fc0 100644 --- a/src/test/lib/EventTest.cpp +++ b/src/test/lib/EventTest.cpp @@ -381,7 +381,7 @@ QuicTestValidateConnectionEvents1( Client.Handle, ClientConfiguration, QuicAddrGetFamily(&ServerLocalAddr.SockAddr), - QUIC_LOCALHOST_FOR_AF( + QUIC_TEST_LOOPBACK_FOR_AF( QuicAddrGetFamily(&ServerLocalAddr.SockAddr)), ServerLocalAddr.GetPort())); @@ -438,7 +438,7 @@ QuicTestValidateConnectionEvents2( Client.Handle, ClientConfiguration, QuicAddrGetFamily(&ServerLocalAddr.SockAddr), - QUIC_LOCALHOST_FOR_AF( + QUIC_TEST_LOOPBACK_FOR_AF( QuicAddrGetFamily(&ServerLocalAddr.SockAddr)), ServerLocalAddr.GetPort())); @@ -512,7 +512,7 @@ QuicTestValidateConnectionEvents3( Client.Handle, ClientConfiguration, QuicAddrGetFamily(&ServerLocalAddr.SockAddr), - QUIC_LOCALHOST_FOR_AF(QuicAddrGetFamily(&ServerLocalAddr.SockAddr)), + QUIC_TEST_LOOPBACK_FOR_AF(QuicAddrGetFamily(&ServerLocalAddr.SockAddr)), QuicAddrGetPort(&ServerLocalAddr.SockAddr))); TEST_TRUE(Client.Complete.WaitTimeout(2000)); @@ -638,7 +638,7 @@ QuicTestValidateStreamEvents1( Client.Handle, ClientConfiguration, QuicAddrGetFamily(&ServerLocalAddr.SockAddr), - QUIC_LOCALHOST_FOR_AF( + QUIC_TEST_LOOPBACK_FOR_AF( QuicAddrGetFamily(&ServerLocalAddr.SockAddr)), ServerLocalAddr.GetPort())); @@ -725,7 +725,7 @@ QuicTestValidateStreamEvents2( Client.Handle, ClientConfiguration, QuicAddrGetFamily(&ServerLocalAddr.SockAddr), - QUIC_LOCALHOST_FOR_AF( + QUIC_TEST_LOOPBACK_FOR_AF( QuicAddrGetFamily(&ServerLocalAddr.SockAddr)), ServerLocalAddr.GetPort())); @@ -824,7 +824,7 @@ QuicTestValidateStreamEvents3( Client.Handle, ClientConfiguration, QuicAddrGetFamily(&ServerLocalAddr.SockAddr), - QUIC_LOCALHOST_FOR_AF( + QUIC_TEST_LOOPBACK_FOR_AF( QuicAddrGetFamily(&ServerLocalAddr.SockAddr)), ServerLocalAddr.GetPort())); TEST_TRUE(Client.HandshakeComplete.WaitTimeout(1000)); @@ -947,7 +947,7 @@ QuicTestValidateStreamEvents4( Client.Handle, ClientConfiguration, QuicAddrGetFamily(&ServerLocalAddr.SockAddr), - QUIC_LOCALHOST_FOR_AF( + QUIC_TEST_LOOPBACK_FOR_AF( QuicAddrGetFamily(&ServerLocalAddr.SockAddr)), ServerLocalAddr.GetPort())); TEST_TRUE(Client.HandshakeComplete.WaitTimeout(1000)); @@ -1075,7 +1075,7 @@ QuicTestValidateStreamEvents5( Client.Handle, ClientConfiguration, QuicAddrGetFamily(&ServerLocalAddr.SockAddr), - QUIC_LOCALHOST_FOR_AF( + QUIC_TEST_LOOPBACK_FOR_AF( QuicAddrGetFamily(&ServerLocalAddr.SockAddr)), ServerLocalAddr.GetPort())); @@ -1182,7 +1182,7 @@ QuicTestValidateStreamEvents6( Client.Handle, ClientConfiguration, QuicAddrGetFamily(&ServerLocalAddr.SockAddr), - QUIC_LOCALHOST_FOR_AF( + QUIC_TEST_LOOPBACK_FOR_AF( QuicAddrGetFamily(&ServerLocalAddr.SockAddr)), ServerLocalAddr.GetPort())); TEST_TRUE(Client.HandshakeComplete.WaitTimeout(1000)); @@ -1302,7 +1302,7 @@ QuicTestValidateStreamEvents7( Client.Handle, ClientConfiguration, QuicAddrGetFamily(&ServerLocalAddr.SockAddr), - QUIC_LOCALHOST_FOR_AF( + QUIC_TEST_LOOPBACK_FOR_AF( QuicAddrGetFamily(&ServerLocalAddr.SockAddr)), ServerLocalAddr.GetPort())); @@ -1402,7 +1402,7 @@ QuicTestValidateStreamEvents8( Client.Handle, ClientConfiguration, QuicAddrGetFamily(&ServerLocalAddr.SockAddr), - QUIC_LOCALHOST_FOR_AF( + QUIC_TEST_LOOPBACK_FOR_AF( QuicAddrGetFamily(&ServerLocalAddr.SockAddr)), ServerLocalAddr.GetPort())); TEST_TRUE(Client.HandshakeComplete.WaitTimeout(1000)); diff --git a/src/test/lib/HandshakeTest.cpp b/src/test/lib/HandshakeTest.cpp index 7ba0b6a6b..ce2d0d11b 100644 --- a/src/test/lib/HandshakeTest.cpp +++ b/src/test/lib/HandshakeTest.cpp @@ -77,7 +77,7 @@ QuicTestPrimeResumption( Client.Start( ClientConfiguration, QuicAddrGetFamily(&ServerLocalAddr.SockAddr), - QUIC_LOCALHOST_FOR_AF(QuicAddrGetFamily(&ServerLocalAddr.SockAddr)), + QUIC_TEST_LOOPBACK_FOR_AF(QuicAddrGetFamily(&ServerLocalAddr.SockAddr)), ServerLocalAddr.GetPort())); if (Client.WaitForConnectionComplete()) { TEST_TRUE(Client.GetIsConnected()); @@ -239,7 +239,7 @@ QuicTestConnect( Client.Start( ClientConfiguration, QuicAddrFamily, - QUIC_LOCALHOST_FOR_AF(QuicAddrFamily), + QUIC_TEST_LOOPBACK_FOR_AF(QuicAddrFamily), ServerLocalAddr.GetPort())); if (AsyncConfiguration) { @@ -363,7 +363,7 @@ QuicTestNatPortRebind( MsQuicConnection Connection(Registration); TEST_QUIC_SUCCEEDED(Connection.GetInitStatus()); - TEST_QUIC_SUCCEEDED(Connection.StartLocalhost(ClientConfiguration, ServerLocalAddr)); + TEST_QUIC_SUCCEEDED(Connection.Start(ClientConfiguration, ServerLocalAddr.GetFamily(), QUIC_TEST_LOOPBACK_FOR_AF(ServerLocalAddr.GetFamily()), ServerLocalAddr.GetPort())); TEST_TRUE(Connection.HandshakeCompleteEvent.WaitTimeout(TestWaitTimeout)); TEST_TRUE(Context.HandshakeCompleteEvent.WaitTimeout(TestWaitTimeout)); TEST_TRUE(Context.Connected); @@ -412,7 +412,7 @@ QuicTestNatAddrRebind( MsQuicConnection Connection(Registration); TEST_QUIC_SUCCEEDED(Connection.GetInitStatus()); - TEST_QUIC_SUCCEEDED(Connection.StartLocalhost(ClientConfiguration, ServerLocalAddr)); + TEST_QUIC_SUCCEEDED(Connection.Start(ClientConfiguration, ServerLocalAddr.GetFamily(), QUIC_TEST_LOOPBACK_FOR_AF(ServerLocalAddr.GetFamily()), ServerLocalAddr.GetPort())); TEST_TRUE(Connection.HandshakeCompleteEvent.WaitTimeout(TestWaitTimeout)); TEST_TRUE(Context.HandshakeCompleteEvent.WaitTimeout(TestWaitTimeout)); TEST_TRUE(Context.Connected); @@ -476,7 +476,7 @@ QuicTestPathValidationTimeout( Client.Start( ClientConfiguration, QuicAddrFamily, - QUIC_LOCALHOST_FOR_AF(QuicAddrFamily), + QUIC_TEST_LOOPBACK_FOR_AF(QuicAddrFamily), ServerLocalAddr.GetPort())); if (!Client.WaitForConnectionComplete()) { @@ -556,7 +556,7 @@ QuicTestChangeMaxStreamID( Client.Start( ClientConfiguration, QuicAddrFamily, - QUIC_LOCALHOST_FOR_AF(QuicAddrFamily), + QUIC_TEST_LOOPBACK_FOR_AF(QuicAddrFamily), ServerLocalAddr.GetPort())); if (!Client.WaitForConnectionComplete()) { @@ -644,7 +644,7 @@ QuicTestConnectAndIdle( Client.Start( ClientConfiguration, QUIC_ADDRESS_FAMILY_UNSPEC, - QUIC_LOCALHOST_FOR_AF( + QUIC_TEST_LOOPBACK_FOR_AF( QuicAddrGetFamily(&ServerLocalAddr.SockAddr)), ServerLocalAddr.GetPort())); @@ -746,7 +746,7 @@ QuicTestCustomCertificateValidation( Client.Start( ClientConfiguration, QUIC_ADDRESS_FAMILY_UNSPEC, - QUIC_LOCALHOST_FOR_AF( + QUIC_TEST_LOOPBACK_FOR_AF( QuicAddrGetFamily(&ServerLocalAddr.SockAddr)), ServerLocalAddr.GetPort())); @@ -803,7 +803,7 @@ QuicTestConnectUnreachable( Client.Start( ClientConfiguration, QuicAddrFamily, - QUIC_LOCALHOST_FOR_AF(QuicAddrFamily), + QUIC_TEST_LOOPBACK_FOR_AF(QuicAddrFamily), TestUdpPortBase - 1)); if (!Client.WaitForConnectionComplete()) { return; @@ -835,9 +835,15 @@ QuicTestConnectInvalidAddress( TEST_TRUE(Client.IsValid()); QuicAddr LocalAddr{QUIC_ADDRESS_FAMILY_INET, true}; + if (UseDuoNic) { + QuicAddrSetToDuoNic(&LocalAddr.SockAddr); + } LocalAddr.SetPort(TestUdpPortBase - 2); QuicAddr RemoteAddr{QUIC_ADDRESS_FAMILY_INET6, true}; + if (UseDuoNic) { + QuicAddrSetToDuoNic(&RemoteAddr.SockAddr); + } RemoteAddr.SetPort(TestUdpPortBase - 1); TEST_QUIC_SUCCEEDED(Client.SetLocalAddr(LocalAddr)); @@ -848,7 +854,7 @@ QuicTestConnectInvalidAddress( Client.Start( ClientConfiguration, QUIC_ADDRESS_FAMILY_INET6, - QUIC_LOCALHOST_FOR_AF(QUIC_ADDRESS_FAMILY_INET6), + QUIC_TEST_LOOPBACK_FOR_AF(QUIC_ADDRESS_FAMILY_INET6), TestUdpPortBase - 1)); if (!Client.WaitForConnectionComplete()) { return; @@ -919,7 +925,7 @@ QuicTestVersionNegotiation( Client.Start( ClientConfiguration, QuicAddrFamily, - QUIC_LOCALHOST_FOR_AF(QuicAddrFamily), + QUIC_TEST_LOOPBACK_FOR_AF(QuicAddrFamily), ServerLocalAddr.GetPort())); if (!Client.WaitForConnectionComplete()) { return; @@ -1017,7 +1023,7 @@ QuicTestVersionNegotiationRetry( Client.Start( ClientConfiguration, QuicAddrFamily, - QUIC_LOCALHOST_FOR_AF(QuicAddrFamily), + QUIC_TEST_LOOPBACK_FOR_AF(QuicAddrFamily), ServerLocalAddr.GetPort())); if (!Client.WaitForConnectionComplete()) { return; @@ -1110,7 +1116,7 @@ QuicTestCompatibleVersionNegotiation( Client.Start( ClientConfiguration, QuicAddrFamily, - QUIC_LOCALHOST_FOR_AF(QuicAddrFamily), + QUIC_TEST_LOOPBACK_FOR_AF(QuicAddrFamily), ServerLocalAddr.GetPort())); if (!Client.WaitForConnectionComplete()) { @@ -1218,7 +1224,7 @@ QuicTestCompatibleVersionNegotiationRetry( Client.Start( ClientConfiguration, QuicAddrFamily, - QUIC_LOCALHOST_FOR_AF(QuicAddrFamily), + QUIC_TEST_LOOPBACK_FOR_AF(QuicAddrFamily), ServerLocalAddr.GetPort())); if (!Client.WaitForConnectionComplete()) { @@ -1309,7 +1315,7 @@ QuicTestCompatibleVersionNegotiationDefaultServer( Client.Start( ClientConfiguration, QuicAddrFamily, - QUIC_LOCALHOST_FOR_AF(QuicAddrFamily), + QUIC_TEST_LOOPBACK_FOR_AF(QuicAddrFamily), ServerLocalAddr.GetPort())); if (!Client.WaitForConnectionComplete()) { @@ -1407,7 +1413,7 @@ QuicTestCompatibleVersionNegotiationDefaultClient( Client.Start( ClientConfiguration, QuicAddrFamily, - QUIC_LOCALHOST_FOR_AF(QuicAddrFamily), + QUIC_TEST_LOOPBACK_FOR_AF(QuicAddrFamily), ServerLocalAddr.GetPort())); if (!Client.WaitForConnectionComplete()) { @@ -1499,7 +1505,7 @@ QuicTestIncompatibleVersionNegotiation( Client.Start( ClientConfiguration, QuicAddrFamily, - QUIC_LOCALHOST_FOR_AF(QuicAddrFamily), + QUIC_TEST_LOOPBACK_FOR_AF(QuicAddrFamily), ServerLocalAddr.GetPort())); if (!Client.WaitForConnectionComplete()) { @@ -1605,7 +1611,7 @@ RunFailedVersionNegotiation( Client.Start( ClientConfiguration, QuicAddrFamily, - QUIC_LOCALHOST_FOR_AF(QuicAddrFamily), + QUIC_TEST_LOOPBACK_FOR_AF(QuicAddrFamily), ServerLocalAddr.GetPort())); Client.WaitForShutdownComplete(); @@ -1699,7 +1705,7 @@ QuicTestConnectBadAlpn( Client.Start( ClientConfiguration, QuicAddrFamily, - QUIC_LOCALHOST_FOR_AF(QuicAddrFamily), + QUIC_TEST_LOOPBACK_FOR_AF(QuicAddrFamily), ServerLocalAddr.GetPort())); if (!Client.WaitForConnectionComplete()) { return; @@ -1752,6 +1758,9 @@ QuicTestConnectBadSni( TEST_TRUE(Client.IsValid()); QuicAddr RemoteAddr(Family == 4 ? QUIC_ADDRESS_FAMILY_INET : QUIC_ADDRESS_FAMILY_INET6, true); + if (UseDuoNic) { + QuicAddrSetToDuoNic(&RemoteAddr.SockAddr); + } TEST_QUIC_SUCCEEDED(Client.SetRemoteAddr(RemoteAddr)); Client.SetExpectedTransportCloseStatus(QUIC_STATUS_CONNECTION_REFUSED); @@ -1832,7 +1841,7 @@ QuicTestConnectServerRejected( Client.Start( ClientConfiguration, QuicAddrFamily, - QUIC_LOCALHOST_FOR_AF(QuicAddrFamily), + QUIC_TEST_LOOPBACK_FOR_AF(QuicAddrFamily), ServerLocalAddr.GetPort())); if (!Client.WaitForShutdownComplete()) { return; @@ -1886,7 +1895,7 @@ QuicTestKeyUpdateRandomLoss( Client.Start( ClientConfiguration, QuicAddrFamily, - QUIC_LOCALHOST_FOR_AF(QuicAddrFamily), + QUIC_TEST_LOOPBACK_FOR_AF(QuicAddrFamily), ServerLocalAddr.GetPort())); if (!Client.WaitForConnectionComplete()) { @@ -2015,7 +2024,7 @@ QuicTestKeyUpdate( Client.Start( ClientConfiguration, QuicAddrFamily, - QUIC_LOCALHOST_FOR_AF(QuicAddrFamily), + QUIC_TEST_LOOPBACK_FOR_AF(QuicAddrFamily), ServerLocalAddr.GetPort())); if (!Client.WaitForConnectionComplete()) { @@ -2158,7 +2167,7 @@ QuicTestCidUpdate( Client.Start( ClientConfiguration, QuicAddrFamily, - QUIC_LOCALHOST_FOR_AF(QuicAddrFamily), + QUIC_TEST_LOOPBACK_FOR_AF(QuicAddrFamily), ServerLocalAddr.GetPort())); if (!Client.WaitForConnectionComplete()) { @@ -2271,7 +2280,7 @@ QuicTestConnectClientCertificate( Client.Start( ClientConfiguration, QuicAddrFamily, - QUIC_LOCALHOST_FOR_AF( + QUIC_TEST_LOOPBACK_FOR_AF( QuicAddrGetFamily(&ServerLocalAddr.SockAddr)), ServerLocalAddr.GetPort())); @@ -2368,7 +2377,7 @@ QuicTestValidAlpnLengths( Client.Start( ClientConfiguration, QuicAddrFamily, - QUIC_LOCALHOST_FOR_AF( + QUIC_TEST_LOOPBACK_FOR_AF( QuicAddrGetFamily(&ServerLocalAddr.SockAddr)), ServerLocalAddr.GetPort())); @@ -2434,7 +2443,7 @@ QuicTestConnectExpiredServerCertificate( Client.Start( ClientConfiguration, QuicAddrFamily, - QUIC_LOCALHOST_FOR_AF( + QUIC_TEST_LOOPBACK_FOR_AF( QuicAddrGetFamily(&ServerLocalAddr.SockAddr)), ServerLocalAddr.GetPort())); @@ -2497,7 +2506,7 @@ QuicTestConnectValidServerCertificate( Client.Start( ClientConfiguration, QuicAddrFamily, - QUIC_LOCALHOST_FOR_AF( + QUIC_TEST_LOOPBACK_FOR_AF( QuicAddrGetFamily(&ServerLocalAddr.SockAddr)), ServerLocalAddr.GetPort())); @@ -2560,7 +2569,7 @@ QuicTestConnectValidClientCertificate( Client.Start( ClientConfiguration, QuicAddrFamily, - QUIC_LOCALHOST_FOR_AF( + QUIC_TEST_LOOPBACK_FOR_AF( QuicAddrGetFamily(&ServerLocalAddr.SockAddr)), ServerLocalAddr.GetPort())); @@ -2623,7 +2632,7 @@ QuicTestConnectExpiredClientCertificate( Client.Start( ClientConfiguration, QuicAddrFamily, - QUIC_LOCALHOST_FOR_AF( + QUIC_TEST_LOOPBACK_FOR_AF( QuicAddrGetFamily(&ServerLocalAddr.SockAddr)), ServerLocalAddr.GetPort())); @@ -2670,10 +2679,18 @@ struct LoadBalancedServer { CxPlatZeroMemory(Listeners, sizeof(MsQuicAutoAcceptListener*) * ListenerCount); MsQuicSettings Settings; Settings.SetServerResumptionLevel(QUIC_SERVER_RESUME_AND_ZERORTT); - QuicAddrSetToLoopback(&PublicAddress.SockAddr); + if (UseDuoNic) { + QuicAddrSetToDuoNic(&PublicAddress.SockAddr); + } else { + QuicAddrSetToLoopback(&PublicAddress.SockAddr); + } for (uint32_t i = 0; i < ListenerCount; ++i) { PrivateAddresses[i] = QuicAddr(QuicAddrFamily); - QuicAddrSetToLoopback(&PrivateAddresses[i].SockAddr); + if (UseDuoNic) { + QuicAddrSetToDuoNic(&PrivateAddresses[i].SockAddr); + } else { + QuicAddrSetToLoopback(&PrivateAddresses[i].SockAddr); + } Configurations[i] = new(std::nothrow) MsQuicConfiguration(Registration, "MsQuicTest", Settings, ServerSelfSignedCredConfig); TEST_QUIC_SUCCEEDED(InitStatus = Configurations[i]->GetInitStatus()); TEST_QUIC_SUCCEEDED(InitStatus = Configurations[i]->SetTicketKey(&KeyConfig)); @@ -2733,7 +2750,7 @@ QuicTestLoadBalancedHandshake( TryingResumption = true; } TEST_QUIC_SUCCEEDED(Connection.SetLocalAddr(ConnLocalAddr)); - TEST_QUIC_SUCCEEDED(Connection.StartLocalhost(ClientConfiguration, Listeners.PublicAddress)); + TEST_QUIC_SUCCEEDED(Connection.Start(ClientConfiguration, Listeners.PublicAddress.GetFamily(), QUIC_TEST_LOOPBACK_FOR_AF(Listeners.PublicAddress.GetFamily()), Listeners.PublicAddress.GetPort())); TEST_TRUE(Connection.HandshakeCompleteEvent.WaitTimeout(TestWaitTimeout)); if (!Connection.HandshakeComplete) { // @@ -2807,7 +2824,7 @@ QuicTestClientSharedLocalPort( MsQuicConnection Connection1(Registration); TEST_QUIC_SUCCEEDED(Connection1.GetInitStatus()); TEST_QUIC_SUCCEEDED(Connection1.SetShareUdpBinding()); - TEST_QUIC_SUCCEEDED(Connection1.StartLocalhost(ClientConfiguration, Server1LocalAddr)); + TEST_QUIC_SUCCEEDED(Connection1.Start(ClientConfiguration, Server1LocalAddr.GetFamily(), QUIC_TEST_LOOPBACK_FOR_AF(Server1LocalAddr.GetFamily()), Server1LocalAddr.GetPort())); TEST_TRUE(Connection1.HandshakeCompleteEvent.WaitTimeout(TestWaitTimeout)); TEST_TRUE(Connection1.HandshakeComplete); QuicAddr Client1LocalAddr; @@ -2817,7 +2834,7 @@ QuicTestClientSharedLocalPort( TEST_QUIC_SUCCEEDED(Connection2.GetInitStatus()); TEST_QUIC_SUCCEEDED(Connection2.SetShareUdpBinding()); TEST_QUIC_SUCCEEDED(Connection2.SetLocalAddr(Client1LocalAddr)); - TEST_QUIC_SUCCEEDED(Connection2.StartLocalhost(ClientConfiguration, Server1LocalAddr)); + TEST_QUIC_SUCCEEDED(Connection2.Start(ClientConfiguration, Server1LocalAddr.GetFamily(), QUIC_TEST_LOOPBACK_FOR_AF(Server1LocalAddr.GetFamily()), Server1LocalAddr.GetPort())); TEST_TRUE(Connection2.HandshakeCompleteEvent.WaitTimeout(TestWaitTimeout)); TEST_TRUE(Connection2.HandshakeComplete); } @@ -2884,14 +2901,14 @@ QuicTestInterfaceBinding( MsQuicConnection Connection1(Registration); TEST_QUIC_SUCCEEDED(Connection1.GetInitStatus()); TEST_QUIC_SUCCEEDED(Connection1.SetLocalInterface(LoopbackInterfaceIndex)); - TEST_QUIC_SUCCEEDED(Connection1.StartLocalhost(ClientConfiguration, ServerLocalAddr)); + TEST_QUIC_SUCCEEDED(Connection1.Start(ClientConfiguration, ServerLocalAddr.GetFamily(), QUIC_TEST_LOOPBACK_FOR_AF(ServerLocalAddr.GetFamily()), ServerLocalAddr.GetPort())); TEST_TRUE(Connection1.HandshakeCompleteEvent.WaitTimeout(TestWaitTimeout)); TEST_TRUE(Connection1.HandshakeComplete); MsQuicConnection Connection2(Registration); TEST_QUIC_SUCCEEDED(Connection2.GetInitStatus()); TEST_QUIC_SUCCEEDED(Connection2.SetLocalInterface(OtherInterfaceIndex)); - TEST_QUIC_SUCCEEDED(Connection2.StartLocalhost(ClientConfiguration, ServerLocalAddr)); + TEST_QUIC_SUCCEEDED(Connection2.Start(ClientConfiguration, ServerLocalAddr.GetFamily(), QUIC_TEST_LOOPBACK_FOR_AF(ServerLocalAddr.GetFamily()), ServerLocalAddr.GetPort())); Connection2.HandshakeCompleteEvent.WaitTimeout(TestWaitTimeout); TEST_TRUE(!Connection2.HandshakeComplete); } @@ -2934,7 +2951,7 @@ QuicTestCibirExtension( if (!ShouldConnnect) { // TODO - Set expected transport error } - TEST_QUIC_SUCCEEDED(Connection.StartLocalhost(ClientConfiguration, ServerLocalAddr)); + TEST_QUIC_SUCCEEDED(Connection.Start(ClientConfiguration, ServerLocalAddr.GetFamily(), QUIC_TEST_LOOPBACK_FOR_AF(ServerLocalAddr.GetFamily()), ServerLocalAddr.GetPort())); TEST_TRUE(Connection.HandshakeCompleteEvent.WaitTimeout(TestWaitTimeout)); TEST_EQUAL(Connection.HandshakeComplete, ShouldConnnect); } diff --git a/src/test/lib/MtuTest.cpp b/src/test/lib/MtuTest.cpp index 7f66ad57a..39bc03005 100644 --- a/src/test/lib/MtuTest.cpp +++ b/src/test/lib/MtuTest.cpp @@ -121,7 +121,7 @@ QuicTestMtuSettings() MsQuicConnection Connection(Registration); TEST_QUIC_SUCCEEDED(Connection.GetInitStatus()); - TEST_QUIC_SUCCEEDED(Connection.StartLocalhost(ClientConfiguration, ServerLocalAddr)); + TEST_QUIC_SUCCEEDED(Connection.Start(ClientConfiguration, ServerLocalAddr.GetFamily(), QUIC_TEST_LOOPBACK_FOR_AF(ServerLocalAddr.GetFamily()), ServerLocalAddr.GetPort())); // // Set connection settings after open, should fail @@ -179,7 +179,7 @@ QuicTestMtuSettings() 0, ServerLocalAddr.GetPort(), 1499); - TEST_QUIC_SUCCEEDED(Connection.StartLocalhost(ClientConfiguration, ServerLocalAddr)); + TEST_QUIC_SUCCEEDED(Connection.Start(ClientConfiguration, ServerLocalAddr.GetFamily(), QUIC_TEST_LOOPBACK_FOR_AF(ServerLocalAddr.GetFamily()), ServerLocalAddr.GetPort())); MsQuicStream Stream(Connection, QUIC_STREAM_OPEN_FLAG_UNIDIRECTIONAL); TEST_QUIC_SUCCEEDED(Stream.GetInitStatus()); @@ -270,7 +270,7 @@ QuicTestMtuDiscovery( MsQuicConnection Connection(Registration); TEST_QUIC_SUCCEEDED(Connection.GetInitStatus()); - TEST_QUIC_SUCCEEDED(Connection.StartLocalhost(ClientConfiguration, ServerLocalAddr)); + TEST_QUIC_SUCCEEDED(Connection.Start(ClientConfiguration, ServerLocalAddr.GetFamily(), QUIC_TEST_LOOPBACK_FOR_AF(ServerLocalAddr.GetFamily()), ServerLocalAddr.GetPort())); CxPlatSleep(4000); // Wait for the first idle period to expire. TEST_NOT_EQUAL(nullptr, Context.Connection); diff --git a/src/test/lib/OwnershipTest.cpp b/src/test/lib/OwnershipTest.cpp index 45edb9add..d77b90796 100644 --- a/src/test/lib/OwnershipTest.cpp +++ b/src/test/lib/OwnershipTest.cpp @@ -210,7 +210,7 @@ void QuicTestRegistrationShutdownAfterConnOpenAndStart() Conn.Connection, ClientConfiguration, QUIC_ADDRESS_FAMILY_INET, - QUIC_LOCALHOST_FOR_AF(QUIC_ADDRESS_FAMILY_INET), + QUIC_TEST_LOOPBACK_FOR_AF(QUIC_ADDRESS_FAMILY_INET), ServerLocalAddr.GetPort()); TEST_TRUE(State.StateEvent.WaitTimeout(2000)); State.StateEvent.Reset(); diff --git a/src/test/lib/PathTest.cpp b/src/test/lib/PathTest.cpp index 81043c02d..76fbf1f00 100644 --- a/src/test/lib/PathTest.cpp +++ b/src/test/lib/PathTest.cpp @@ -89,7 +89,7 @@ QuicTestLocalPathChanges( MsQuicConnection Connection(Registration, CleanUpManual, ClientCallback, &PeerStreamsChanged); TEST_QUIC_SUCCEEDED(Connection.GetInitStatus()); - TEST_QUIC_SUCCEEDED(Connection.StartLocalhost(ClientConfiguration, ServerLocalAddr)); + TEST_QUIC_SUCCEEDED(Connection.Start(ClientConfiguration, ServerLocalAddr.GetFamily(), QUIC_TEST_LOOPBACK_FOR_AF(ServerLocalAddr.GetFamily()), ServerLocalAddr.GetPort())); TEST_TRUE(Connection.HandshakeCompleteEvent.WaitTimeout(TestWaitTimeout)); TEST_NOT_EQUAL(nullptr, Context.Connection); TEST_TRUE(Context.Connection->HandshakeCompleteEvent.WaitTimeout(TestWaitTimeout)); diff --git a/src/test/lib/QuicDrill.cpp b/src/test/lib/QuicDrill.cpp index f37eaa219..021968edb 100644 --- a/src/test/lib/QuicDrill.cpp +++ b/src/test/lib/QuicDrill.cpp @@ -286,7 +286,7 @@ QuicDrillInitialPacketFailureTest( Status = Sender.Initialize( - QUIC_LOCALHOST_FOR_AF(QuicAddrFamily), + QUIC_TEST_LOOPBACK_FOR_AF(QuicAddrFamily), QuicAddrFamily, (QuicAddrFamily == QUIC_ADDRESS_FAMILY_INET) ? ServerAddress.SockAddr.Ipv4.sin_port : diff --git a/src/test/lib/TestHelpers.h b/src/test/lib/TestHelpers.h index 3fe735808..327ca0db8 100644 --- a/src/test/lib/TestHelpers.h +++ b/src/test/lib/TestHelpers.h @@ -13,6 +13,38 @@ Abstract: #include "TestHelpers.h.clog.h" #endif +extern bool UseDuoNic; + +// +// Connect to the duonic address (if using duonic) or localhost (if not). +// +#define QUIC_TEST_LOOPBACK_FOR_AF(Af) (UseDuoNic ? ((Af == QUIC_ADDRESS_FAMILY_INET) ? "192.168.1.11" : "fc00::1:11") : QUIC_LOCALHOST_FOR_AF(Af)) + +// +// Set a QUIC_ADDR to the duonic "server" address. +// +inline +void +QuicAddrSetToDuoNic( + _Inout_ QUIC_ADDR* Addr + ) +{ + if (QuicAddrGetFamily(Addr) == QUIC_ADDRESS_FAMILY_INET) { + // 192.168.1.11 + ((uint32_t*)&(Addr->Ipv4.sin_addr))[0] = 184658112; + } else { + // fc00::1:11 + ((uint16_t*)&(Addr->Ipv6.sin6_addr))[0] = 252; + ((uint16_t*)&(Addr->Ipv6.sin6_addr))[1] = 0; + ((uint16_t*)&(Addr->Ipv6.sin6_addr))[2] = 0; + ((uint16_t*)&(Addr->Ipv6.sin6_addr))[3] = 0; + ((uint16_t*)&(Addr->Ipv6.sin6_addr))[4] = 0; + ((uint16_t*)&(Addr->Ipv6.sin6_addr))[5] = 0; + ((uint16_t*)&(Addr->Ipv6.sin6_addr))[6] = 256; + ((uint16_t*)&(Addr->Ipv6.sin6_addr))[7] = 4352; + } +} + #include "msquic.hpp" #include "quic_toeplitz.h" diff --git a/src/test/lib/TestListener.cpp b/src/test/lib/TestListener.cpp index 96dde31d3..cc0cc3519 100644 --- a/src/test/lib/TestListener.cpp +++ b/src/test/lib/TestListener.cpp @@ -112,11 +112,11 @@ TestListener::HandleListenerEvent( case QUIC_LISTENER_EVENT_NEW_CONNECTION: if (Event->NEW_CONNECTION.Info->ServerName != nullptr && _strnicmp( - QUIC_LOCALHOST_FOR_AF(QUIC_ADDRESS_FAMILY_INET), + QUIC_TEST_LOOPBACK_FOR_AF(QUIC_ADDRESS_FAMILY_INET), Event->NEW_CONNECTION.Info->ServerName, Event->NEW_CONNECTION.Info->ServerNameLength) != 0 && _strnicmp( - QUIC_LOCALHOST_FOR_AF(QUIC_ADDRESS_FAMILY_INET6), + QUIC_TEST_LOOPBACK_FOR_AF(QUIC_ADDRESS_FAMILY_INET6), Event->NEW_CONNECTION.Info->ServerName, Event->NEW_CONNECTION.Info->ServerNameLength) != 0) { break; // We don't fail the test, just reject the connection.