- Merge aicom-network-fixes up to r37266

svn path=/trunk/; revision=37267
This commit is contained in:
Cameron Gutman
2008-11-09 18:17:00 +00:00
parent e570a2c8de
commit c5a57ba3d6
12 changed files with 76 additions and 43 deletions
+10 -5
View File
@@ -83,11 +83,6 @@ AfdGetSockOrPeerName( PDEVICE_OBJECT DeviceObject, PIRP Irp,
if( !SocketAcquireStateLock( FCB ) ) return LostSocket( Irp );
if( FCB->AddressFile.Object == NULL) {
return UnlockAndMaybeComplete( FCB, STATUS_INVALID_PARAMETER, Irp, 0,
NULL );
}
Mdl = IoAllocateMdl
( Irp->UserBuffer,
IrpSp->Parameters.DeviceIoControl.OutputBufferLength,
@@ -105,11 +100,21 @@ AfdGetSockOrPeerName( PDEVICE_OBJECT DeviceObject, PIRP Irp,
if( NT_SUCCESS(Status) ) {
if( Local ) {
if( FCB->AddressFile.Object == NULL ) {
return UnlockAndMaybeComplete( FCB, STATUS_INVALID_PARAMETER, Irp, 0,
NULL );
}
Status = TdiQueryInformation
( FCB->AddressFile.Object,
TDI_QUERY_ADDRESS_INFO,
Mdl );
} else {
if( FCB->Connection.Object == NULL ) {
return UnlockAndMaybeComplete( FCB, STATUS_INVALID_PARAMETER, Irp, 0,
NULL );
}
if( NT_SUCCESS
( Status = TdiBuildNullConnectionInfo
( &ConnInfo,
+1 -1
View File
@@ -25,7 +25,7 @@ PVOID LockRequest( PIRP Irp, PIO_STACK_LOCATION IrpSp ) {
NULL );
if( Irp->MdlAddress ) {
_SEH_TRY {
MmProbeAndLockPages( Irp->MdlAddress, KernelMode, IoModifyAccess );
MmProbeAndLockPages( Irp->MdlAddress, Irp->RequestorMode, IoModifyAccess );
} _SEH_HANDLE {
LockFailed = TRUE;
} _SEH_END;
+1 -1
View File
@@ -425,7 +425,7 @@ SatisfyPacketRecvRequest( PAFD_FCB FCB, PIRP Irp,
*TotalBytesCopied = BytesToCopy;
if (!RecvReq->TdiFlags & TDI_RECEIVE_PEEK) {
if (!(RecvReq->TdiFlags & TDI_RECEIVE_PEEK)) {
FCB->Recv.BytesUsed = 0;
}
}
+9 -9
View File
@@ -74,7 +74,7 @@ static NTSTATUS TdiCall(
KeWaitForSingleObject(
Event,
Executive,
UserMode,
KernelMode,
FALSE,
NULL);
Status = Iosb->Status;
@@ -853,7 +853,7 @@ NTSTATUS TdiSend
BufferLength, /* Length of buffer */
FALSE, /* Not secondary */
FALSE, /* Don't charge quota */
*Irp); /* use IRP */
*Irp); /* Use IRP */
if (!Mdl) {
AFD_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
IoFreeIrp(*Irp);
@@ -862,7 +862,7 @@ NTSTATUS TdiSend
}
_SEH_TRY {
MmProbeAndLockPages(Mdl, KernelMode, IoModifyAccess);
MmProbeAndLockPages(Mdl, (*Irp)->RequestorMode, IoModifyAccess);
} _SEH_HANDLE {
AFD_DbgPrint(MIN_TRACE, ("MmProbeAndLockPages() failed.\n"));
IoFreeMdl(Mdl);
@@ -934,7 +934,7 @@ NTSTATUS TdiReceive(
BufferLength, /* Length of buffer */
FALSE, /* Not secondary */
FALSE, /* Don't charge quota */
*Irp); /* Don't use IRP */
*Irp); /* Use IRP */
if (!Mdl) {
AFD_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
IoFreeIrp(*Irp);
@@ -944,7 +944,7 @@ NTSTATUS TdiReceive(
_SEH_TRY {
AFD_DbgPrint(MIN_TRACE, ("probe and lock\n"));
MmProbeAndLockPages(Mdl, KernelMode, IoModifyAccess);
MmProbeAndLockPages(Mdl, (*Irp)->RequestorMode, IoModifyAccess);
AFD_DbgPrint(MIN_TRACE, ("probe and lock done\n"));
} _SEH_HANDLE {
AFD_DbgPrint(MIN_TRACE, ("MmProbeAndLockPages() failed.\n"));
@@ -1034,7 +1034,7 @@ NTSTATUS TdiReceiveDatagram(
BufferLength, /* Length of buffer */
FALSE, /* Not secondary */
FALSE, /* Don't charge quota */
*Irp); /* Don't use IRP */
*Irp); /* Use IRP */
if (!Mdl) {
AFD_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
IoFreeIrp(*Irp);
@@ -1043,7 +1043,7 @@ NTSTATUS TdiReceiveDatagram(
}
_SEH_TRY {
MmProbeAndLockPages(Mdl, KernelMode, IoModifyAccess);
MmProbeAndLockPages(Mdl, (*Irp)->RequestorMode, IoModifyAccess);
} _SEH_HANDLE {
AFD_DbgPrint(MIN_TRACE, ("MmProbeAndLockPages() failed.\n"));
IoFreeMdl(Mdl);
@@ -1132,7 +1132,7 @@ NTSTATUS TdiSendDatagram(
BufferLength, /* Length of buffer */
FALSE, /* Not secondary */
FALSE, /* Don't charge quota */
*Irp); /* Don't use IRP */
*Irp); /* Use IRP */
if (!Mdl) {
AFD_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
@@ -1142,7 +1142,7 @@ NTSTATUS TdiSendDatagram(
}
_SEH_TRY {
MmProbeAndLockPages(Mdl, KernelMode, IoModifyAccess);
MmProbeAndLockPages(Mdl, (*Irp)->RequestorMode, IoModifyAccess);
} _SEH_HANDLE {
AFD_DbgPrint(MIN_TRACE, ("MmProbeAndLockPages() failed.\n"));
IoFreeMdl(Mdl);
@@ -220,7 +220,7 @@ VOID DeleteConnectionEndpoint(
RemoveEntryList(&Connection->ListEntry);
TcpipReleaseSpinLock(&ConnectionEndpointListLock, OldIrql);
ExFreePool(Connection);
TCPFreeConnectionEndpoint(Connection);
TI_DbgPrint(MAX_TRACE, ("Leaving.\n"));
}
@@ -387,8 +387,10 @@ NTSTATUS FileCloseAddress(
switch (AddrFile->Protocol) {
case IPPROTO_TCP:
TCPFreePort( AddrFile->Port );
if( AddrFile->Listener )
TCPClose( AddrFile->Listener );
if( AddrFile->Listener ) {
TCPClose( AddrFile->Listener );
ExFreePool( AddrFile->Listener );
}
break;
case IPPROTO_UDP:
@@ -488,20 +490,18 @@ NTSTATUS FileCloseConnection(
PTDI_REQUEST Request)
{
PCONNECTION_ENDPOINT Connection;
NTSTATUS Status = STATUS_SUCCESS;
TI_DbgPrint(MID_TRACE, ("Called.\n"));
Connection = Request->Handle.ConnectionContext;
TcpipRecursiveMutexEnter( &TCPLock, TRUE );
TCPClose(Connection);
DeleteConnectionEndpoint(Connection);
TcpipRecursiveMutexLeave( &TCPLock );
TI_DbgPrint(MAX_TRACE, ("Leaving.\n"));
return Status;
return STATUS_SUCCESS;
}
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
<module name="ip" type="staticlibrary" allowwarnings="true">
<module name="ip" type="staticlibrary">
<define name="__NTDRIVER__"/>
<include base="tcpip">include</include>
<include base="oskittcp">include</include>
+6 -1
View File
@@ -181,6 +181,7 @@ VOID ICMPTransmit(
*/
{
PNEIGHBOR_CACHE_ENTRY NCE;
NTSTATUS Status;
TI_DbgPrint(DEBUG_ICMP, ("Called.\n"));
@@ -191,7 +192,11 @@ VOID ICMPTransmit(
/* Get a route to the destination address */
if ((NCE = RouteGetRouteToDestination(&IPPacket->DstAddr))) {
/* Send the packet */
IPSendDatagram(IPPacket, NCE, Complete, Context);
Status = IPSendDatagram(IPPacket, NCE, Complete, Context);
if (!NT_SUCCESS(Status))
{
Complete(Context, IPPacket->NdisPacket, Status);
}
} else {
/* No route to destination (or no free resources) */
TI_DbgPrint(DEBUG_ICMP, ("No route to destination address 0x%X.\n",
+11 -6
View File
@@ -150,12 +150,17 @@ VOID IPDispatchProtocol(
Protocol = 0;
}
/* Call the appropriate protocol handler */
(*ProtocolTable[Protocol])(Interface, IPPacket);
/* Special case for ICMP -- ICMP can be caught by a SOCK_RAW but also
* must be handled here. */
if( Protocol == IPPROTO_ICMP )
ICMPReceive( Interface, IPPacket );
if (Protocol < IP_PROTOCOL_TABLE_SIZE &&
Protocol >= 0)
{
/* Call the appropriate protocol handler */
(*ProtocolTable[Protocol])(Interface, IPPacket);
/* Special case for ICMP -- ICMP can be caught by a SOCK_RAW but also
* must be handled here. */
if( Protocol == IPPROTO_ICMP )
ICMPReceive( Interface, IPPacket );
}
}
@@ -196,6 +196,7 @@ NDIS_STATUS LoopRegisterAdapter(
AddrInitIPv4(&Loopback->Unicast, LOOPBACK_ADDRESS_IPv4);
AddrInitIPv4(&Loopback->Netmask, LOOPBACK_ADDRMASK_IPv4);
AddrInitIPv4(&Loopback->Broadcast, LOOPBACK_BCASTADDR_IPv4);
IPRegisterInterface(Loopback);
+25 -7
View File
@@ -28,13 +28,20 @@ VOID NBCompleteSend( PVOID Context,
VOID NBSendPackets( PNEIGHBOR_CACHE_ENTRY NCE ) {
PLIST_ENTRY PacketEntry;
PNEIGHBOR_PACKET Packet;
UINT HashValue;
if(!(NCE->State & NUD_CONNECTED))
return;
HashValue = *(PULONG)(&NCE->Address.Address);
HashValue ^= HashValue >> 16;
HashValue ^= HashValue >> 8;
HashValue ^= HashValue >> 4;
HashValue &= NB_HASHMASK;
/* Send any waiting packets */
PacketEntry = ExInterlockedRemoveHeadList(&NCE->PacketQueue,
&NCE->Table->Lock);
&NeighborCache[HashValue].Lock);
if( PacketEntry != NULL ) {
Packet = CONTAINING_RECORD( PacketEntry, NEIGHBOR_PACKET, Next );
@@ -333,15 +340,22 @@ VOID NBUpdateNeighbor(
*/
{
KIRQL OldIrql;
UINT HashValue;
TI_DbgPrint(DEBUG_NCACHE, ("Called. NCE (0x%X) LinkAddress (0x%X) State (0x%X).\n", NCE, LinkAddress, State));
TcpipAcquireSpinLock(&NCE->Table->Lock, &OldIrql);
HashValue = *(PULONG)(&NCE->Address.Address);
HashValue ^= HashValue >> 16;
HashValue ^= HashValue >> 8;
HashValue ^= HashValue >> 4;
HashValue &= NB_HASHMASK;
TcpipAcquireSpinLock(&NeighborCache[HashValue].Lock, &OldIrql);
RtlCopyMemory(NCE->LinkAddress, LinkAddress, NCE->LinkAddressLength);
NCE->State = State;
TcpipReleaseSpinLock(&NCE->Table->Lock, OldIrql);
TcpipReleaseSpinLock(&NeighborCache[HashValue].Lock, OldIrql);
if( NCE->State & NUD_CONNECTED )
NBSendPackets( NCE );
@@ -444,9 +458,9 @@ BOOLEAN NBQueuePacket(
* TRUE if the packet was successfully queued, FALSE if not
*/
{
PKSPIN_LOCK Lock;
KIRQL OldIrql;
PNEIGHBOR_PACKET Packet;
UINT HashValue;
TI_DbgPrint
(DEBUG_NCACHE,
@@ -457,16 +471,20 @@ BOOLEAN NBQueuePacket(
/* FIXME: Should we limit the number of queued packets? */
Lock = &NCE->Table->Lock;
HashValue = *(PULONG)(&NCE->Address.Address);
HashValue ^= HashValue >> 16;
HashValue ^= HashValue >> 8;
HashValue ^= HashValue >> 4;
HashValue &= NB_HASHMASK;
TcpipAcquireSpinLock(Lock, &OldIrql);
TcpipAcquireSpinLock(&NeighborCache[HashValue].Lock, &OldIrql);
Packet->Complete = PacketComplete;
Packet->Context = PacketContext;
Packet->Packet = NdisPacket;
InsertTailList( &NCE->PacketQueue, &Packet->Next );
TcpipReleaseSpinLock(Lock, OldIrql);
TcpipReleaseSpinLock(&NeighborCache[HashValue].Lock, OldIrql);
if( NCE->State & NUD_CONNECTED )
NBSendPackets( NCE );
@@ -112,13 +112,14 @@ VOID TCPAbortListenForSocket( PCONNECTION_ENDPOINT Listener,
ListEntry = Listener->ListenRequest.Flink;
while ( ListEntry != &Listener->ListenRequest ) {
Bucket = CONTAINING_RECORD(ListEntry, TDI_BUCKET, Entry);
ListEntry = ListEntry->Flink;
if( Bucket->AssociatedEndpoint == Connection ) {
RemoveEntryList( ListEntry->Blink );
RemoveEntryList( &Bucket->Entry );
ExFreePool( Bucket );
break;
}
ListEntry = ListEntry->Flink;
}
TcpipRecursiveMutexLeave( &TCPLock );
+2 -4
View File
@@ -36,7 +36,6 @@ static VOID HandleSignalledConnection( PCONNECTION_ENDPOINT Connection,
/* Things that can happen when we try the initial connection */
if( NewState & SEL_CONNECT ) {
while( !IsListEmpty( &Connection->ConnectRequest ) ) {
Connection->State |= NewState;
Entry = RemoveHeadList( &Connection->ConnectRequest );
TI_DbgPrint(DEBUG_TCP, ("Connect Event\n"));
@@ -283,8 +282,7 @@ PCONNECTION_ENDPOINT TCPAllocateConnectionEndpoint( PVOID ClientContext ) {
}
VOID TCPFreeConnectionEndpoint( PCONNECTION_ENDPOINT Connection ) {
TI_DbgPrint(MAX_TRACE,("FIXME: Cancel all pending requests\n"));
/* XXX Cancel all pending requests */
TCPClose( Connection );
ExFreePool( Connection );
}
@@ -839,7 +837,7 @@ VOID TCPRemoveIRP( PCONNECTION_ENDPOINT Endpoint, PIRP Irp ) {
TcpipAcquireSpinLock( &Endpoint->Lock, &OldIrql );
for( i = 0; i < sizeof( ListHead ) / sizeof( ListHead[0] ); i++ ) {
for( i = 0; i < 4; i++ ) {
for( Entry = ListHead[i]->Flink;
Entry != ListHead[i];
Entry = Entry->Flink ) {