[ros-diffs] [cgutman] 43077: - Changed some behavior from the last neighbor cache rewrite - NCEs are no longer destroyed when they become stale so the hardware address can be saved for direct communication - The route selection code has been changed to choose against stale NCEs if possible

cgutman at svn.reactos.org cgutman at svn.reactos.org
Sat Sep 19 03:39:16 CEST 2009


Author: cgutman
Date: Sat Sep 19 03:39:16 2009
New Revision: 43077

URL: http://svn.reactos.org/svn/reactos?rev=43077&view=rev
Log:
 - Changed some behavior from the last neighbor cache rewrite
 - NCEs are no longer destroyed when they become stale so the hardware address can be saved for direct communication
 - The route selection code has been changed to choose against stale NCEs if possible

Modified:
    trunk/reactos/drivers/network/tcpip/include/neighbor.h
    trunk/reactos/lib/drivers/ip/network/arp.c
    trunk/reactos/lib/drivers/ip/network/ip.c
    trunk/reactos/lib/drivers/ip/network/neighbor.c
    trunk/reactos/lib/drivers/ip/network/router.c

Modified: trunk/reactos/drivers/network/tcpip/include/neighbor.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/include/neighbor.h?rev=43077&r1=43076&r2=43077&view=diff
==============================================================================
--- trunk/reactos/drivers/network/tcpip/include/neighbor.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/tcpip/include/neighbor.h [iso-8859-1] Sat Sep 19 03:39:16 2009
@@ -41,11 +41,8 @@
 
 /* NCE states */
 #define NUD_INCOMPLETE 0x01
-#define NUD_REACHABLE  0x02
-#define NUD_PERMANENT  0x04
-
-#define NUD_BROADCAST (NUD_PERMANENT | NUD_REACHABLE)
-#define NUD_LOCAL (NUD_PERMANENT | NUD_REACHABLE)
+#define NUD_PERMANENT  0x02
+#define NUD_STALE      0x04
 
 /* Number of seconds before the NCE times out */
 #define ARP_TIMEOUT 30

Modified: trunk/reactos/lib/drivers/ip/network/arp.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/network/arp.c?rev=43077&r1=43076&r2=43077&view=diff
==============================================================================
--- trunk/reactos/lib/drivers/ip/network/arp.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/network/arp.c [iso-8859-1] Sat Sep 19 03:39:16 2009
@@ -215,13 +215,13 @@
     if (NCE) {
         /* We know the sender. Update the hardware address
            and state in our neighbor address cache */
-        NBUpdateNeighbor(NCE, SenderHWAddress, NUD_REACHABLE);
+        NBUpdateNeighbor(NCE, SenderHWAddress, 0);
     } else {
         /* The packet had our protocol address as target. The sender
            may want to communicate with us soon, so add his address
            to our address cache */
         NCE = NBAddNeighbor(Interface, &Address, SenderHWAddress,
-            Header->HWAddrLen, NUD_REACHABLE, ARP_TIMEOUT);
+            Header->HWAddrLen, 0, ARP_TIMEOUT);
     }
 
     if (Header->Opcode != ARP_OPCODE_REQUEST)

Modified: trunk/reactos/lib/drivers/ip/network/ip.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/network/ip.c?rev=43077&r1=43076&r2=43077&view=diff
==============================================================================
--- trunk/reactos/lib/drivers/ip/network/ip.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/network/ip.c [iso-8859-1] Sat Sep 19 03:39:16 2009
@@ -212,7 +212,7 @@
     /* Add a permanent neighbor for this NTE */
     NCE = NBAddNeighbor(IF, &IF->Unicast,
 			IF->Address, IF->AddressLength,
-			NUD_LOCAL, 0);
+			NUD_PERMANENT, 0);
     if (!NCE) {
 	TI_DbgPrint(MIN_TRACE, ("Could not create NCE.\n"));
         return;

Modified: trunk/reactos/lib/drivers/ip/network/neighbor.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/network/neighbor.c?rev=43077&r1=43076&r2=43077&view=diff
==============================================================================
--- trunk/reactos/lib/drivers/ip/network/neighbor.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/network/neighbor.c [iso-8859-1] Sat Sep 19 03:39:16 2009
@@ -30,7 +30,7 @@
     PNEIGHBOR_PACKET Packet;
     UINT HashValue;
 
-    ASSERT(NCE->State & NUD_REACHABLE);
+    ASSERT(!(NCE->State & NUD_INCOMPLETE));
 
     HashValue  = *(PULONG)(&NCE->Address.Address);
     HashValue ^= HashValue >> 16;
@@ -105,26 +105,22 @@
         TcpipAcquireSpinLock(&NeighborCache[i].Lock, &OldIrql);
 
         for (PrevNCE = &NeighborCache[i].Cache;
-             (NCE = *PrevNCE) != NULL;) {
+             (NCE = *PrevNCE) != NULL;
+             PrevNCE = &NCE->Next) {
             /* Check if event timer is running */
             if (NCE->EventTimer > 0)  {
+                ASSERT(!(NCE->State & NUD_PERMANENT));
                 NCE->EventCount++;
                 if (NCE->EventCount % ARP_RATE == 0)
                     NBSendSolicit(NCE);
                 if (NCE->EventTimer - NCE->EventCount == 0) {
-                    ASSERT(!(NCE->State & NUD_PERMANENT));
-
-                    /* Flush packet queue */
-                    NBFlushPacketQueue( NCE, NDIS_STATUS_REQUEST_ABORTED );
-
-                    *PrevNCE = NCE->Next;
-
-                    exFreePool(NCE);
-
-                    continue;
+                    DbgPrint("Marking NCE stale: %s\n", A2S(&NCE->Address));
+
+                    NCE->State |= NUD_STALE;
+
+                    NCE->EventCount = 0;
                 }
             }
-            PrevNCE = &NCE->Next;
         }
 
         TcpipReleaseSpinLock(&NeighborCache[i].Lock, OldIrql);
@@ -304,7 +300,7 @@
 
     TcpipReleaseSpinLock(&NeighborCache[HashValue].Lock, OldIrql);
 
-    if( NCE->State & NUD_REACHABLE )
+    if( !(NCE->State & NUD_INCOMPLETE) )
 	NBSendPackets( NCE );
 }
 
@@ -376,7 +372,7 @@
             AddrIsUnspecified(Address) ) {
             TI_DbgPrint(MID_TRACE,("Packet targeted at broadcast addr\n"));
             NCE = NBAddNeighbor(Interface, Address, NULL,
-                                Interface->AddressLength, NUD_BROADCAST, 0);
+                                Interface->AddressLength, NUD_PERMANENT, 0);
         } else {
             NCE = NBAddNeighbor(Interface, Address, NULL,
                                 Interface->AddressLength, NUD_INCOMPLETE, ARP_TIMEOUT);
@@ -430,7 +426,7 @@
 
   TcpipReleaseSpinLock(&NeighborCache[HashValue].Lock, OldIrql);
 
-  if( NCE->State & NUD_REACHABLE )
+  if( !(NCE->State & NUD_INCOMPLETE) )
       NBSendPackets( NCE );
 
   return TRUE;
@@ -505,10 +501,10 @@
 		  ArpTable[Size].LogAddr = CurNCE->Address.Address.IPv4Address;
 		  if( CurNCE->State & NUD_PERMANENT )
 		      ArpTable[Size].Type = ARP_ENTRY_STATIC;
-		  else if( CurNCE->State & NUD_REACHABLE )
+		  else if( CurNCE->State & NUD_INCOMPLETE )
+		      ArpTable[Size].Type = ARP_ENTRY_INVALID;
+		  else
 		      ArpTable[Size].Type = ARP_ENTRY_DYNAMIC;
-		  else
-		      ArpTable[Size].Type = ARP_ENTRY_OTHER;
 	      }
 	      Size++;
 	  }

Modified: trunk/reactos/lib/drivers/ip/network/router.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/network/router.c?rev=43077&r1=43076&r2=43077&view=diff
==============================================================================
--- trunk/reactos/lib/drivers/ip/network/router.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/network/router.c [iso-8859-1] Sat Sep 19 03:39:16 2009
@@ -274,7 +274,8 @@
 	TI_DbgPrint(DEBUG_ROUTER,("This-Route: %s (Sharing %d bits)\n",
 				  A2S(&NCE->Address), Length));
 
-	if(Length >= MaskLength && (Length > BestLength || !BestLength)) {
+	if(Length >= MaskLength && (Length > BestLength || !BestLength) &&
+           (!(State & NUD_STALE) || !BestState)) {
 	    /* This seems to be a better router */
 	    BestNCE    = NCE;
 	    BestLength = Length;




More information about the Ros-diffs mailing list