1
0
Fork 0
forked from nuttx/nuttx-update

Improvements in TCP connections allocation.

This commit is contained in:
Fotis Panagiotopoulos 2022-11-04 12:38:07 +02:00 committed by Xiang Xiao
parent 7d3a9b1cbc
commit 8f9dfe0be1
51 changed files with 128 additions and 78 deletions

View file

@ -29,7 +29,7 @@ CONFIG_NET_MAX_LISTENPORTS=8
CONFIG_NET_SOCKOPTS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_TCP_CONNS=16
CONFIG_NET_TCP_PREALLOC_CONNS=16
CONFIG_PTHREAD_STACK_DEFAULT=4096
CONFIG_RAM_SIZE=285212672
CONFIG_RAM_START=0

View file

@ -48,7 +48,7 @@ CONFIG_NET_NACTIVESOCKETS=12
CONFIG_NET_SOCKOPTS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_TCP_CONNS=12
CONFIG_NET_TCP_PREALLOC_CONNS=12
CONFIG_NET_TCP_WRITE_BUFFERS=y
CONFIG_NUNGET_CHARS=0
CONFIG_PIPES=y

View file

@ -37,7 +37,7 @@ CONFIG_NET_MAX_LISTENPORTS=8
CONFIG_NET_SOCKOPTS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_TCP_CONNS=16
CONFIG_NET_TCP_PREALLOC_CONNS=16
CONFIG_NUNGET_CHARS=0
CONFIG_NXFLAT=y
CONFIG_PIPES=y

View file

@ -45,7 +45,7 @@ CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_MAX_LISTENPORTS=8
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_TCP_CONNS=16
CONFIG_NET_TCP_PREALLOC_CONNS=16
CONFIG_NET_UDP=y
CONFIG_NET_UDP_CHECKSUMS=y
CONFIG_NSH_ARCHINIT=y

View file

@ -36,7 +36,7 @@ CONFIG_NET_SLIP=y
CONFIG_NET_SOCKOPTS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_TCP_CONNS=16
CONFIG_NET_TCP_PREALLOC_CONNS=16
CONFIG_NUNGET_CHARS=0
CONFIG_NXFLAT=y
CONFIG_PIPES=y

View file

@ -41,7 +41,7 @@ CONFIG_NET_MAX_LISTENPORTS=8
CONFIG_NET_SOCKOPTS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_TCP_CONNS=16
CONFIG_NET_TCP_PREALLOC_CONNS=16
CONFIG_NUNGET_CHARS=0
CONFIG_PIPES=y
CONFIG_RAM_SIZE=32768

View file

@ -38,7 +38,7 @@ CONFIG_NET_MAX_LISTENPORTS=8
CONFIG_NET_SOCKOPTS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_TCP_CONNS=16
CONFIG_NET_TCP_PREALLOC_CONNS=16
CONFIG_NUNGET_CHARS=0
CONFIG_NXFLAT=y
CONFIG_PIPES=y

View file

@ -35,7 +35,7 @@ CONFIG_NET_MAX_LISTENPORTS=8
CONFIG_NET_SOCKOPTS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_TCP_CONNS=16
CONFIG_NET_TCP_PREALLOC_CONNS=16
CONFIG_NUNGET_CHARS=0
CONFIG_NXFLAT=y
CONFIG_RAM_SIZE=32768

View file

@ -40,7 +40,7 @@ CONFIG_NET_MAX_LISTENPORTS=8
CONFIG_NET_SOCKOPTS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_TCP_CONNS=16
CONFIG_NET_TCP_PREALLOC_CONNS=16
CONFIG_NUNGET_CHARS=0
CONFIG_NXFLAT=y
CONFIG_PIPES=y

View file

@ -59,7 +59,7 @@ CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_STATISTICS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_TCP_CONNS=40
CONFIG_NET_TCP_PREALLOC_CONNS=40
CONFIG_NET_UDP=y
CONFIG_NET_UDP_CHECKSUMS=y
CONFIG_NSH_ARCHINIT=y

View file

@ -43,7 +43,7 @@ CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_MAX_LISTENPORTS=16
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_TCP_CONNS=16
CONFIG_NET_TCP_PREALLOC_CONNS=16
CONFIG_NET_TCP_WRITE_BUFFERS=y
CONFIG_NET_UDP=y
CONFIG_NET_UDP_CHECKSUMS=y

View file

@ -61,7 +61,7 @@ CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_MAX_LISTENPORTS=16
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_TCP_CONNS=16
CONFIG_NET_TCP_PREALLOC_CONNS=16
CONFIG_NET_UDP=y
CONFIG_NET_UDP_CHECKSUMS=y
CONFIG_NSH_ARCHINIT=y

View file

@ -51,7 +51,7 @@ CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_MAX_LISTENPORTS=16
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_TCP_CONNS=16
CONFIG_NET_TCP_PREALLOC_CONNS=16
CONFIG_NET_UDP=y
CONFIG_NET_UDP_CHECKSUMS=y
CONFIG_NSH_ARCHINIT=y

View file

@ -40,7 +40,7 @@ CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_STATISTICS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_TCP_CONNS=40
CONFIG_NET_TCP_PREALLOC_CONNS=40
CONFIG_NET_UDP=y
CONFIG_NET_UDP_CHECKSUMS=y
CONFIG_NSH_ARCHINIT=y

View file

@ -46,7 +46,7 @@ CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_MAX_LISTENPORTS=16
CONFIG_NET_STATISTICS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCP_CONNS=16
CONFIG_NET_TCP_PREALLOC_CONNS=16
CONFIG_NET_UDP=y
CONFIG_NET_UDP_CHECKSUMS=y
CONFIG_NSH_ARCHINIT=y

View file

@ -38,7 +38,7 @@ CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_STATISTICS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_TCP_CONNS=40
CONFIG_NET_TCP_PREALLOC_CONNS=40
CONFIG_NET_UDP=y
CONFIG_NET_UDP_CHECKSUMS=y
CONFIG_PREALLOC_TIMERS=4

View file

@ -41,7 +41,7 @@ CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_STATISTICS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_TCP_CONNS=40
CONFIG_NET_TCP_PREALLOC_CONNS=40
CONFIG_NET_UDP=y
CONFIG_NET_UDP_CHECKSUMS=y
CONFIG_NSH_BUILTIN_APPS=y

View file

@ -44,7 +44,7 @@ CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_STATISTICS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_TCP_CONNS=40
CONFIG_NET_TCP_PREALLOC_CONNS=40
CONFIG_NET_UDP=y
CONFIG_NET_UDP_CHECKSUMS=y
CONFIG_PREALLOC_TIMERS=4

View file

@ -40,7 +40,7 @@ CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_STATISTICS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_TCP_CONNS=40
CONFIG_NET_TCP_PREALLOC_CONNS=40
CONFIG_NET_UDP=y
CONFIG_NET_UDP_CHECKSUMS=y
CONFIG_PREALLOC_TIMERS=4

View file

@ -37,7 +37,7 @@ CONFIG_NET_ICMP=y
CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_TCP=y
CONFIG_NET_TCP_CONNS=40
CONFIG_NET_TCP_PREALLOC_CONNS=40
CONFIG_NET_UDP=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_READLINE=y

View file

@ -39,7 +39,7 @@ CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_STATISTICS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_TCP_CONNS=40
CONFIG_NET_TCP_PREALLOC_CONNS=40
CONFIG_NET_UDP=y
CONFIG_NET_UDP_CHECKSUMS=y
CONFIG_NSH_ARCHINIT=y

View file

@ -53,7 +53,7 @@ CONFIG_NET_MAX_LISTENPORTS=16
CONFIG_NET_STATISTICS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_TCP_CONNS=16
CONFIG_NET_TCP_PREALLOC_CONNS=16
CONFIG_NET_UDP=y
CONFIG_NET_UDP_CHECKSUMS=y
CONFIG_NSH_ARCHINIT=y

View file

@ -46,7 +46,7 @@ CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_STATISTICS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_TCP_CONNS=40
CONFIG_NET_TCP_PREALLOC_CONNS=40
CONFIG_NET_UDP=y
CONFIG_NET_UDP_CHECKSUMS=y
CONFIG_NSH_ARCHINIT=y

View file

@ -33,7 +33,7 @@ CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_SOCKOPTS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCP_CONNS=40
CONFIG_NET_TCP_PREALLOC_CONNS=40
CONFIG_NUNGET_CHARS=0
CONFIG_RAM_SIZE=196608
CONFIG_RAM_START=0x20000000

View file

@ -42,7 +42,7 @@ CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_STATISTICS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_TCP_CONNS=40
CONFIG_NET_TCP_PREALLOC_CONNS=40
CONFIG_NET_UDP=y
CONFIG_NET_UDP_CHECKSUMS=y
CONFIG_NSH_BUILTIN_APPS=y

View file

@ -52,7 +52,7 @@ CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_STATISTICS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_TCP_CONNS=40
CONFIG_NET_TCP_PREALLOC_CONNS=40
CONFIG_NET_UDP=y
CONFIG_NET_UDP_CHECKSUMS=y
CONFIG_NSH_ARCHINIT=y

View file

@ -52,7 +52,7 @@ CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_STATISTICS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_TCP_CONNS=40
CONFIG_NET_TCP_PREALLOC_CONNS=40
CONFIG_NET_UDP=y
CONFIG_NET_UDP_CHECKSUMS=y
CONFIG_NSH_FILEIOSIZE=512

View file

@ -36,7 +36,7 @@ CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_SOCKOPTS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCP_CONNS=40
CONFIG_NET_TCP_PREALLOC_CONNS=40
CONFIG_NUNGET_CHARS=0
CONFIG_RAM_SIZE=196608
CONFIG_RAM_START=0x20000000

View file

@ -40,7 +40,7 @@ CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_STATISTICS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_TCP_CONNS=40
CONFIG_NET_TCP_PREALLOC_CONNS=40
CONFIG_NET_UDP=y
CONFIG_NET_UDP_CHECKSUMS=y
CONFIG_PREALLOC_TIMERS=4

View file

@ -35,7 +35,7 @@ CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_SOCKOPTS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCP_CONNS=40
CONFIG_NET_TCP_PREALLOC_CONNS=40
CONFIG_NUNGET_CHARS=0
CONFIG_RAM_SIZE=196608
CONFIG_RAM_START=0x20000000

View file

@ -46,7 +46,7 @@ CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_STATISTICS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_TCP_CONNS=40
CONFIG_NET_TCP_PREALLOC_CONNS=40
CONFIG_NET_UDP=y
CONFIG_NET_UDP_CHECKSUMS=y
CONFIG_NSH_BUILTIN_APPS=y

View file

@ -53,7 +53,7 @@ CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_STATISTICS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_TCP_CONNS=40
CONFIG_NET_TCP_PREALLOC_CONNS=40
CONFIG_NET_UDP=y
CONFIG_NET_UDP_CHECKSUMS=y
CONFIG_NSH_ARCHINIT=y

View file

@ -55,7 +55,7 @@ CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_STATISTICS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_TCP_CONNS=40
CONFIG_NET_TCP_PREALLOC_CONNS=40
CONFIG_NET_UDP=y
CONFIG_NET_UDP_CHECKSUMS=y
CONFIG_NSH_BUILTIN_APPS=y

View file

@ -52,7 +52,7 @@ CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_STATISTICS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_TCP_CONNS=40
CONFIG_NET_TCP_PREALLOC_CONNS=40
CONFIG_NET_UDP=y
CONFIG_NET_UDP_CHECKSUMS=y
CONFIG_NSH_FILEIOSIZE=512

View file

@ -37,7 +37,7 @@ CONFIG_NET_ICMP=y
CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_SOCKOPTS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCP_CONNS=40
CONFIG_NET_TCP_PREALLOC_CONNS=40
CONFIG_NUNGET_CHARS=0
CONFIG_RAM_SIZE=196608
CONFIG_RAM_START=0x20000000

View file

@ -41,7 +41,7 @@ CONFIG_NET_SOCKOPTS=y
CONFIG_NET_STATISTICS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_TCP_CONNS=40
CONFIG_NET_TCP_PREALLOC_CONNS=40
CONFIG_NET_UDP=y
CONFIG_NET_UDP_CHECKSUMS=y
CONFIG_NSH_FILEIOSIZE=512

View file

@ -40,7 +40,7 @@ CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_STATISTICS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_TCP_CONNS=40
CONFIG_NET_TCP_PREALLOC_CONNS=40
CONFIG_NET_UDP=y
CONFIG_NET_UDP_CHECKSUMS=y
CONFIG_PREALLOC_TIMERS=4

View file

@ -42,7 +42,7 @@ CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_MAX_LISTENPORTS=16
CONFIG_NET_STATISTICS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCP_CONNS=16
CONFIG_NET_TCP_PREALLOC_CONNS=16
CONFIG_NET_UDP=y
CONFIG_NET_UDP_CHECKSUMS=y
CONFIG_NET_W5500=y

View file

@ -43,7 +43,7 @@ CONFIG_NET_IPv6=y
CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_ROUTE=y
CONFIG_NET_TCP=y
CONFIG_NET_TCP_CONNS=40
CONFIG_NET_TCP_PREALLOC_CONNS=40
CONFIG_NET_TCP_WRITE_BUFFERS=y
CONFIG_NET_UDP=y
CONFIG_NSH_ARCHINIT=y

View file

@ -38,7 +38,7 @@ CONFIG_NET_SOCKOPTS=y
CONFIG_NET_STATISTICS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_TCP_CONNS=40
CONFIG_NET_TCP_PREALLOC_CONNS=40
CONFIG_NET_TCP_WRITE_BUFFERS=y
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_BUILTIN_APPS=y

View file

@ -30,7 +30,7 @@ CONFIG_NET_SOCKOPTS=y
CONFIG_NET_STATISTICS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_TCP_CONNS=16
CONFIG_NET_TCP_PREALLOC_CONNS=16
CONFIG_NUNGET_CHARS=0
CONFIG_RAM_SIZE=65536
CONFIG_RAM_START=0x20000000

View file

@ -31,7 +31,7 @@ CONFIG_NET_MAX_LISTENPORTS=8
CONFIG_NET_SOCKOPTS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_TCP_CONNS=16
CONFIG_NET_TCP_PREALLOC_CONNS=16
CONFIG_NUNGET_CHARS=0
CONFIG_NXFLAT=y
CONFIG_PIPES=y

View file

@ -38,7 +38,7 @@ CONFIG_NET_MAX_LISTENPORTS=8
CONFIG_NET_STATISTICS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_TCP_CONNS=16
CONFIG_NET_TCP_PREALLOC_CONNS=16
CONFIG_NET_UDP=y
CONFIG_NET_UDP_CHECKSUMS=y
CONFIG_PREALLOC_TIMERS=4

View file

@ -45,7 +45,7 @@ CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_TCP_CONNS=40
CONFIG_NET_TCP_PREALLOC_CONNS=40
CONFIG_NET_UDP=y
CONFIG_NET_UDP_CHECKSUMS=y
CONFIG_NSH_ARCHINIT=y

View file

@ -47,7 +47,7 @@ CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_TCP_CONNS=40
CONFIG_NET_TCP_PREALLOC_CONNS=40
CONFIG_NET_UDP=y
CONFIG_NET_UDP_CHECKSUMS=y
CONFIG_NSH_ARCHINIT=y

View file

@ -59,7 +59,7 @@ CONFIG_NET_ICMP=y
CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_TCP=y
CONFIG_NET_TCP_CONNS=40
CONFIG_NET_TCP_PREALLOC_CONNS=40
CONFIG_NET_TCP_WRITE_BUFFERS=y
CONFIG_NET_UDP=y
CONFIG_NET_UDP_CHECKSUMS=y

View file

@ -23,7 +23,7 @@ CONFIG_NET_MAX_LISTENPORTS=40
CONFIG_NET_SOCKOPTS=y
CONFIG_NET_STATISTICS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCP_CONNS=40
CONFIG_NET_TCP_PREALLOC_CONNS=40
CONFIG_SCHED_LPWORK=y
CONFIG_START_DAY=16
CONFIG_START_MONTH=8

View file

@ -35,7 +35,7 @@ CONFIG_NET_SOCKOPTS=y
CONFIG_NET_STATISTICS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_TCP_CONNS=16
CONFIG_NET_TCP_PREALLOC_CONNS=16
CONFIG_NUNGET_CHARS=0
CONFIG_RAM_SIZE=65536
CONFIG_RR_INTERVAL=200

View file

@ -416,21 +416,6 @@
/* TCP configuration options */
/* The maximum number of simultaneously open TCP connections.
*
* Since the TCP connections are statically allocated, turning this
* configuration knob down results in less RAM used. Each TCP
* connection requires approximately 30 bytes of memory.
*/
#ifndef CONFIG_NET_TCP_CONNS
# ifdef CONFIG_NET_TCP
# define CONFIG_NET_TCP_CONNS 10
# else
# define CONFIG_NET_TCP_CONNS 0
# endif
#endif
/* The maximum number of simultaneously listening TCP ports.
*
* Each listening TCP port requires 2 bytes of memory.
@ -446,7 +431,8 @@
*/
#ifndef CONFIG_NET_NACTIVESOCKETS
# define CONFIG_NET_NACTIVESOCKETS (CONFIG_NET_TCP_CONNS + CONFIG_NET_UDP_CONNS)
# define CONFIG_NET_NACTIVESOCKETS (CONFIG_NET_TCP_PREALLOC_CONNS + \
CONFIG_NET_UDP_CONNS)
#endif
/* The initial retransmission timeout counted in timer pulses.

View file

@ -50,11 +50,46 @@ config NET_TCPURGDATA
compiled in. Urgent data (out-of-band data) is a rarely used TCP feature
that is very seldom would be required.
config NET_TCP_CONNS
int "Number of TCP/IP connections"
config NET_TCP_PREALLOC_CONNS
int "Preallocated TCP/IP connections"
default 8
---help---
Maximum number of TCP/IP connections (all tasks)
Number of TCP/IP connections (all tasks).
This number of connections will be pre-allocated during system boot.
If dynamic connections allocation is enabled, more connections may
be allocated at a later time, as the system needs them. Else this
will be the maximum number of connections available to the system
at all times.
Set to 0 to disable (and rely only on dynamic allocations).
config NET_TCP_ALLOC_CONNS
int "Dynamic TCP/IP connections allocation"
default 0
---help---
Dynamic memory allocations for TCP/IP.
When set to 0 all dynamic allocations are disabled.
When set to 1 a new connection will be allocated every time,
and it will be free'd when no longer needed.
Setting this to 2 or more will allocate the connections in
batches (with batch size equal to this config). When a
connection is no longer needed, it will be returned to the
free connections pool, and it will never be deallocated!
config NET_TCP_MAX_CONNS
int "Maximum number of TCP/IP connections"
default 0
depends on NET_TCP_ALLOC_CONNS > 0
---help---
If dynamic connections allocation is selected (NET_TCP_ALLOC_CONNS > 0)
this will limit the number of connections that can be allocated.
This is useful in case the system is under very heavy load (or
under attack), ensuring that the heap will not be exhausted.
config NET_TCP_NPOLLWAITERS
int "Number of TCP poll waiters"

View file

@ -76,8 +76,8 @@
/* The array containing all TCP connections. */
#ifndef CONFIG_NET_ALLOC_CONNS
static struct tcp_conn_s g_tcp_connections[CONFIG_NET_TCP_CONNS];
#if CONFIG_NET_TCP_PREALLOC_CONNS > 0
static struct tcp_conn_s g_tcp_connections[CONFIG_NET_TCP_PREALLOC_CONNS];
#endif
/* A list of all free TCP connections */
@ -439,7 +439,7 @@ static inline int tcp_ipv6_bind(FAR struct tcp_conn_s *conn,
*
****************************************************************************/
#ifdef CONFIG_NET_ALLOC_CONNS
#if CONFIG_NET_TCP_ALLOC_CONNS > 0
FAR struct tcp_conn_s *tcp_alloc_conn(void)
{
FAR struct tcp_conn_s *conn;
@ -449,8 +449,16 @@ FAR struct tcp_conn_s *tcp_alloc_conn(void)
if (dq_peek(&g_free_tcp_connections) == NULL)
{
#if CONFIG_NET_TCP_MAX_CONNS > 0
if (dq_count(&g_active_tcp_connections) + CONFIG_NET_TCP_ALLOC_CONNS
>= CONFIG_NET_TCP_MAX_CONNS)
{
return NULL;
}
#endif
conn = kmm_zalloc(sizeof(struct tcp_conn_s) *
CONFIG_NET_TCP_CONNS);
CONFIG_NET_TCP_ALLOC_CONNS);
if (conn == NULL)
{
return conn;
@ -458,7 +466,7 @@ FAR struct tcp_conn_s *tcp_alloc_conn(void)
/* Now initialize each connection structure */
for (i = 0; i < CONFIG_NET_TCP_CONNS; i++)
for (i = 0; i < CONFIG_NET_TCP_ALLOC_CONNS; i++)
{
/* Mark the connection closed and move it to the free list */
@ -597,10 +605,10 @@ int tcp_selectport(uint8_t domain,
void tcp_initialize(void)
{
#ifndef CONFIG_NET_ALLOC_CONNS
#if CONFIG_NET_TCP_PREALLOC_CONNS > 0
int i;
for (i = 0; i < CONFIG_NET_TCP_CONNS; i++)
for (i = 0; i < CONFIG_NET_TCP_PREALLOC_CONNS; i++)
{
/* Mark the connection closed and move it to the free list */
@ -700,7 +708,12 @@ FAR struct tcp_conn_s *tcp_alloc(uint8_t domain)
tcp_free(conn);
/* Now there is guaranteed to be one free connection. Get it! */
/* Now there should be one free connection. If dynamic connections
* allocation is disabled, it is guaranteed so. In case that
* dynamic connections are used, it may be already in the free
* list, or at least there should be enough space in the heap for
* a new connection.
*/
conn = (FAR struct tcp_conn_s *)
dq_remfirst(&g_free_tcp_connections);
@ -710,7 +723,7 @@ FAR struct tcp_conn_s *tcp_alloc(uint8_t domain)
/* Allocate the connect entry from heap */
#ifdef CONFIG_NET_ALLOC_CONNS
#if CONFIG_NET_TCP_ALLOC_CONNS > 0
if (conn == NULL)
{
conn = tcp_alloc_conn();
@ -876,10 +889,26 @@ void tcp_free(FAR struct tcp_conn_s *conn)
}
#endif
/* Mark the connection available and put it into the free list */
/* Mark the connection available. */
conn->tcpstateflags = TCP_CLOSED;
dq_addlast(&conn->sconn.node, &g_free_tcp_connections);
/* If this is a preallocated or a batch allocated connection store it in
* the free connections list. Else free it.
*/
#if CONFIG_NET_TCP_ALLOC_CONNS == 1
if (conn < g_tcp_connections || conn >= (g_tcp_connections +
CONFIG_NET_TCP_PREALLOC_CONNS))
{
kmm_free(conn);
}
else
#endif
{
dq_addlast(&conn->sconn.node, &g_free_tcp_connections);
}
net_unlock();
}