mirror of
https://github.com/reactos/reactos.git
synced 2025-01-01 03:54:02 +00:00
[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 svn path=/trunk/; revision=54171
This commit is contained in:
parent
97eddfb464
commit
18254a9593
11 changed files with 53 additions and 60 deletions
|
@ -197,8 +197,7 @@ typedef VOID (*IP_PROTOCOL_HANDLER)(
|
||||||
#define IPPROTO_UDP 17 /* User Datagram Protocol */
|
#define IPPROTO_UDP 17 /* User Datagram Protocol */
|
||||||
|
|
||||||
/* Timeout timer constants */
|
/* Timeout timer constants */
|
||||||
#define IP_TICKS_SECOND 2 /* Two ticks per second */
|
#define IP_TIMEOUT 1000 /* Timeout in milliseconds */
|
||||||
#define IP_TIMEOUT (1000 / IP_TICKS_SECOND) /* Timeout in milliseconds */
|
|
||||||
#define IP_DEFAULT_LINK_SPEED 10000
|
#define IP_DEFAULT_LINK_SPEED 10000
|
||||||
|
|
||||||
extern LIST_ENTRY InterfaceListHead;
|
extern LIST_ENTRY InterfaceListHead;
|
||||||
|
|
|
@ -42,11 +42,14 @@ typedef struct NEIGHBOR_CACHE_ENTRY {
|
||||||
#define NUD_PERMANENT 0x02
|
#define NUD_PERMANENT 0x02
|
||||||
#define NUD_STALE 0x04
|
#define NUD_STALE 0x04
|
||||||
|
|
||||||
|
/* Timeout for incomplete NCE ARP requests */
|
||||||
|
#define ARP_INCOMPLETE_TIMEOUT 5
|
||||||
|
|
||||||
/* Number of seconds between ARP transmissions */
|
/* Number of seconds between ARP transmissions */
|
||||||
#define ARP_RATE 900
|
#define ARP_RATE 900
|
||||||
|
|
||||||
/* Number of seconds before the NCE times out */
|
/* 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 */
|
/* Number of seconds before retransmission */
|
||||||
#define ARP_TIMEOUT_RETRANSMISSION 5
|
#define ARP_TIMEOUT_RETRANSMISSION 5
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
|
|
||||||
#include <ip.h>
|
#include <ip.h>
|
||||||
|
|
||||||
/* Number of timeout ticks before destroying the IPDR */
|
/* Number of seconds before destroying the IPDR */
|
||||||
#define MAX_TIMEOUT_COUNT 10
|
#define MAX_TIMEOUT_COUNT 5
|
||||||
|
|
||||||
/* IP datagram fragment descriptor. Used to store IP datagram fragments */
|
/* IP datagram fragment descriptor. Used to store IP datagram fragments */
|
||||||
typedef struct IP_FRAGMENT {
|
typedef struct IP_FRAGMENT {
|
||||||
|
|
|
@ -30,7 +30,5 @@ typedef struct IPFRAGMENT_CONTEXT {
|
||||||
} IPFRAGMENT_CONTEXT, *PIPFRAGMENT_CONTEXT;
|
} IPFRAGMENT_CONTEXT, *PIPFRAGMENT_CONTEXT;
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS IPSendDatagram(PIP_PACKET IPPacket, PNEIGHBOR_CACHE_ENTRY NCE,
|
NTSTATUS IPSendDatagram(PIP_PACKET IPPacket, PNEIGHBOR_CACHE_ENTRY NCE);
|
||||||
PIP_TRANSMIT_COMPLETE Complete, PVOID Context);
|
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -229,7 +229,7 @@ VOID ARPReceive(
|
||||||
may want to communicate with us soon, so add his address
|
may want to communicate with us soon, so add his address
|
||||||
to our address cache */
|
to our address cache */
|
||||||
NCE = NBAddNeighbor(Interface, &SrcAddress, SenderHWAddress,
|
NCE = NBAddNeighbor(Interface, &SrcAddress, SenderHWAddress,
|
||||||
Header->HWAddrLen, 0, ARP_TIMEOUT);
|
Header->HWAddrLen, 0, ARP_COMPLETE_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Header->Opcode != ARP_OPCODE_REQUEST)
|
if (Header->Opcode != ARP_OPCODE_REQUEST)
|
||||||
|
|
|
@ -221,11 +221,10 @@ NTSTATUS ICMPSendDatagram(
|
||||||
|
|
||||||
TI_DbgPrint(MID_TRACE,("About to send datagram\n"));
|
TI_DbgPrint(MID_TRACE,("About to send datagram\n"));
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status = IPSendDatagram( &Packet, NCE, ICMPSendPacketComplete, NULL )))
|
Status = IPSendDatagram(&Packet, NCE);
|
||||||
{
|
FreeNdisPacket(Packet.NdisPacket);
|
||||||
FreeNdisPacket(Packet.NdisPacket);
|
if (!NT_SUCCESS(Status))
|
||||||
return Status;
|
return Status;
|
||||||
}
|
|
||||||
|
|
||||||
*DataUsed = DataSize;
|
*DataUsed = DataSize;
|
||||||
|
|
||||||
|
@ -312,11 +311,8 @@ VOID ICMPTransmit(
|
||||||
/* Get a route to the destination address */
|
/* Get a route to the destination address */
|
||||||
if ((NCE = RouteGetRouteToDestination(&IPPacket->DstAddr))) {
|
if ((NCE = RouteGetRouteToDestination(&IPPacket->DstAddr))) {
|
||||||
/* Send the packet */
|
/* Send the packet */
|
||||||
Status = IPSendDatagram(IPPacket, NCE, Complete, Context);
|
Status = IPSendDatagram(IPPacket, NCE);
|
||||||
if (!NT_SUCCESS(Status))
|
Complete(Context, IPPacket->NdisPacket, Status);
|
||||||
{
|
|
||||||
Complete(Context, IPPacket->NdisPacket, Status);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
/* No route to destination (or no free resources) */
|
/* No route to destination (or no free resources) */
|
||||||
TI_DbgPrint(DEBUG_ICMP, ("No route to destination address 0x%X.\n",
|
TI_DbgPrint(DEBUG_ICMP, ("No route to destination address 0x%X.\n",
|
||||||
|
|
|
@ -99,6 +99,7 @@ VOID NBTimeout(VOID)
|
||||||
UINT i;
|
UINT i;
|
||||||
PNEIGHBOR_CACHE_ENTRY *PrevNCE;
|
PNEIGHBOR_CACHE_ENTRY *PrevNCE;
|
||||||
PNEIGHBOR_CACHE_ENTRY NCE;
|
PNEIGHBOR_CACHE_ENTRY NCE;
|
||||||
|
NDIS_STATUS Status;
|
||||||
|
|
||||||
for (i = 0; i <= NB_HASHMASK; i++) {
|
for (i = 0; i <= NB_HASHMASK; i++) {
|
||||||
TcpipAcquireSpinLockAtDpcLevel(&NeighborCache[i].Lock);
|
TcpipAcquireSpinLockAtDpcLevel(&NeighborCache[i].Lock);
|
||||||
|
@ -109,7 +110,13 @@ VOID NBTimeout(VOID)
|
||||||
if (NCE->EventTimer > 0) {
|
if (NCE->EventTimer > 0) {
|
||||||
ASSERT(!(NCE->State & NUD_PERMANENT));
|
ASSERT(!(NCE->State & NUD_PERMANENT));
|
||||||
NCE->EventCount++;
|
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_TIMEOUT_RETRANSMISSION == 0) ||
|
||||||
(NCE->EventCount == ARP_RATE))
|
(NCE->EventCount == ARP_RATE))
|
||||||
{
|
{
|
||||||
|
@ -120,13 +127,22 @@ VOID NBTimeout(VOID)
|
||||||
NBSendSolicit(NCE);
|
NBSendSolicit(NCE);
|
||||||
}
|
}
|
||||||
if (NCE->EventTimer - NCE->EventCount == 0) {
|
if (NCE->EventTimer - NCE->EventCount == 0) {
|
||||||
/* Solicit one last time */
|
|
||||||
NBSendSolicit(NCE);
|
|
||||||
|
|
||||||
/* Unlink and destroy the NCE */
|
/* Unlink and destroy the NCE */
|
||||||
*PrevNCE = NCE->Next;
|
*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);
|
ExFreePoolWithTag(NCE, NCE_TAG);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
@ -314,7 +330,10 @@ VOID NBUpdateNeighbor(
|
||||||
TcpipReleaseSpinLock(&NeighborCache[HashValue].Lock, OldIrql);
|
TcpipReleaseSpinLock(&NeighborCache[HashValue].Lock, OldIrql);
|
||||||
|
|
||||||
if( !(NCE->State & NUD_INCOMPLETE) )
|
if( !(NCE->State & NUD_INCOMPLETE) )
|
||||||
NBSendPackets( NCE );
|
{
|
||||||
|
NCE->EventTimer = ARP_COMPLETE_TIMEOUT;
|
||||||
|
NBSendPackets( NCE );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
|
@ -419,7 +438,7 @@ PNEIGHBOR_CACHE_ENTRY NBFindOrCreateNeighbor(
|
||||||
Interface->AddressLength, NUD_PERMANENT, 0);
|
Interface->AddressLength, NUD_PERMANENT, 0);
|
||||||
} else {
|
} else {
|
||||||
NCE = NBAddNeighbor(Interface, Address, NULL,
|
NCE = NBAddNeighbor(Interface, Address, NULL,
|
||||||
Interface->AddressLength, NUD_INCOMPLETE, ARP_TIMEOUT);
|
Interface->AddressLength, NUD_INCOMPLETE, ARP_INCOMPLETE_TIMEOUT);
|
||||||
if (!NCE) return NULL;
|
if (!NCE) return NULL;
|
||||||
NBSendSolicit(NCE);
|
NBSendSolicit(NCE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,9 +132,7 @@ BOOLEAN PrepareNextFragment(
|
||||||
NTSTATUS SendFragments(
|
NTSTATUS SendFragments(
|
||||||
PIP_PACKET IPPacket,
|
PIP_PACKET IPPacket,
|
||||||
PNEIGHBOR_CACHE_ENTRY NCE,
|
PNEIGHBOR_CACHE_ENTRY NCE,
|
||||||
UINT PathMTU,
|
UINT PathMTU)
|
||||||
PIP_TRANSMIT_COMPLETE Complete,
|
|
||||||
PVOID Context)
|
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Fragments and sends the first fragment of an IP datagram
|
* FUNCTION: Fragments and sends the first fragment of an IP datagram
|
||||||
* ARGUMENTS:
|
* ARGUMENTS:
|
||||||
|
@ -214,13 +212,10 @@ NTSTATUS SendFragments(
|
||||||
FreeNdisPacket(IFC->NdisPacket);
|
FreeNdisPacket(IFC->NdisPacket);
|
||||||
ExFreePoolWithTag(IFC, IFC_TAG);
|
ExFreePoolWithTag(IFC, IFC_TAG);
|
||||||
|
|
||||||
Complete(Context, IPPacket->NdisPacket, NdisStatus);
|
|
||||||
|
|
||||||
return NdisStatus;
|
return NdisStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS IPSendDatagram(PIP_PACKET IPPacket, PNEIGHBOR_CACHE_ENTRY NCE,
|
NTSTATUS IPSendDatagram(PIP_PACKET IPPacket, PNEIGHBOR_CACHE_ENTRY NCE)
|
||||||
PIP_TRANSMIT_COMPLETE Complete, PVOID Context)
|
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Sends an IP datagram to a remote address
|
* FUNCTION: Sends an IP datagram to a remote address
|
||||||
* ARGUMENTS:
|
* ARGUMENTS:
|
||||||
|
@ -252,8 +247,7 @@ NTSTATUS IPSendDatagram(PIP_PACKET IPPacket, PNEIGHBOR_CACHE_ENTRY NCE,
|
||||||
|
|
||||||
NCE->Interface->Stats.OutBytes += PacketSize;
|
NCE->Interface->Stats.OutBytes += PacketSize;
|
||||||
|
|
||||||
return SendFragments(IPPacket, NCE, NCE->Interface->MTU,
|
return SendFragments(IPPacket, NCE, NCE->Interface->MTU);
|
||||||
Complete, Context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -167,11 +167,6 @@ NTSTATUS BuildRawIpPacket(
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID RawIpSendPacketComplete
|
|
||||||
( PVOID Context, PNDIS_PACKET Packet, NDIS_STATUS Status ) {
|
|
||||||
FreeNdisPacket( Packet );
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS RawIPSendDatagram(
|
NTSTATUS RawIPSendDatagram(
|
||||||
PADDRESS_FILE AddrFile,
|
PADDRESS_FILE AddrFile,
|
||||||
PTDI_CONNECTION_INFORMATION ConnInfo,
|
PTDI_CONNECTION_INFORMATION ConnInfo,
|
||||||
|
@ -256,11 +251,10 @@ NTSTATUS RawIPSendDatagram(
|
||||||
|
|
||||||
TI_DbgPrint(MID_TRACE,("About to send datagram\n"));
|
TI_DbgPrint(MID_TRACE,("About to send datagram\n"));
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status = IPSendDatagram( &Packet, NCE, RawIpSendPacketComplete, NULL )))
|
Status = IPSendDatagram(&Packet, NCE);
|
||||||
{
|
FreeNdisPacket(Packet.NdisPacket);
|
||||||
FreeNdisPacket(Packet.NdisPacket);
|
if (!NT_SUCCESS(Status))
|
||||||
return Status;
|
return Status;
|
||||||
}
|
|
||||||
|
|
||||||
*DataUsed = DataSize;
|
*DataUsed = DataSize;
|
||||||
|
|
||||||
|
|
|
@ -7,11 +7,6 @@
|
||||||
#include "lwip/api.h"
|
#include "lwip/api.h"
|
||||||
#include "lwip/tcpip.h"
|
#include "lwip/tcpip.h"
|
||||||
|
|
||||||
void TCPPacketSendComplete(PVOID Context, PNDIS_PACKET NdisPacket, NDIS_STATUS NdisStatus)
|
|
||||||
{
|
|
||||||
FreeNdisPacket(NdisPacket);
|
|
||||||
}
|
|
||||||
|
|
||||||
err_t
|
err_t
|
||||||
TCPSendDataCallback(struct netif *netif, struct pbuf *p, struct ip_addr *dest)
|
TCPSendDataCallback(struct netif *netif, struct pbuf *p, struct ip_addr *dest)
|
||||||
{
|
{
|
||||||
|
@ -64,10 +59,11 @@ TCPSendDataCallback(struct netif *netif, struct pbuf *p, struct ip_addr *dest)
|
||||||
Packet.SrcAddr = LocalAddress;
|
Packet.SrcAddr = LocalAddress;
|
||||||
Packet.DstAddr = RemoteAddress;
|
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_RTE;
|
||||||
return ERR_IF;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -143,11 +143,6 @@ NTSTATUS BuildUDPPacket(
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID UDPSendPacketComplete
|
|
||||||
( PVOID Context, PNDIS_PACKET Packet, NDIS_STATUS Status ) {
|
|
||||||
FreeNdisPacket( Packet );
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS UDPSendDatagram(
|
NTSTATUS UDPSendDatagram(
|
||||||
PADDRESS_FILE AddrFile,
|
PADDRESS_FILE AddrFile,
|
||||||
PTDI_CONNECTION_INFORMATION ConnInfo,
|
PTDI_CONNECTION_INFORMATION ConnInfo,
|
||||||
|
@ -229,11 +224,10 @@ NTSTATUS UDPSendDatagram(
|
||||||
if( !NT_SUCCESS(Status) )
|
if( !NT_SUCCESS(Status) )
|
||||||
return Status;
|
return Status;
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status = IPSendDatagram( &Packet, NCE, UDPSendPacketComplete, NULL )))
|
Status = IPSendDatagram(&Packet, NCE);
|
||||||
{
|
FreeNdisPacket(Packet.NdisPacket);
|
||||||
FreeNdisPacket(Packet.NdisPacket);
|
if (!NT_SUCCESS(Status))
|
||||||
return Status;
|
return Status;
|
||||||
}
|
|
||||||
|
|
||||||
*DataUsed = DataSize;
|
*DataUsed = DataSize;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue