mirror of
https://github.com/reactos/reactos.git
synced 2025-01-05 22:12:46 +00:00
Removed RouteFriendlyAddRoute. Not needed.
Router now chooses a route correctly: - Only choose a route if the prefix length is greater than or equal to the netmask. for the target route. (We still choose the most specific route). - Changed NBAddNeighbor to NBFindOrCreateNeighbor in RouteAddRouteToDestination because it triggers an ARP probe. Setting the ARP cache state initially to PROBE skips the first ARP query and runs a bit afoul of the cache entry state machine. svn path=/trunk/; revision=11824
This commit is contained in:
parent
ca85c39272
commit
80178bd318
3 changed files with 18 additions and 35 deletions
|
@ -129,7 +129,7 @@ VOID NCETimeout(
|
|||
/* FIXME: Probe state */
|
||||
TI_DbgPrint(DEBUG_NCACHE, ("NCE probe state.\n"));
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
/* Should not happen since the event timer is not used in the other states */
|
||||
TI_DbgPrint(MIN_TRACE, ("Invalid NCE state (%d).\n", NCE->State));
|
||||
|
|
|
@ -607,17 +607,4 @@ VOID RouteInvalidateNCE(
|
|||
TcpipReleaseSpinLock(&RouteCacheLock, OldIrql);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
RouteFriendlyAddRoute( PIPROUTE_ENTRY ire ) {
|
||||
KIRQL OldIrql;
|
||||
|
||||
|
||||
/* Find IF */
|
||||
TcpipAcquireSpinLock(&InterfaceListLock, &OldIrql);
|
||||
//RouteAddRouteToDestination(&Dest,Nte,If,Nce);
|
||||
TcpipReleaseSpinLock(&InterfaceListLock, OldIrql);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -227,7 +227,7 @@ PNEIGHBOR_CACHE_ENTRY RouterGetRoute(PIP_ADDRESS Destination)
|
|||
PLIST_ENTRY NextEntry;
|
||||
PFIB_ENTRY Current;
|
||||
UCHAR State, BestState = 0;
|
||||
UINT Length, BestLength = 0;
|
||||
UINT Length, BestLength = 0, MaskLength;
|
||||
PNEIGHBOR_CACHE_ENTRY NCE, BestNCE = NULL;
|
||||
|
||||
TI_DbgPrint(DEBUG_ROUTER, ("Called. Destination (0x%X)\n", Destination));
|
||||
|
@ -244,25 +244,18 @@ PNEIGHBOR_CACHE_ENTRY RouterGetRoute(PIP_ADDRESS Destination)
|
|||
NCE = Current->Router;
|
||||
State = NCE->State;
|
||||
|
||||
if (Destination)
|
||||
Length = CommonPrefixLength(Destination, &NCE->Address);
|
||||
else
|
||||
Length = 0;
|
||||
Length = CommonPrefixLength(Destination, &Current->NetworkAddress);
|
||||
MaskLength = AddrCountPrefixBits(&Current->Netmask);
|
||||
|
||||
TI_DbgPrint(DEBUG_ROUTER,("This-Route: %s (Sharing %d bits)\n",
|
||||
A2S(&NCE->Address), Length));
|
||||
|
||||
if (BestNCE) {
|
||||
if ((State > BestState) ||
|
||||
((State == BestState) &&
|
||||
(Length > BestLength))) {
|
||||
/* This seems to be a better router */
|
||||
BestNCE = NCE;
|
||||
BestLength = Length;
|
||||
BestState = State;
|
||||
}
|
||||
} else {
|
||||
/* First suitable router found, save it */
|
||||
if(Length >= MaskLength && Length > BestLength) {
|
||||
/* This seems to be a better router */
|
||||
BestNCE = NCE;
|
||||
BestLength = Length;
|
||||
BestState = State;
|
||||
TI_DbgPrint(DEBUG_ROUTER,("Route selected\n"));
|
||||
}
|
||||
|
||||
CurrentEntry = NextEntry;
|
||||
|
@ -270,6 +263,12 @@ PNEIGHBOR_CACHE_ENTRY RouterGetRoute(PIP_ADDRESS Destination)
|
|||
|
||||
TcpipReleaseSpinLock(&FIBLock, OldIrql);
|
||||
|
||||
if( BestNCE ) {
|
||||
TI_DbgPrint(DEBUG_ROUTER,("Routing to %s\n", A2S(&BestNCE->Address)));
|
||||
} else {
|
||||
TI_DbgPrint(DEBUG_ROUTER,("Packet won't be routed\n"));
|
||||
}
|
||||
|
||||
return BestNCE;
|
||||
}
|
||||
|
||||
|
@ -349,11 +348,8 @@ PFIB_ENTRY RouterCreateRoute(
|
|||
PFIB_ENTRY FIBE;
|
||||
|
||||
/* The NCE references RouterAddress. The NCE is referenced for us */
|
||||
NCE = NBAddNeighbor(Interface,
|
||||
RouterAddress,
|
||||
NULL,
|
||||
Interface->AddressLength,
|
||||
NUD_PROBE);
|
||||
NCE = NBFindOrCreateNeighbor(Interface, RouterAddress);
|
||||
|
||||
if (!NCE) {
|
||||
/* Not enough free resources */
|
||||
return NULL;
|
||||
|
|
Loading…
Reference in a new issue