From 4b653bed974c83a1d494d6118b8cd0d5a2db0c38 Mon Sep 17 00:00:00 2001 From: tzachid Date: Mon, 21 Nov 2005 12:30:06 +0000 Subject: [PATCH] Allow connection on the same machine. All sockets can be used by all threads. Fix a few typos. (Integrate 592 from branch) (Rev 625) git-svn-id: svn://openib.tc.cornell.edu/gen1@181 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- trunk/ulp/sdp/kernel/SdpGenUtils.h | 1 + trunk/ulp/sdp/kernel/SdpSocket.cpp | 17 ++++++++++++----- trunk/ulp/sdp/kernel/SdpUserFile.cpp | 3 ++- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/trunk/ulp/sdp/kernel/SdpGenUtils.h b/trunk/ulp/sdp/kernel/SdpGenUtils.h index 458f2895..53356d1f 100644 --- a/trunk/ulp/sdp/kernel/SdpGenUtils.h +++ b/trunk/ulp/sdp/kernel/SdpGenUtils.h @@ -82,6 +82,7 @@ void* __cdecl operator new(size_t n, void *addr ) throw(); int IbalToWsaError(const ib_api_status_t ib_status ); #define INADDR_ANY (ULONG)0x00000000 +#define INADDR_LOOPBACK 0x7f000001 // This error codes are taken from winsock2.h (the file can not) // be included from kernel mode diff --git a/trunk/ulp/sdp/kernel/SdpSocket.cpp b/trunk/ulp/sdp/kernel/SdpSocket.cpp index de3717bb..0c373d0f 100644 --- a/trunk/ulp/sdp/kernel/SdpSocket.cpp +++ b/trunk/ulp/sdp/kernel/SdpSocket.cpp @@ -13,7 +13,7 @@ static NTSTATUS __accept_requests(SdpSocket * pSdpSocket); static void AL_API cm_rej_callback(IN ib_cm_rej_rec_t *p_cm_rej_rec ) { - SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("dispatch level = %d\n", KeGetCurrentIrql())); + SDP_PRINT(SDP_ERR, SDP_SOCKET, ("dispatch level = %d\n", KeGetCurrentIrql())); // BUGBUG: This should be used to return error to the connecting side } @@ -180,7 +180,7 @@ NTSTATUS SdpSocket::WSPSend( WspSendOut *pWspSendOut ) { - SDP_PRINT(SDP_DEBUG, SDP_SOCKET, ("this = 0x%p \n",this)); + SDP_PRINT(SDP_DEBUG, SDP_SOCKET, ("this = 0x%p size = %d \n",this, pWspSendIn->BufferSize)); NTSTATUS rc = STATUS_SUCCESS; NTSTATUS rc1; // used only to check that there are no more errors on the @@ -442,6 +442,7 @@ NTSTATUS SdpSocket::WSPConnect( ib_gid_t DestPortGid; ib_path_rec_t path_rec; + ULONG SrcIp = 0; SDP_PRINT(SDP_TRACE, SDP_SOCKET, ("this = 0x%p remote addresses ip=%d.%d.%d.%d:%d\n", this, @@ -483,6 +484,13 @@ NTSTATUS SdpSocket::WSPConnect( // No explicit bind was done, we use the default addresses m_SrcIp = pWspConnectIn->SrcIP; } + if (m_SrcIp == INADDR_LOOPBACK) { + // This is the loopback case, we use the dest IP in order to + // get the port + SrcIp = pWspConnectIn->DestIP; + } else { + SrcIp = m_SrcIp; + } // Now that we know the source IP we can decide about the src port if (m_SrcPort == 0) { @@ -497,9 +505,8 @@ NTSTATUS SdpSocket::WSPConnect( // We need to connect to the global table of ports } - - rc = g_pSdpDriver->m_pSdpArp->SourcePortGidFromIP(m_SrcIp, &m_SrcPortGuid, &m_SrcCaGuid); + rc = g_pSdpDriver->m_pSdpArp->SourcePortGidFromIP(SrcIp, &m_SrcPortGuid, &m_SrcCaGuid); if (!NT_SUCCESS(rc)) { SDP_PRINT(SDP_ERR, SDP_SOCKET, ("m_pSdpArp->SourcePortGidFromIP failed rc = 0x%x\n", rc )); pWspConnectOut->Errno = WSAENETUNREACH; // BUGBUG: verify this error @@ -1489,7 +1496,7 @@ SdpSocket::CmReqCallback(IN ib_cm_req_rec_t *p_cm_req_rec) if( ib_status != IB_SUCCESS ) { SDP_PRINT(SDP_ERR, SDP_SOCKET, ("ib_cm_rep failed ib_status = 0x%d\n", ib_status )); rc = IB2Status(ib_status); - goto Cleanup; + goto ErrorLocked; } // Add this socket to the list of sockets ?????? should this also be done on errors ???? diff --git a/trunk/ulp/sdp/kernel/SdpUserFile.cpp b/trunk/ulp/sdp/kernel/SdpUserFile.cpp index 760d7084..77003e08 100644 --- a/trunk/ulp/sdp/kernel/SdpUserFile.cpp +++ b/trunk/ulp/sdp/kernel/SdpUserFile.cpp @@ -115,6 +115,7 @@ SdpSocket *SdpUserFile::SocketByPointer(VOID *Socket, bool LookInGlobal) pSdpSocket = g_pSdpDriver->m_SdpGlobalSockets->SocketByPointer(Socket, false); if (pSdpSocket) { // We will now move this socket to the correct place +#if 0 RemoveSocket(pSdpSocket); // removes it no meter from rc = AddSocket(pSdpSocket); if(!NT_SUCCESS(rc)) { @@ -123,7 +124,7 @@ SdpSocket *SdpUserFile::SocketByPointer(VOID *Socket, bool LookInGlobal) pSdpSocket->Release(); pSdpSocket = NULL; } - +#endif } -- 2.41.0