incubator-nuttx/net
chao an e46688c1ee net/tcp: use independent work to free the conn instance
I noticed that the conn instance will leak during stress test,
The close work queued from tcp_close_eventhandler() will be canceled
by tcp_timer() immediately:

Breakpoint 1, tcp_close_eventhandler (dev=0x565cd338 <up_irq_restore+108>, pvpriv=0x5655e6ff <getpid+12>, flags=0) at tcp/tcp_close.c:71
(gdb) bt
| #0  tcp_close_eventhandler (dev=0x565cd338 <up_irq_restore+108>, pvpriv=0x5655e6ff <getpid+12>, flags=0) at tcp/tcp_close.c:71
| #1  0x5658bf1e in devif_conn_event (dev=0x5660bd80 <g_sim_dev>, flags=512, list=0x5660d558 <g_cbprealloc+312>) at devif/devif_callback.c:508
| #2  0x5658a219 in tcp_callback (dev=0x5660bd80 <g_sim_dev>, conn=0x5660c4a0 <g_tcp_connections>, flags=512) at tcp/tcp_callback.c:167
| #3  0x56589253 in tcp_timer (dev=0x5660bd80 <g_sim_dev>, conn=0x5660c4a0 <g_tcp_connections>) at tcp/tcp_timer.c:378
| #4  0x5658dd47 in tcp_poll (dev=0x5660bd80 <g_sim_dev>, conn=0x5660c4a0 <g_tcp_connections>) at tcp/tcp_devpoll.c:95
| #5  0x5658b95f in devif_poll_tcp_connections (dev=0x5660bd80 <g_sim_dev>, callback=0x565770f2 <netdriver_txpoll>) at devif/devif_poll.c:601
| #6  0x5658b9ea in devif_poll (dev=0x5660bd80 <g_sim_dev>, callback=0x565770f2 <netdriver_txpoll>) at devif/devif_poll.c:722
| #7  0x56577230 in netdriver_txavail_work (arg=0x5660bd80 <g_sim_dev>) at sim/up_netdriver.c:308
| #8  0x5655999e in work_thread (argc=2, argv=0xf3db5dd0) at wqueue/kwork_thread.c:178
| #9  0x5655983f in nxtask_start () at task/task_start.c:129

(gdb) c
Continuing.
Breakpoint 2, tcp_update_timer (conn=0x5660c4a0 <g_tcp_connections>) at tcp/tcp_timer.c:178
(gdb) bt
| #0  tcp_update_timer (conn=0x5660c4a0 <g_tcp_connections>) at tcp/tcp_timer.c:178
| #1  0x5658952a in tcp_timer (dev=0x5660bd80 <g_sim_dev>, conn=0x5660c4a0 <g_tcp_connections>) at tcp/tcp_timer.c:708
| #2  0x5658dd47 in tcp_poll (dev=0x5660bd80 <g_sim_dev>, conn=0x5660c4a0 <g_tcp_connections>) at tcp/tcp_devpoll.c:95
| #3  0x5658b95f in devif_poll_tcp_connections (dev=0x5660bd80 <g_sim_dev>, callback=0x565770f2 <netdriver_txpoll>) at devif/devif_poll.c:601
| #4  0x5658b9ea in devif_poll (dev=0x5660bd80 <g_sim_dev>, callback=0x565770f2 <netdriver_txpoll>) at devif/devif_poll.c:722
| #5  0x56577230 in netdriver_txavail_work (arg=0x5660bd80 <g_sim_dev>) at sim/up_netdriver.c:308
| #6  0x5655999e in work_thread (argc=2, argv=0xf3db5dd0) at wqueue/kwork_thread.c:178
| #7  0x5655983f in nxtask_start () at task/task_start.c:129

Since a separate work will add 24 bytes to each conn instance,
but in order to support the feature of asynchronous close(),
I can not find a better way than adding a separate work,
for resource constraints, I recommend the developers to enable
CONFIG_NET_ALLOC_CONNS, which will reduce the ram usage.

Signed-off-by: chao an <anchao@xiaomi.com>
2022-09-22 23:33:00 +08:00
..
arp net: cleanup pvconn reference to avoid confuse 2022-08-26 20:58:11 +08:00
bluetooth net: cleanup pvconn reference to avoid confuse 2022-08-26 20:58:11 +08:00
can net: cleanup pvconn reference to avoid confuse 2022-08-26 20:58:11 +08:00
devif net: cleanup pvconn reference to avoid confuse 2022-08-26 20:58:11 +08:00
icmp net: Align the prototype of sock_intf_s::si_ioctl with file_operations::ioctl 2022-09-06 22:46:37 +08:00
icmpv6 net: Align the prototype of sock_intf_s::si_ioctl with file_operations::ioctl 2022-09-06 22:46:37 +08:00
ieee802154 net: cleanup pvconn reference to avoid confuse 2022-08-26 20:58:11 +08:00
igmp net/igmp: Remove igmp_initialize 2022-03-12 19:24:17 +02:00
inet net/inet: invalid addrlen length should return EINVAL 2022-09-08 09:02:30 +08:00
ipforward net: cleanup pvconn reference to avoid confuse 2022-08-26 20:58:11 +08:00
local net: Align the prototype of sock_intf_s::si_ioctl with file_operations::ioctl 2022-09-06 22:46:37 +08:00
mld Kconfig: Remove EXPERIMENTAL for features which is been around a long time 2022-09-19 11:39:22 -03:00
neighbor net: use HTONS, NTOHS, HTONL, NTOHL macro in kernel code 2022-01-18 10:59:47 +01:00
netdev net/wireless: separate command catagory of bt/pktradio from wireless ioctl 2022-09-20 01:16:22 +08:00
netlink Fix ENOENT errors when polling on Netlink socket 2022-05-14 00:35:29 +03:00
pkt Kconfig: Remove EXPERIMENTAL for features which is been around a long time 2022-09-19 11:39:22 -03:00
procfs net/procfs: disable tcp/udp proc node if no stack available 2022-09-19 15:45:19 +08:00
route net/mld/route: fix build warning 2022-09-06 18:24:20 +08:00
rpmsg net: Align the prototype of sock_intf_s::si_ioctl with file_operations::ioctl 2022-09-06 22:46:37 +08:00
sixlowpan net: cleanup pvconn reference to avoid confuse 2022-08-26 20:58:11 +08:00
socket net: Implement SO_RCVBUF and SO_SNDBUF for getsockopt 2022-09-21 09:03:20 +02:00
tcp net/tcp: use independent work to free the conn instance 2022-09-22 23:33:00 +08:00
udp udp: Remove the unnessary check of addr size in udp_readahead 2022-09-09 17:21:33 +02:00
usrsock net/usrsock: Simplify the return value process of net_timedwait 2022-09-11 10:08:04 +09:00
utils net:add btsnoop and snoop 2022-08-24 21:42:30 +08:00
Kconfig net/slip: Rename and clarify orphaned Kconfig options 2022-07-20 13:17:09 +08:00
Makefile
README.txt
net_initialize.c net: Reoder the initialize sequence(mac->ip->tcp/udp) 2022-03-12 19:24:17 +02:00

README.txt

README
======

Directory Structure
===================

  nuttx/
   |
   `- net/
       |
       +- arp        - Address resolution protocol (IPv4)
       +- bluetooth  - PF_BLUETOOTH socket interface
       +- devif      - Stack/device interface layer
       +- icmp       - Internet Control Message Protocol (IPv4)
       +- icmpv6     - Internet Control Message Protocol (IPv6)
       +- ieee802154 - PF_IEEE802154 socket interface
       +- inet       - PF_INET/PF_INET6 socket interface
       +- ipforward  - IP forwarding logic
       +- local      - Unix domain (local) sockets
       +- mld        - Multicast Listener Discovery (MLD)
       +- neighbor   - Neighbor Discovery Protocol (IPv6)
       +- netdev     - Socket network device interface
       +- netlink    - Netlink IPC socket interface
       +- pkt        - "Raw" packet socket support
       +- sixlowpan  - 6LoWPAN implementation
       +- socket     - BSD socket interface
       +- route      - Routing table support
       +- tcp        - Transmission Control Protocol
       +- udp        - User Datagram Protocol
       +- usrsock    - User socket API for user-space networking stack
       `- utils      - Miscellaneous utility functions

    +-------------------------------------------------------------------++------------------------+
    |                     Application layer                             || usrsock daemon         |
    +-------------------------------------------------------------------++------------------------+
    +-------------------------------------------------------------------++----------------+ +-----+
    |                   Socket layer (socket/)                          || /dev/usrsock   | |     |
    +-------------------------------------------------------------------++----------------+ |     |
    +------------++--------------------------------------------------++-------------------+ |     |
    |  Network   || Protocol stacks (arp, ipv6, icmp, pkt, tcp, udp) || usrsock/          | |     |
    |   Device   |+--------------------------------------------------++-------------------+ |     |
    | Interface  |+------------------------------------++---------------------------------+ |     |
    | (netdev/)  ||  Network Device Interface (devif/) || Utilities                       | |     |
    +------------++------------------------------------++---------------------------------+ |     |
    +----------------------------------------------------------------+                      |     |
    |                    Network Device Drivers                      |                      | HAL |
    +----------------------------------------------------------------+                      +-----+
    +----------------------------------------------------------------+ +--------------------------+
    |                    Networking Hardware                         | |  Hardware TCP/IP Stack   |
    +----------------------------------------------------------------+ +--------------------------+