Author: cgutman
Date: Mon Oct 17 01:37:56 2011
New Revision: 54171
URL:
http://svn.reactos.org/svn/reactos?rev=54171&view=rev
Log:
[TCPIP]
- Differentiate between incomplete and complete NCEs with regard to the timeout
- Change the IP timer to fire only once each second
- Remove unneeded completion functions
Modified:
trunk/reactos/drivers/network/tcpip/include/ip.h
trunk/reactos/drivers/network/tcpip/include/neighbor.h
trunk/reactos/drivers/network/tcpip/include/receive.h
trunk/reactos/drivers/network/tcpip/include/transmit.h
trunk/reactos/lib/drivers/ip/network/arp.c
trunk/reactos/lib/drivers/ip/network/icmp.c
trunk/reactos/lib/drivers/ip/network/neighbor.c
trunk/reactos/lib/drivers/ip/network/transmit.c
trunk/reactos/lib/drivers/ip/transport/rawip/rawip.c
trunk/reactos/lib/drivers/ip/transport/tcp/if.c
trunk/reactos/lib/drivers/ip/transport/udp/udp.c
Modified: trunk/reactos/drivers/network/tcpip/include/ip.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/incl…
==============================================================================
--- trunk/reactos/drivers/network/tcpip/include/ip.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/tcpip/include/ip.h [iso-8859-1] Mon Oct 17 01:37:56
2011
@@ -197,8 +197,7 @@
#define IPPROTO_UDP 17 /* User Datagram Protocol */
/* Timeout timer constants */
-#define IP_TICKS_SECOND 2 /* Two ticks per second */
-#define IP_TIMEOUT (1000 / IP_TICKS_SECOND) /* Timeout in milliseconds */
+#define IP_TIMEOUT 1000 /* Timeout in milliseconds */
#define IP_DEFAULT_LINK_SPEED 10000
extern LIST_ENTRY InterfaceListHead;
Modified: trunk/reactos/drivers/network/tcpip/include/neighbor.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/incl…
==============================================================================
--- trunk/reactos/drivers/network/tcpip/include/neighbor.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/tcpip/include/neighbor.h [iso-8859-1] Mon Oct 17
01:37:56 2011
@@ -42,11 +42,14 @@
#define NUD_PERMANENT 0x02
#define NUD_STALE 0x04
+/* Timeout for incomplete NCE ARP requests */
+#define ARP_INCOMPLETE_TIMEOUT 5
+
/* Number of seconds between ARP transmissions */
#define ARP_RATE 900
/* Number of seconds before the NCE times out */
-#define ARP_TIMEOUT ARP_RATE + 15
+#define ARP_COMPLETE_TIMEOUT (ARP_RATE + 15)
/* Number of seconds before retransmission */
#define ARP_TIMEOUT_RETRANSMISSION 5
Modified: trunk/reactos/drivers/network/tcpip/include/receive.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/incl…
==============================================================================
--- trunk/reactos/drivers/network/tcpip/include/receive.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/tcpip/include/receive.h [iso-8859-1] Mon Oct 17 01:37:56
2011
@@ -9,8 +9,8 @@
#include <ip.h>
-/* Number of timeout ticks before destroying the IPDR */
-#define MAX_TIMEOUT_COUNT 10
+/* Number of seconds before destroying the IPDR */
+#define MAX_TIMEOUT_COUNT 5
/* IP datagram fragment descriptor. Used to store IP datagram fragments */
typedef struct IP_FRAGMENT {
Modified: trunk/reactos/drivers/network/tcpip/include/transmit.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/incl…
==============================================================================
--- trunk/reactos/drivers/network/tcpip/include/transmit.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/tcpip/include/transmit.h [iso-8859-1] Mon Oct 17
01:37:56 2011
@@ -30,7 +30,5 @@
} IPFRAGMENT_CONTEXT, *PIPFRAGMENT_CONTEXT;
-NTSTATUS IPSendDatagram(PIP_PACKET IPPacket, PNEIGHBOR_CACHE_ENTRY NCE,
- PIP_TRANSMIT_COMPLETE Complete, PVOID Context);
-
+NTSTATUS IPSendDatagram(PIP_PACKET IPPacket, PNEIGHBOR_CACHE_ENTRY NCE);
/* EOF */
Modified: trunk/reactos/lib/drivers/ip/network/arp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/network/arp…
==============================================================================
--- trunk/reactos/lib/drivers/ip/network/arp.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/network/arp.c [iso-8859-1] Mon Oct 17 01:37:56 2011
@@ -229,7 +229,7 @@
may want to communicate with us soon, so add his address
to our address cache */
NCE = NBAddNeighbor(Interface, &SrcAddress, SenderHWAddress,
- Header->HWAddrLen, 0, ARP_TIMEOUT);
+ Header->HWAddrLen, 0, ARP_COMPLETE_TIMEOUT);
}
if (Header->Opcode != ARP_OPCODE_REQUEST)
Modified: trunk/reactos/lib/drivers/ip/network/icmp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/network/icm…
==============================================================================
--- trunk/reactos/lib/drivers/ip/network/icmp.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/network/icmp.c [iso-8859-1] Mon Oct 17 01:37:56 2011
@@ -221,11 +221,10 @@
TI_DbgPrint(MID_TRACE,("About to send datagram\n"));
- if (!NT_SUCCESS(Status = IPSendDatagram( &Packet, NCE, ICMPSendPacketComplete,
NULL )))
- {
- FreeNdisPacket(Packet.NdisPacket);
+ Status = IPSendDatagram(&Packet, NCE);
+ FreeNdisPacket(Packet.NdisPacket);
+ if (!NT_SUCCESS(Status))
return Status;
- }
*DataUsed = DataSize;
@@ -312,11 +311,8 @@
/* Get a route to the destination address */
if ((NCE = RouteGetRouteToDestination(&IPPacket->DstAddr))) {
/* Send the packet */
- Status = IPSendDatagram(IPPacket, NCE, Complete, Context);
- if (!NT_SUCCESS(Status))
- {
- Complete(Context, IPPacket->NdisPacket, Status);
- }
+ Status = IPSendDatagram(IPPacket, NCE);
+ 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: trunk/reactos/lib/drivers/ip/network/neighbor.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/network/nei…
==============================================================================
--- trunk/reactos/lib/drivers/ip/network/neighbor.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/network/neighbor.c [iso-8859-1] Mon Oct 17 01:37:56 2011
@@ -99,6 +99,7 @@
UINT i;
PNEIGHBOR_CACHE_ENTRY *PrevNCE;
PNEIGHBOR_CACHE_ENTRY NCE;
+ NDIS_STATUS Status;
for (i = 0; i <= NB_HASHMASK; i++) {
TcpipAcquireSpinLockAtDpcLevel(&NeighborCache[i].Lock);
@@ -109,7 +110,13 @@
if (NCE->EventTimer > 0) {
ASSERT(!(NCE->State & NUD_PERMANENT));
NCE->EventCount++;
- if ((NCE->EventCount > ARP_RATE &&
+ if (NCE->State & NUD_INCOMPLETE)
+ {
+ /* We desperately need an address in this state or
+ * we timeout in 5 seconds */
+ NBSendSolicit(NCE);
+ }
+ else if ((NCE->EventCount > ARP_RATE &&
NCE->EventCount % ARP_TIMEOUT_RETRANSMISSION == 0) ||
(NCE->EventCount == ARP_RATE))
{
@@ -120,13 +127,22 @@
NBSendSolicit(NCE);
}
if (NCE->EventTimer - NCE->EventCount == 0) {
- /* Solicit one last time */
- NBSendSolicit(NCE);
-
/* Unlink and destroy the NCE */
*PrevNCE = NCE->Next;
- NBFlushPacketQueue(NCE, NDIS_STATUS_REQUEST_ABORTED);
+ /* Choose the proper failure status */
+ if (NCE->State & NUD_INCOMPLETE)
+ {
+ /* We couldn't get an address to this IP at all */
+ Status = NDIS_STATUS_NETWORK_UNREACHABLE;
+ }
+ else
+ {
+ /* This guy was stale for way too long */
+ Status = NDIS_STATUS_REQUEST_ABORTED;
+ }
+
+ NBFlushPacketQueue(NCE, Status);
ExFreePoolWithTag(NCE, NCE_TAG);
continue;
@@ -314,7 +330,10 @@
TcpipReleaseSpinLock(&NeighborCache[HashValue].Lock, OldIrql);
if( !(NCE->State & NUD_INCOMPLETE) )
- NBSendPackets( NCE );
+ {
+ NCE->EventTimer = ARP_COMPLETE_TIMEOUT;
+ NBSendPackets( NCE );
+ }
}
VOID
@@ -419,7 +438,7 @@
Interface->AddressLength, NUD_PERMANENT, 0);
} else {
NCE = NBAddNeighbor(Interface, Address, NULL,
- Interface->AddressLength, NUD_INCOMPLETE,
ARP_TIMEOUT);
+ Interface->AddressLength, NUD_INCOMPLETE,
ARP_INCOMPLETE_TIMEOUT);
if (!NCE) return NULL;
NBSendSolicit(NCE);
}
Modified: trunk/reactos/lib/drivers/ip/network/transmit.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/network/tra…
==============================================================================
--- trunk/reactos/lib/drivers/ip/network/transmit.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/network/transmit.c [iso-8859-1] Mon Oct 17 01:37:56 2011
@@ -132,9 +132,7 @@
NTSTATUS SendFragments(
PIP_PACKET IPPacket,
PNEIGHBOR_CACHE_ENTRY NCE,
- UINT PathMTU,
- PIP_TRANSMIT_COMPLETE Complete,
- PVOID Context)
+ UINT PathMTU)
/*
* FUNCTION: Fragments and sends the first fragment of an IP datagram
* ARGUMENTS:
@@ -214,13 +212,10 @@
FreeNdisPacket(IFC->NdisPacket);
ExFreePoolWithTag(IFC, IFC_TAG);
- Complete(Context, IPPacket->NdisPacket, NdisStatus);
-
return NdisStatus;
}
-NTSTATUS IPSendDatagram(PIP_PACKET IPPacket, PNEIGHBOR_CACHE_ENTRY NCE,
- PIP_TRANSMIT_COMPLETE Complete, PVOID Context)
+NTSTATUS IPSendDatagram(PIP_PACKET IPPacket, PNEIGHBOR_CACHE_ENTRY NCE)
/*
* FUNCTION: Sends an IP datagram to a remote address
* ARGUMENTS:
@@ -252,8 +247,7 @@
NCE->Interface->Stats.OutBytes += PacketSize;
- return SendFragments(IPPacket, NCE, NCE->Interface->MTU,
- Complete, Context);
+ return SendFragments(IPPacket, NCE, NCE->Interface->MTU);
}
/* EOF */
Modified: trunk/reactos/lib/drivers/ip/transport/rawip/rawip.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/transport/r…
==============================================================================
--- trunk/reactos/lib/drivers/ip/transport/rawip/rawip.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/transport/rawip/rawip.c [iso-8859-1] Mon Oct 17 01:37:56
2011
@@ -167,11 +167,6 @@
return STATUS_SUCCESS;
}
-VOID RawIpSendPacketComplete
-( PVOID Context, PNDIS_PACKET Packet, NDIS_STATUS Status ) {
- FreeNdisPacket( Packet );
-}
-
NTSTATUS RawIPSendDatagram(
PADDRESS_FILE AddrFile,
PTDI_CONNECTION_INFORMATION ConnInfo,
@@ -256,11 +251,10 @@
TI_DbgPrint(MID_TRACE,("About to send datagram\n"));
- if (!NT_SUCCESS(Status = IPSendDatagram( &Packet, NCE, RawIpSendPacketComplete,
NULL )))
- {
- FreeNdisPacket(Packet.NdisPacket);
+ Status = IPSendDatagram(&Packet, NCE);
+ FreeNdisPacket(Packet.NdisPacket);
+ if (!NT_SUCCESS(Status))
return Status;
- }
*DataUsed = DataSize;
Modified: trunk/reactos/lib/drivers/ip/transport/tcp/if.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/transport/t…
==============================================================================
--- trunk/reactos/lib/drivers/ip/transport/tcp/if.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/transport/tcp/if.c [iso-8859-1] Mon Oct 17 01:37:56 2011
@@ -6,11 +6,6 @@
#include "lwip/ip.h"
#include "lwip/api.h"
#include "lwip/tcpip.h"
-
-void TCPPacketSendComplete(PVOID Context, PNDIS_PACKET NdisPacket, NDIS_STATUS
NdisStatus)
-{
- FreeNdisPacket(NdisPacket);
-}
err_t
TCPSendDataCallback(struct netif *netif, struct pbuf *p, struct ip_addr *dest)
@@ -64,10 +59,11 @@
Packet.SrcAddr = LocalAddress;
Packet.DstAddr = RemoteAddress;
- if (!NT_SUCCESS(IPSendDatagram(&Packet, NCE, TCPPacketSendComplete, NULL)))
+ NdisStatus = IPSendDatagram(&Packet, NCE);
+ FreeNdisPacket(Packet.NdisPacket);
+ if (!NT_SUCCESS(NdisStatus))
{
- FreeNdisPacket(Packet.NdisPacket);
- return ERR_IF;
+ return ERR_RTE;
}
return 0;
Modified: trunk/reactos/lib/drivers/ip/transport/udp/udp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/transport/u…
==============================================================================
--- trunk/reactos/lib/drivers/ip/transport/udp/udp.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/transport/udp/udp.c [iso-8859-1] Mon Oct 17 01:37:56
2011
@@ -143,11 +143,6 @@
return STATUS_SUCCESS;
}
-VOID UDPSendPacketComplete
-( PVOID Context, PNDIS_PACKET Packet, NDIS_STATUS Status ) {
- FreeNdisPacket( Packet );
-}
-
NTSTATUS UDPSendDatagram(
PADDRESS_FILE AddrFile,
PTDI_CONNECTION_INFORMATION ConnInfo,
@@ -229,11 +224,10 @@
if( !NT_SUCCESS(Status) )
return Status;
- if (!NT_SUCCESS(Status = IPSendDatagram( &Packet, NCE, UDPSendPacketComplete,
NULL )))
- {
- FreeNdisPacket(Packet.NdisPacket);
+ Status = IPSendDatagram(&Packet, NCE);
+ FreeNdisPacket(Packet.NdisPacket);
+ if (!NT_SUCCESS(Status))
return Status;
- }
*DataUsed = DataSize;