You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2023/02/20 01:06:53 UTC
[nuttx] branch master updated (7d3a9b1cbc -> b6eb3c828c)
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
from 7d3a9b1cbc Revert "STM32 Nucleo: warning: #warning "Default Flash Configuration Used""
new 8f9dfe0be1 Improvements in TCP connections allocation.
new 7f3591b9cc Improvements in UDP connections allocation.
new f207072121 Improvements in usrsock connections allocation.
new 1c07a3a696 Improvements in ICMP connections allocation.
new 90a93a7474 Improvements in ICMPv6 connections allocation.
new c5cc70a8b1 Improvements in Bluetooth connections allocation.
new 22a82b3f51 Improvements in IEEE 802.15.4 connections allocation.
new 74bb921a19 Improvements in packet connections allocation.
new cf15d6b63a Improvements in Netlink connections allocation.
new 9b4d784307 Improvements in sockets allocation.
new b5b7d24ba1 Improvements in CAN connections allocation.
new b6eb3c828c Removed obsolete option NET_ALLOC_CONNS.
The 12 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
boards/arm/c5471/c5471evm/configs/httpd/defconfig | 2 +-
.../arm/cxd56xx/spresense/configs/wifi/defconfig | 2 +-
.../cxd56xx/spresense/configs/wifi_smp/defconfig | 2 +-
.../lincoln60/configs/thttpd-binfs/defconfig | 4 +-
.../lpcxpresso-lpc1768/configs/thttpd/defconfig | 2 +-
.../olimex-lpc1766stk/configs/ftpc/defconfig | 2 +-
.../olimex-lpc1766stk/configs/slip-httpd/defconfig | 2 +-
.../configs/thttpd-binfs/defconfig | 2 +-
.../configs/thttpd-nxflat/defconfig | 2 +-
.../zkit-arm-1769/configs/hello/defconfig | 2 +-
.../zkit-arm-1769/configs/thttpd/defconfig | 2 +-
.../lpc43xx/bambino-200e/configs/netnsh/defconfig | 2 +-
boards/arm/sam34/sam4e-ek/configs/nsh/defconfig | 2 +-
boards/arm/sam34/sam4e-ek/configs/nxwm/defconfig | 2 +-
boards/arm/sam34/sam4e-ek/configs/usbnsh/defconfig | 2 +-
.../sama5d3-xplained/configs/bridge/defconfig | 2 +-
.../arm/sama5/sama5d4-ek/configs/bridge/defconfig | 2 +-
boards/arm/stm32/cloudctrl/configs/nsh/defconfig | 2 +-
.../arm/stm32/fire-stm32v2/configs/nsh/defconfig | 2 +-
.../stm32/nucleo-f302r8/configs/cansock/defconfig | 2 +-
.../olimex-stm32-e407/configs/discover/defconfig | 2 +-
.../olimex-stm32-e407/configs/netnsh/defconfig | 2 +-
.../olimex-stm32-e407/configs/telnetd/defconfig | 2 +-
.../olimex-stm32-e407/configs/webserver/defconfig | 2 +-
.../stm32/olimex-stm32-p107/configs/nsh/defconfig | 2 +-
boards/arm/stm32/shenzhou/configs/nsh/defconfig | 2 +-
boards/arm/stm32/shenzhou/configs/nxwm/defconfig | 2 +-
boards/arm/stm32/shenzhou/configs/thttpd/defconfig | 2 +-
.../stm32/stm3220g-eval/configs/nettest/defconfig | 2 +-
.../arm/stm32/stm3220g-eval/configs/nsh/defconfig | 2 +-
.../arm/stm32/stm3220g-eval/configs/nsh2/defconfig | 2 +-
.../arm/stm32/stm3220g-eval/configs/nxwm/defconfig | 2 +-
.../stm32/stm3220g-eval/configs/telnetd/defconfig | 2 +-
.../stm32/stm3240g-eval/configs/discover/defconfig | 2 +-
.../stm32/stm3240g-eval/configs/nettest/defconfig | 2 +-
.../arm/stm32/stm3240g-eval/configs/nsh/defconfig | 2 +-
.../arm/stm32/stm3240g-eval/configs/nsh2/defconfig | 2 +-
.../stm32/stm3240g-eval/configs/nxterm/defconfig | 2 +-
.../arm/stm32/stm3240g-eval/configs/nxwm/defconfig | 2 +-
.../stm32/stm3240g-eval/configs/telnetd/defconfig | 2 +-
.../stm3240g-eval/configs/webserver/defconfig | 2 +-
.../stm32/stm3240g-eval/configs/xmlrpc/defconfig | 2 +-
.../stm32f4discovery/configs/ether_w5500/defconfig | 2 +-
.../stm32/stm32f4discovery/configs/wifi/defconfig | 2 +-
boards/arm/stm32/viewtool-stm32f107/README.txt | 2 +-
.../viewtool-stm32f107/configs/netnsh/defconfig | 2 +-
.../configs/tcpblaster/defconfig | 2 +-
.../nucleo-h743zi2/configs/socketcan/defconfig | 2 +-
boards/arm/tiva/eagle100/configs/httpd/defconfig | 2 +-
boards/arm/tiva/eagle100/configs/thttpd/defconfig | 2 +-
.../arm/tiva/lm3s6965-ek/configs/tcpecho/defconfig | 2 +-
.../pic32mx-starterkit/configs/nsh2/defconfig | 2 +-
.../mips/pic32mx/pic32mx7mmb/configs/nsh/defconfig | 2 +-
boards/misoc/lm32/misoc/configs/hello/defconfig | 2 +-
boards/sim/sim/sim/configs/dynconns/defconfig | 12 ++++-
boards/sim/sim/sim/configs/nettest/defconfig | 2 +-
.../esp32/esp32-devkitc/configs/audio/defconfig | 2 +-
.../esp32/esp32-devkitc/configs/blewifi/defconfig | 2 +-
.../esp32/esp32-devkitc/configs/coex/defconfig | 2 +-
.../esp32/esp32-devkitc/configs/efuse/defconfig | 2 +-
.../esp32/esp32-devkitc/configs/nxlooper/defconfig | 2 +-
.../esp32/esp32-devkitc/configs/wapi/defconfig | 2 +-
.../esp32/esp32-lyrat/configs/audio/defconfig | 2 +-
.../esp32/esp32-lyrat/configs/wapi/defconfig | 2 +-
.../ez80/ez80f910200zco/configs/httpd/defconfig | 2 +-
include/nuttx/net/netconfig.h | 46 -------------------
net/Kconfig | 10 -----
net/bluetooth/Kconfig | 41 ++++++++++++++++-
net/bluetooth/bluetooth_conn.c | 42 +++++++++++++-----
net/can/Kconfig | 41 +++++++++++++++--
net/can/can_conn.c | 42 +++++++++++++-----
net/devif/devif_callback.c | 38 +++++++++++-----
net/icmp/Kconfig | 41 ++++++++++++++++-
net/icmp/icmp_conn.c | 39 +++++++++++++----
net/icmpv6/Kconfig | 41 ++++++++++++++++-
net/icmpv6/icmpv6_conn.c | 40 +++++++++++++----
net/ieee802154/Kconfig | 41 ++++++++++++++++-
net/ieee802154/ieee802154_conn.c | 43 +++++++++++++-----
net/netlink/Kconfig | 41 +++++++++++++++--
net/netlink/netlink_conn.c | 43 +++++++++++++-----
net/pkt/Kconfig | 41 ++++++++++++++++-
net/pkt/pkt_conn.c | 42 +++++++++++++-----
net/socket/Kconfig | 31 +++++++++++--
net/tcp/Kconfig | 41 +++++++++++++++--
net/tcp/tcp_conn.c | 51 +++++++++++++++++-----
net/udp/Kconfig | 41 +++++++++++++++--
net/udp/udp_conn.c | 51 +++++++++++++++++-----
net/usrsock/Kconfig | 41 +++++++++++++++--
net/usrsock/usrsock_conn.c | 43 +++++++++++++-----
89 files changed, 848 insertions(+), 265 deletions(-)
[nuttx] 11/12: Improvements in CAN connections allocation.
Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit b5b7d24ba1557dd745e0ef48e8f13a7a8a9a3865
Author: Fotis Panagiotopoulos <f....@amco.gr>
AuthorDate: Mon Feb 13 19:15:37 2023 +0200
Improvements in CAN connections allocation.
---
.../nucleo-h743zi2/configs/socketcan/defconfig | 2 +-
net/can/Kconfig | 41 +++++++++++++++++++--
net/can/can_conn.c | 42 ++++++++++++++++------
3 files changed, 71 insertions(+), 14 deletions(-)
diff --git a/boards/arm/stm32h7/nucleo-h743zi2/configs/socketcan/defconfig b/boards/arm/stm32h7/nucleo-h743zi2/configs/socketcan/defconfig
index 5101756e2a..798bc06cea 100644
--- a/boards/arm/stm32h7/nucleo-h743zi2/configs/socketcan/defconfig
+++ b/boards/arm/stm32h7/nucleo-h743zi2/configs/socketcan/defconfig
@@ -25,7 +25,7 @@ CONFIG_BOARD_LOOPSPERMSEC=43103
CONFIG_BUILTIN=y
CONFIG_CANUTILS_CANDUMP=y
CONFIG_CANUTILS_CANSEND=y
-CONFIG_CAN_CONNS=2
+CONFIG_CAN_PREALLOC_CONNS=2
CONFIG_DEBUG_ERROR=y
CONFIG_DEBUG_FEATURES=y
CONFIG_DEBUG_INFO=y
diff --git a/net/can/Kconfig b/net/can/Kconfig
index 10cffb0024..3f053e7f38 100644
--- a/net/can/Kconfig
+++ b/net/can/Kconfig
@@ -30,11 +30,46 @@ config NET_CAN_HAVE_ERRORS
bool
default n
-config CAN_CONNS
- int "Max number of CAN socket connections"
+config CAN_PREALLOC_CONNS
+ int "Preallocated CAN socket connections"
default 4
---help---
- Maximum number of CAN connections (all tasks).
+ Number of CAN 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 CAN_ALLOC_CONNS
+ int "Dynamic CAN connections allocation"
+ default 0
+ ---help---
+ Dynamic memory allocations for CAN.
+
+ 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 CAN_MAX_CONNS
+ int "Maximum number of CAN connections"
+ default 0
+ depends on CAN_ALLOC_CONNS > 0
+ ---help---
+ If dynamic connections allocation is selected (CAN_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_CAN_EXTID
bool "Enable CAN extended IDs"
diff --git a/net/can/can_conn.c b/net/can/can_conn.c
index b12683427b..4310bc81bb 100644
--- a/net/can/can_conn.c
+++ b/net/can/can_conn.c
@@ -49,8 +49,8 @@
/* The array containing all NetLink connections. */
-#ifndef CONFIG_NET_ALLOC_CONNS
-static struct can_conn_s g_can_connections[CONFIG_CAN_CONNS];
+#if CONFIG_CAN_PREALLOC_CONNS > 0
+static struct can_conn_s g_can_connections[CONFIG_CAN_PREALLOC_CONNS];
#endif
/* A list of all free NetLink connections */
@@ -77,10 +77,10 @@ static dq_queue_t g_active_can_connections;
void can_initialize(void)
{
-#ifndef CONFIG_NET_ALLOC_CONNS
+#if CONFIG_CAN_PREALLOC_CONNS > 0
int i;
- for (i = 0; i < CONFIG_CAN_CONNS; i++)
+ for (i = 0; i < CONFIG_CAN_PREALLOC_CONNS; i++)
{
/* Mark the connection closed and move it to the free list */
@@ -101,20 +101,29 @@ void can_initialize(void)
FAR struct can_conn_s *can_alloc(void)
{
FAR struct can_conn_s *conn;
-#ifdef CONFIG_NET_ALLOC_CONNS
+#if CONFIG_CAN_ALLOC_CONNS > 0
int i;
#endif
/* The free list is protected by a a mutex. */
nxmutex_lock(&g_free_lock);
-#ifdef CONFIG_NET_ALLOC_CONNS
+#if CONFIG_CAN_ALLOC_CONNS > 0
if (dq_peek(&g_free_can_connections) == NULL)
{
- conn = kmm_zalloc(sizeof(*conn) * CONFIG_CAN_CONNS);
+#if CONFIG_CAN_MAX_CONNS > 0
+ if (dq_count(&g_active_can_connections) + CONFIG_CAN_ALLOC_CONNS
+ >= CONFIG_CAN_MAX_CONNS)
+ {
+ nxmutex_unlock(&g_free_lock);
+ return NULL;
+ }
+#endif
+
+ conn = kmm_zalloc(sizeof(*conn) * CONFIG_CAN_ALLOC_CONNS);
if (conn != NULL)
{
- for (i = 0; i < CONFIG_CAN_CONNS; i++)
+ for (i = 0; i < CONFIG_CAN_ALLOC_CONNS; i++)
{
dq_addlast(&conn[i].sconn.node, &g_free_can_connections);
}
@@ -177,9 +186,22 @@ void can_free(FAR struct can_conn_s *conn)
memset(conn, 0, sizeof(*conn));
- /* Free the connection */
+ /* If this is a preallocated or a batch allocated connection store it in
+ * the free connections list. Else free it.
+ */
+
+#if CONFIG_CAN_ALLOC_CONNS == 1
+ if (conn < g_can_connections || conn >= (g_can_connections +
+ CONFIG_CAN_PREALLOC_CONNS))
+ {
+ kmm_free(conn);
+ }
+ else
+#endif
+ {
+ dq_addlast(&conn->sconn.node, &g_free_can_connections);
+ }
- dq_addlast(&conn->sconn.node, &g_free_can_connections);
nxmutex_unlock(&g_free_lock);
}
[nuttx] 01/12: Improvements in TCP connections allocation.
Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 8f9dfe0be13b223bec19c2bd3ae687df1e66ec16
Author: Fotis Panagiotopoulos <f....@amco.gr>
AuthorDate: Fri Nov 4 12:38:07 2022 +0200
Improvements in TCP connections allocation.
---
boards/arm/c5471/c5471evm/configs/httpd/defconfig | 2 +-
.../lincoln60/configs/thttpd-binfs/defconfig | 2 +-
.../lpcxpresso-lpc1768/configs/thttpd/defconfig | 2 +-
.../olimex-lpc1766stk/configs/ftpc/defconfig | 2 +-
.../olimex-lpc1766stk/configs/slip-httpd/defconfig | 2 +-
.../configs/thttpd-binfs/defconfig | 2 +-
.../configs/thttpd-nxflat/defconfig | 2 +-
.../zkit-arm-1769/configs/hello/defconfig | 2 +-
.../zkit-arm-1769/configs/thttpd/defconfig | 2 +-
.../lpc43xx/bambino-200e/configs/netnsh/defconfig | 2 +-
boards/arm/sam34/sam4e-ek/configs/nsh/defconfig | 2 +-
boards/arm/sam34/sam4e-ek/configs/nxwm/defconfig | 2 +-
boards/arm/sam34/sam4e-ek/configs/usbnsh/defconfig | 2 +-
boards/arm/stm32/cloudctrl/configs/nsh/defconfig | 2 +-
.../arm/stm32/fire-stm32v2/configs/nsh/defconfig | 2 +-
.../olimex-stm32-e407/configs/discover/defconfig | 2 +-
.../olimex-stm32-e407/configs/netnsh/defconfig | 2 +-
.../olimex-stm32-e407/configs/telnetd/defconfig | 2 +-
.../olimex-stm32-e407/configs/webserver/defconfig | 2 +-
.../stm32/olimex-stm32-p107/configs/nsh/defconfig | 2 +-
boards/arm/stm32/shenzhou/configs/nsh/defconfig | 2 +-
boards/arm/stm32/shenzhou/configs/nxwm/defconfig | 2 +-
boards/arm/stm32/shenzhou/configs/thttpd/defconfig | 2 +-
.../stm32/stm3220g-eval/configs/nettest/defconfig | 2 +-
.../arm/stm32/stm3220g-eval/configs/nsh/defconfig | 2 +-
.../arm/stm32/stm3220g-eval/configs/nsh2/defconfig | 2 +-
.../arm/stm32/stm3220g-eval/configs/nxwm/defconfig | 2 +-
.../stm32/stm3220g-eval/configs/telnetd/defconfig | 2 +-
.../stm32/stm3240g-eval/configs/discover/defconfig | 2 +-
.../stm32/stm3240g-eval/configs/nettest/defconfig | 2 +-
.../arm/stm32/stm3240g-eval/configs/nsh/defconfig | 2 +-
.../arm/stm32/stm3240g-eval/configs/nsh2/defconfig | 2 +-
.../stm32/stm3240g-eval/configs/nxterm/defconfig | 2 +-
.../arm/stm32/stm3240g-eval/configs/nxwm/defconfig | 2 +-
.../stm32/stm3240g-eval/configs/telnetd/defconfig | 2 +-
.../stm3240g-eval/configs/webserver/defconfig | 2 +-
.../stm32/stm3240g-eval/configs/xmlrpc/defconfig | 2 +-
.../stm32f4discovery/configs/ether_w5500/defconfig | 2 +-
.../viewtool-stm32f107/configs/netnsh/defconfig | 2 +-
.../configs/tcpblaster/defconfig | 2 +-
boards/arm/tiva/eagle100/configs/httpd/defconfig | 2 +-
boards/arm/tiva/eagle100/configs/thttpd/defconfig | 2 +-
.../arm/tiva/lm3s6965-ek/configs/tcpecho/defconfig | 2 +-
.../pic32mx-starterkit/configs/nsh2/defconfig | 2 +-
.../mips/pic32mx/pic32mx7mmb/configs/nsh/defconfig | 2 +-
boards/misoc/lm32/misoc/configs/hello/defconfig | 2 +-
boards/sim/sim/sim/configs/nettest/defconfig | 2 +-
.../ez80/ez80f910200zco/configs/httpd/defconfig | 2 +-
include/nuttx/net/netconfig.h | 18 +-------
net/tcp/Kconfig | 41 +++++++++++++++--
net/tcp/tcp_conn.c | 51 +++++++++++++++++-----
51 files changed, 128 insertions(+), 78 deletions(-)
diff --git a/boards/arm/c5471/c5471evm/configs/httpd/defconfig b/boards/arm/c5471/c5471evm/configs/httpd/defconfig
index b43a7d58ea..66740d662e 100644
--- a/boards/arm/c5471/c5471evm/configs/httpd/defconfig
+++ b/boards/arm/c5471/c5471evm/configs/httpd/defconfig
@@ -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
diff --git a/boards/arm/lpc17xx_40xx/lincoln60/configs/thttpd-binfs/defconfig b/boards/arm/lpc17xx_40xx/lincoln60/configs/thttpd-binfs/defconfig
index 7e0bdebf5d..a1f7992624 100644
--- a/boards/arm/lpc17xx_40xx/lincoln60/configs/thttpd-binfs/defconfig
+++ b/boards/arm/lpc17xx_40xx/lincoln60/configs/thttpd-binfs/defconfig
@@ -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
diff --git a/boards/arm/lpc17xx_40xx/lpcxpresso-lpc1768/configs/thttpd/defconfig b/boards/arm/lpc17xx_40xx/lpcxpresso-lpc1768/configs/thttpd/defconfig
index 22b441e171..86eeac0d18 100644
--- a/boards/arm/lpc17xx_40xx/lpcxpresso-lpc1768/configs/thttpd/defconfig
+++ b/boards/arm/lpc17xx_40xx/lpcxpresso-lpc1768/configs/thttpd/defconfig
@@ -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
diff --git a/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/configs/ftpc/defconfig b/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/configs/ftpc/defconfig
index a8fc9195c2..f272656176 100644
--- a/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/configs/ftpc/defconfig
+++ b/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/configs/ftpc/defconfig
@@ -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
diff --git a/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/configs/slip-httpd/defconfig b/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/configs/slip-httpd/defconfig
index d8b0c31d6d..f2b1645b0a 100644
--- a/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/configs/slip-httpd/defconfig
+++ b/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/configs/slip-httpd/defconfig
@@ -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
diff --git a/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/configs/thttpd-binfs/defconfig b/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/configs/thttpd-binfs/defconfig
index 5f501b8e90..788f09d5fb 100644
--- a/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/configs/thttpd-binfs/defconfig
+++ b/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/configs/thttpd-binfs/defconfig
@@ -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
diff --git a/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/configs/thttpd-nxflat/defconfig b/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/configs/thttpd-nxflat/defconfig
index 3678528bed..d52666745d 100644
--- a/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/configs/thttpd-nxflat/defconfig
+++ b/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/configs/thttpd-nxflat/defconfig
@@ -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
diff --git a/boards/arm/lpc17xx_40xx/zkit-arm-1769/configs/hello/defconfig b/boards/arm/lpc17xx_40xx/zkit-arm-1769/configs/hello/defconfig
index 7fd413782b..df15f119da 100644
--- a/boards/arm/lpc17xx_40xx/zkit-arm-1769/configs/hello/defconfig
+++ b/boards/arm/lpc17xx_40xx/zkit-arm-1769/configs/hello/defconfig
@@ -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
diff --git a/boards/arm/lpc17xx_40xx/zkit-arm-1769/configs/thttpd/defconfig b/boards/arm/lpc17xx_40xx/zkit-arm-1769/configs/thttpd/defconfig
index 7374e372fa..9dc91ac32f 100644
--- a/boards/arm/lpc17xx_40xx/zkit-arm-1769/configs/thttpd/defconfig
+++ b/boards/arm/lpc17xx_40xx/zkit-arm-1769/configs/thttpd/defconfig
@@ -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
diff --git a/boards/arm/lpc43xx/bambino-200e/configs/netnsh/defconfig b/boards/arm/lpc43xx/bambino-200e/configs/netnsh/defconfig
index e0eeec8cd0..8a07b2527c 100644
--- a/boards/arm/lpc43xx/bambino-200e/configs/netnsh/defconfig
+++ b/boards/arm/lpc43xx/bambino-200e/configs/netnsh/defconfig
@@ -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
diff --git a/boards/arm/sam34/sam4e-ek/configs/nsh/defconfig b/boards/arm/sam34/sam4e-ek/configs/nsh/defconfig
index 0aed921c2f..4776c8c52b 100644
--- a/boards/arm/sam34/sam4e-ek/configs/nsh/defconfig
+++ b/boards/arm/sam34/sam4e-ek/configs/nsh/defconfig
@@ -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
diff --git a/boards/arm/sam34/sam4e-ek/configs/nxwm/defconfig b/boards/arm/sam34/sam4e-ek/configs/nxwm/defconfig
index d1fbf78e32..71b1032981 100644
--- a/boards/arm/sam34/sam4e-ek/configs/nxwm/defconfig
+++ b/boards/arm/sam34/sam4e-ek/configs/nxwm/defconfig
@@ -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
diff --git a/boards/arm/sam34/sam4e-ek/configs/usbnsh/defconfig b/boards/arm/sam34/sam4e-ek/configs/usbnsh/defconfig
index ba40da82ea..82f1189e39 100644
--- a/boards/arm/sam34/sam4e-ek/configs/usbnsh/defconfig
+++ b/boards/arm/sam34/sam4e-ek/configs/usbnsh/defconfig
@@ -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
diff --git a/boards/arm/stm32/cloudctrl/configs/nsh/defconfig b/boards/arm/stm32/cloudctrl/configs/nsh/defconfig
index 5cd72b7a98..7f311a346a 100644
--- a/boards/arm/stm32/cloudctrl/configs/nsh/defconfig
+++ b/boards/arm/stm32/cloudctrl/configs/nsh/defconfig
@@ -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
diff --git a/boards/arm/stm32/fire-stm32v2/configs/nsh/defconfig b/boards/arm/stm32/fire-stm32v2/configs/nsh/defconfig
index 1bb005f364..ef74b86197 100644
--- a/boards/arm/stm32/fire-stm32v2/configs/nsh/defconfig
+++ b/boards/arm/stm32/fire-stm32v2/configs/nsh/defconfig
@@ -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
diff --git a/boards/arm/stm32/olimex-stm32-e407/configs/discover/defconfig b/boards/arm/stm32/olimex-stm32-e407/configs/discover/defconfig
index eaee0aa150..57f01c3656 100644
--- a/boards/arm/stm32/olimex-stm32-e407/configs/discover/defconfig
+++ b/boards/arm/stm32/olimex-stm32-e407/configs/discover/defconfig
@@ -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
diff --git a/boards/arm/stm32/olimex-stm32-e407/configs/netnsh/defconfig b/boards/arm/stm32/olimex-stm32-e407/configs/netnsh/defconfig
index e76a865267..a28eec4dd3 100644
--- a/boards/arm/stm32/olimex-stm32-e407/configs/netnsh/defconfig
+++ b/boards/arm/stm32/olimex-stm32-e407/configs/netnsh/defconfig
@@ -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
diff --git a/boards/arm/stm32/olimex-stm32-e407/configs/telnetd/defconfig b/boards/arm/stm32/olimex-stm32-e407/configs/telnetd/defconfig
index 8bd778e9a1..618fc0d513 100644
--- a/boards/arm/stm32/olimex-stm32-e407/configs/telnetd/defconfig
+++ b/boards/arm/stm32/olimex-stm32-e407/configs/telnetd/defconfig
@@ -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
diff --git a/boards/arm/stm32/olimex-stm32-e407/configs/webserver/defconfig b/boards/arm/stm32/olimex-stm32-e407/configs/webserver/defconfig
index 2d489b8832..8fcb418f92 100644
--- a/boards/arm/stm32/olimex-stm32-e407/configs/webserver/defconfig
+++ b/boards/arm/stm32/olimex-stm32-e407/configs/webserver/defconfig
@@ -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
diff --git a/boards/arm/stm32/olimex-stm32-p107/configs/nsh/defconfig b/boards/arm/stm32/olimex-stm32-p107/configs/nsh/defconfig
index 9c9d8811d5..0c2215bad8 100644
--- a/boards/arm/stm32/olimex-stm32-p107/configs/nsh/defconfig
+++ b/boards/arm/stm32/olimex-stm32-p107/configs/nsh/defconfig
@@ -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
diff --git a/boards/arm/stm32/shenzhou/configs/nsh/defconfig b/boards/arm/stm32/shenzhou/configs/nsh/defconfig
index b0193bda35..b8e9ee196a 100644
--- a/boards/arm/stm32/shenzhou/configs/nsh/defconfig
+++ b/boards/arm/stm32/shenzhou/configs/nsh/defconfig
@@ -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
diff --git a/boards/arm/stm32/shenzhou/configs/nxwm/defconfig b/boards/arm/stm32/shenzhou/configs/nxwm/defconfig
index 2d88512d76..8e80c6f95a 100644
--- a/boards/arm/stm32/shenzhou/configs/nxwm/defconfig
+++ b/boards/arm/stm32/shenzhou/configs/nxwm/defconfig
@@ -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
diff --git a/boards/arm/stm32/shenzhou/configs/thttpd/defconfig b/boards/arm/stm32/shenzhou/configs/thttpd/defconfig
index 70414c06bb..2df9a74f5e 100644
--- a/boards/arm/stm32/shenzhou/configs/thttpd/defconfig
+++ b/boards/arm/stm32/shenzhou/configs/thttpd/defconfig
@@ -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
diff --git a/boards/arm/stm32/stm3220g-eval/configs/nettest/defconfig b/boards/arm/stm32/stm3220g-eval/configs/nettest/defconfig
index 06254e4bb2..dd5f3d9790 100644
--- a/boards/arm/stm32/stm3220g-eval/configs/nettest/defconfig
+++ b/boards/arm/stm32/stm3220g-eval/configs/nettest/defconfig
@@ -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
diff --git a/boards/arm/stm32/stm3220g-eval/configs/nsh/defconfig b/boards/arm/stm32/stm3220g-eval/configs/nsh/defconfig
index 5cfce6c8da..c2f3c17ef1 100644
--- a/boards/arm/stm32/stm3220g-eval/configs/nsh/defconfig
+++ b/boards/arm/stm32/stm3220g-eval/configs/nsh/defconfig
@@ -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
diff --git a/boards/arm/stm32/stm3220g-eval/configs/nsh2/defconfig b/boards/arm/stm32/stm3220g-eval/configs/nsh2/defconfig
index e71af6c3a8..1078fb44fe 100644
--- a/boards/arm/stm32/stm3220g-eval/configs/nsh2/defconfig
+++ b/boards/arm/stm32/stm3220g-eval/configs/nsh2/defconfig
@@ -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
diff --git a/boards/arm/stm32/stm3220g-eval/configs/nxwm/defconfig b/boards/arm/stm32/stm3220g-eval/configs/nxwm/defconfig
index fb1ce1a428..1eb3b205b7 100644
--- a/boards/arm/stm32/stm3220g-eval/configs/nxwm/defconfig
+++ b/boards/arm/stm32/stm3220g-eval/configs/nxwm/defconfig
@@ -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
diff --git a/boards/arm/stm32/stm3220g-eval/configs/telnetd/defconfig b/boards/arm/stm32/stm3220g-eval/configs/telnetd/defconfig
index cf1cbed82b..f37f078a50 100644
--- a/boards/arm/stm32/stm3220g-eval/configs/telnetd/defconfig
+++ b/boards/arm/stm32/stm3220g-eval/configs/telnetd/defconfig
@@ -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
diff --git a/boards/arm/stm32/stm3240g-eval/configs/discover/defconfig b/boards/arm/stm32/stm3240g-eval/configs/discover/defconfig
index c91b073c9c..4f50a036ce 100644
--- a/boards/arm/stm32/stm3240g-eval/configs/discover/defconfig
+++ b/boards/arm/stm32/stm3240g-eval/configs/discover/defconfig
@@ -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
diff --git a/boards/arm/stm32/stm3240g-eval/configs/nettest/defconfig b/boards/arm/stm32/stm3240g-eval/configs/nettest/defconfig
index 377286c799..507834a9a5 100644
--- a/boards/arm/stm32/stm3240g-eval/configs/nettest/defconfig
+++ b/boards/arm/stm32/stm3240g-eval/configs/nettest/defconfig
@@ -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
diff --git a/boards/arm/stm32/stm3240g-eval/configs/nsh/defconfig b/boards/arm/stm32/stm3240g-eval/configs/nsh/defconfig
index f2b16548e8..a5421e4fa8 100644
--- a/boards/arm/stm32/stm3240g-eval/configs/nsh/defconfig
+++ b/boards/arm/stm32/stm3240g-eval/configs/nsh/defconfig
@@ -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
diff --git a/boards/arm/stm32/stm3240g-eval/configs/nsh2/defconfig b/boards/arm/stm32/stm3240g-eval/configs/nsh2/defconfig
index e0a0c734da..1296ac118a 100644
--- a/boards/arm/stm32/stm3240g-eval/configs/nsh2/defconfig
+++ b/boards/arm/stm32/stm3240g-eval/configs/nsh2/defconfig
@@ -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
diff --git a/boards/arm/stm32/stm3240g-eval/configs/nxterm/defconfig b/boards/arm/stm32/stm3240g-eval/configs/nxterm/defconfig
index 4b1f17f303..43ec247269 100644
--- a/boards/arm/stm32/stm3240g-eval/configs/nxterm/defconfig
+++ b/boards/arm/stm32/stm3240g-eval/configs/nxterm/defconfig
@@ -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
diff --git a/boards/arm/stm32/stm3240g-eval/configs/nxwm/defconfig b/boards/arm/stm32/stm3240g-eval/configs/nxwm/defconfig
index 271233fb6f..1f0cb71624 100644
--- a/boards/arm/stm32/stm3240g-eval/configs/nxwm/defconfig
+++ b/boards/arm/stm32/stm3240g-eval/configs/nxwm/defconfig
@@ -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
diff --git a/boards/arm/stm32/stm3240g-eval/configs/telnetd/defconfig b/boards/arm/stm32/stm3240g-eval/configs/telnetd/defconfig
index 11b4d672f9..5c2429c491 100644
--- a/boards/arm/stm32/stm3240g-eval/configs/telnetd/defconfig
+++ b/boards/arm/stm32/stm3240g-eval/configs/telnetd/defconfig
@@ -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
diff --git a/boards/arm/stm32/stm3240g-eval/configs/webserver/defconfig b/boards/arm/stm32/stm3240g-eval/configs/webserver/defconfig
index 478006924c..ba3d6964d6 100644
--- a/boards/arm/stm32/stm3240g-eval/configs/webserver/defconfig
+++ b/boards/arm/stm32/stm3240g-eval/configs/webserver/defconfig
@@ -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
diff --git a/boards/arm/stm32/stm3240g-eval/configs/xmlrpc/defconfig b/boards/arm/stm32/stm3240g-eval/configs/xmlrpc/defconfig
index e1703134b7..73473c20cc 100644
--- a/boards/arm/stm32/stm3240g-eval/configs/xmlrpc/defconfig
+++ b/boards/arm/stm32/stm3240g-eval/configs/xmlrpc/defconfig
@@ -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
diff --git a/boards/arm/stm32/stm32f4discovery/configs/ether_w5500/defconfig b/boards/arm/stm32/stm32f4discovery/configs/ether_w5500/defconfig
index 5daa1d19ee..ecca5b2c5f 100644
--- a/boards/arm/stm32/stm32f4discovery/configs/ether_w5500/defconfig
+++ b/boards/arm/stm32/stm32f4discovery/configs/ether_w5500/defconfig
@@ -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
diff --git a/boards/arm/stm32/viewtool-stm32f107/configs/netnsh/defconfig b/boards/arm/stm32/viewtool-stm32f107/configs/netnsh/defconfig
index 4dfbe472be..03d5b72c9e 100644
--- a/boards/arm/stm32/viewtool-stm32f107/configs/netnsh/defconfig
+++ b/boards/arm/stm32/viewtool-stm32f107/configs/netnsh/defconfig
@@ -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
diff --git a/boards/arm/stm32/viewtool-stm32f107/configs/tcpblaster/defconfig b/boards/arm/stm32/viewtool-stm32f107/configs/tcpblaster/defconfig
index caa2c442a0..d5c556005c 100644
--- a/boards/arm/stm32/viewtool-stm32f107/configs/tcpblaster/defconfig
+++ b/boards/arm/stm32/viewtool-stm32f107/configs/tcpblaster/defconfig
@@ -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
diff --git a/boards/arm/tiva/eagle100/configs/httpd/defconfig b/boards/arm/tiva/eagle100/configs/httpd/defconfig
index 8993b172ac..3888433b9b 100644
--- a/boards/arm/tiva/eagle100/configs/httpd/defconfig
+++ b/boards/arm/tiva/eagle100/configs/httpd/defconfig
@@ -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
diff --git a/boards/arm/tiva/eagle100/configs/thttpd/defconfig b/boards/arm/tiva/eagle100/configs/thttpd/defconfig
index b724af6798..531b8e7b64 100644
--- a/boards/arm/tiva/eagle100/configs/thttpd/defconfig
+++ b/boards/arm/tiva/eagle100/configs/thttpd/defconfig
@@ -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
diff --git a/boards/arm/tiva/lm3s6965-ek/configs/tcpecho/defconfig b/boards/arm/tiva/lm3s6965-ek/configs/tcpecho/defconfig
index c63aecafeb..c0c55edb03 100644
--- a/boards/arm/tiva/lm3s6965-ek/configs/tcpecho/defconfig
+++ b/boards/arm/tiva/lm3s6965-ek/configs/tcpecho/defconfig
@@ -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
diff --git a/boards/mips/pic32mx/pic32mx-starterkit/configs/nsh2/defconfig b/boards/mips/pic32mx/pic32mx-starterkit/configs/nsh2/defconfig
index 412ac92ce6..51f63ed9a3 100644
--- a/boards/mips/pic32mx/pic32mx-starterkit/configs/nsh2/defconfig
+++ b/boards/mips/pic32mx/pic32mx-starterkit/configs/nsh2/defconfig
@@ -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
diff --git a/boards/mips/pic32mx/pic32mx7mmb/configs/nsh/defconfig b/boards/mips/pic32mx/pic32mx7mmb/configs/nsh/defconfig
index f4650acc55..59196ad95d 100644
--- a/boards/mips/pic32mx/pic32mx7mmb/configs/nsh/defconfig
+++ b/boards/mips/pic32mx/pic32mx7mmb/configs/nsh/defconfig
@@ -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
diff --git a/boards/misoc/lm32/misoc/configs/hello/defconfig b/boards/misoc/lm32/misoc/configs/hello/defconfig
index af50b096d4..98fefeb189 100644
--- a/boards/misoc/lm32/misoc/configs/hello/defconfig
+++ b/boards/misoc/lm32/misoc/configs/hello/defconfig
@@ -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
diff --git a/boards/sim/sim/sim/configs/nettest/defconfig b/boards/sim/sim/sim/configs/nettest/defconfig
index d19c646b6c..e40363dc78 100644
--- a/boards/sim/sim/sim/configs/nettest/defconfig
+++ b/boards/sim/sim/sim/configs/nettest/defconfig
@@ -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
diff --git a/boards/z80/ez80/ez80f910200zco/configs/httpd/defconfig b/boards/z80/ez80/ez80f910200zco/configs/httpd/defconfig
index 4fe7bd471d..5fe1851e79 100644
--- a/boards/z80/ez80/ez80f910200zco/configs/httpd/defconfig
+++ b/boards/z80/ez80/ez80f910200zco/configs/httpd/defconfig
@@ -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
diff --git a/include/nuttx/net/netconfig.h b/include/nuttx/net/netconfig.h
index b2e1b072d2..93e8e80cb8 100644
--- a/include/nuttx/net/netconfig.h
+++ b/include/nuttx/net/netconfig.h
@@ -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.
diff --git a/net/tcp/Kconfig b/net/tcp/Kconfig
index b53c20da74..900fea25b2 100644
--- a/net/tcp/Kconfig
+++ b/net/tcp/Kconfig
@@ -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"
diff --git a/net/tcp/tcp_conn.c b/net/tcp/tcp_conn.c
index 28b2d9c749..e71592b78b 100644
--- a/net/tcp/tcp_conn.c
+++ b/net/tcp/tcp_conn.c
@@ -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();
}
[nuttx] 10/12: Improvements in sockets allocation.
Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 9b4d784307925b39c59f0feaedeee7ade7070012
Author: Fotis Panagiotopoulos <f....@amco.gr>
AuthorDate: Mon Feb 13 18:30:21 2023 +0200
Improvements in sockets allocation.
---
.../lincoln60/configs/thttpd-binfs/defconfig | 2 +-
.../stm32/nucleo-f302r8/configs/cansock/defconfig | 2 +-
.../esp32/esp32-devkitc/configs/audio/defconfig | 2 +-
.../esp32/esp32-devkitc/configs/blewifi/defconfig | 2 +-
.../esp32/esp32-devkitc/configs/coex/defconfig | 2 +-
.../esp32/esp32-devkitc/configs/efuse/defconfig | 2 +-
.../esp32/esp32-devkitc/configs/nxlooper/defconfig | 2 +-
.../esp32/esp32-devkitc/configs/wapi/defconfig | 2 +-
.../esp32/esp32-lyrat/configs/audio/defconfig | 2 +-
.../esp32/esp32-lyrat/configs/wapi/defconfig | 2 +-
include/nuttx/net/netconfig.h | 10 ------
net/devif/devif_callback.c | 38 +++++++++++++++-------
net/socket/Kconfig | 31 +++++++++++++++---
13 files changed, 63 insertions(+), 36 deletions(-)
diff --git a/boards/arm/lpc17xx_40xx/lincoln60/configs/thttpd-binfs/defconfig b/boards/arm/lpc17xx_40xx/lincoln60/configs/thttpd-binfs/defconfig
index a1f7992624..e90ee1dedc 100644
--- a/boards/arm/lpc17xx_40xx/lincoln60/configs/thttpd-binfs/defconfig
+++ b/boards/arm/lpc17xx_40xx/lincoln60/configs/thttpd-binfs/defconfig
@@ -44,7 +44,7 @@ CONFIG_NET_ARP_SEND=y
CONFIG_NET_ICMP=y
CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_MAX_LISTENPORTS=8
-CONFIG_NET_NACTIVESOCKETS=12
+CONFIG_NET_PREALLOC_DEVIF_CALLBACKS=12
CONFIG_NET_SOCKOPTS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
diff --git a/boards/arm/stm32/nucleo-f302r8/configs/cansock/defconfig b/boards/arm/stm32/nucleo-f302r8/configs/cansock/defconfig
index 2553dea628..baf1572ab7 100644
--- a/boards/arm/stm32/nucleo-f302r8/configs/cansock/defconfig
+++ b/boards/arm/stm32/nucleo-f302r8/configs/cansock/defconfig
@@ -35,7 +35,7 @@ CONFIG_NETDEV_IFINDEX=y
CONFIG_NETDEV_LATEINIT=y
CONFIG_NET_CAN=y
CONFIG_NET_CAN_ERRORS=y
-CONFIG_NET_NACTIVESOCKETS=16
+CONFIG_NET_PREALLOC_DEVIF_CALLBACKS=16
CONFIG_NET_SOCKOPTS=y
CONFIG_NET_STATISTICS=y
CONFIG_NSH_BUILTIN_APPS=y
diff --git a/boards/xtensa/esp32/esp32-devkitc/configs/audio/defconfig b/boards/xtensa/esp32/esp32-devkitc/configs/audio/defconfig
index bf62e35fa4..8fbc8481b3 100644
--- a/boards/xtensa/esp32/esp32-devkitc/configs/audio/defconfig
+++ b/boards/xtensa/esp32/esp32-devkitc/configs/audio/defconfig
@@ -83,7 +83,7 @@ CONFIG_NET_BROADCAST=y
CONFIG_NET_ETH_PKTSIZE=1518
CONFIG_NET_ICMP=y
CONFIG_NET_ICMP_SOCKET=y
-CONFIG_NET_NACTIVESOCKETS=32
+CONFIG_NET_PREALLOC_DEVIF_CALLBACKS=32
CONFIG_NET_STATISTICS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCP_DELAYED_ACK=y
diff --git a/boards/xtensa/esp32/esp32-devkitc/configs/blewifi/defconfig b/boards/xtensa/esp32/esp32-devkitc/configs/blewifi/defconfig
index 3b7f1bfa56..8a67773340 100644
--- a/boards/xtensa/esp32/esp32-devkitc/configs/blewifi/defconfig
+++ b/boards/xtensa/esp32/esp32-devkitc/configs/blewifi/defconfig
@@ -57,7 +57,7 @@ CONFIG_NET_BROADCAST=y
CONFIG_NET_ETH_PKTSIZE=1518
CONFIG_NET_ICMP=y
CONFIG_NET_ICMP_SOCKET=y
-CONFIG_NET_NACTIVESOCKETS=32
+CONFIG_NET_PREALLOC_DEVIF_CALLBACKS=32
CONFIG_NET_STATISTICS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCP_DELAYED_ACK=y
diff --git a/boards/xtensa/esp32/esp32-devkitc/configs/coex/defconfig b/boards/xtensa/esp32/esp32-devkitc/configs/coex/defconfig
index e3d402c280..679db90c1f 100644
--- a/boards/xtensa/esp32/esp32-devkitc/configs/coex/defconfig
+++ b/boards/xtensa/esp32/esp32-devkitc/configs/coex/defconfig
@@ -110,7 +110,7 @@ CONFIG_NET_BROADCAST=y
CONFIG_NET_ETH_PKTSIZE=1518
CONFIG_NET_ICMP=y
CONFIG_NET_ICMP_SOCKET=y
-CONFIG_NET_NACTIVESOCKETS=32
+CONFIG_NET_PREALLOC_DEVIF_CALLBACKS=32
CONFIG_NET_STATISTICS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCP_DELAYED_ACK=y
diff --git a/boards/xtensa/esp32/esp32-devkitc/configs/efuse/defconfig b/boards/xtensa/esp32/esp32-devkitc/configs/efuse/defconfig
index 105ac17b9a..3f847f4a3c 100644
--- a/boards/xtensa/esp32/esp32-devkitc/configs/efuse/defconfig
+++ b/boards/xtensa/esp32/esp32-devkitc/configs/efuse/defconfig
@@ -64,7 +64,7 @@ CONFIG_NET_BROADCAST=y
CONFIG_NET_ETH_PKTSIZE=1518
CONFIG_NET_ICMP=y
CONFIG_NET_ICMP_SOCKET=y
-CONFIG_NET_NACTIVESOCKETS=32
+CONFIG_NET_PREALLOC_DEVIF_CALLBACKS=32
CONFIG_NET_STATISTICS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCP_DELAYED_ACK=y
diff --git a/boards/xtensa/esp32/esp32-devkitc/configs/nxlooper/defconfig b/boards/xtensa/esp32/esp32-devkitc/configs/nxlooper/defconfig
index b1f9aa5523..9817112f82 100644
--- a/boards/xtensa/esp32/esp32-devkitc/configs/nxlooper/defconfig
+++ b/boards/xtensa/esp32/esp32-devkitc/configs/nxlooper/defconfig
@@ -84,7 +84,7 @@ CONFIG_NET_BROADCAST=y
CONFIG_NET_ETH_PKTSIZE=1518
CONFIG_NET_ICMP=y
CONFIG_NET_ICMP_SOCKET=y
-CONFIG_NET_NACTIVESOCKETS=32
+CONFIG_NET_PREALLOC_DEVIF_CALLBACKS=32
CONFIG_NET_STATISTICS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCP_DELAYED_ACK=y
diff --git a/boards/xtensa/esp32/esp32-devkitc/configs/wapi/defconfig b/boards/xtensa/esp32/esp32-devkitc/configs/wapi/defconfig
index b385c548ab..0cc0d9a5ea 100644
--- a/boards/xtensa/esp32/esp32-devkitc/configs/wapi/defconfig
+++ b/boards/xtensa/esp32/esp32-devkitc/configs/wapi/defconfig
@@ -52,7 +52,7 @@ CONFIG_NET_BROADCAST=y
CONFIG_NET_ETH_PKTSIZE=1518
CONFIG_NET_ICMP=y
CONFIG_NET_ICMP_SOCKET=y
-CONFIG_NET_NACTIVESOCKETS=32
+CONFIG_NET_PREALLOC_DEVIF_CALLBACKS=32
CONFIG_NET_STATISTICS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCP_DELAYED_ACK=y
diff --git a/boards/xtensa/esp32/esp32-lyrat/configs/audio/defconfig b/boards/xtensa/esp32/esp32-lyrat/configs/audio/defconfig
index 0ada8d4578..a7bf4aafe5 100644
--- a/boards/xtensa/esp32/esp32-lyrat/configs/audio/defconfig
+++ b/boards/xtensa/esp32/esp32-lyrat/configs/audio/defconfig
@@ -83,7 +83,7 @@ CONFIG_NET_BROADCAST=y
CONFIG_NET_ETH_PKTSIZE=1518
CONFIG_NET_ICMP=y
CONFIG_NET_ICMP_SOCKET=y
-CONFIG_NET_NACTIVESOCKETS=32
+CONFIG_NET_PREALLOC_DEVIF_CALLBACKS=32
CONFIG_NET_STATISTICS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCP_DELAYED_ACK=y
diff --git a/boards/xtensa/esp32/esp32-lyrat/configs/wapi/defconfig b/boards/xtensa/esp32/esp32-lyrat/configs/wapi/defconfig
index 85a3511a70..790ed9c53c 100644
--- a/boards/xtensa/esp32/esp32-lyrat/configs/wapi/defconfig
+++ b/boards/xtensa/esp32/esp32-lyrat/configs/wapi/defconfig
@@ -52,7 +52,7 @@ CONFIG_NET_BROADCAST=y
CONFIG_NET_ETH_PKTSIZE=1518
CONFIG_NET_ICMP=y
CONFIG_NET_ICMP_SOCKET=y
-CONFIG_NET_NACTIVESOCKETS=32
+CONFIG_NET_PREALLOC_DEVIF_CALLBACKS=32
CONFIG_NET_STATISTICS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCP_DELAYED_ACK=y
diff --git a/include/nuttx/net/netconfig.h b/include/nuttx/net/netconfig.h
index aa04a949c0..1573a3588e 100644
--- a/include/nuttx/net/netconfig.h
+++ b/include/nuttx/net/netconfig.h
@@ -415,16 +415,6 @@
# define CONFIG_NET_MAX_LISTENPORTS 20
#endif
-/* Define the maximum number of concurrently active UDP and TCP
- * ports. This number must be greater than the number of open
- * sockets in order to support multi-threaded read/write operations.
- */
-
-#ifndef CONFIG_NET_NACTIVESOCKETS
-# define CONFIG_NET_NACTIVESOCKETS (CONFIG_NET_TCP_PREALLOC_CONNS + \
- CONFIG_NET_UDP_PREALLOC_CONNS)
-#endif
-
/* The initial retransmission timeout counted in timer pulses.
* REVISIT: TCP RTO really should be calculated dynamically for each TCP
* connection.
diff --git a/net/devif/devif_callback.c b/net/devif/devif_callback.c
index 68ce2aece4..fac4d5dcbf 100644
--- a/net/devif/devif_callback.c
+++ b/net/devif/devif_callback.c
@@ -43,8 +43,9 @@
* Private Data
****************************************************************************/
-#ifndef CONFIG_NET_ALLOC_CONNS
-static struct devif_callback_s g_cbprealloc[CONFIG_NET_NACTIVESOCKETS];
+#if CONFIG_NET_PREALLOC_DEVIF_CALLBACKS > 0
+static struct devif_callback_s
+ g_cbprealloc[CONFIG_NET_PREALLOC_DEVIF_CALLBACKS];
#endif
static FAR struct devif_callback_s *g_cbfreelist = NULL;
@@ -164,11 +165,24 @@ static void devif_callback_free(FAR struct net_driver_s *dev,
}
}
- /* Put the structure into the free list */
+ /* If this is a preallocated or a batch allocated callback store it in
+ * the free callbacks list. Else free it.
+ */
+
+#if CONFIG_NET_ALLOC_DEVIF_CALLBACKS == 1
+ if (cb < g_cbprealloc || cb >= (g_cbprealloc +
+ CONFIG_NET_PREALLOC_DEVIF_CALLBACKS))
+ {
+ kmm_free(cb);
+ }
+ else
+#endif
+ {
+ cb->nxtconn = g_cbfreelist;
+ cb->nxtdev = NULL;
+ g_cbfreelist = cb;
+ }
- cb->nxtconn = g_cbfreelist;
- cb->nxtdev = NULL;
- g_cbfreelist = cb;
net_unlock();
}
}
@@ -230,10 +244,10 @@ static bool devif_event_trigger(uint16_t events, uint16_t triggers)
void devif_callback_init(void)
{
-#ifndef CONFIG_NET_ALLOC_CONNS
+#if CONFIG_NET_PREALLOC_DEVIF_CALLBACKS > 0
int i;
- for (i = 0; i < CONFIG_NET_NACTIVESOCKETS; i++)
+ for (i = 0; i < CONFIG_NET_PREALLOC_DEVIF_CALLBACKS; i++)
{
g_cbprealloc[i].nxtconn = g_cbfreelist;
g_cbfreelist = &g_cbprealloc[i];
@@ -263,7 +277,7 @@ FAR struct devif_callback_s *
FAR struct devif_callback_s **list_tail)
{
FAR struct devif_callback_s *ret;
-#ifdef CONFIG_NET_ALLOC_CONNS
+#if CONFIG_NET_ALLOC_DEVIF_CALLBACKS > 0
int i;
#endif
@@ -290,14 +304,14 @@ FAR struct devif_callback_s *
/* Allocate the callback entry from heap */
-#ifdef CONFIG_NET_ALLOC_CONNS
+#if CONFIG_NET_ALLOC_DEVIF_CALLBACKS > 0
if (g_cbfreelist == NULL)
{
ret = kmm_zalloc(sizeof(struct devif_callback_s) *
- CONFIG_NET_NACTIVESOCKETS);
+ CONFIG_NET_ALLOC_DEVIF_CALLBACKS);
if (ret != NULL)
{
- for (i = 0; i < CONFIG_NET_NACTIVESOCKETS; i++)
+ for (i = 0; i < CONFIG_NET_ALLOC_DEVIF_CALLBACKS; i++)
{
ret[i].nxtconn = g_cbfreelist;
g_cbfreelist = &ret[i];
diff --git a/net/socket/Kconfig b/net/socket/Kconfig
index 3dc7002099..153ff79cf7 100644
--- a/net/socket/Kconfig
+++ b/net/socket/Kconfig
@@ -5,13 +5,36 @@
menu "Socket Support"
-config NET_NACTIVESOCKETS
- int "Max socket operations"
+config NET_PREALLOC_DEVIF_CALLBACKS
+ int "Preallocated socket callbacks"
default 16 if !DEFAULT_SMALL
default 4 if DEFAULT_SMALL
---help---
- Maximum number of concurrent socket operations (recv, send,
- connection monitoring, etc.). Default: 16
+ Number of preallocated socket callbacks (all tasks).
+
+ This number of callbacks will be pre-allocated during system boot.
+ If dynamic callbacks allocation is enabled, more callbacks may be
+ allocated at a later time, as the system needs them. Else this
+ will be the maximum number of callbacks available to the system
+ at all times.
+
+ Set to 0 to disable (and rely only on dynamic allocations).
+
+config NET_ALLOC_DEVIF_CALLBACKS
+ int "Dynamic socket callbacks allocation"
+ default 0
+ ---help---
+ Dynamic memory allocations for socket callbacks.
+
+ When set to 0 all dynamic allocations are disabled.
+
+ When set to 1 a new callback will be allocated every time, and
+ it will be free'd when no longer needed.
+
+ Setting this to 2 or more will allocate the callbacks in batches
+ (with batch size equal to this config). When a callback is no
+ longer needed, it will be returned to the free callbacks pool,
+ and it will never be deallocated!
config NET_SOCKOPTS
bool "Socket options"
[nuttx] 08/12: Improvements in packet connections allocation.
Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 74bb921a19f2ea710f53745ae428077ddd462c01
Author: Fotis Panagiotopoulos <f....@amco.gr>
AuthorDate: Mon Feb 13 15:05:40 2023 +0200
Improvements in packet connections allocation.
---
net/pkt/Kconfig | 41 +++++++++++++++++++++++++++++++++++++++--
net/pkt/pkt_conn.c | 42 ++++++++++++++++++++++++++++++++----------
2 files changed, 71 insertions(+), 12 deletions(-)
diff --git a/net/pkt/Kconfig b/net/pkt/Kconfig
index 578cf69267..282a9429a9 100644
--- a/net/pkt/Kconfig
+++ b/net/pkt/Kconfig
@@ -22,9 +22,46 @@ config NET_PKT
if NET_PKT
-config NET_PKT_CONNS
- int "Max packet sockets"
+config NET_PKT_PREALLOC_CONNS
+ int "Preallocated packet sockets"
default 1
+ ---help---
+ Number of packet 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_PKT_ALLOC_CONNS
+ int "Dynamic packet connections allocation"
+ default 0
+ ---help---
+ Dynamic memory allocations for packet sockets.
+
+ 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_PKT_MAX_CONNS
+ int "Maximum number of packet connections"
+ default 0
+ depends on NET_PKT_ALLOC_CONNS > 0
+ ---help---
+ If dynamic connections allocation is selected (NET_PKT_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.
endif # NET_PKT
endmenu # Raw Socket Support
diff --git a/net/pkt/pkt_conn.c b/net/pkt/pkt_conn.c
index 5392861d13..a7663a764e 100644
--- a/net/pkt/pkt_conn.c
+++ b/net/pkt/pkt_conn.c
@@ -56,8 +56,8 @@
/* The array containing all packet socket connections */
-#ifndef CONFIG_NET_ALLOC_CONNS
-static struct pkt_conn_s g_pkt_connections[CONFIG_NET_PKT_CONNS];
+#if CONFIG_NET_PKT_PREALLOC_CONNS > 0
+static struct pkt_conn_s g_pkt_connections[CONFIG_NET_PKT_PREALLOC_CONNS];
#endif
/* A list of all free packet socket connections */
@@ -84,10 +84,10 @@ static dq_queue_t g_active_pkt_connections;
void pkt_initialize(void)
{
-#ifndef CONFIG_NET_ALLOC_CONNS
+#if CONFIG_NET_PKT_PREALLOC_CONNS > 0
int i;
- for (i = 0; i < CONFIG_NET_PKT_CONNS; i++)
+ for (i = 0; i < CONFIG_NET_PKT_PREALLOC_CONNS; i++)
{
dq_addlast(&g_pkt_connections[i].sconn.node, &g_free_pkt_connections);
}
@@ -106,20 +106,29 @@ void pkt_initialize(void)
FAR struct pkt_conn_s *pkt_alloc(void)
{
FAR struct pkt_conn_s *conn;
-#ifdef CONFIG_NET_ALLOC_CONNS
+#if CONFIG_NET_PKT_ALLOC_CONNS > 0
int i;
#endif
/* The free list is protected by a mutex. */
nxmutex_lock(&g_free_lock);
-#ifdef CONFIG_NET_ALLOC_CONNS
+#if CONFIG_NET_PKT_ALLOC_CONNS > 0
if (dq_peek(&g_free_pkt_connections) == NULL)
{
- conn = kmm_zalloc(sizeof(*conn) * CONFIG_NET_PKT_CONNS);
+#if CONFIG_NET_PKT_MAX_CONNS > 0
+ if (dq_count(&g_active_pkt_connections) + CONFIG_NET_PKT_ALLOC_CONNS
+ >= CONFIG_NET_PKT_MAX_CONNS)
+ {
+ nxmutex_unlock(&g_free_lock);
+ return NULL;
+ }
+#endif
+
+ conn = kmm_zalloc(sizeof(*conn) * CONFIG_NET_PKT_ALLOC_CONNS);
if (conn != NULL)
{
- for (i = 0; i < CONFIG_NET_PKT_CONNS; i++)
+ for (i = 0; i < CONFIG_NET_PKT_ALLOC_CONNS; i++)
{
dq_addlast(&conn[i].sconn.node, &g_free_pkt_connections);
}
@@ -164,9 +173,22 @@ void pkt_free(FAR struct pkt_conn_s *conn)
memset(conn, 0, sizeof(*conn));
- /* Free the connection */
+ /* If this is a preallocated or a batch allocated connection store it in
+ * the free connections list. Else free it.
+ */
+
+#if CONFIG_NET_PKT_ALLOC_CONNS == 1
+ if (conn < g_pkt_connections || conn >= (g_pkt_connections +
+ CONFIG_NET_PKT_PREALLOC_CONNS))
+ {
+ kmm_free(conn);
+ }
+ else
+#endif
+ {
+ dq_addlast(&conn->sconn.node, &g_free_pkt_connections);
+ }
- dq_addlast(&conn->sconn.node, &g_free_pkt_connections);
nxmutex_unlock(&g_free_lock);
}
[nuttx] 03/12: Improvements in usrsock connections allocation.
Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit f207072121eee08c448c5b47f177094cf1fb3935
Author: Fotis Panagiotopoulos <f....@amco.gr>
AuthorDate: Tue Feb 7 14:59:36 2023 +0200
Improvements in usrsock connections allocation.
---
.../arm/cxd56xx/spresense/configs/wifi/defconfig | 2 +-
.../cxd56xx/spresense/configs/wifi_smp/defconfig | 2 +-
.../stm32/stm32f4discovery/configs/wifi/defconfig | 2 +-
include/nuttx/net/netconfig.h | 12 ------
net/usrsock/Kconfig | 41 +++++++++++++++++++--
net/usrsock/usrsock_conn.c | 43 +++++++++++++++++-----
6 files changed, 74 insertions(+), 28 deletions(-)
diff --git a/boards/arm/cxd56xx/spresense/configs/wifi/defconfig b/boards/arm/cxd56xx/spresense/configs/wifi/defconfig
index 241819e3e8..2a280f9ec6 100644
--- a/boards/arm/cxd56xx/spresense/configs/wifi/defconfig
+++ b/boards/arm/cxd56xx/spresense/configs/wifi/defconfig
@@ -104,7 +104,7 @@ CONFIG_NETUTILS_TELNETD=y
CONFIG_NETUTILS_WEBCLIENT=y
CONFIG_NETUTILS_WEBSERVER=y
CONFIG_NET_USRSOCK=y
-CONFIG_NET_USRSOCK_CONNS=16
+CONFIG_NET_USRSOCK_PREALLOC_CONNS=16
CONFIG_NET_USRSOCK_UDP=y
CONFIG_NFS=y
CONFIG_NSH_ARCHINIT=y
diff --git a/boards/arm/cxd56xx/spresense/configs/wifi_smp/defconfig b/boards/arm/cxd56xx/spresense/configs/wifi_smp/defconfig
index 679cd4b2eb..c90d757cd9 100644
--- a/boards/arm/cxd56xx/spresense/configs/wifi_smp/defconfig
+++ b/boards/arm/cxd56xx/spresense/configs/wifi_smp/defconfig
@@ -107,7 +107,7 @@ CONFIG_NETUTILS_TELNETD=y
CONFIG_NETUTILS_WEBCLIENT=y
CONFIG_NETUTILS_WEBSERVER=y
CONFIG_NET_USRSOCK=y
-CONFIG_NET_USRSOCK_CONNS=16
+CONFIG_NET_USRSOCK_PREALLOC_CONNS=16
CONFIG_NET_USRSOCK_UDP=y
CONFIG_NFS=y
CONFIG_NSH_ARCHINIT=y
diff --git a/boards/arm/stm32/stm32f4discovery/configs/wifi/defconfig b/boards/arm/stm32/stm32f4discovery/configs/wifi/defconfig
index a4c7134d82..549f12d456 100644
--- a/boards/arm/stm32/stm32f4discovery/configs/wifi/defconfig
+++ b/boards/arm/stm32/stm32f4discovery/configs/wifi/defconfig
@@ -55,7 +55,7 @@ CONFIG_NETUTILS_TELNETD=y
CONFIG_NETUTILS_WEBCLIENT=y
CONFIG_NETUTILS_WEBSERVER=y
CONFIG_NET_USRSOCK=y
-CONFIG_NET_USRSOCK_CONNS=16
+CONFIG_NET_USRSOCK_PREALLOC_CONNS=16
CONFIG_NET_USRSOCK_UDP=y
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_BUILTIN_APPS=y
diff --git a/include/nuttx/net/netconfig.h b/include/nuttx/net/netconfig.h
index 732bc5d00f..aa04a949c0 100644
--- a/include/nuttx/net/netconfig.h
+++ b/include/nuttx/net/netconfig.h
@@ -631,18 +631,6 @@
# define CONFIG_NET_ARP_MAXAGE 120
#endif
-/* Usrsock configuration options */
-
-/* The maximum amount of concurrent usrsock connections, Default: 6 */
-
-#ifndef CONFIG_NET_USRSOCK_CONNS
-# ifdef CONFIG_NET_USRSOCK
-# define CONFIG_NET_USRSOCK_CONNS 6
-# else
-# define CONFIG_NET_USRSOCK_CONNS 0
-# endif
-#endif
-
/****************************************************************************
* Public Type Definitions
****************************************************************************/
diff --git a/net/usrsock/Kconfig b/net/usrsock/Kconfig
index 136b053de6..f50a366721 100644
--- a/net/usrsock/Kconfig
+++ b/net/usrsock/Kconfig
@@ -25,15 +25,50 @@ config NET_USRSOCK
if NET_USRSOCK
-config NET_USRSOCK_CONNS
- int "Number of usrsock connections"
+config NET_USRSOCK_PREALLOC_CONNS
+ int "Preallocated usrsock connections"
default 6
---help---
- Maximum number of usrsock connections (all tasks).
+ Number of usrsock 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).
Note: Usrsock daemon can impose additional restrictions for
maximum number of concurrent connections supported.
+config NET_USRSOCK_ALLOC_CONNS
+ int "Dynamic usrsock connections allocation"
+ default 0
+ ---help---
+ Dynamic memory allocations for usrsock.
+
+ 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_USRSOCK_MAX_CONNS
+ int "Maximum number of usrsock connections"
+ default 0
+ depends on NET_USRSOCK_ALLOC_CONNS > 0
+ ---help---
+ If dynamic connections allocation is selected (NET_USRSOCK_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_USRSOCK_NPOLLWAITERS
int "Number of usrsock poll waiters"
default 1
diff --git a/net/usrsock/usrsock_conn.c b/net/usrsock/usrsock_conn.c
index 5b4ae2463d..675a3ca3f7 100644
--- a/net/usrsock/usrsock_conn.c
+++ b/net/usrsock/usrsock_conn.c
@@ -48,8 +48,9 @@
/* The array containing all usrsock connections. */
-#ifndef CONFIG_NET_ALLOC_CONNS
-static struct usrsock_conn_s g_usrsock_connections[CONFIG_NET_USRSOCK_CONNS];
+#if CONFIG_NET_USRSOCK_PREALLOC_CONNS > 0
+static struct usrsock_conn_s
+ g_usrsock_connections[CONFIG_NET_USRSOCK_PREALLOC_CONNS];
#endif
/* A list of all free usrsock connections */
@@ -77,20 +78,29 @@ static dq_queue_t g_active_usrsock_connections;
FAR struct usrsock_conn_s *usrsock_alloc(void)
{
FAR struct usrsock_conn_s *conn;
-#ifdef CONFIG_NET_ALLOC_CONNS
+#if CONFIG_NET_USRSOCK_ALLOC_CONNS > 0
int i;
#endif
/* The free list is protected by a a mutex. */
nxmutex_lock(&g_free_lock);
-#ifdef CONFIG_NET_ALLOC_CONNS
+#if CONFIG_NET_USRSOCK_ALLOC_CONNS > 0
if (dq_peek(&g_free_usrsock_connections) == NULL)
{
- conn = kmm_zalloc(sizeof(*conn) * CONFIG_NET_USRSOCK_CONNS);
+#if CONFIG_NET_USRSOCK_MAX_CONNS > 0
+ if (dq_count(&g_active_usrsock_connections) +
+ CONFIG_NET_USRSOCK_ALLOC_CONNS >= CONFIG_NET_USRSOCK_MAX_CONNS)
+ {
+ nxmutex_unlock(&g_free_lock);
+ return NULL;
+ }
+#endif
+
+ conn = kmm_zalloc(sizeof(*conn) * CONFIG_NET_USRSOCK_ALLOC_CONNS);
if (conn != NULL)
{
- for (i = 0; i < CONFIG_NET_USRSOCK_CONNS; i++)
+ for (i = 0; i < CONFIG_NET_USRSOCK_ALLOC_CONNS; i++)
{
dq_addlast(&conn[i].sconn.node, &g_free_usrsock_connections);
}
@@ -143,9 +153,22 @@ void usrsock_free(FAR struct usrsock_conn_s *conn)
nxsem_destroy(&conn->resp.sem);
memset(conn, 0, sizeof(*conn));
- /* Free the connection */
+ /* If this is a preallocated or a batch allocated connection store it in
+ * the free connections list. Else free it.
+ */
+
+#if CONFIG_NET_USRSOCK_ALLOC_CONNS == 1
+ if (conn < g_usrsock_connections || conn >= (g_usrsock_connections +
+ CONFIG_NET_USRSOCK_PREALLOC_CONNS))
+ {
+ kmm_free(conn);
+ }
+ else
+#endif
+ {
+ dq_addlast(&conn->sconn.node, &g_free_usrsock_connections);
+ }
- dq_addlast(&conn->sconn.node, &g_free_usrsock_connections);
nxmutex_unlock(&g_free_lock);
}
@@ -309,11 +332,11 @@ void usrsock_setup_datain(FAR struct usrsock_conn_s *conn,
void usrsock_initialize(void)
{
-#ifndef CONFIG_NET_ALLOC_CONNS
+#if CONFIG_NET_USRSOCK_PREALLOC_CONNS > 0
FAR struct usrsock_conn_s *conn;
int i;
- for (i = 0; i < CONFIG_NET_USRSOCK_CONNS; i++)
+ for (i = 0; i < CONFIG_NET_USRSOCK_PREALLOC_CONNS; i++)
{
conn = &g_usrsock_connections[i];
[nuttx] 06/12: Improvements in Bluetooth connections allocation.
Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit c5cc70a8b176680ffcbcd0ee6a5f4d1ef687c372
Author: Fotis Panagiotopoulos <f....@amco.gr>
AuthorDate: Sat Feb 11 16:50:03 2023 +0200
Improvements in Bluetooth connections allocation.
---
net/bluetooth/Kconfig | 41 +++++++++++++++++++++++++++++++++++++++--
net/bluetooth/bluetooth_conn.c | 42 +++++++++++++++++++++++++++++++-----------
2 files changed, 70 insertions(+), 13 deletions(-)
diff --git a/net/bluetooth/Kconfig b/net/bluetooth/Kconfig
index 65e8e5d804..768a6396da 100644
--- a/net/bluetooth/Kconfig
+++ b/net/bluetooth/Kconfig
@@ -22,9 +22,46 @@ config NET_BLUETOOTH
if NET_BLUETOOTH
-config NET_BLUETOOTH_NCONNS
- int "Max Bluetooth sockets"
+config NET_BLUETOOTH_PREALLOC_CONNS
+ int "Preallocated Bluetooth sockets"
default 4
+ ---help---
+ Number of Bluetooth 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_BLUETOOTH_ALLOC_CONNS
+ int "Dynamic Bluetooth connections allocation"
+ default 0
+ ---help---
+ Dynamic memory allocations for Bluetooth.
+
+ 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_BLUETOOTH_MAX_CONNS
+ int "Maximum number of Bluetooth connections"
+ default 0
+ depends on NET_BLUETOOTH_ALLOC_CONNS > 0
+ ---help---
+ If dynamic connections allocation is selected (NET_BLUETOOTH_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_BLUETOOTH_NCONTAINERS
int "Number of pre-allocated frame containers"
diff --git a/net/bluetooth/bluetooth_conn.c b/net/bluetooth/bluetooth_conn.c
index d5c086fb82..9851710d9b 100644
--- a/net/bluetooth/bluetooth_conn.c
+++ b/net/bluetooth/bluetooth_conn.c
@@ -52,9 +52,9 @@
* network lock.
*/
-#ifndef CONFIG_NET_ALLOC_CONNS
+#if CONFIG_NET_BLUETOOTH_PREALLOC_CONNS > 0
static struct bluetooth_conn_s
- g_bluetooth_connections[CONFIG_NET_BLUETOOTH_NCONNS];
+ g_bluetooth_connections[CONFIG_NET_BLUETOOTH_PREALLOC_CONNS];
#endif
/* A list of all free packet socket connections */
@@ -88,10 +88,10 @@ static const bt_addr_t g_any_addr =
void bluetooth_conn_initialize(void)
{
-#ifndef CONFIG_NET_ALLOC_CONNS
+#if CONFIG_NET_BLUETOOTH_PREALLOC_CONNS > 0
int i;
- for (i = 0; i < CONFIG_NET_BLUETOOTH_NCONNS; i++)
+ for (i = 0; i < CONFIG_NET_BLUETOOTH_PREALLOC_CONNS; i++)
{
/* Link each pre-allocated connection structure into the free list. */
@@ -113,20 +113,29 @@ void bluetooth_conn_initialize(void)
FAR struct bluetooth_conn_s *bluetooth_conn_alloc(void)
{
FAR struct bluetooth_conn_s *conn;
-#ifdef CONFIG_NET_ALLOC_CONNS
+#if CONFIG_NET_BLUETOOTH_ALLOC_CONNS > 0
int i;
#endif
/* The free list is protected by the network lock */
net_lock();
-#ifdef CONFIG_NET_ALLOC_CONNS
+#if CONFIG_NET_BLUETOOTH_ALLOC_CONNS > 0
if (dq_peek(&g_active_bluetooth_connections) == NULL)
{
- conn = kmm_zalloc(sizeof(*conn) * CONFIG_NET_BLUETOOTH_NCONNS);
+#if CONFIG_NET_BLUETOOTH_MAX_CONNS > 0
+ if (dq_count(&g_active_bluetooth_connections) +
+ CONFIG_NET_BLUETOOTH_ALLOC_CONNS >= CONFIG_NET_BLUETOOTH_MAX_CONNS)
+ {
+ net_unlock();
+ return NULL;
+ }
+#endif
+
+ conn = kmm_zalloc(sizeof(*conn) * CONFIG_NET_BLUETOOTH_ALLOC_CONNS);
if (conn != NULL)
{
- for (i = 0; i < CONFIG_NET_BLUETOOTH_NCONNS; i++)
+ for (i = 0; i < CONFIG_NET_BLUETOOTH_ALLOC_CONNS; i++)
{
dq_addlast(&conn[i].bc_conn.node,
&g_active_bluetooth_connections);
@@ -200,9 +209,20 @@ void bluetooth_conn_free(FAR struct bluetooth_conn_s *conn)
memset(conn, 0, sizeof(*conn));
- /* Free the connection */
-
- dq_addlast(&conn->bc_conn.node, &g_free_bluetooth_connections);
+ /* If this is a preallocated or a batch allocated connection store it in
+ * the free connections list. Else free it.
+ */
+#if CONFIG_NET_BLUETOOTH_ALLOC_CONNS == 1
+ if (conn < g_bluetooth_connections || conn >= (g_bluetooth_connections +
+ CONFIG_NET_BLUETOOTH_PREALLOC_CONNS))
+ {
+ kmm_free(conn);
+ }
+ else
+#endif
+ {
+ dq_addlast(&conn->bc_conn.node, &g_free_bluetooth_connections);
+ }
net_unlock();
}
[nuttx] 09/12: Improvements in Netlink connections allocation.
Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit cf15d6b63ade66b2b811866d71a0bfe901d312ee
Author: Fotis Panagiotopoulos <f....@amco.gr>
AuthorDate: Mon Feb 13 16:57:17 2023 +0200
Improvements in Netlink connections allocation.
---
net/netlink/Kconfig | 41 ++++++++++++++++++++++++++++++++++++++---
net/netlink/netlink_conn.c | 43 +++++++++++++++++++++++++++++++++----------
2 files changed, 71 insertions(+), 13 deletions(-)
diff --git a/net/netlink/Kconfig b/net/netlink/Kconfig
index d92efeff03..0a07a04364 100644
--- a/net/netlink/Kconfig
+++ b/net/netlink/Kconfig
@@ -22,11 +22,46 @@ config NET_NETLINK
if NET_NETLINK
-config NETLINK_CONNS
- int "Number of Netlink connections"
+config NETLINK_PREALLOC_CONNS
+ int "Preallocated Netlink connections"
default 4
---help---
- Maximum number of Netlink connections (all tasks).
+ Number of Netlink 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 NETLINK_ALLOC_CONNS
+ int "Dynamic Netlink connections allocation"
+ default 0
+ ---help---
+ Dynamic memory allocations for Netlink.
+
+ 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 NETLINK_MAX_CONNS
+ int "Maximum number of Netlink connections"
+ default 0
+ depends on NETLINK_ALLOC_CONNS > 0
+ ---help---
+ If dynamic connections allocation is selected (NETLINK_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.
menu "Netlink Protocols"
diff --git a/net/netlink/netlink_conn.c b/net/netlink/netlink_conn.c
index 772b733eb9..443e004b0b 100644
--- a/net/netlink/netlink_conn.c
+++ b/net/netlink/netlink_conn.c
@@ -51,8 +51,9 @@
/* The array containing all NetLink connections. */
-#ifndef CONFIG_NET_ALLOC_CONNS
-static struct netlink_conn_s g_netlink_connections[CONFIG_NETLINK_CONNS];
+#if CONFIG_NETLINK_PREALLOC_CONNS > 0
+static struct netlink_conn_s
+ g_netlink_connections[CONFIG_NETLINK_PREALLOC_CONNS];
#endif
/* A list of all free NetLink connections */
@@ -106,10 +107,10 @@ static void netlink_response_available(FAR void *arg)
void netlink_initialize(void)
{
-#ifndef CONFIG_NET_ALLOC_CONNS
+#if CONFIG_NETLINK_PREALLOC_CONNS > 0
int i;
- for (i = 0; i < CONFIG_NETLINK_CONNS; i++)
+ for (i = 0; i < CONFIG_NETLINK_PREALLOC_CONNS; i++)
{
/* Mark the connection closed and move it to the free list */
@@ -131,20 +132,29 @@ void netlink_initialize(void)
FAR struct netlink_conn_s *netlink_alloc(void)
{
FAR struct netlink_conn_s *conn;
-#ifdef CONFIG_NET_ALLOC_CONNS
+#if CONFIG_NETLINK_ALLOC_CONNS > 0
int i;
#endif
/* The free list is protected by a mutex. */
nxmutex_lock(&g_free_lock);
-#ifdef CONFIG_NET_ALLOC_CONNS
+#if CONFIG_NETLINK_ALLOC_CONNS > 0
if (dq_peek(&g_free_netlink_connections) == NULL)
{
- conn = kmm_zalloc(sizeof(*conn) * CONFIG_NETLINK_CONNS);
+#if CONFIG_NETLINK_MAX_CONNS > 0
+ if (dq_count(&g_active_netlink_connections) +
+ CONFIG_NETLINK_ALLOC_CONNS >= CONFIG_NETLINK_MAX_CONNS)
+ {
+ nxmutex_unlock(&g_free_lock);
+ return NULL;
+ }
+#endif
+
+ conn = kmm_zalloc(sizeof(*conn) * CONFIG_NETLINK_ALLOC_CONNS);
if (conn != NULL)
{
- for (i = 0; i < CONFIG_NETLINK_CONNS; i++)
+ for (i = 0; i < CONFIG_NETLINK_ALLOC_CONNS; i++)
{
dq_addlast(&conn[i].sconn.node, &g_free_netlink_connections);
}
@@ -199,9 +209,22 @@ void netlink_free(FAR struct netlink_conn_s *conn)
memset(conn, 0, sizeof(*conn));
- /* Free the connection */
+ /* If this is a preallocated or a batch allocated connection store it in
+ * the free connections list. Else free it.
+ */
+
+#if CONFIG_NETLINK_ALLOC_CONNS == 1
+ if (conn < g_netlink_connections || conn >= (g_netlink_connections +
+ CONFIG_NETLINK_PREALLOC_CONNS))
+ {
+ kmm_free(conn);
+ }
+ else
+#endif
+ {
+ dq_addlast(&conn->sconn.node, &g_free_netlink_connections);
+ }
- dq_addlast(&conn->sconn.node, &g_free_netlink_connections);
nxmutex_unlock(&g_free_lock);
}
[nuttx] 05/12: Improvements in ICMPv6 connections allocation.
Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 90a93a747412aa26df1ce91a8fa4a294ba503bd3
Author: Fotis Panagiotopoulos <f....@amco.gr>
AuthorDate: Sat Feb 11 15:09:01 2023 +0200
Improvements in ICMPv6 connections allocation.
---
net/icmpv6/Kconfig | 41 +++++++++++++++++++++++++++++++++++++++--
net/icmpv6/icmpv6_conn.c | 40 +++++++++++++++++++++++++++++++---------
2 files changed, 70 insertions(+), 11 deletions(-)
diff --git a/net/icmpv6/Kconfig b/net/icmpv6/Kconfig
index 248f0224f0..471204b981 100644
--- a/net/icmpv6/Kconfig
+++ b/net/icmpv6/Kconfig
@@ -200,9 +200,46 @@ endif # NET_ICMPv6_ROUTER
if NET_ICMPv6_SOCKET
-config NET_ICMPv6_NCONNS
- int "Max ICMPv6 packet sockets"
+config NET_ICMPv6_PREALLOC_CONNS
+ int "Preallocated ICMPv6 packet sockets"
default 4
+ ---help---
+ Number of ICMPv6 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_ICMPv6_ALLOC_CONNS
+ int "Dynamic ICMPv6 connections allocation"
+ default 0
+ ---help---
+ Dynamic memory allocations for ICMPv6.
+
+ 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_ICMPv6_MAX_CONNS
+ int "Maximum number of ICMPv6 connections"
+ default 0
+ depends on NET_ICMPv6_ALLOC_CONNS > 0
+ ---help---
+ If dynamic connections allocation is selected (NET_ICMPv6_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_ICMPv6_NPOLLWAITERS
int "Number of ICMPv6 poll waiters"
diff --git a/net/icmpv6/icmpv6_conn.c b/net/icmpv6/icmpv6_conn.c
index b10e7daf3d..4299fb62ac 100644
--- a/net/icmpv6/icmpv6_conn.c
+++ b/net/icmpv6/icmpv6_conn.c
@@ -48,8 +48,9 @@
/* The array containing all IPPROTO_ICMP socket connections */
-#ifndef CONFIG_NET_ALLOC_CONNS
-static struct icmpv6_conn_s g_icmpv6_connections[CONFIG_NET_ICMPv6_NCONNS];
+#if CONFIG_NET_ICMPv6_PREALLOC_CONNS > 0
+static struct icmpv6_conn_s
+ g_icmpv6_connections[CONFIG_NET_ICMPv6_PREALLOC_CONNS];
#endif
/* A list of all free IPPROTO_ICMP socket connections */
@@ -76,10 +77,10 @@ static dq_queue_t g_active_icmpv6_connections;
void icmpv6_sock_initialize(void)
{
-#ifndef CONFIG_NET_ALLOC_CONNS
+#if CONFIG_NET_ICMPv6_PREALLOC_CONNS > 0
int i;
- for (i = 0; i < CONFIG_NET_ICMPv6_NCONNS; i++)
+ for (i = 0; i < CONFIG_NET_ICMPv6_PREALLOC_CONNS; i++)
{
/* Move the connection structure to the free list */
@@ -109,13 +110,22 @@ FAR struct icmpv6_conn_s *icmpv6_alloc(void)
ret = nxmutex_lock(&g_free_lock);
if (ret >= 0)
{
-#ifdef CONFIG_NET_ALLOC_CONNS
+#if CONFIG_NET_ICMPv6_ALLOC_CONNS > 0
if (dq_peek(&g_active_icmpv6_connections) == NULL)
{
- conn = kmm_zalloc(sizeof(*conn) * CONFIG_NET_ICMPv6_NCONNS);
+#if CONFIG_NET_ICMPv6_MAX_CONNS > 0
+ if (dq_count(&g_active_icmpv6_connections) +
+ CONFIG_NET_ICMPv6_ALLOC_CONNS >= CONFIG_NET_ICMPv6_MAX_CONNS)
+ {
+ nxmutex_unlock(&g_free_lock);
+ return NULL;
+ }
+#endif
+
+ conn = kmm_zalloc(sizeof(*conn) * CONFIG_NET_ICMPv6_ALLOC_CONNS);
if (conn != NULL)
{
- for (ret = 0; ret < CONFIG_NET_ICMPv6_NCONNS; ret++)
+ for (ret = 0; ret < CONFIG_NET_ICMPv6_ALLOC_CONNS; ret++)
{
dq_addlast(&conn[ret].sconn.node,
&g_free_icmpv6_connections);
@@ -166,9 +176,21 @@ void icmpv6_free(FAR struct icmpv6_conn_s *conn)
memset(conn, 0, sizeof(*conn));
- /* Free the connection */
+ /* If this is a preallocated or a batch allocated connection store it in
+ * the free connections list. Else free it.
+ */
+#if CONFIG_NET_ICMPv6_ALLOC_CONNS == 1
+ if (conn < g_icmpv6_connections || conn >= (g_icmpv6_connections +
+ CONFIG_NET_ICMPv6_PREALLOC_CONNS))
+ {
+ kmm_free(conn);
+ }
+ else
+#endif
+ {
+ dq_addlast(&conn->sconn.node, &g_free_icmpv6_connections);
+ }
- dq_addlast(&conn->sconn.node, &g_free_icmpv6_connections);
nxmutex_unlock(&g_free_lock);
}
[nuttx] 04/12: Improvements in ICMP connections allocation.
Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 1c07a3a696acfcdf7fc48063994bf64a5783063f
Author: Fotis Panagiotopoulos <f....@amco.gr>
AuthorDate: Tue Feb 7 19:02:52 2023 +0200
Improvements in ICMP connections allocation.
---
net/icmp/Kconfig | 41 +++++++++++++++++++++++++++++++++++++++--
net/icmp/icmp_conn.c | 39 ++++++++++++++++++++++++++++++---------
2 files changed, 69 insertions(+), 11 deletions(-)
diff --git a/net/icmp/Kconfig b/net/icmp/Kconfig
index 8ce7ceaa77..5cee9de515 100644
--- a/net/icmp/Kconfig
+++ b/net/icmp/Kconfig
@@ -32,9 +32,46 @@ config NET_ICMP_SOCKET
if NET_ICMP_SOCKET
-config NET_ICMP_NCONNS
- int "Max ICMP packet sockets"
+config NET_ICMP_PREALLOC_CONNS
+ int "Preallocated ICMP packet sockets"
default 4
+ ---help---
+ Number of ICMP 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_ICMP_ALLOC_CONNS
+ int "Dynamic ICMP connections allocation"
+ default 0
+ ---help---
+ Dynamic memory allocations for ICMP.
+
+ 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_ICMP_MAX_CONNS
+ int "Maximum number of ICMP connections"
+ default 0
+ depends on NET_ICMP_ALLOC_CONNS > 0
+ ---help---
+ If dynamic connections allocation is selected (NET_ICMP_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_ICMP_NPOLLWAITERS
int "Number of ICMP poll waiters"
diff --git a/net/icmp/icmp_conn.c b/net/icmp/icmp_conn.c
index a8456c4967..2ddcc6903d 100644
--- a/net/icmp/icmp_conn.c
+++ b/net/icmp/icmp_conn.c
@@ -48,8 +48,8 @@
/* The array containing all IPPROTO_ICMP socket connections */
-#ifndef CONFIG_NET_ALLOC_CONNS
-static struct icmp_conn_s g_icmp_connections[CONFIG_NET_ICMP_NCONNS];
+#if CONFIG_NET_ICMP_PREALLOC_CONNS > 0
+static struct icmp_conn_s g_icmp_connections[CONFIG_NET_ICMP_PREALLOC_CONNS];
#endif
/* A list of all free IPPROTO_ICMP socket connections */
@@ -76,10 +76,10 @@ static dq_queue_t g_active_icmp_connections;
void icmp_sock_initialize(void)
{
-#ifndef CONFIG_NET_ALLOC_CONNS
+#if CONFIG_NET_ICMP_PREALLOC_CONNS > 0
int i;
- for (i = 0; i < CONFIG_NET_ICMP_NCONNS; i++)
+ for (i = 0; i < CONFIG_NET_ICMP_PREALLOC_CONNS; i++)
{
/* Move the connection structure to the free list */
@@ -109,13 +109,22 @@ FAR struct icmp_conn_s *icmp_alloc(void)
ret = nxmutex_lock(&g_free_lock);
if (ret >= 0)
{
-#ifdef CONFIG_NET_ALLOC_CONNS
+#if CONFIG_NET_ICMP_ALLOC_CONNS > 0
if (dq_peek(&g_free_icmp_connections) == NULL)
{
- conn = kmm_zalloc(sizeof(*conn) * CONFIG_NET_ICMP_NCONNS);
+#if CONFIG_NET_ICMP_MAX_CONNS > 0
+ if (dq_count(&g_active_icmp_connections) +
+ CONFIG_NET_ICMP_ALLOC_CONNS >= CONFIG_NET_ICMP_MAX_CONNS)
+ {
+ nxmutex_unlock(&g_free_lock);
+ return NULL;
+ }
+#endif
+
+ conn = kmm_zalloc(sizeof(*conn) * CONFIG_NET_ICMP_ALLOC_CONNS);
if (conn != NULL)
{
- for (ret = 0; ret < CONFIG_NET_ICMP_NCONNS; ret++)
+ for (ret = 0; ret < CONFIG_NET_ICMP_ALLOC_CONNS; ret++)
{
dq_addlast(&conn[ret].sconn.node,
&g_free_icmp_connections);
@@ -177,9 +186,21 @@ void icmp_free(FAR struct icmp_conn_s *conn)
memset(conn, 0, sizeof(*conn));
- /* Free the connection */
+ /* If this is a preallocated or a batch allocated connection store it
+ * in the free connections list. Else free it.
+ */
- dq_addlast(&conn->sconn.node, &g_free_icmp_connections);
+#if CONFIG_NET_ICMP_ALLOC_CONNS == 1
+ if (conn < g_icmp_connections || conn >= (g_icmp_connections +
+ CONFIG_NET_ICMP_PREALLOC_CONNS))
+ {
+ kmm_free(conn);
+ }
+ else
+#endif
+ {
+ dq_addlast(&conn->sconn.node, &g_free_icmp_connections);
+ }
}
nxmutex_unlock(&g_free_lock);
[nuttx] 02/12: Improvements in UDP connections allocation.
Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 7f3591b9cc39ea8bbceb000eb4699534451fe48d
Author: Fotis Panagiotopoulos <f....@amco.gr>
AuthorDate: Thu Feb 2 16:20:55 2023 +0200
Improvements in UDP connections allocation.
---
.../sama5d3-xplained/configs/bridge/defconfig | 2 +-
.../arm/sama5/sama5d4-ek/configs/bridge/defconfig | 2 +-
boards/arm/stm32/viewtool-stm32f107/README.txt | 2 +-
include/nuttx/net/netconfig.h | 12 +----
net/udp/Kconfig | 41 +++++++++++++++--
net/udp/udp_conn.c | 51 +++++++++++++++++-----
6 files changed, 81 insertions(+), 29 deletions(-)
diff --git a/boards/arm/sama5/sama5d3-xplained/configs/bridge/defconfig b/boards/arm/sama5/sama5d3-xplained/configs/bridge/defconfig
index d501178b58..aac7dd5c3e 100644
--- a/boards/arm/sama5/sama5d3-xplained/configs/bridge/defconfig
+++ b/boards/arm/sama5/sama5d3-xplained/configs/bridge/defconfig
@@ -42,7 +42,7 @@ CONFIG_NET_BROADCAST=y
CONFIG_NET_ICMP=y
CONFIG_NET_SOCKOPTS=y
CONFIG_NET_UDP=y
-CONFIG_NET_UDP_CONNS=16
+CONFIG_NET_UDP_PREALLOC_CONNS=16
CONFIG_PREALLOC_TIMERS=4
CONFIG_RAM_SIZE=268435456
CONFIG_RAM_START=0x20000000
diff --git a/boards/arm/sama5/sama5d4-ek/configs/bridge/defconfig b/boards/arm/sama5/sama5d4-ek/configs/bridge/defconfig
index 70e7b19beb..91c1d651b5 100644
--- a/boards/arm/sama5/sama5d4-ek/configs/bridge/defconfig
+++ b/boards/arm/sama5/sama5d4-ek/configs/bridge/defconfig
@@ -40,7 +40,7 @@ CONFIG_NET_BROADCAST=y
CONFIG_NET_ICMP=y
CONFIG_NET_SOCKOPTS=y
CONFIG_NET_UDP=y
-CONFIG_NET_UDP_CONNS=16
+CONFIG_NET_UDP_PREALLOC_CONNS=16
CONFIG_PREALLOC_TIMERS=4
CONFIG_RAM_SIZE=268435456
CONFIG_RAM_START=0x20000000
diff --git a/boards/arm/stm32/viewtool-stm32f107/README.txt b/boards/arm/stm32/viewtool-stm32f107/README.txt
index 0b1ca0b6a7..c0b25ea7b9 100644
--- a/boards/arm/stm32/viewtool-stm32f107/README.txt
+++ b/boards/arm/stm32/viewtool-stm32f107/README.txt
@@ -377,7 +377,7 @@ ViewTool DP83848 Ethernet Module
CONFIG_NET_NTCP_READAHEAD_BUFFERS=8
CONFIG_NET_UDP=y : UDP support
- CONFIG_NET_UDP_CONNS=8
+ CONFIG_NET_UDP_PREALLOC_CONNS=8
CONFIG_NET_ICMP=y : ICMP support
CONFIG_NET_ICMP_SOCKET=y
diff --git a/include/nuttx/net/netconfig.h b/include/nuttx/net/netconfig.h
index 93e8e80cb8..732bc5d00f 100644
--- a/include/nuttx/net/netconfig.h
+++ b/include/nuttx/net/netconfig.h
@@ -288,16 +288,6 @@
/* UDP configuration options */
-/* The maximum amount of concurrent UDP connection, Default: 10 */
-
-#ifndef CONFIG_NET_UDP_CONNS
-# ifdef CONFIG_NET_UDP
-# define CONFIG_NET_UDP_CONNS 10
-# else
-# define CONFIG_NET_UDP_CONNS 0
-# endif
-#endif
-
/* The UDP maximum packet size. This should not be set to more than
* NETDEV_PKTSIZE(d) - NET_LL_HDRLEN(dev) - __UDP_HDRLEN - IPv*_HDRLEN.
*/
@@ -432,7 +422,7 @@
#ifndef CONFIG_NET_NACTIVESOCKETS
# define CONFIG_NET_NACTIVESOCKETS (CONFIG_NET_TCP_PREALLOC_CONNS + \
- CONFIG_NET_UDP_CONNS)
+ CONFIG_NET_UDP_PREALLOC_CONNS)
#endif
/* The initial retransmission timeout counted in timer pulses.
diff --git a/net/udp/Kconfig b/net/udp/Kconfig
index b2606e1fce..9239367396 100644
--- a/net/udp/Kconfig
+++ b/net/udp/Kconfig
@@ -36,11 +36,46 @@ config NET_UDP_CHECKSUMS
Enable/disable UDP checksum support. UDP checksum support is
REQUIRED for IPv6.
-config NET_UDP_CONNS
- int "Number of UDP sockets"
+config NET_UDP_PREALLOC_CONNS
+ int "Preallocated UDP sockets"
default 8
---help---
- The maximum amount of open concurrent UDP sockets
+ Number of UDP 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_UDP_ALLOC_CONNS
+ int "Dynamic UDP connections allocation"
+ default 0
+ ---help---
+ Dynamic memory allocations for UDP.
+
+ 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_UDP_MAX_CONNS
+ int "Maximum number of UDP connections"
+ default 0
+ depends on NET_UDP_ALLOC_CONNS > 0
+ ---help---
+ If dynamic connections allocation is selected (NET_UDP_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_UDP_NPOLLWAITERS
int "Number of UDP poll waiters"
diff --git a/net/udp/udp_conn.c b/net/udp/udp_conn.c
index 9051bb23c6..6b3cc628f7 100644
--- a/net/udp/udp_conn.c
+++ b/net/udp/udp_conn.c
@@ -76,8 +76,8 @@
/* The array containing all UDP connections. */
-#ifndef CONFIG_NET_ALLOC_CONNS
-struct udp_conn_s g_udp_connections[CONFIG_NET_UDP_CONNS];
+#if CONFIG_NET_UDP_PREALLOC_CONNS > 0
+struct udp_conn_s g_udp_connections[CONFIG_NET_UDP_PREALLOC_CONNS];
#endif
/* A list of all free UDP connections */
@@ -462,7 +462,7 @@ static inline FAR struct udp_conn_s *
*
****************************************************************************/
-#ifdef CONFIG_NET_ALLOC_CONNS
+#if CONFIG_NET_UDP_ALLOC_CONNS > 0
FAR struct udp_conn_s *udp_alloc_conn(void)
{
FAR struct udp_conn_s *conn;
@@ -472,8 +472,16 @@ FAR struct udp_conn_s *udp_alloc_conn(void)
if (dq_peek(&g_free_udp_connections) == NULL)
{
+#if CONFIG_NET_UDP_MAX_CONNS > 0
+ if (dq_count(&g_active_udp_connections) + CONFIG_NET_UDP_ALLOC_CONNS
+ >= CONFIG_NET_UDP_MAX_CONNS)
+ {
+ return NULL;
+ }
+#endif
+
conn = kmm_zalloc(sizeof(struct udp_conn_s) *
- CONFIG_NET_UDP_CONNS);
+ CONFIG_NET_UDP_ALLOC_CONNS);
if (conn == NULL)
{
return conn;
@@ -481,7 +489,7 @@ FAR struct udp_conn_s *udp_alloc_conn(void)
/* Now initialize each connection structure */
- for (i = 0; i < CONFIG_NET_UDP_CONNS; i++)
+ for (i = 0; i < CONFIG_NET_UDP_ALLOC_CONNS; i++)
{
/* Mark the connection closed and move it to the free list */
@@ -585,10 +593,10 @@ uint16_t udp_select_port(uint8_t domain, FAR union ip_binding_u *u)
void udp_initialize(void)
{
-#ifndef CONFIG_NET_ALLOC_CONNS
+#if CONFIG_NET_UDP_PREALLOC_CONNS > 0
int i;
- for (i = 0; i < CONFIG_NET_UDP_CONNS; i++)
+ for (i = 0; i < CONFIG_NET_UDP_PREALLOC_CONNS; i++)
{
/* Mark the connection closed and move it to the free list */
@@ -614,11 +622,16 @@ FAR struct udp_conn_s *udp_alloc(uint8_t domain)
/* The free list is protected by a mutex. */
nxmutex_lock(&g_free_lock);
-#ifndef CONFIG_NET_ALLOC_CONNS
+
conn = (FAR struct udp_conn_s *)dq_remfirst(&g_free_udp_connections);
-#else
- conn = udp_alloc_conn();
+
+#if CONFIG_NET_UDP_ALLOC_CONNS > 0
+ if (conn == NULL)
+ {
+ conn = udp_alloc_conn();
+ }
#endif
+
if (conn)
{
/* Make sure that the connection is marked as uninitialized */
@@ -703,9 +716,23 @@ void udp_free(FAR struct udp_conn_s *conn)
memset(conn, 0, sizeof(*conn));
- /* Free the connection */
+ /* Free the connection.
+ * If this is a preallocated or a batch allocated connection store it in
+ * the free connections list. Else free it.
+ */
+
+#if CONFIG_NET_UDP_ALLOC_CONNS == 1
+ if (conn < g_udp_connections || conn >= (g_udp_connections +
+ CONFIG_NET_UDP_PREALLOC_CONNS))
+ {
+ kmm_free(conn);
+ }
+ else
+#endif
+ {
+ dq_addlast(&conn->sconn.node, &g_free_udp_connections);
+ }
- dq_addlast(&conn->sconn.node, &g_free_udp_connections);
nxmutex_unlock(&g_free_lock);
}
[nuttx] 07/12: Improvements in IEEE 802.15.4 connections allocation.
Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 22a82b3f51e25c1be81f00d51664032bbdda0ac3
Author: Fotis Panagiotopoulos <f....@amco.gr>
AuthorDate: Mon Feb 13 12:21:46 2023 +0200
Improvements in IEEE 802.15.4 connections allocation.
---
net/ieee802154/Kconfig | 41 ++++++++++++++++++++++++++++++++++++--
net/ieee802154/ieee802154_conn.c | 43 ++++++++++++++++++++++++++++++----------
2 files changed, 72 insertions(+), 12 deletions(-)
diff --git a/net/ieee802154/Kconfig b/net/ieee802154/Kconfig
index 302fecb500..9cb0716556 100644
--- a/net/ieee802154/Kconfig
+++ b/net/ieee802154/Kconfig
@@ -33,9 +33,46 @@ config NET_IEEE802154_FRAMELEN
This setting is currently used only for detection data transfers
that would exceed the radio frame length.
-config NET_IEEE802154_NCONNS
- int "Max IEEE 802.15.4 sockets"
+config NET_IEEE802154_PREALLOC_CONNS
+ int "Preallocated IEEE 802.15.4 sockets"
default 4
+ ---help---
+ Number of IEEE 802.15.4 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_IEEE802154_ALLOC_CONNS
+ int "Dynamic IEEE 802.15.4 connections allocation"
+ default 0
+ ---help---
+ Dynamic memory allocations for IEEE 802.15.4.
+
+ 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_IEEE802154_MAX_CONNS
+ int "Maximum number of IEEE 802.15.4 connections"
+ default 0
+ depends on NET_IEEE802154_ALLOC_CONNS > 0
+ ---help---
+ If dynamic connections allocation is selected (NET_IEEE802154_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_IEEE802154_NCONTAINERS
int "Number of pre-allocated frame containers"
diff --git a/net/ieee802154/ieee802154_conn.c b/net/ieee802154/ieee802154_conn.c
index d32db2d2d0..a6133a100f 100644
--- a/net/ieee802154/ieee802154_conn.c
+++ b/net/ieee802154/ieee802154_conn.c
@@ -51,9 +51,9 @@
* network lock.
*/
-#ifndef CONFIG_NET_ALLOC_CONNS
+#if CONFIG_NET_IEEE802154_PREALLOC_CONNS > 0
static struct ieee802154_conn_s
- g_ieee802154_connections[CONFIG_NET_IEEE802154_NCONNS];
+ g_ieee802154_connections[CONFIG_NET_IEEE802154_PREALLOC_CONNS];
#endif
/* A list of all free packet socket connections */
@@ -82,10 +82,10 @@ static dq_queue_t g_active_ieee802154_connections;
void ieee802154_conn_initialize(void)
{
-#ifndef CONFIG_NET_ALLOC_CONNS
+#if CONFIG_NET_IEEE802154_PREALLOC_CONNS > 0
int i;
- for (i = 0; i < CONFIG_NET_IEEE802154_NCONNS; i++)
+ for (i = 0; i < CONFIG_NET_IEEE802154_PREALLOC_CONNS; i++)
{
/* Link each pre-allocated connection structure into the free list. */
@@ -107,20 +107,30 @@ void ieee802154_conn_initialize(void)
FAR struct ieee802154_conn_s *ieee802154_conn_alloc(void)
{
FAR struct ieee802154_conn_s *conn;
-#ifdef CONFIG_NET_ALLOC_CONNS
+#if CONFIG_NET_IEEE802154_ALLOC_CONNS > 0
int i;
#endif
/* The free list is protected by the network lock. */
net_lock();
-#ifdef CONFIG_NET_ALLOC_CONNS
+#if CONFIG_NET_IEEE802154_ALLOC_CONNS > 0
if (dq_peek(&g_free_ieee802154_connections) == NULL)
{
- conn = kmm_zalloc(sizeof(*conn) * CONFIG_NET_IEEE802154_NCONNS);
+#if CONFIG_NET_IEEE802154_MAX_CONNS > 0
+ if (dq_count(&g_active_ieee802154_connections) +
+ CONFIG_NET_IEEE802154_ALLOC_CONNS
+ >= CONFIG_NET_IEEE802154_MAX_CONNS)
+ {
+ net_unlock();
+ return NULL;
+ }
+#endif
+
+ conn = kmm_zalloc(sizeof(*conn) * CONFIG_NET_IEEE802154_ALLOC_CONNS);
if (conn != NULL)
{
- for (i = 0; i < CONFIG_NET_IEEE802154_NCONNS; i++)
+ for (i = 0; i < CONFIG_NET_IEEE802154_ALLOC_CONNS; i++)
{
dq_addlast(&conn[i].sconn.node,
&g_free_ieee802154_connections);
@@ -188,9 +198,22 @@ void ieee802154_conn_free(FAR struct ieee802154_conn_s *conn)
memset(conn, 0, sizeof(*conn));
- /* Free the connection */
+ /* If this is a preallocated or a batch allocated connection store it in
+ * the free connections list. Else free it.
+ */
+
+#if CONFIG_NET_IEEE802154_ALLOC_CONNS == 1
+ if (conn < g_ieee802154_connections || conn >= (g_ieee802154_connections +
+ CONFIG_NET_IEEE802154_PREALLOC_CONNS))
+ {
+ kmm_free(conn);
+ }
+ else
+#endif
+ {
+ dq_addlast(&conn->sconn.node, &g_free_ieee802154_connections);
+ }
- dq_addlast(&conn->sconn.node, &g_free_ieee802154_connections);
net_unlock();
}
[nuttx] 12/12: Removed obsolete option NET_ALLOC_CONNS.
Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit b6eb3c828cff36ec00b61b8dd704fb67d622b765
Author: Fotis Panagiotopoulos <f....@amco.gr>
AuthorDate: Tue Feb 14 12:54:53 2023 +0200
Removed obsolete option NET_ALLOC_CONNS.
---
boards/sim/sim/sim/configs/dynconns/defconfig | 12 +++++++++++-
net/Kconfig | 10 ----------
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/boards/sim/sim/sim/configs/dynconns/defconfig b/boards/sim/sim/sim/configs/dynconns/defconfig
index c4e05b93a2..467013b557 100644
--- a/boards/sim/sim/sim/configs/dynconns/defconfig
+++ b/boards/sim/sim/sim/configs/dynconns/defconfig
@@ -18,6 +18,7 @@ CONFIG_BOARDCTL_ROMDISK=y
CONFIG_BOARD_LOOPSPERMSEC=0
CONFIG_BOOT_RUNFROMEXTSRAM=y
CONFIG_BUILTIN=y
+CONFIG_CAN_ALLOC_CONNS=1
CONFIG_DEV_LOOP=y
CONFIG_DEV_ZERO=y
CONFIG_FSUTILS_PASSWD=y
@@ -38,17 +39,19 @@ CONFIG_NETDEV_CAN_FILTER_IOCTL=y
CONFIG_NETDEV_LATEINIT=y
CONFIG_NETDEV_PHY_IOCTL=y
CONFIG_NETDOWN_NOTIFIER=y
+CONFIG_NETLINK_ALLOC_CONNS=1
CONFIG_NETLINK_ROUTE=y
CONFIG_NET_6LOWPAN=y
CONFIG_NET_6LOWPAN_EXTENDEDADDR=y
CONFIG_NET_6LOWPAN_MAXADDRCONTEXT_PREINIT_1=y
CONFIG_NET_6LOWPAN_MAXADDRCONTEXT_PREINIT_2=y
CONFIG_NET_6LOWPAN_REASS_STATIC=y
-CONFIG_NET_ALLOC_CONNS=y
+CONFIG_NET_ALLOC_DEVIF_CALLBACKS=1
CONFIG_NET_ARP_IPIN=y
CONFIG_NET_ARP_SEND=y
CONFIG_NET_BINDTODEVICE=y
CONFIG_NET_BLUETOOTH=y
+CONFIG_NET_BLUETOOTH_ALLOC_CONNS=1
CONFIG_NET_BROADCAST=y
CONFIG_NET_CAN=y
CONFIG_NET_CAN_EXTID=y
@@ -56,14 +59,17 @@ CONFIG_NET_CAN_NOTIFIER=y
CONFIG_NET_CAN_SOCK_OPTS=y
CONFIG_NET_CELLULAR=y
CONFIG_NET_ICMP=y
+CONFIG_NET_ICMP_ALLOC_CONNS=1
CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_ICMPv6=y
+CONFIG_NET_ICMPv6_ALLOC_CONNS=1
CONFIG_NET_ICMPv6_AUTOCONF=y
CONFIG_NET_ICMPv6_NEIGHBOR=y
CONFIG_NET_ICMPv6_ROUTER=y
CONFIG_NET_ICMPv6_ROUTER_MANUAL=y
CONFIG_NET_ICMPv6_SOCKET=y
CONFIG_NET_IEEE802154=y
+CONFIG_NET_IEEE802154_ALLOC_CONNS=1
CONFIG_NET_IGMP=y
CONFIG_NET_IPFORWARD=y
CONFIG_NET_IPFORWARD_BROADCAST=y
@@ -78,6 +84,7 @@ CONFIG_NET_MLD_TXDUMP=y
CONFIG_NET_NAT=y
CONFIG_NET_NETLINK=y
CONFIG_NET_PKT=y
+CONFIG_NET_PKT_ALLOC_CONNS=1
CONFIG_NET_PROMISCUOUS=y
CONFIG_NET_ROUTE=y
CONFIG_NET_SENDFILE=y
@@ -88,6 +95,7 @@ CONFIG_NET_STATISTICS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_TCPURGDATA=y
+CONFIG_NET_TCP_ALLOC_CONNS=1
CONFIG_NET_TCP_DEBUG_DROP_RECV=y
CONFIG_NET_TCP_DEBUG_DROP_SEND=y
CONFIG_NET_TCP_DELAYED_ACK=y
@@ -99,8 +107,10 @@ CONFIG_NET_TCP_WRITE_BUFFERS=y
CONFIG_NET_TIMESTAMP=y
CONFIG_NET_TUN=y
CONFIG_NET_UDP=y
+CONFIG_NET_UDP_ALLOC_CONNS=1
CONFIG_NET_UDP_WRITE_BUFFERS=y
CONFIG_NET_USRSOCK=y
+CONFIG_NET_USRSOCK_ALLOC_CONNS=1
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_LINELEN=200
diff --git a/net/Kconfig b/net/Kconfig
index 63944dbb28..0d11685b83 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -335,16 +335,6 @@ source "net/ipfrag/Kconfig"
endmenu # Internet Protocol Selection
-config NET_ALLOC_CONNS
- bool "Allocate connect instance dynamically"
- default n
- ---help---
- Enable to allocate connection instances dynamically.
- Use this feature if the number of connections can not be determined at
- compile time. When enabled the stack will be compiled without the static
- pre-allocate connection list and all connection instances will be dynamically
- allocated from heap at run time.
-
source "net/socket/Kconfig"
source "net/inet/Kconfig"
source "net/pkt/Kconfig"