Commit Graph

2438 Commits

Author SHA1 Message Date
Xiang Xiao
838690fc9f net/local: Remove the sync preamble from datagram
since pipe is a reliable transport, the sync just waste the space and time

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-08-10 09:50:25 +03:00
Jiuzhu Dong
fe17f747a7 fs/directory: move private directory information to filesystem
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-08-09 23:30:01 +08:00
Jiuzhu Dong
90db4daca9 fs/directory: update readdir interface for all filesystem
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-08-09 23:30:01 +08:00
田昕
20b9cc37d5 net/local:Make local send multi-thread safe
Signed-off-by: 田昕 <tianxin7@xiaomi.com>
2022-08-08 22:45:44 +08:00
Petro Karashchenko
b3cd9090d1 drivers/net: make sure that net driver d_buf is 16-bit aligned
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-08-05 22:21:37 +08:00
Peter van der Perk
013a562478 Net thread-safe ntoa functions
Apply suggestions from code review

Co-authored-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-08-02 21:04:19 +08:00
Peter van der Perk
26dbdba5d8 [TCP] Close RAM usage optimization 2022-07-29 23:51:06 +08:00
liyi
b232508bd9 make sure conn's domain is match with addr's family 2022-07-29 13:53:19 +08:00
ligd
8a3683fb9f rptun: add ns_match callback to resolve rptun deadlock
thread A: accept -> net_lock -> socket_rpmsg_accept
          -> rpmsg_register_callabck -> rptun_lock
thread B: ns_bind -> rpmsg_socket_ns_bind -> get_tx_payload_buffer
          -> rptun_wait_tx -> usrsock_rpmsg_ept_cb -> usrsockdev_write
          -> net_lock -> deadlock

fix:
add ns_match callback

Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-07-27 20:36:51 +08:00
zhanghongyu
fc35cf4737 udp: Use s_sndtimeo as the actual timeout time
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-07-26 12:06:14 +03:00
zhanghongyu
ef660083c8 tcp: check option length before d_len update
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-07-26 12:05:06 +03:00
Peter van der Perk
b3590f00b3 NXStyle and preprocessor fixes
Co-authored-by: Jari van Ewijk <jari.vanewijk@nxp.com>
2022-07-25 23:47:05 +08:00
Jari van Ewijk
51a845ce54 SocketCAN: add non-blocking write
Co-authored-by: Peter van der Perk <peter.vanderperk@nxp.com>
2022-07-25 23:47:05 +08:00
zhanghongyu
51a262150d wifi: clear IFF_RUNNING flag when ifdown
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-07-25 15:29:24 +08:00
zhanghongyu
7467586d55 netdev: add return value for ifup / ifdown
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-07-25 15:29:24 +08:00
ligd
79952163c1 rpmsg_socket: use sendto_nocopy() instead of send_nocopy().
only wait ept ready after ept_create, not after ept_destroy

Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-07-23 08:16:48 +03:00
ligd
9c106c1bdc rpmsg_socket: defalut set POLLERR POLLHUP to events
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-07-23 08:16:48 +03:00
ligd
ba990619ed socket_rpmsg: set poll err instead return err
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-07-23 08:16:48 +03:00
ligd
630ca45a50 rpmsg_socket: connect addrlen can bigger then expect
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-07-23 08:16:48 +03:00
Jiuzhu Dong
fab2f6d3d8 net/rpmsg: fix minor issue on strncpy
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-07-23 08:16:48 +03:00
ligd
5b9a953381 local: fix nx_style
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-07-22 14:07:12 +03:00
ligd
390de249a0 local: connect operation should jump self's connection
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-07-22 14:07:12 +03:00
ligd
cd5ab80f2f local: server accept should wait client connect done
server:
at accept last nxsem_post(&client->lc_waitsem);

client:
connect wait(&client->lc_waitsem) then local_open_client_rx();

But if the server priority is higher then client,
and after server accept return, immediately call send().
At this time the client has no way do local_open_client_rx().
Then server send() return error.

Fix:
add lc_done sem to client

Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-07-22 14:07:12 +03:00
ligd
e489a308c8 local_socket: remove error log when use nonblock mode
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-07-22 14:07:12 +03:00
Denis Tolstov
e937cfcbce net/slip: Rename and clarify orphaned Kconfig options 2022-07-20 13:17:09 +08:00
Xiang Xiao
2166c98809 Add printflike and scanflike to all printf/scanf like functions
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-07-18 14:14:36 +03:00
larry
8f72799e8e net: Fix frame count check fail
bc_rxtail/rxtail should always point to newly frame.
If input more than one frame before receive,
missing assignment can result in old frame lost.

Signed-off-by: larry <larry@transtekcorp.com>
2022-07-14 22:56:05 +03:00
Gustavo Henrique Nihei
3948736c41 net: Convert DEBUGASSERT(false) into more intuitive DEBUGPANIC()
Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
2022-07-14 12:08:45 +08:00
chao.an
1c80675e87 net/tcp: fix regression of invalid update the rexmit_seq in buffer mode
fix regression of invalid update the rexmit_seq in buffer mode
rexmit_seq should not be used instead of sndseq in fast retransmission,
sndseq of retransmission in the packet does not need to be re-updated

Signed-off-by: chao.an <anchao@xiaomi.com>
2022-07-12 11:04:39 +03:00
chao.an
8ae8c10954 net/poll: fix race condition if connect free before poll teardown
Net poll teardown is not protected by net lock, if the conn is released
before teardown, the assertion failure will be triggered during free dev
callback, this patch will add the net lock around net poll teardown to
fix race condition

nuttx/libs/libc/assert/lib_assert.c:36
nuttx/net/devif/devif_callback.c:85
nuttx/net/tcp/tcp_netpoll.c:405
nuttx/fs/vfs/fs_poll.c:244
nuttx/fs/vfs/fs_poll.c:500

Signed-off-by: chao.an <anchao@xiaomi.com>
2022-07-09 19:11:42 +08:00
chao.an
9bdeed73e2 net/tcp: fix assertion of fallback connection alloc
When the free connection list is unenough to alloc a new instance,
the TCP stack will reuse the currently closed connection, but if
the handle is not released by the user via close(2), the reference
count of the connection remains in a non-zero value, it will cause
the assertion to fail, so when the handle is not released we should
not use such a conn instance when being actively closed, and ensure
that the reference count is assigned within the net lock protection

|(gdb) bt
|#0  up_assert (filename=0x565c78f7 "tcp/tcp_conn.c", lineno=771) at sim/up_assert.c:75
|#1  0x56566177 in _assert (filename=0x565c78f7 "tcp/tcp_conn.c", linenum=771) at assert/lib_assert.c:36
|#2  0x5657d620 in tcp_free (conn=0x565fb3e0 <g_tcp_connections>) at tcp/tcp_conn.c:771
|#3  0x5657d5a1 in tcp_alloc (domain=2 '\002') at tcp/tcp_conn.c:700
|#4  0x565b1f50 in inet_tcp_alloc (psock=0xf3dea150) at inet/inet_sockif.c:144
|#5  0x565b2082 in inet_setup (psock=0xf3dea150, protocol=0) at inet/inet_sockif.c:253
|#6  0x565b1bf0 in psock_socket (domain=2, type=1, protocol=0, psock=0xf3dea150) at socket/socket.c:121
|#7  0x56588f5f in socket (domain=2, type=1, protocol=0) at socket/socket.c:278
|#8  0x565b11c0 in hello_main (argc=1, argv=0xf3dfab10) at hello_main.c:35
|#9  0x56566631 in nxtask_startup (entrypt=0x565b10ef <hello_main>, argc=1, argv=0xf3dfab10) at sched/task_startup.c:70
|#10 0x565597fa in nxtask_start () at task/task_start.c:134

Signed-off-by: chao.an <anchao@xiaomi.com>
2022-07-09 09:37:49 +09:00
YAMAMOTO Takashi
19eb4d7d77 Revert "net/tcp: discard connect reference before free"
This reverts commit b88a1fd7fd. [1]

Because:

* It casues assertion failures like [2].

* I don't understand what it attempted to fix.

[1]
```
commit b88a1fd7fd
Author: chao.an <anchao@xiaomi.com>
Date:   Sat Jul 2 13:17:41 2022 +0800

    net/tcp: discard connect reference before free

    connect reference should be set to 0 before free

    Signed-off-by: chao.an <anchao@xiaomi.com>
```

[2]
```
    #0  up_assert (filename=0x5516d0 "tcp/tcp_conn.c", lineno=771) at sim/up_assert.c:75
    #1  0x000000000040a4bb in _assert (filename=0x5516d0 "tcp/tcp_conn.c", linenum=771) at assert/lib_assert.c:36
    #2  0x000000000042a2ad in tcp_free (conn=0x597fe0 <g_tcp_connections+384>) at tcp/tcp_conn.c:771
    #3  0x000000000053bdc2 in tcp_close_disconnect (psock=0x7f58d1abbd80) at tcp/tcp_close.c:331
    #4  0x000000000053bc69 in tcp_close (psock=0x7f58d1abbd80) at tcp/tcp_close.c:366
    #5  0x000000000052eefe in inet_close (psock=0x7f58d1abbd80) at inet/inet_sockif.c:1689
    #6  0x000000000052eb9b in psock_close (psock=0x7f58d1abbd80) at socket/net_close.c:102
    #7  0x0000000000440495 in sock_file_close (filep=0x7f58d1b35f40) at socket/socket.c:115
    #8  0x000000000043b8b6 in file_close (filep=0x7f58d1b35f40) at vfs/fs_close.c:74
    #9  0x000000000043ab22 in nx_close (fd=9) at inode/fs_files.c:544
    #10 0x000000000043ab7f in close (fd=9) at inode/fs_files.c:578
```
2022-07-08 16:11:24 +08:00
zhanghongyu
c7c5c75451 net_if: add IFF_LOOPBACK/POINTOPOINT/MULTICAST/BROADCAST
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-07-03 09:57:10 -04:00
chao.an
58dcee641e net/netdev: move netdev_ifup/down to public header
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-07-03 02:28:50 +08:00
chao.an
b88a1fd7fd net/tcp: discard connect reference before free
connect reference should be set to 0 before free

Signed-off-by: chao.an <anchao@xiaomi.com>
2022-07-02 16:07:34 +08:00
Xiang Xiao
abc72ad128 net: Ensure sendmsg and sendfile return -EAGAIN in case of timeout
instead of -ETIMEOUT, as specify here:
https://pubs.opengroup.org/onlinepubs/009604599/functions/sendmsg.html
https://man7.org/linux/man-pages/man2/sendfile.2.html

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-06-28 06:19:13 +03:00
chao.an
252985fc1d netdev/carrier: check the IF stautus before carrier
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-06-25 19:52:53 +08:00
chao.an
669fb83706 net/tcp(buffered): retransmit only one the earliest not acknowledged segment
Retransmit only one the earliest not acknowledged segment
(according to RFC 6298 (5.4)). The issue is the same as it was
in tcp_send_unbuffered.c and tcp_sendfile.c.

Signed-off-by: chao.an <anchao@xiaomi.com>
2022-06-16 18:14:29 +08:00
chao.an
845e259ac7 net/tcp: d_appdata should remove the tcp specific option field
applicate data field should not touch data of IP layer

Signed-off-by: chao.an <anchao@xiaomi.com>
2022-06-15 20:28:10 +08:00
chao.an
0636c17a63 net/tcp: wave hands on background
The time consuming of tcp waving hands(close(2)) will be affected
by network jitter, especially the wireless device cannot receive
the last-ack under worst environment, in this change we move the
tcp close callback into background and invoke the resource free
from workqueue, which will avoid the user application from being
blocked for a long time and unable to return in the call of close

Signed-off-by: chao.an <anchao@xiaomi.com>
2022-06-09 18:19:25 +03:00
Sebastien Lorquet
6bd36d64e3 Packet dropped in IPv4/v6 input is now an info, not a warning 2022-06-09 16:07:34 +02:00
Xiang Xiao
9d4c708913 net/tcp: Search conn list again to aovid the race condition in tcp_timer_expiry
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-06-07 20:15:41 +03:00
Xiang Xiao
fe85e9d0fa net: Remove devif_timer from comment
since devif_timer has been removed in:
commit 035d925864
Author: zhanghongyu <zhanghongyu@xiaomi.com>
Date:   Sun May 29 21:47:28 2022 +0800

    devif: remove all devif_timer

    Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-06-07 20:15:41 +03:00
Xiang Xiao
298b4aba0c net/tcp: Hold the net lock in tcp_timer_expiry
to follow the call convention for d_txavail

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-06-07 20:15:41 +03:00
zhanghongyu
035d925864 devif: remove all devif_timer
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-06-02 20:11:50 -03:00
anjiahao
b88a8cf39f use rmutex inside of all repeated implementation
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2022-05-30 19:43:48 +08:00
Xiang Xiao
7ec6b4c7dd Change dpends on SCHED_[L|H]PWORK to SCHED_WORKQUEUE
since the code could map the unsupported work to the
supported one and remove select SCHED_WORKQUEUE from
Kconfig since SCHED_[L|H]PWORK already do the selection

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-05-28 18:41:51 +03:00
zhanghongyu
3f8b71924f tcp: move wd_timer from wifi driver to tcp stack
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-05-28 16:29:51 +08:00
Xiang Xiao
753aa98ca7 net/tcp: Zero keeptimer in case caller set keepalive to false
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-05-19 09:08:36 -03:00
Xiang Xiao
d8b97d7ae8 net/tcp: Use the relative value for keep alive timer
unify the timer process logic as other tcp state

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-05-18 18:40:41 +03:00