Commit Graph

2687 Commits

Author SHA1 Message Date
Nathan Hartman 6b89b6f945 Remove executable permissions from source files
* arch/arm/src/sama5/sam_flexcom_spi.h,
  arch/risc-v/src/mpfs/mpfs_ihc_sbi.c,
  drivers/usbdev/adb.c,
  libs/libc/math/lib_scalbn.c,
  libs/libc/math/lib_scalbnf.c,
  net/ipfrag/Make.defs,
  net/ipfrag/ipfrag.c,
  net/ipfrag/ipfrag.h,
  net/ipfrag/ipv4_frag.c,
  net/ipfrag/ipv6_frag.c: Remove executable permission.
2023-01-30 20:34:51 -03:00
Zhe Weng be89bcc044 mm/iob: Support negative offset when copyin/out.
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-01-31 00:39:15 +08:00
梁超众 b33474cb11 free TCP rx buffer immediately in tcp_close
Issue:
TCP rx buffer is freed after 4-way handshake with current design.
3 socket's rx buffer might be consumed during ffmpeg switch music procedure,
and this might cause IOB exhausted.

Solution:
free TCP rx buffer immediately in tcp_close to make sure IOB won't be
exhausted.

Signed-off-by: 梁超众 <liangchaozhong@xiaomi.com>
Signed-off-by: chao an <anchao@xiaomi.com>
2023-01-30 11:25:36 +08:00
chao an 98e1f9c36d net/tcp: reuse common api to replace some ip select code
Signed-off-by: chao an <anchao@xiaomi.com>
2023-01-30 11:25:10 +08:00
luojun1 861004725a Fix ICMPv6 RA parsing procedure
Signed-off-by: luojun1 <luojun1@xiaomi.com>
2023-01-29 14:32:59 +08:00
zhanghongyu 3e4e416786 tcp/udp_connect: If the remote addr is ANY, change it to LOOPBACK
Behavior alignment to Linux

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-01-29 13:46:43 +08:00
chao an 85a8249821 Revert "socket:return -EAGAIN if timeout happends in psock_tcp_send"
This reverts commit fbe641a916.

This issue already fixed by below change:

| commit 715785245c
| Author: chao an <anchao@xiaomi.com>
| Date:   Mon Jan 16 12:37:44 2023 +0800
|
|     net/tcp: fix potential busy loop in tcp_send_buffered.c
|
|     if the wrbuffer does not have enough space to send the rest of
|     the data, then the send function will loop infinitely in nonblock
|     mode, add send timeout check to avoid this issue.
|
|     Signed-off-by: chao an <anchao@xiaomi.com>

Signed-off-by: chao an <anchao@xiaomi.com>
2023-01-29 13:46:01 +08:00
zhanghongyu 26286fd19e tcp: modify errno when connect raddr is ANY for ltp
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-01-29 13:45:49 +08:00
zhanghongyu 65e08b750c tcp_reset: check the conn is exist when tcp_reset
tcp_input:
If we didn't find an active connection that expected the packet,
If the SYN flag isn't set,
It is an old packet and we send a RST.
conn is NULL when this case

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-01-29 13:43:44 +08:00
梁超众 5012195bde support ipv4 ToS and ipv6 TrafficClass
Signed-off-by: 梁超众 <liangchaozhong@xiaomi.com>
2023-01-29 13:43:44 +08:00
梁超众 5e0af0ecfd add UDP compile option to avoid build error
The following build error happens when CONFIG_NET_IPv6 is enabled and CONFIG_NET_UDP is not enabled.

inet/ipv6_setsockopt.c:132:19: error: invalid use of undefined type 'struct udp_conn_s'
132 |               conn->flags |= _UDP_FLAG_PKTINFO;
|                   ^~
  inet/ipv6_setsockopt.c:132:30: error: '_UDP_FLAG_PKTINFO' undeclared (first use in this function)
    132 |               conn->flags |= _UDP_FLAG_PKTINFO;
        |                              ^~~~~~~~~~~~~~~~~
  inet/ipv6_setsockopt.c:132:30: note: each undeclared identifier is reported only once for each function it appears in
  inet/ipv6_setsockopt.c:136:19: error: invalid use of undefined type 'struct udp_conn_s'
    136 |               conn->flags &= ~_UDP_FLAG_PKTINFO;

Signed-off-by: 梁超众 <liangchaozhong@xiaomi.com>
2023-01-29 13:43:44 +08:00
zhanghongyu 1857a4a3c8 udp: Ipv4/6 can be bound to the same port
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-01-28 23:28:33 +02:00
yintao 82e2e4124a net/local_connect:Align the returned error code with Linux
When using PIPE connect to a file, ENOTSOCK or ECONNREFUSED should be returned
and when using PIPE connect to invalid pipe name, ENOENT should be returned in libuv

Signed-off-by: yintao <yintao@xiaomi.com>
2023-01-28 23:27:58 +02:00
zhanghongyu 86d602f734 tcp_netpoll: add assert into tcp_pollsetup when pollinfo invalid
In order to expose similar problems quickly in the future

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-01-28 23:27:14 +02:00
liangchaozhong 7e80879f88 usrsock: Output the log if usrsock_request return error
Signed-off-by: liangchaozhong <liangchaozhong@xiaomi.com>
2023-01-28 16:27:21 +09:00
liangchaozhong cc940e8f69 net_lock:fix deadlock issue when running iperf tx test on usrsock
Issue Description:
deadlock happens when runnging iperf TCP tx on usrsock with the
following commands:
device command: iperf2 -c <PC IP address> -u -i 1 -p 1122  -t 10
PC command: iperf -s -u -i 1 -p 1122

iperf's thread holds net_lock before call usrsock_setup_request_callback
and waits for conn->resp.sem by calling
nxsem_wait_uninterruptible(&conn->resp.sem), while conn->resp.sem
can only be signaled in usrsock_response, who is waiting for net_lock in
tptun's thread.

Solution:
call net_lockedwait_uninterruptible to make sure net_lock can be
released when conn->resp.sem is not available.

Here's the backtrace:
up_block_task
nuttx/arch/arm/src/common/arm_blocktask.c:151
nxsem_wait
nuttx/sched/semaphore/sem_wait.c:185 (discriminator 2)
nxsem_wait_uninterruptible
nuttx/sched/semaphore/sem_wait.c:223 (discriminator 1)
usrsock_setup_request_callback
nuttx/net/usrsock/usrsock_conn.c:228
usrsock_setup_data_request_callback
nuttx/net/usrsock/usrsock_conn.c:257
usrsock_getsockopt
nuttx/net/usrsock/usrsock_getsockopt.c:202
psock_getsockopt
nuttx/net/socket/getsockopt.c:448
getsockopt
nuttx/net/socket/getsockopt.c:515
getsock_tcp_windowsize
external/iperf2/iperf2/src/tcp_window_size.c:165
reporter_reportsettings
external/iperf2/iperf2/src/ReportDefault.c:384
reporter_print
external/iperf2/iperf2/src/Reporter.c:1402
reporter_process_report
external/iperf2/iperf2/src/Reporter.c:860
reporter_process_report
external/iperf2/iperf2/src/Reporter.c:828
reporter_spawn
external/iperf2/iperf2/src/Reporter.c:720
thread_run_wrapper
external/iperf2/iperf2/compat/Thread.c:270
pthread_startup
nuttx/libs/libc/pthread/pthread_create.c:59 (discriminator 2)
pthread_start
nuttx/sched/pthread/pthread_create.c:182 (discriminator 4)

up_block_task
nuttx/arch/arm/src/common/arm_blocktask.c:151
nxsem_wait
nuttx/sched/semaphore/sem_wait.c:185 (discriminator 2)
sem_wait
nuttx/sched/semaphore/sem_wait.c:271
nxmutex_lock
nuttx/include/nuttx/mutex.h:165
nxrmutex_lock
nuttx/include/nuttx/mutex.h:369
usrsock_handle_req_response
nuttx/net/usrsock/usrsock_devif.c:466
usrsockdev_write
nuttx/drivers/usrsock/usrsock_dev.c:304
file_write
nuttx/fs/vfs/fs_write.c:90
usrsock_rpmsg_default_handler
apps/netutils/usrsock_rpmsg/usrsock_rpmsg_client.c:137
rpmsg_virtio_rx_callback
nuttx/openamp/open-amp/lib/rpmsg/rpmsg_virtio.c:371
virtqueue_notification
nuttx/openamp/open-amp/lib/virtio/virtqueue.c:706
rproc_virtio_notified
nuttx/openamp/open-amp/lib/remoteproc/remoteproc_virtio.c:337 (discriminator 2)
remoteproc_get_notification
nuttx/openamp/open-amp/lib/remoteproc/remoteproc.c:999
rptun_worker
nuttx/drivers/rptun/rptun.c:333
rptun_thread
nuttx/drivers/rptun/rptun.c:364 (discriminator 1)
nxtask_start
nuttx/sched/task/task_start.c:144

Signed-off-by: liangchaozhong <liangchaozhong@xiaomi.com>
2023-01-28 16:27:21 +09:00
zhanghongyu 99c2d2009a udp: remove DEBUGASSERT for ip6_is_ipv4addr
fix build break if enable CONFIG_NET_IPv6 only

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-01-28 09:04:29 +02:00
zhanghongyu c1521b2ef2 tcp: add TCP_ACKDATA flag to close event callback
The close package cannot be sent in time without TCP_ACKDATA

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-01-28 09:02:42 +02:00
zhanghongyu 3725fe28fb tcp: fix trans data error when fast retrans
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-01-28 09:02:14 +02:00
liangchaozhong fbe641a916 socket:return -EAGAIN if timeout happends in psock_tcp_send
psock_tcp_send will enter busyloop state when no IOB keeps at unavailable state
when the socket is blocking socket and this will cause WDT.
According to socket's manpage, -1 should be returned while errno set to EAGAIN
if send/recv timeout was set.

Here's the description:
SO_RCVTIMEO and SO_SNDTIMEO
Specify the receiving or sending timeouts until reporting an error. The argument is a struct timeval. If an input or output function blocks for this period of time, and data has been sent or received, the return value of that function will be the amount of data transferred; if no data has been transferred and the timeout has been reached then -1 is returned with errno set to EAGAIN or EWOULDBLOCK, or EINPROGRESS (for connect(2)) just as if the socket was specified to be nonblocking. If the timeout is set to zero (the default) then the operation will never timeout. Timeouts only have effect for system calls that perform socket I/O (e.g., read(2), recvmsg(2), send(2), sendmsg(2)); timeouts have no effect for select(2), poll(2), epoll_wait(2), and so on.

Signed-off-by: liangchaozhong <liangchaozhong@xiaomi.com>
2023-01-28 08:06:57 +02:00
David 22feaeeebb Bugfixed the SocketCAN send via setting the dev->d_len to dev->d_sndlen. The dev->d_len wouldn't be assigned otherwise. 2023-01-27 23:08:05 +08:00
Masayuki Ishikawa dc454765fb Revert "add holder for mutex"
This reverts commit fc176addeb.
2023-01-19 06:04:48 +09:00
lilei19 fc176addeb add holder for mutex
Signed-off-by: lilei19 <lilei19@xiaomi.com>
2023-01-18 17:40:58 +08:00
chao an 64dd7e6376 net/tcp: add Selective-ACK support
Reference:
https://datatracker.ietf.org/doc/html/rfc2018

Iperf2 client/server test on esp32c3:

Drop(1/50):
CONFIG_NET_TCP_DEBUG_DROP_SEND=y
CONFIG_NET_TCP_DEBUG_DROP_SEND_PROBABILITY=50  // Drop probability: 1/50
CONFIG_NET_TCP_DEBUG_DROP_RECV=y
CONFIG_NET_TCP_DEBUG_DROP_RECV_PROBABILITY=50  // Drop probability: 1/50

Drop(1/50) + OFO/SACK:
CONFIG_NET_TCP_DEBUG_DROP_SEND=y
CONFIG_NET_TCP_DEBUG_DROP_SEND_PROBABILITY=50  // Drop probability: 1/50
CONFIG_NET_TCP_DEBUG_DROP_RECV=y
CONFIG_NET_TCP_DEBUG_DROP_RECV_PROBABILITY=50  // Drop probability: 1/50

CONFIG_NET_TCP_OUT_OF_ORDER=y
CONFIG_NET_TCP_SELECTIVE_ACK=y

---------------------------------------------------------
|  TCP Config            | Server | Client |            |
|-------------------------------------------------------|
|  Original              |   12   |     9  |  Mbits/sec |
|  Drop(1/50)            |  0.6   |   0.3  |  Mbits/sec |
|  Drop(1/50) + OFO/SACK |    8   |     8  |  Mbits/sec |
---------------------------------------------------------

Signed-off-by: chao an <anchao@xiaomi.com>
2023-01-18 16:24:09 +08:00
chao an c581cc5f9b net/tcp: parse tcp options in common function
Signed-off-by: chao an <anchao@xiaomi.com>
2023-01-18 16:24:09 +08:00
chao an d175f50f01 net/tcp: add out-of-order segment support
Signed-off-by: chao an <anchao@xiaomi.com>
2023-01-18 16:24:09 +08:00
chao an 0e7d397553 net/tcp: new api tcp_dataconcat() to concatenate/pack iob chain
Signed-off-by: chao an <anchao@xiaomi.com>
2023-01-18 16:24:09 +08:00
Zhe Weng 1cf3147626 net/netdev: Avoid hardcoded guardsize when using d_iob
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-01-18 14:41:07 +08:00
chao an 2afa1b3b64 net/udp: correct linger timeout
UDP linger timeout will be wrongly converted to UINT_MAX by _SO_TIMEOUT() when it is set to 0,

net/socket/socket.h:
|
| #  define _SO_TIMEOUT(t) ((t) ? (t) * MSEC_PER_DSEC : UINT_MAX)

net/udp/udp_close.c:
|
| if (_SO_GETOPT(conn->sconn.s_options, SO_LINGER))
|   {
|     timeout = _SO_TIMEOUT(conn->sconn.s_linger);
|   }

this change will correct this behavior, if the linger is set to 0, the timeout value should be 0

Signed-off-by: chao an <anchao@xiaomi.com>
2023-01-18 02:47:12 +08:00
chao an 1f75d02bb5 net/tcp: correct behavior of SO_LINGER
1. Remove tcp_txdrain() from close() to avoid indefinitely block
2. Send TCP_RST immediately if linger timeout

Signed-off-by: chao an <anchao@xiaomi.com>
2023-01-18 02:47:12 +08:00
chao an fa6ba05097 net/tcp: move drop send source code to correct place
Merge conflicts lead to code being placed in thre wrong place
The debug code should placed in tcp_send() not tcp_synack()

Signed-off-by: chao an <anchao@xiaomi.com>
2023-01-18 02:12:43 +08:00
chao an 9ae7119a39 net/devif: bypass send length check if ip fragment enabled
Signed-off-by: chao an <anchao@xiaomi.com>
2023-01-18 02:12:02 +08:00
chao an 715785245c net/tcp: fix potential busy loop in tcp_send_buffered.c
if the wrbuffer does not have enough space to send the rest of
the data, then the send function will loop infinitely in nonblock
mode, add send timeout check to avoid this issue.

Signed-off-by: chao an <anchao@xiaomi.com>
2023-01-18 02:11:33 +08:00
ligd 1b333bfad5 rpmsg_socket: destroy_ept only at close
Signed-off-by: ligd <liguiding1@xiaomi.com>
2023-01-18 02:11:16 +08:00
ligd a7dea8ddf6 rpmsg_socket: shouldn't call create_device again after create_ept
Signed-off-by: ligd <liguiding1@xiaomi.com>
2023-01-18 02:11:16 +08:00
ligd d6cad21a17 rpmsg_socket: rpmsg_send_nocpy() should lock with rpmsg_destroy_ept
Signed-off-by: ligd <liguiding1@xiaomi.com>
2023-01-18 02:11:16 +08:00
ligd c0735f06f6 rpmsg_socket: release tx buffer when send_oncopy failed
Signed-off-by: ligd <liguiding1@xiaomi.com>
2023-01-18 02:11:16 +08:00
luojun1234 ff3733b5b5 Support fragmentation and reassembly
Signed-off-by: luojun1 <luojun1@xiaomi.com>
2023-01-17 14:01:37 +08:00
crafcat7 2ec117b3ca fs/fs_fsync:Fix the expected error of socket,fifo and pipe returning error in fsync case 2023-01-17 01:56:40 +08:00
Xiang Xiao a851ad84c3 net: consistent the net sem wait naming conversion
to prepare the new mutex wait function

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-15 12:31:30 -03:00
chao an 22348c890b net/tcp: debug feature to drop the tx/rx packet
Add 2 configurations
1. Config to drop recived packet
CONFIG_NET_TCP_DEBUG_DROP_RECV=y
CONFIG_NET_TCP_DEBUG_DROP_RECV_PROBABILITY=50 /* Default drop probability is 1/50 */

2. Config to drop sent packet
CONFIG_NET_TCP_DEBUG_DROP_SEND=y
CONFIG_NET_TCP_DEBUG_DROP_SEND_PROBABILITY=50 /* Default drop probability is 1/50 */

Iperf2 client/server test on esp32c3:

---------------------------------------------------------
|  TCP Config            | Server | Client |            |
|-------------------------------------------------------|
|  Original              |   12   |     9  |  Mbits/sec |
|  Drop(1/50)            |  0.6   |   0.3  |  Mbits/sec |
|  Drop(1/50) + OFO/SACK |    8   |     8  |  Mbits/sec |
---------------------------------------------------------

Signed-off-by: chao an <anchao@xiaomi.com>
2023-01-14 14:05:26 +08:00
Xiang Xiao 695f42f8d2 net: Move accept to libc after https://github.com/apache/nuttx/pull/8083
since accept can simply forward to kernel accept4 function

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-13 11:23:42 +02:00
chao an 8a63d29c6e net/devif_poll: optimize device buffer alloc in txpoll
Allocate the device buffer only if the protocol really need to send data.
not all protocols require the driver to prepare additional iob before
sending, especially UDP, each iob reserves l2/l3 header in advance
after prepare write buffer, net device could reuse this entry to send directly

Signed-off-by: chao an <anchao@xiaomi.com>
2023-01-13 16:41:10 +08:00
chao an 0cbbbb9215 net/devif: reuse devif_send() for can/pkt/icmp stack
Signed-off-by: chao an <anchao@xiaomi.com>
2023-01-13 16:41:10 +08:00
田昕 40c9e627d6 net/local:set POLLIN/POLLOUT threshold for local fifo
Signed-off-by: 田昕 <tianxin7@xiaomi.com>
2023-01-13 12:27:54 +08:00
chao an 1a513588bf net/mld: update help manual for mld router
Signed-off-by: chao an <anchao@xiaomi.com>
2023-01-12 15:06:22 +08:00
Zhe Weng 6222ad5764 Revert "net: downgrade iob priority of input/udp/icmp to avoid blocking devif"
This reverts commit d87620abc9.
2023-01-12 01:56:18 +08:00
zhanghongyu 48c9d10336 net_socket: add accept4 function
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-01-11 23:28:08 +08:00
chao an 47d628d22e net/mld: fix build break of mld router
Signed-off-by: chao an <anchao@xiaomi.com>
2023-01-11 22:58:21 +08:00
梁超众 aca1a065a8 move usrsock to kernel space
Signed-off-by: 梁超众 <liangchaozhong@xiaomi.com>
2023-01-11 15:14:03 +08:00