[ros-diffs] [cgutman] 41638: - Always call the completion handler so we don't leak packet descriptors - Don't remove the NCE if we fail because it may not be ours - Mark the IRPs pending before we insert them into our queue - Check that the addresses match so we don't receive somebody else's packets - Part 1 of 2

cgutman at svn.reactos.org cgutman at svn.reactos.org
Sun Jun 28 10:32:11 CEST 2009


Author: cgutman
Date: Sat Jun 27 12:48:58 2009
New Revision: 41638

URL: http://svn.reactos.org/svn/reactos?rev=41638&view=rev
Log:
 - Always call the completion handler so we don't leak packet descriptors
 - Don't remove the NCE if we fail because it may not be ours
 - Mark the IRPs pending before we insert them into our queue
 - Check that the addresses match so we don't receive somebody else's packets
 - Part 1 of 2

Modified:
    trunk/reactos/lib/drivers/ip/network/neighbor.c
    trunk/reactos/lib/drivers/ip/network/router.c
    trunk/reactos/lib/drivers/ip/transport/datagram/datagram.c
    trunk/reactos/lib/drivers/ip/transport/tcp/accept.c
    trunk/reactos/lib/drivers/ip/transport/tcp/tcp.c

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=41638&r1=41637&r2=41638&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 Jun 27 12:48:58 2009
@@ -64,7 +64,6 @@
 
 /* Must be called with table lock acquired */
 VOID NBFlushPacketQueue( PNEIGHBOR_CACHE_ENTRY NCE,
-			 BOOLEAN CallComplete,
 			 NTSTATUS ErrorCode ) {
     PLIST_ENTRY PacketEntry;
     PNEIGHBOR_PACKET Packet;
@@ -81,13 +80,10 @@
 	     ("PacketEntry: %x, NdisPacket %x\n",
 	      PacketEntry, Packet->Packet));
 
-	if( CallComplete )
-        {
-            ASSERT_KM_POINTER(Packet->Complete);
-	    Packet->Complete( Packet->Context,
-			      Packet->Packet,
-			      ErrorCode );
-        }
+        ASSERT_KM_POINTER(Packet->Complete);
+	Packet->Complete( Packet->Context,
+                          Packet->Packet,
+                          ErrorCode );
 
 	exFreePool( Packet );
     }
@@ -117,7 +113,7 @@
 	       so maybe it's not that big a problem */
 
             /* Flush packet queue */
-	    NBFlushPacketQueue( NCE, TRUE, NDIS_STATUS_REQUEST_ABORTED );
+	    NBFlushPacketQueue( NCE, NDIS_STATUS_REQUEST_ABORTED );
             NCE->EventCount = 0;
 	}
         else
@@ -213,7 +209,7 @@
           NextNCE = CurNCE->Next;
 
           /* Flush wait queue */
-	  NBFlushPacketQueue( CurNCE, FALSE, STATUS_SUCCESS );
+	  NBFlushPacketQueue( CurNCE, NDIS_STATUS_NOT_ACCEPTED );
 
 	  CurNCE = NextNCE;
       }
@@ -528,7 +524,7 @@
           /* Found it, now unlink it from the list */
           *PrevNCE = CurNCE->Next;
 
-	  NBFlushPacketQueue( CurNCE, TRUE, NDIS_STATUS_REQUEST_ABORTED );
+	  NBFlushPacketQueue( CurNCE, NDIS_STATUS_REQUEST_ABORTED );
           exFreePool(CurNCE);
 
 	  break;

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=41638&r1=41637&r2=41638&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 Jun 27 12:48:58 2009
@@ -415,7 +415,6 @@
  */
 {
     KIRQL OldIrql;
-    PFIB_ENTRY FIBE;
     PLIST_ENTRY CurrentEntry;
     PLIST_ENTRY NextEntry;
     PFIB_ENTRY Current;
@@ -450,13 +449,7 @@
         return NULL;
     }
 
-    FIBE = RouterAddRoute(NetworkAddress, Netmask, NCE, Metric);
-    if (!FIBE) {
-        /* Not enough free resources */
-        NBRemoveNeighbor(NCE);
-    }
-
-    return FIBE;
+    return RouterAddRoute(NetworkAddress, Netmask, NCE, Metric);
 }
 
 

Modified: trunk/reactos/lib/drivers/ip/transport/datagram/datagram.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/transport/datagram/datagram.c?rev=41638&r1=41637&r2=41638&view=diff
==============================================================================
--- trunk/reactos/lib/drivers/ip/transport/datagram/datagram.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/transport/datagram/datagram.c [iso-8859-1] Sat Jun 27 12:48:58 2009
@@ -106,7 +106,10 @@
       while((CurrentEntry != &AddrFile->ReceiveQueue) && (!Found)) {
           Current = CONTAINING_RECORD(CurrentEntry, DATAGRAM_RECEIVE_REQUEST, ListEntry);
 
-	  if( DstPort == AddrFile->Port ) {
+	  if( DstPort == AddrFile->Port &&
+              (AddrIsEqual(DstAddress, &AddrFile->Address) ||
+               AddrIsUnspecified(&AddrFile->Address) ||
+               AddrIsUnspecified(DstAddress))) {
 	      Found = TRUE;
 	      /* Remove the request from the queue */
 	      RemoveEntryList(&Current->ListEntry);

Modified: trunk/reactos/lib/drivers/ip/transport/tcp/accept.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/transport/tcp/accept.c?rev=41638&r1=41637&r2=41638&view=diff
==============================================================================
--- trunk/reactos/lib/drivers/ip/transport/tcp/accept.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/transport/tcp/accept.c [iso-8859-1] Sat Jun 27 12:48:58 2009
@@ -148,6 +148,7 @@
             Bucket->AssociatedEndpoint = Connection;
             Bucket->Request.RequestNotifyObject = Complete;
             Bucket->Request.RequestContext = Context;
+            IoMarkIrpPending((PIRP)Context);
             InsertHeadList( &Listener->ListenRequest, &Bucket->Entry );
         } else
             Status = STATUS_NO_MEMORY;

Modified: trunk/reactos/lib/drivers/ip/transport/tcp/tcp.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/transport/tcp/tcp.c?rev=41638&r1=41637&r2=41638&view=diff
==============================================================================
--- trunk/reactos/lib/drivers/ip/transport/tcp/tcp.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/transport/tcp/tcp.c [iso-8859-1] Sat Jun 27 12:48:58 2009
@@ -643,6 +643,8 @@
             Bucket->Request.RequestNotifyObject = (PVOID)Complete;
             Bucket->Request.RequestContext = Context;
             
+            IoMarkIrpPending((PIRP)Context);
+			
             InsertHeadList( &Connection->ConnectRequest, &Bucket->Entry );
         }
     }
@@ -767,8 +769,9 @@
         Bucket->Request.RequestContext = Context;
         *BytesReceived = 0;
 
+        IoMarkIrpPending((PIRP)Context);
+
         InsertTailList( &Connection->ReceiveRequest, &Bucket->Entry );
-        Status = STATUS_PENDING;
         TI_DbgPrint(DEBUG_TCP,("Queued read irp\n"));
     } else {
         TI_DbgPrint(DEBUG_TCP,("Got status %x, bytes %d\n", Status, Received));
@@ -833,6 +836,8 @@
         Bucket->Request.RequestNotifyObject = Complete;
         Bucket->Request.RequestContext = Context;
         *BytesSent = 0;
+
+        IoMarkIrpPending((PIRP)Context);
         
         InsertTailList( &Connection->SendRequest, &Bucket->Entry );
         TI_DbgPrint(DEBUG_TCP,("Queued write irp\n"));



More information about the Ros-diffs mailing list