Author: cgutman
Date: Sun Aug 4 12:35:05 2013
New Revision: 59632
URL:
http://svn.reactos.org/svn/reactos?rev=59632&view=rev
Log:
[TCPIP]
- Properly support having the same neighbor addresses on different interfaces
Modified:
trunk/reactos/drivers/network/tcpip/include/interface.h
trunk/reactos/drivers/network/tcpip/include/neighbor.h
trunk/reactos/drivers/network/tcpip/tcpip/iinfo.c
trunk/reactos/lib/drivers/ip/network/arp.c
trunk/reactos/lib/drivers/ip/network/icmp.c
trunk/reactos/lib/drivers/ip/network/ip.c
trunk/reactos/lib/drivers/ip/network/neighbor.c
trunk/reactos/lib/drivers/ip/transport/rawip/rawip.c
trunk/reactos/lib/drivers/ip/transport/udp/udp.c
Modified: trunk/reactos/drivers/network/tcpip/include/interface.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/incl…
==============================================================================
--- trunk/reactos/drivers/network/tcpip/include/interface.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/tcpip/include/interface.h [iso-8859-1] Sun Aug 4
12:35:05 2013
@@ -15,3 +15,4 @@
NTSTATUS GetInterfaceConnectionStatus( PIP_INTERFACE Interface,
PULONG OperStatus );
PIP_INTERFACE FindOnLinkInterface(PIP_ADDRESS Address);
+PIP_INTERFACE GetDefaultInterface(VOID);
Modified: trunk/reactos/drivers/network/tcpip/include/neighbor.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/incl…
==============================================================================
--- trunk/reactos/drivers/network/tcpip/include/neighbor.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/tcpip/include/neighbor.h [iso-8859-1] Sun Aug 4
12:35:05 2013
@@ -83,7 +83,8 @@
UCHAR State);
PNEIGHBOR_CACHE_ENTRY NBLocateNeighbor(
- PIP_ADDRESS Address);
+ PIP_ADDRESS Address,
+ PIP_INTERFACE Interface);
PNEIGHBOR_CACHE_ENTRY NBFindOrCreateNeighbor(
PIP_INTERFACE Interface,
Modified: trunk/reactos/drivers/network/tcpip/tcpip/iinfo.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/tcpi…
==============================================================================
--- trunk/reactos/drivers/network/tcpip/tcpip/iinfo.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/tcpip/tcpip/iinfo.c [iso-8859-1] Sun Aug 4 12:35:05
2013
@@ -145,7 +145,7 @@
AddrInitIPv4(&Address, ArpEntry->LogAddr);
- if ((NCE = NBLocateNeighbor(&Address)))
+ if ((NCE = NBLocateNeighbor(&Address, IF)))
NBRemoveNeighbor(NCE);
if (NBAddNeighbor(IF,
Modified: trunk/reactos/lib/drivers/ip/network/arp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/network/arp…
==============================================================================
--- trunk/reactos/lib/drivers/ip/network/arp.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/network/arp.c [iso-8859-1] Sun Aug 4 12:35:05 2013
@@ -271,7 +271,7 @@
AddrInitIPv4(&SrcAddress, *((PULONG)SenderProtoAddress));
/* Check if we know the sender */
- NCE = NBLocateNeighbor(&SrcAddress);
+ NCE = NBLocateNeighbor(&SrcAddress, Interface);
if (NCE) {
/* We know the sender. Update the hardware address
and state in our neighbor address cache */
Modified: trunk/reactos/lib/drivers/ip/network/icmp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/network/icm…
==============================================================================
--- trunk/reactos/lib/drivers/ip/network/icmp.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/network/icmp.c [iso-8859-1] Sun Aug 4 12:35:05 2013
@@ -173,7 +173,7 @@
}
else
{
- if(!(NCE = NBLocateNeighbor( &LocalAddress )))
+ if(!(NCE = NBLocateNeighbor( &LocalAddress, NULL )))
{
UnlockObject(AddrFile, OldIrql);
return STATUS_INVALID_PARAMETER;
Modified: trunk/reactos/lib/drivers/ip/network/ip.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/network/ip.…
==============================================================================
--- trunk/reactos/lib/drivers/ip/network/ip.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/network/ip.c [iso-8859-1] Sun Aug 4 12:35:05 2013
@@ -327,7 +327,7 @@
PNEIGHBOR_CACHE_ENTRY NCE;
IP_ADDRESS GeneralRoute;
- NCE = NBLocateNeighbor(&IF->Unicast);
+ NCE = NBLocateNeighbor(&IF->Unicast, IF);
if (NCE)
{
TI_DbgPrint(DEBUG_IP,("Removing interface Addr %s\n",
A2S(&IF->Unicast)));
Modified: trunk/reactos/lib/drivers/ip/network/neighbor.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/network/nei…
==============================================================================
--- trunk/reactos/lib/drivers/ip/network/neighbor.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/network/neighbor.c [iso-8859-1] Sun Aug 4 12:35:05 2013
@@ -415,11 +415,13 @@
}
PNEIGHBOR_CACHE_ENTRY NBLocateNeighbor(
- PIP_ADDRESS Address)
+ PIP_ADDRESS Address,
+ PIP_INTERFACE Interface)
/*
* FUNCTION: Locates a neighbor in the neighbor cache
* ARGUMENTS:
* Address = Pointer to IP address
+ * Interface = Pointer to IP interface
* RETURNS:
* Pointer to NCE, NULL if not found
* NOTES:
@@ -430,6 +432,7 @@
PNEIGHBOR_CACHE_ENTRY NCE;
UINT HashValue;
KIRQL OldIrql;
+ PIP_INTERFACE FirstInterface;
TI_DbgPrint(DEBUG_NCACHE, ("Called. Address (0x%X).\n", Address));
@@ -443,10 +446,36 @@
NCE = NeighborCache[HashValue].Cache;
- while ((NCE) && (!AddrIsEqual(Address, &NCE->Address)))
- {
- NCE = NCE->Next;
- }
+ /* If there's no adapter specified, we'll look for a match on
+ * each one. */
+ if (Interface == NULL)
+ {
+ FirstInterface = GetDefaultInterface();
+ Interface = FirstInterface;
+ }
+ else
+ {
+ FirstInterface = NULL;
+ }
+
+ do
+ {
+ while (NCE != NULL)
+ {
+ if (NCE->Interface == Interface &&
+ AddrIsEqual(Address, &NCE->Address))
+ {
+ break;
+ }
+
+ NCE = NCE->Next;
+ }
+
+ if (NCE != NULL)
+ break;
+ }
+ while ((FirstInterface != NULL) &&
+ ((Interface = GetDefaultInterface()) != FirstInterface));
TcpipReleaseSpinLock(&NeighborCache[HashValue].Lock, OldIrql);
@@ -475,7 +504,7 @@
TI_DbgPrint(DEBUG_NCACHE, ("Called. Interface (0x%X) Address (0x%X).\n",
Interface, Address));
- NCE = NBLocateNeighbor(Address);
+ NCE = NBLocateNeighbor(Address, Interface);
if (NCE == NULL)
{
TI_DbgPrint(MID_TRACE,("BCAST: %s\n",
A2S(&Interface->Broadcast)));
Modified: trunk/reactos/lib/drivers/ip/transport/rawip/rawip.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/transport/r…
==============================================================================
--- trunk/reactos/lib/drivers/ip/transport/rawip/rawip.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/transport/rawip/rawip.c [iso-8859-1] Sun Aug 4 12:35:05
2013
@@ -230,7 +230,7 @@
}
else
{
- if(!(NCE = NBLocateNeighbor( &LocalAddress ))) {
+ if(!(NCE = NBLocateNeighbor( &LocalAddress, NULL ))) {
UnlockObject(AddrFile, OldIrql);
return STATUS_INVALID_PARAMETER;
}
Modified: trunk/reactos/lib/drivers/ip/transport/udp/udp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/transport/u…
==============================================================================
--- trunk/reactos/lib/drivers/ip/transport/udp/udp.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/transport/udp/udp.c [iso-8859-1] Sun Aug 4 12:35:05
2013
@@ -208,7 +208,7 @@
}
else
{
- if(!(NCE = NBLocateNeighbor( &LocalAddress ))) {
+ if(!(NCE = NBLocateNeighbor( &LocalAddress, NULL ))) {
UnlockObject(AddrFile, OldIrql);
return STATUS_INVALID_PARAMETER;
}