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:
Art Yerkes 2004-11-26 20:32:54 +00:00
parent ca85c39272
commit 80178bd318
3 changed files with 18 additions and 35 deletions

View file

@ -129,7 +129,7 @@ VOID NCETimeout(
/* FIXME: Probe state */ /* FIXME: Probe state */
TI_DbgPrint(DEBUG_NCACHE, ("NCE probe state.\n")); TI_DbgPrint(DEBUG_NCACHE, ("NCE probe state.\n"));
break; break;
default: default:
/* Should not happen since the event timer is not used in the other states */ /* 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)); TI_DbgPrint(MIN_TRACE, ("Invalid NCE state (%d).\n", NCE->State));

View file

@ -607,17 +607,4 @@ VOID RouteInvalidateNCE(
TcpipReleaseSpinLock(&RouteCacheLock, OldIrql); 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 */ /* EOF */

View file

@ -227,7 +227,7 @@ PNEIGHBOR_CACHE_ENTRY RouterGetRoute(PIP_ADDRESS Destination)
PLIST_ENTRY NextEntry; PLIST_ENTRY NextEntry;
PFIB_ENTRY Current; PFIB_ENTRY Current;
UCHAR State, BestState = 0; UCHAR State, BestState = 0;
UINT Length, BestLength = 0; UINT Length, BestLength = 0, MaskLength;
PNEIGHBOR_CACHE_ENTRY NCE, BestNCE = NULL; PNEIGHBOR_CACHE_ENTRY NCE, BestNCE = NULL;
TI_DbgPrint(DEBUG_ROUTER, ("Called. Destination (0x%X)\n", Destination)); TI_DbgPrint(DEBUG_ROUTER, ("Called. Destination (0x%X)\n", Destination));
@ -244,25 +244,18 @@ PNEIGHBOR_CACHE_ENTRY RouterGetRoute(PIP_ADDRESS Destination)
NCE = Current->Router; NCE = Current->Router;
State = NCE->State; State = NCE->State;
if (Destination) Length = CommonPrefixLength(Destination, &Current->NetworkAddress);
Length = CommonPrefixLength(Destination, &NCE->Address); MaskLength = AddrCountPrefixBits(&Current->Netmask);
else
Length = 0; TI_DbgPrint(DEBUG_ROUTER,("This-Route: %s (Sharing %d bits)\n",
A2S(&NCE->Address), Length));
if (BestNCE) { if(Length >= MaskLength && Length > BestLength) {
if ((State > BestState) || /* This seems to be a better router */
((State == BestState) &&
(Length > BestLength))) {
/* This seems to be a better router */
BestNCE = NCE;
BestLength = Length;
BestState = State;
}
} else {
/* First suitable router found, save it */
BestNCE = NCE; BestNCE = NCE;
BestLength = Length; BestLength = Length;
BestState = State; BestState = State;
TI_DbgPrint(DEBUG_ROUTER,("Route selected\n"));
} }
CurrentEntry = NextEntry; CurrentEntry = NextEntry;
@ -270,6 +263,12 @@ PNEIGHBOR_CACHE_ENTRY RouterGetRoute(PIP_ADDRESS Destination)
TcpipReleaseSpinLock(&FIBLock, OldIrql); 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; return BestNCE;
} }
@ -349,11 +348,8 @@ PFIB_ENTRY RouterCreateRoute(
PFIB_ENTRY FIBE; PFIB_ENTRY FIBE;
/* The NCE references RouterAddress. The NCE is referenced for us */ /* The NCE references RouterAddress. The NCE is referenced for us */
NCE = NBAddNeighbor(Interface, NCE = NBFindOrCreateNeighbor(Interface, RouterAddress);
RouterAddress,
NULL,
Interface->AddressLength,
NUD_PROBE);
if (!NCE) { if (!NCE) {
/* Not enough free resources */ /* Not enough free resources */
return NULL; return NULL;