mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 08:25:03 +00:00
[0.4.11][IP][TCPIP][LWIP] Backports 2023-08-13 (also fixes a BSOD)
0.4.15-dev-6399-gf8a6542b15
[IP] Don't reference uninitialized PCB to avoid BSOD. CORE-18982 0.4.15-dev-6395-g2010a5b8d9
[IP] Unlock Connection when TCPAllocatePort() fails. CORE-18371 0.4.15-dev-5707-g874d317a71
[IP] Allow 0xFFFF as Valid Network Port Number (#5074) CORE-18371 CORE-18764 PARTIALLY pick 0.4.14-dev-1326-g792b64ea46
[TCPIP][FORMATTING] Format TiDispatch function. No functional changes (#2112) 0.4.13-dev-368-g3a98d96eac
[LWIP] Fix src/core/init.c a bit (#1620) and strip some EOL-whitespace. Just to make sure that the binary sizes did not increase: tcpip.sys master GCC8.4.0dbg RosBEWin2.2.2 462.848 tcpip.sys 0.4.14 GCC4.7.2dbg RosBEWin2.1.6 425.984 -> 425.984 tcpip.sys 0.4.13 GCC4.7.2dbg RosBEWin2.1.6 417.792 -> 417.792 tcpip.sys 0.4.12 GCC4.7.2dbg RosBEWin2.1.6 421.888 -> 421.888 tcpip.sys 0.4.11 GCC4.7.2dbg RosBEWin2.1.6 421.888 -> 421.888 tcpip.sys 0.4.10 GCC4.7.2dbg RosBEWin2.1.6 413.696 -> 413.696 tcpip.sys 0.4. 9 GCC4.7.2dbg RosBEWin2.1.6 413.696 -> 413.696 tcpip.sys 0.4. 8 GCC4.7.2dbg RosBEWin2.1.6 413.696 -> 413.696 tcpip.sys 0.4. 7 GCC4.7.2dbg RosBEWin2.1.6 413.696 -> 413.696
This commit is contained in:
parent
7b99293b02
commit
cc2f6571df
10 changed files with 132 additions and 117 deletions
|
@ -392,6 +392,7 @@ NTSTATUS FileOpenAddress(
|
|||
PVOID Options)
|
||||
{
|
||||
PADDRESS_FILE AddrFile;
|
||||
UINT AllocatedPort;
|
||||
|
||||
TI_DbgPrint(MID_TRACE, ("Called (Proto %d).\n", Protocol));
|
||||
|
||||
|
@ -449,14 +450,15 @@ NTSTATUS FileOpenAddress(
|
|||
if (Address->Address[0].Address[0].sin_port)
|
||||
{
|
||||
/* The client specified an explicit port so we force a bind to this */
|
||||
AddrFile->Port = TCPAllocatePort(Address->Address[0].Address[0].sin_port);
|
||||
AllocatedPort = TCPAllocatePort(Address->Address[0].Address[0].sin_port);
|
||||
|
||||
/* Check for bind success */
|
||||
if (AddrFile->Port == 0xffff)
|
||||
if (AllocatedPort == (UINT)-1)
|
||||
{
|
||||
ExFreePoolWithTag(AddrFile, ADDR_FILE_TAG);
|
||||
return STATUS_ADDRESS_ALREADY_EXISTS;
|
||||
}
|
||||
AddrFile->Port = AllocatedPort;
|
||||
|
||||
/* Sanity check */
|
||||
ASSERT(Address->Address[0].Address[0].sin_port == AddrFile->Port);
|
||||
|
@ -464,14 +466,15 @@ NTSTATUS FileOpenAddress(
|
|||
else if (!AddrIsUnspecified(&AddrFile->Address))
|
||||
{
|
||||
/* The client is trying to bind to a local address so allocate a port now too */
|
||||
AddrFile->Port = TCPAllocatePort(0);
|
||||
AllocatedPort = TCPAllocatePort(0);
|
||||
|
||||
/* Check for bind success */
|
||||
if (AddrFile->Port == 0xffff)
|
||||
if (AllocatedPort == (UINT)-1)
|
||||
{
|
||||
ExFreePoolWithTag(AddrFile, ADDR_FILE_TAG);
|
||||
return STATUS_ADDRESS_ALREADY_EXISTS;
|
||||
}
|
||||
AddrFile->Port = AllocatedPort;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -486,16 +489,16 @@ NTSTATUS FileOpenAddress(
|
|||
|
||||
case IPPROTO_UDP:
|
||||
TI_DbgPrint(MID_TRACE,("Allocating udp port\n"));
|
||||
AddrFile->Port =
|
||||
UDPAllocatePort(Address->Address[0].Address[0].sin_port);
|
||||
AllocatedPort = UDPAllocatePort(Address->Address[0].Address[0].sin_port);
|
||||
|
||||
if ((Address->Address[0].Address[0].sin_port &&
|
||||
AddrFile->Port != Address->Address[0].Address[0].sin_port) ||
|
||||
AddrFile->Port == 0xffff)
|
||||
AllocatedPort != Address->Address[0].Address[0].sin_port) ||
|
||||
AllocatedPort == (UINT)-1)
|
||||
{
|
||||
ExFreePoolWithTag(AddrFile, ADDR_FILE_TAG);
|
||||
return STATUS_ADDRESS_ALREADY_EXISTS;
|
||||
}
|
||||
AddrFile->Port = AllocatedPort;
|
||||
|
||||
TI_DbgPrint(MID_TRACE,("Setting port %d (wanted %d)\n",
|
||||
AddrFile->Port,
|
||||
|
|
|
@ -473,10 +473,6 @@ TiDispatchInternal(
|
|||
}
|
||||
|
||||
|
||||
NTSTATUS NTAPI
|
||||
TiDispatch(
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp)
|
||||
/*
|
||||
* FUNCTION: Dispatch routine for IRP_MJ_DEVICE_CONTROL requests
|
||||
* ARGUMENTS:
|
||||
|
@ -485,6 +481,10 @@ TiDispatch(
|
|||
* RETURNS:
|
||||
* Status of the operation
|
||||
*/
|
||||
NTSTATUS NTAPI
|
||||
TiDispatch(
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
PIO_STACK_LOCATION IrpSp;
|
||||
|
@ -541,7 +541,7 @@ TiDispatch(
|
|||
|
||||
TI_DbgPrint(DEBUG_IRP, ("[TCPIP, TiDispatch] Leaving. Status = (0x%X).\n", Status));
|
||||
|
||||
return IRPFinish( Irp, Status );
|
||||
return IRPFinish(Irp, Status);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -78,10 +78,14 @@ NTSTATUS TCPListen(PCONNECTION_ENDPOINT Connection, UINT Backlog)
|
|||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
/* Allocate the port in the port bitmap */
|
||||
Connection->AddressFile->Port = TCPAllocatePort(LocalAddress.Address[0].Address[0].sin_port);
|
||||
|
||||
/* This should never fail */
|
||||
ASSERT(Connection->AddressFile->Port != 0xFFFF);
|
||||
UINT AllocatedPort = TCPAllocatePort(LocalAddress.Address[0].Address[0].sin_port);
|
||||
/* This should never fail unless all ports are in use */
|
||||
if (AllocatedPort == (UINT) -1)
|
||||
{
|
||||
UnlockObject(Connection, OldIrql);
|
||||
return STATUS_TOO_MANY_ADDRESSES;
|
||||
}
|
||||
Connection->AddressFile->Port = AllocatedPort;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -189,7 +189,7 @@ NTSTATUS TCPStartup(VOID)
|
|||
{
|
||||
NTSTATUS Status;
|
||||
|
||||
Status = PortsStartup( &TCPPorts, 1, 0xfffe );
|
||||
Status = PortsStartup(&TCPPorts, 1, 0xffff);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return Status;
|
||||
|
@ -342,15 +342,21 @@ NTSTATUS TCPConnect
|
|||
/* Check if we had an unspecified port */
|
||||
if (!Connection->AddressFile->Port)
|
||||
{
|
||||
UINT AllocatedPort;
|
||||
|
||||
/* We did, so we need to copy back the port */
|
||||
Status = TCPGetSockAddress(Connection, (PTRANSPORT_ADDRESS)&LocalAddress, FALSE);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
/* Allocate the port in the port bitmap */
|
||||
Connection->AddressFile->Port = TCPAllocatePort(LocalAddress.Address[0].Address[0].sin_port);
|
||||
|
||||
/* This should never fail */
|
||||
ASSERT(Connection->AddressFile->Port != 0xFFFF);
|
||||
AllocatedPort = TCPAllocatePort(LocalAddress.Address[0].Address[0].sin_port);
|
||||
/* This should never fail unless all ports are in use */
|
||||
if (AllocatedPort == (UINT) -1)
|
||||
{
|
||||
UnlockObject(Connection, OldIrql);;
|
||||
return STATUS_TOO_MANY_ADDRESSES;
|
||||
}
|
||||
Connection->AddressFile->Port = AllocatedPort;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -373,6 +379,11 @@ NTSTATUS TCPConnect
|
|||
Status = TCPTranslateError(LibTCPConnect(Connection,
|
||||
&connaddr,
|
||||
RemotePort));
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
RemoveEntryList(&Bucket->Entry);
|
||||
ExFreeToNPagedLookasideList(&TdiBucketLookasideList, Bucket);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -70,9 +70,6 @@
|
|||
#if (!LWIP_UDP && LWIP_UDPLITE)
|
||||
#error "If you want to use UDP Lite, you have to define LWIP_UDP=1 in your lwipopts.h"
|
||||
#endif
|
||||
#if (!LWIP_UDP && LWIP_SNMP)
|
||||
#error "If you want to use SNMP, you have to define LWIP_UDP=1 in your lwipopts.h"
|
||||
#endif
|
||||
#if (!LWIP_UDP && LWIP_DHCP)
|
||||
#error "If you want to use DHCP, you have to define LWIP_UDP=1 in your lwipopts.h"
|
||||
#endif
|
||||
|
@ -124,7 +121,7 @@
|
|||
#if (LWIP_TCP && ((TCP_MAXRTX > 12) || (TCP_SYNMAXRTX > 12)))
|
||||
#error "If you want to use TCP, TCP_MAXRTX and TCP_SYNMAXRTX must less or equal to 12 (due to tcp_backoff table), so, you have to reduce them in your lwipopts.h"
|
||||
#endif
|
||||
#if (LWIP_TCP && TCP_LISTEN_BACKLOG && (TCP_DEFAULT_LISTEN_BACKLOG < 0) || (TCP_DEFAULT_LISTEN_BACKLOG > 0xff))
|
||||
#if (LWIP_TCP && TCP_LISTEN_BACKLOG && ((TCP_DEFAULT_LISTEN_BACKLOG < 0) || (TCP_DEFAULT_LISTEN_BACKLOG > 0xff)))
|
||||
#error "If you want to use TCP backlog, TCP_DEFAULT_LISTEN_BACKLOG must fit into an u8_t"
|
||||
#endif
|
||||
#if (LWIP_NETIF_API && (NO_SYS==1))
|
||||
|
@ -166,7 +163,7 @@
|
|||
#if (DNS_LOCAL_HOSTLIST && !DNS_LOCAL_HOSTLIST_IS_DYNAMIC && !(defined(DNS_LOCAL_HOSTLIST_INIT)))
|
||||
#error "you have to define define DNS_LOCAL_HOSTLIST_INIT {{'host1', 0x123}, {'host2', 0x234}} to initialize DNS_LOCAL_HOSTLIST"
|
||||
#endif
|
||||
#if PPP_SUPPORT && !PPPOS_SUPPORT & !PPPOE_SUPPORT
|
||||
#if PPP_SUPPORT && !PPPOS_SUPPORT && !PPPOE_SUPPORT
|
||||
#error "PPP_SUPPORT needs either PPPOS_SUPPORT or PPPOE_SUPPORT turned on"
|
||||
#endif
|
||||
#if !LWIP_ETHERNET && (LWIP_ARP || PPPOE_SUPPORT)
|
||||
|
|
Loading…
Reference in a new issue