Author: cgutman Date: Fri Nov 7 14:31:34 2008 New Revision: 37248
URL: http://svn.reactos.org/svn/reactos?rev=37248&view=rev Log: - Check the status of IPSendDatagram - Validate the protocol - Use the hash value of the NCE address to get the lock - Simplify TCPAbortListenForSocket - Hardcode the length of the array
Modified: branches/aicom-network-fixes/lib/drivers/ip/network/icmp.c branches/aicom-network-fixes/lib/drivers/ip/network/ip.c branches/aicom-network-fixes/lib/drivers/ip/network/neighbor.c branches/aicom-network-fixes/lib/drivers/ip/transport/tcp/accept.c branches/aicom-network-fixes/lib/drivers/ip/transport/tcp/tcp.c
Modified: branches/aicom-network-fixes/lib/drivers/ip/network/icmp.c URL: http://svn.reactos.org/svn/reactos/branches/aicom-network-fixes/lib/drivers/... ============================================================================== --- branches/aicom-network-fixes/lib/drivers/ip/network/icmp.c [iso-8859-1] (original) +++ branches/aicom-network-fixes/lib/drivers/ip/network/icmp.c [iso-8859-1] Fri Nov 7 14:31:34 2008 @@ -181,6 +181,7 @@ */ { PNEIGHBOR_CACHE_ENTRY NCE; + NTSTATUS Status;
TI_DbgPrint(DEBUG_ICMP, ("Called.\n"));
@@ -191,7 +192,11 @@ /* 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",
Modified: branches/aicom-network-fixes/lib/drivers/ip/network/ip.c URL: http://svn.reactos.org/svn/reactos/branches/aicom-network-fixes/lib/drivers/... ============================================================================== --- branches/aicom-network-fixes/lib/drivers/ip/network/ip.c [iso-8859-1] (original) +++ branches/aicom-network-fixes/lib/drivers/ip/network/ip.c [iso-8859-1] Fri Nov 7 14:31:34 2008 @@ -150,12 +150,17 @@ 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 ); + } }
Modified: branches/aicom-network-fixes/lib/drivers/ip/network/neighbor.c URL: http://svn.reactos.org/svn/reactos/branches/aicom-network-fixes/lib/drivers/... ============================================================================== --- branches/aicom-network-fixes/lib/drivers/ip/network/neighbor.c [iso-8859-1] (original) +++ branches/aicom-network-fixes/lib/drivers/ip/network/neighbor.c [iso-8859-1] Fri Nov 7 14:31:34 2008 @@ -28,13 +28,20 @@ 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 @@ */ { 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 @@ * 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 @@
/* FIXME: Should we limit the number of queued packets? */
- Lock = &NCE->Table->Lock; - - TcpipAcquireSpinLock(Lock, &OldIrql); + HashValue = *(PULONG)(&NCE->Address.Address); + HashValue ^= HashValue >> 16; + HashValue ^= HashValue >> 8; + HashValue ^= HashValue >> 4; + HashValue &= NB_HASHMASK; + + 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 );
Modified: branches/aicom-network-fixes/lib/drivers/ip/transport/tcp/accept.c URL: http://svn.reactos.org/svn/reactos/branches/aicom-network-fixes/lib/drivers/... ============================================================================== --- branches/aicom-network-fixes/lib/drivers/ip/transport/tcp/accept.c [iso-8859-1] (original) +++ branches/aicom-network-fixes/lib/drivers/ip/transport/tcp/accept.c [iso-8859-1] Fri Nov 7 14:31:34 2008 @@ -112,13 +112,14 @@ 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 );
Modified: branches/aicom-network-fixes/lib/drivers/ip/transport/tcp/tcp.c URL: http://svn.reactos.org/svn/reactos/branches/aicom-network-fixes/lib/drivers/... ============================================================================== --- branches/aicom-network-fixes/lib/drivers/ip/transport/tcp/tcp.c [iso-8859-1] (original) +++ branches/aicom-network-fixes/lib/drivers/ip/transport/tcp/tcp.c [iso-8859-1] Fri Nov 7 14:31:34 2008 @@ -36,7 +36,6 @@ /* 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"));
@@ -838,7 +837,7 @@
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 ) {