Author: cgutman
Date: Tue Jun 30 00:18:32 2009
New Revision: 41698
URL:
http://svn.reactos.org/svn/reactos?rev=41698&view=rev
Log:
- Allocate IP_PACKET on the stack
- Reduces non-paged memory consumption
Modified:
trunk/reactos/lib/drivers/ip/network/ip.c
trunk/reactos/lib/drivers/ip/network/receive.c
Modified: trunk/reactos/lib/drivers/ip/network/ip.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/network/ip.…
==============================================================================
--- trunk/reactos/lib/drivers/ip/network/ip.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/network/ip.c [iso-8859-1] Tue Jun 30 00:18:32 2009
@@ -19,23 +19,9 @@
UINT MinLLFrameSize; /* Largest minimum frame size */
BOOLEAN IPInitialized = FALSE;
BOOLEAN IpWorkItemQueued = FALSE;
-NPAGED_LOOKASIDE_LIST IPPacketList;
/* Work around calling timer at Dpc level */
IP_PROTOCOL_HANDLER ProtocolTable[IP_PROTOCOL_TABLE_SIZE];
-
-
-VOID FreePacket(
- PVOID Object)
-/*
- * FUNCTION: Frees an IP packet object
- * ARGUMENTS:
- * Object = Pointer to an IP packet structure
- */
-{
- exFreeToNPagedLookasideList(&IPPacketList, Object);
-}
-
VOID DontFreePacket(
PVOID Object)
@@ -56,34 +42,6 @@
*/
{
exFreePool(Object);
-}
-
-
-PIP_PACKET IPCreatePacket(ULONG Type)
-/*
- * FUNCTION: Creates an IP packet object
- * ARGUMENTS:
- * Type = Type of IP packet
- * RETURNS:
- * Pointer to the created IP packet. NULL if there was not enough free resources.
- */
-{
- PIP_PACKET IPPacket;
-
- IPPacket = exAllocateFromNPagedLookasideList(&IPPacketList);
- if (!IPPacket)
- return NULL;
-
- /* FIXME: Is this needed? */
- RtlZeroMemory(IPPacket, sizeof(IP_PACKET));
-
- INIT_TAG(IPPacket, TAG('I','P','K','T'));
-
- IPPacket->Free = FreePacket;
- IPPacket->Type = Type;
- IPPacket->HeaderSize = 20;
-
- return IPPacket;
}
PIP_PACKET IPInitializePacket(
@@ -416,15 +374,6 @@
0); /* Depth */
ExInitializeNPagedLookasideList(
- &IPPacketList, /* Lookaside list */
- NULL, /* Allocate routine */
- NULL, /* Free routine */
- 0, /* Flags */
- sizeof(IP_PACKET), /* Size of each entry */
- TAG('I','P','P','K'), /* Tag */
- 0); /* Depth */
-
- ExInitializeNPagedLookasideList(
&IPFragmentList, /* Lookaside list */
NULL, /* Allocate routine */
NULL, /* Free routine */
@@ -491,7 +440,6 @@
/* Destroy lookaside lists */
ExDeleteNPagedLookasideList(&IPHoleList);
ExDeleteNPagedLookasideList(&IPDRList);
- ExDeleteNPagedLookasideList(&IPPacketList);
ExDeleteNPagedLookasideList(&IPFragmentList);
IPInitialized = FALSE;
Modified: trunk/reactos/lib/drivers/ip/network/receive.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/network/rec…
==============================================================================
--- trunk/reactos/lib/drivers/ip/network/receive.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/network/receive.c [iso-8859-1] Tue Jun 30 00:18:32 2009
@@ -174,7 +174,9 @@
}
-PIP_PACKET ReassembleDatagram(
+BOOLEAN
+ReassembleDatagram(
+ PIP_PACKET IPPacket,
PIPDATAGRAM_REASSEMBLY IPDR)
/*
* FUNCTION: Reassembles an IP datagram
@@ -189,7 +191,6 @@
* At this point, header is expected to point to the IP header
*/
{
- PIP_PACKET IPPacket;
PLIST_ENTRY CurrentEntry;
PIP_FRAGMENT Current;
PVOID Data;
@@ -200,11 +201,6 @@
TI_DbgPrint(DEBUG_IP, ("Fragment header:\n"));
//OskitDumpBuffer((PCHAR)IPDR->IPv4Header, IPDR->HeaderSize);
-
- /* FIXME: Assume IPv4 */
- IPPacket = IPCreatePacket(IP_ADDRESS_V4);
- if (!IPPacket)
- return NULL;
IPPacket->TotalSize = IPDR->HeaderSize + IPDR->DataSize;
IPPacket->ContigSize = IPPacket->TotalSize;
@@ -219,7 +215,7 @@
if (!IPPacket->Header) {
TI_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
(*IPPacket->Free)(IPPacket);
- return NULL;
+ return FALSE;
}
/* Copy the header into the buffer */
@@ -243,7 +239,7 @@
CurrentEntry = CurrentEntry->Flink;
}
- return IPPacket;
+ return TRUE;
}
@@ -289,8 +285,9 @@
USHORT FragLast;
BOOLEAN MoreFragments;
PIPv4_HEADER IPv4Header;
- PIP_PACKET Datagram;
+ IP_PACKET Datagram;
PIP_FRAGMENT Fragment;
+ BOOLEAN Success;
/* FIXME: Assume IPv4 */
@@ -448,26 +445,29 @@
TI_DbgPrint(DEBUG_IP, ("Complete datagram received.\n"));
- Datagram = ReassembleDatagram(IPDR);
+ /* FIXME: Assumes IPv4 */
+ IPInitializePacket(&Datagram, IP_ADDRESS_V4);
+
+ Success = ReassembleDatagram(&Datagram, IPDR);
RemoveIPDR(IPDR);
TcpipReleaseSpinLock(&IPDR->Lock, OldIrql);
FreeIPDR(IPDR);
- if (!Datagram)
+ if (!Success)
/* Not enough free resources, discard the packet */
return;
- DISPLAY_IP_PACKET(Datagram);
+ DISPLAY_IP_PACKET(&Datagram);
/* Give the packet to the protocol dispatcher */
- IPDispatchProtocol(IF, Datagram);
+ IPDispatchProtocol(IF, &Datagram);
/* We're done with this datagram */
- exFreePool(Datagram->Header);
+ exFreePool(Datagram.Header);
TI_DbgPrint(MAX_TRACE, ("Freeing datagram at (0x%X).\n", Datagram));
- (*Datagram->Free)(Datagram);
+ (*Datagram.Free)(&Datagram);
} else
TcpipReleaseSpinLock(&IPDR->Lock, OldIrql);
}