[ros-diffs] [cgutman] 54939: [TCPIP] - Configure route NCEs to never timeout to prevent them from falling out from under the routing code - Fix a typo - Fix detection of duplicate routes [NETCFGX] - Don't dele...

cgutman at svn.reactos.org cgutman at svn.reactos.org
Fri Jan 13 18:32:31 UTC 2012


Author: cgutman
Date: Fri Jan 13 18:32:30 2012
New Revision: 54939

URL: http://svn.reactos.org/svn/reactos?rev=54939&view=rev
Log:
[TCPIP]
- Configure route NCEs to never timeout to prevent them from falling out from under the routing code
- Fix a typo
- Fix detection of duplicate routes
[NETCFGX]
- Don't delete all routes for an interface when adding a default gateway

Modified:
    branches/wlan-bringup/dll/win32/netcfgx/tcpipconf_notify.c
    branches/wlan-bringup/drivers/network/tcpip/datalink/lan.c
    branches/wlan-bringup/drivers/network/tcpip/include/neighbor.h
    branches/wlan-bringup/drivers/network/tcpip/tcpip/dispatch.c
    branches/wlan-bringup/lib/drivers/ip/network/neighbor.c
    branches/wlan-bringup/lib/drivers/ip/network/router.c

Modified: branches/wlan-bringup/dll/win32/netcfgx/tcpipconf_notify.c
URL: http://svn.reactos.org/svn/reactos/branches/wlan-bringup/dll/win32/netcfgx/tcpipconf_notify.c?rev=54939&r1=54938&r2=54939&view=diff
==============================================================================
--- branches/wlan-bringup/dll/win32/netcfgx/tcpipconf_notify.c [iso-8859-1] (original)
+++ branches/wlan-bringup/dll/win32/netcfgx/tcpipconf_notify.c [iso-8859-1] Fri Jan 13 18:32:30 2012
@@ -3243,7 +3243,8 @@
                         {
                             for (Index = 0; Index < pIpForwardTable->dwNumEntries; Index++)
                             {
-                                if (pIpForwardTable->table[Index].dwForwardIfIndex == pOldConfig->Index)
+                                if (pIpForwardTable->table[Index].dwForwardIfIndex == pOldConfig->Index &&
+                                    pIpForwardTable->table[Index].dwForwardDest == 0)
                                 {
                                     DeleteIpForwardEntry(&pIpForwardTable->table[Index]);
                                 }

Modified: branches/wlan-bringup/drivers/network/tcpip/datalink/lan.c
URL: http://svn.reactos.org/svn/reactos/branches/wlan-bringup/drivers/network/tcpip/datalink/lan.c?rev=54939&r1=54938&r2=54939&view=diff
==============================================================================
--- branches/wlan-bringup/drivers/network/tcpip/datalink/lan.c [iso-8859-1] (original)
+++ branches/wlan-bringup/drivers/network/tcpip/datalink/lan.c [iso-8859-1] Fri Jan 13 18:32:30 2012
@@ -709,14 +709,14 @@
             Interface->Broadcast.Type = IP_ADDRESS_V4;
             Interface->Broadcast.Address.IPv4Address = Interface->Unicast.Address.IPv4Address |
                                                       ~Interface->Netmask.Address.IPv4Address;
+            
+            /* Add the interface route for a static IP */
+            if (!AddrIsUnspecified(&Interface->Unicast))
+                IPAddInterfaceRoute(Interface);
 
             /* Add the default route */
             if (!AddrIsUnspecified(&Interface->StaticRouter))
                 RouterCreateRoute(&DefaultMask, &DefaultMask, &Interface->StaticRouter, Interface, 1);
-
-            /* Add the interface route for a static IP */
-            if (!AddrIsUnspecified(&Interface->Unicast))
-                IPAddInterfaceRoute(Interface);
         }
     }
     else if (!FinishedReset)

Modified: branches/wlan-bringup/drivers/network/tcpip/include/neighbor.h
URL: http://svn.reactos.org/svn/reactos/branches/wlan-bringup/drivers/network/tcpip/include/neighbor.h?rev=54939&r1=54938&r2=54939&view=diff
==============================================================================
--- branches/wlan-bringup/drivers/network/tcpip/include/neighbor.h [iso-8859-1] (original)
+++ branches/wlan-bringup/drivers/network/tcpip/include/neighbor.h [iso-8859-1] Fri Jan 13 18:32:30 2012
@@ -43,16 +43,16 @@
 #define NUD_STALE      0x04
 
 /* Timeout for incomplete NCE ARP requests */
-#define ARP_INCOMPLETE_TIMEOUT 5
+#define ARP_INCOMPLETE_TIMEOUT 3
 
 /* Number of seconds between ARP transmissions */
 #define ARP_RATE 900
 
 /* Number of seconds before the NCE times out */
-#define ARP_COMPLETE_TIMEOUT (ARP_RATE + 15)
+#define ARP_COMPLETE_TIMEOUT (ARP_RATE + 9)
 
 /* Number of seconds before retransmission */
-#define ARP_TIMEOUT_RETRANSMISSION 5
+#define ARP_TIMEOUT_RETRANSMISSION 3
 
 extern NEIGHBOR_CACHE_TABLE NeighborCache[NB_HASHMASK + 1];
 
@@ -87,7 +87,8 @@
 
 PNEIGHBOR_CACHE_ENTRY NBFindOrCreateNeighbor(
     PIP_INTERFACE Interface,
-    PIP_ADDRESS Address);
+    PIP_ADDRESS Address,
+    BOOLEAN NoTimeout);
 
 BOOLEAN NBQueuePacket(
     PNEIGHBOR_CACHE_ENTRY NCE,

Modified: branches/wlan-bringup/drivers/network/tcpip/tcpip/dispatch.c
URL: http://svn.reactos.org/svn/reactos/branches/wlan-bringup/drivers/network/tcpip/tcpip/dispatch.c?rev=54939&r1=54938&r2=54939&view=diff
==============================================================================
--- branches/wlan-bringup/drivers/network/tcpip/tcpip/dispatch.c [iso-8859-1] (original)
+++ branches/wlan-bringup/drivers/network/tcpip/tcpip/dispatch.c [iso-8859-1] Fri Jan 13 18:32:30 2012
@@ -1596,7 +1596,7 @@
 
             IF->Netmask.Type = IP_ADDRESS_V4;
             IF->Netmask.Address.IPv4Address = 0;
-            IF->StaticNetmask = IF->StaticNetmask;
+            IF->StaticNetmask = IF->Netmask;
 
             IF->Broadcast.Type = IP_ADDRESS_V4;
             IF->Broadcast.Address.IPv4Address = 0;

Modified: branches/wlan-bringup/lib/drivers/ip/network/neighbor.c
URL: http://svn.reactos.org/svn/reactos/branches/wlan-bringup/lib/drivers/ip/network/neighbor.c?rev=54939&r1=54938&r2=54939&view=diff
==============================================================================
--- branches/wlan-bringup/lib/drivers/ip/network/neighbor.c [iso-8859-1] (original)
+++ branches/wlan-bringup/lib/drivers/ip/network/neighbor.c [iso-8859-1] Fri Jan 13 18:32:30 2012
@@ -106,17 +106,27 @@
 
         for (PrevNCE = &NeighborCache[i].Cache;
              (NCE = *PrevNCE) != NULL;) {
+            if (NCE->State & NUD_INCOMPLETE)
+            {
+                /* Solicit for an address */
+                NBSendSolicit(NCE);
+                if (NCE->EventTimer == 0)
+                {
+                    NCE->EventCount++;
+                    if (NCE->EventCount == ARP_INCOMPLETE_TIMEOUT)
+                    {
+                        NBFlushPacketQueue(NCE, NDIS_STATUS_NETWORK_UNREACHABLE);
+                        NCE->EventCount = 0;
+                    }
+                }
+            }
+
             /* Check if event timer is running */
             if (NCE->EventTimer > 0)  {
                 ASSERT(!(NCE->State & NUD_PERMANENT));
                 NCE->EventCount++;
-                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 &&
+
+                if ((NCE->EventCount > ARP_RATE &&
                      NCE->EventCount % ARP_TIMEOUT_RETRANSMISSION == 0) ||
                     (NCE->EventCount == ARP_RATE))
                 {
@@ -129,7 +139,7 @@
                 if (NCE->EventTimer - NCE->EventCount == 0) {
                     /* Unlink and destroy the NCE */
                     *PrevNCE = NCE->Next;
-
+                    
                     /* Choose the proper failure status */
                     if (NCE->State & NUD_INCOMPLETE)
                     {
@@ -141,8 +151,9 @@
                         /* This guy was stale for way too long */
                         Status = NDIS_STATUS_REQUEST_ABORTED;
                     }
-
+                    
                     NBFlushPacketQueue(NCE, Status);
+
                     ExFreePoolWithTag(NCE, NCE_TAG);
 
                     continue;
@@ -367,7 +378,7 @@
 
     if( !(NCE->State & NUD_INCOMPLETE) )
     {
-        NCE->EventTimer = ARP_COMPLETE_TIMEOUT;
+        if (NCE->EventTimer) NCE->EventTimer = ARP_COMPLETE_TIMEOUT;
         NBSendPackets( NCE );
     }
 }
@@ -446,7 +457,8 @@
 
 PNEIGHBOR_CACHE_ENTRY NBFindOrCreateNeighbor(
   PIP_INTERFACE Interface,
-  PIP_ADDRESS Address)
+  PIP_ADDRESS Address,
+  BOOLEAN NoTimeout)
 /*
  * FUNCTION: Tries to find a neighbor and if unsuccesful, creates a new NCE
  * ARGUMENTS:
@@ -474,7 +486,7 @@
                                 Interface->AddressLength, NUD_PERMANENT, 0);
         } else {
             NCE = NBAddNeighbor(Interface, Address, NULL,
-                                Interface->AddressLength, NUD_INCOMPLETE, ARP_INCOMPLETE_TIMEOUT);
+                                Interface->AddressLength, NUD_INCOMPLETE, NoTimeout ? 0 : ARP_INCOMPLETE_TIMEOUT);
             if (!NCE) return NULL;
             NBSendSolicit(NCE);
         }

Modified: branches/wlan-bringup/lib/drivers/ip/network/router.c
URL: http://svn.reactos.org/svn/reactos/branches/wlan-bringup/lib/drivers/ip/network/router.c?rev=54939&r1=54938&r2=54939&view=diff
==============================================================================
--- branches/wlan-bringup/lib/drivers/ip/network/router.c [iso-8859-1] (original)
+++ branches/wlan-bringup/lib/drivers/ip/network/router.c [iso-8859-1] Fri Jan 13 18:32:30 2012
@@ -327,7 +327,7 @@
     Interface = FindOnLinkInterface(Destination);
     if (Interface) {
 	/* The destination address is on-link. Check our neighbor cache */
-	NCE = NBFindOrCreateNeighbor(Interface, Destination);
+	NCE = NBFindOrCreateNeighbor(Interface, Destination, FALSE);
     } else {
 	/* Destination is not on any subnets we're on. Find a router to use */
 	NCE = RouterGetRoute(Destination);
@@ -454,8 +454,10 @@
 
         NCE   = Current->Router;
 
-        if( AddrIsEqual(NetworkAddress, &Current->NetworkAddress) &&
-           AddrIsEqual(Netmask, &Current->Netmask) ) {
+        if(AddrIsEqual(NetworkAddress, &Current->NetworkAddress) &&
+           AddrIsEqual(Netmask, &Current->Netmask) &&
+           NCE->Interface == Interface)
+        {
             TI_DbgPrint(DEBUG_ROUTER,("Attempting to add duplicate route to %s\n", A2S(NetworkAddress)));
             TcpipReleaseSpinLock(&FIBLock, OldIrql);
             return NULL;
@@ -467,7 +469,7 @@
     TcpipReleaseSpinLock(&FIBLock, OldIrql);
 
     /* The NCE references RouterAddress. The NCE is referenced for us */
-    NCE = NBFindOrCreateNeighbor(Interface, RouterAddress);
+    NCE = NBFindOrCreateNeighbor(Interface, RouterAddress, TRUE);
 
     if (!NCE) {
         /* Not enough free resources */




More information about the Ros-diffs mailing list