[ofw] [Patch 61/62] Reference implementation of NDv2
Fab Tillier
ftillier at microsoft.com
Wed Feb 20 21:15:28 PST 2013
NDFLTR: Add support for cancelling path queries when EP is destroyed, refine state transitions, don't NULL deref.
Signed-off-by: Fab Tillier <ftillier at microsoft.com>
diff -dwup3 -X excl.txt -I ^ \*$ -I ^ \* \$ -r \dev\openib\Mellanox\11011\core\ndfltr\kernel\nd_ep.cpp .\core\ndfltr\kernel\nd_ep.cpp
--- \dev\openib\Mellanox\11011\core\ndfltr\kernel\nd_ep.cpp Thu Sep 20 17:51:02 2012
+++ .\core\ndfltr\kernel\nd_ep.cpp Thu Oct 04 16:33:02 2012
@@ -67,6 +67,7 @@ ND_ENDPOINT::ND_ENDPOINT(ND_ADAPTER* pAd
{
m_pWork = reinterpret_cast<PIO_WORKITEM>(this + 1);
IoInitializeWorkItem(WdfDeviceWdmGetDeviceObject(pAdapter->GetDevice()->WdfDev), m_pWork);
+ RtlZeroMemory(&m_DestinationHwAddress, sizeof(m_DestinationHwAddress));
RtlZeroMemory(&m_ReadLimits, sizeof(m_ReadLimits));
pAdapter->AddEp(&m_Entry);
}
@@ -75,11 +76,26 @@ ND_ENDPOINT::ND_ENDPOINT(ND_ADAPTER* pAd
ND_ENDPOINT::~ND_ENDPOINT()
{
WdfObjectAcquireLock(m_Queue);
+ STATE prevState = m_State;
m_State = NdEpDestroying;
WdfObjectReleaseLock(m_Queue);
UnbindQp(true, NULL, 0);
+ if( prevState == NdEpResolving ) {
+ NTSTATUS status = m_pParent->GetProvider()->GetPartition()->CancelQuery(
+ m_LocalAddress,
+ m_PeerAddress,
+ m_DestinationHwAddress,
+ ND_ENDPOINT::QueryPathHandler,
+ this
+ );
+ if( status == STATUS_SUCCESS )
+ {
+ Dereference();
+ }
+ }
+
_Base::RunDown();
if (m_hIfc != NULL) {
@@ -602,13 +618,14 @@ ND_ENDPOINT::Connect(
} else {
m_PeerAddress = DestinationAddress;
}
+ m_DestinationHwAddress = DestinationHwAddress;
WdfObjectReleaseLock(m_Queue);
Reference();
status = m_pParent->GetProvider()->GetPartition()->QueryPath(
m_LocalAddress,
m_PeerAddress,
- DestinationHwAddress,
+ m_DestinationHwAddress,
ND_ENDPOINT::QueryPathHandler,
this,
&m_Route
@@ -1671,18 +1688,21 @@ NTSTATUS ND_ENDPOINT::GetPeerAddress(__o
NTSTATUS status;
WdfObjectAcquireLock(m_Queue);
switch (m_State) {
- case NdEpDisconnected:
+ case NdEpIdle:
+ case NdEpQueued:
+ case NdEpAddressBound:
status = STATUS_CONNECTION_INVALID;
break;
- case NdEpReqReceived:
- case NdEpRepReceived:
- *pAddress = m_PeerAddress;
- status = STATUS_SUCCESS;
+ case NdEpListening:
+ case NdEpDestroying:
+ status = STATUS_INVALID_DEVICE_STATE;
break;
default:
- status = STATUS_INVALID_DEVICE_STATE;
+ *pAddress = m_PeerAddress;
+ status = STATUS_SUCCESS;
+ break;
}
WdfObjectReleaseLock(m_Queue);
return status;
@@ -1750,22 +1770,13 @@ NTSTATUS ND_ENDPOINT::GetAddress(__out S
status = STATUS_ADDRESS_NOT_ASSOCIATED;
break;
- case NdEpAddressBound:
- case NdEpListening:
- case NdEpReqReceived:
- case NdEpResolving:
- case NdEpReqSent:
- case NdEpRepReceived:
+ case NdEpDestroying:
+ status = STATUS_INVALID_DEVICE_STATE;
+
+ default:
*pAddress = m_LocalAddress;
status = STATUS_SUCCESS;
break;
-
- case NdEpDisconnected:
- status = STATUS_CONNECTION_INVALID;
- break;
-
- default:
- status = STATUS_INVALID_DEVICE_STATE;
}
WdfObjectReleaseLock(m_Queue);
return status;
diff -dwup3 -X excl.txt -I ^ \*$ -I ^ \* \$ -r \dev\openib\Mellanox\11011\core\ndfltr\kernel\nd_ep.h .\core\ndfltr\kernel\nd_ep.h
--- \dev\openib\Mellanox\11011\core\ndfltr\kernel\nd_ep.h Thu Sep 20 17:51:02 2012
+++ .\core\ndfltr\kernel\nd_ep.h Tue Oct 02 12:20:22 2012
@@ -133,6 +133,9 @@ private:
ULONG m_StartingPsn;
ND_READ_LIMITS m_ReadLimits;
+
+ IF_PHYSICAL_ADDRESS m_DestinationHwAddress;
+
UINT8 m_PrivateDataLength;
BYTE m_PrivateData[IB_REJ_PDATA_SIZE];
diff -dwup3 -X excl.txt -I ^ \*$ -I ^ \* \$ -r \dev\openib\Mellanox\11011\core\ndfltr\kernel\nd_partition.cpp .\core\ndfltr\kernel\nd_partition.cpp
--- \dev\openib\Mellanox\11011\core\ndfltr\kernel\nd_partition.cpp Thu Sep 20 17:51:02 2012
+++ .\core\ndfltr\kernel\nd_partition.cpp Tue Oct 02 12:20:19 2012
@@ -381,6 +381,50 @@ ND_PARTITION::QueryPath(
}
+NTSTATUS
+ND_PARTITION::CancelQuery(
+ __in const SOCKADDR_INET& LocalAddress,
+ __in const SOCKADDR_INET& RemoteAddress,
+ __in const IF_PHYSICAL_ADDRESS& RemoteHwAddress,
+ __in FN_IBAT_QUERY_PATH_CALLBACK* CompletionCallback,
+ __in VOID* CompletionContext
+ )
+{
+ if (m_AdapterId == 0) {
+ return IbatInterface.CancelQueryByIpAddress(
+ &LocalAddress,
+ &RemoteAddress,
+ CompletionCallback,
+ CompletionContext
+ );
+ }
+
+ UINT64 remoteMac = HwAddressToMac(RemoteHwAddress);
+ if (remoteMac == 0) {
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ NTSTATUS status = STATUS_INVALID_ADDRESS;
+ LockShared();
+ for(ADDRESS_ENTRY* entry = static_cast<ADDRESS_ENTRY*>(m_AddrList.Flink);
+ entry != &m_AddrList;
+ entry = static_cast<ADDRESS_ENTRY*>(entry->Flink))
+ {
+ if (IsEqual(entry->Addr, LocalAddress) == true) {
+ status = IbatInterface.CancelQueryByPhysicalAddress(
+ entry->Mac,
+ remoteMac,
+ CompletionCallback,
+ CompletionContext
+ );
+ break;
+ }
+ }
+ Unlock();
+ return status;
+}
+
+
//static
void
ND_PARTITION::ResolveAdapterId(
diff -dwup3 -X excl.txt -I ^ \*$ -I ^ \* \$ -r \dev\openib\Mellanox\11011\core\ndfltr\kernel\nd_partition.h .\core\ndfltr\kernel\nd_partition.h
--- \dev\openib\Mellanox\11011\core\ndfltr\kernel\nd_partition.h Thu Sep 20 17:51:02 2012
+++ .\core\ndfltr\kernel\nd_partition.h Tue Oct 02 12:19:21 2012
@@ -123,6 +123,15 @@ public:
__out ib_path_rec_t* pPath
);
+ NTSTATUS
+ CancelQuery(
+ __in const SOCKADDR_INET& pLocalAddress,
+ __in const SOCKADDR_INET& pRemoteAddress,
+ __in const IF_PHYSICAL_ADDRESS& RemoteHwAddress,
+ __in FN_IBAT_QUERY_PATH_CALLBACK* CompletionCallback,
+ __in VOID* CompletionContext
+ );
+
public:
static FN_REQUEST_HANDLER ResolveAdapterId;
static FN_REQUEST_HANDLER Free;
diff -dwup3 -X excl.txt -I ^ \*$ -I ^ \* \$ -r \dev\openib\Mellanox\11011\core\ndfltr\kernel\nd_provider.h .\core\ndfltr\kernel\nd_provider.h
--- \dev\openib\Mellanox\11011\core\ndfltr\kernel\nd_provider.h Thu Sep 20 17:51:02 2012
+++ .\core\ndfltr\kernel\nd_provider.h Sat Sep 15 14:47:59 2012
@@ -145,7 +145,7 @@ public:
static __inline UINT64 HandleFromFile(WDFFILEOBJECT File)
{
DEVICE_OBJECT* pDevObj = IoGetRelatedDeviceObject(WdfFileObjectWdmGetFileObject(File));
- if (pDevObj != WdfDeviceWdmGetDeviceObject(ControlDevice)) {
+ if (ControlDevice == NULL || pDevObj != WdfDeviceWdmGetDeviceObject(ControlDevice)) {
return 0;
}
return reinterpret_cast<ULONG_PTR>(WdfFileObjectWdmGetFileObject(File)->FsContext);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ndv2.61.patch
Type: application/octet-stream
Size: 7304 bytes
Desc: ndv2.61.patch
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20130221/4db6be2f/attachment.obj>
More information about the ofw
mailing list