Commit Graph

2384 Commits

Author SHA1 Message Date
Alexander Lunev
8042de1145 net/devif/devif_callback.c: devif_callback_free() call is not needed anymore in devif_callback_alloc() 2022-01-06 22:47:18 +08:00
Xiang Xiao
e27962a997 net/devif: Fix the memory leak in case of netdev isn't alive
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-01-05 22:01:13 +08:00
raiden00pl
a8ca1ec026 SocketCAN: add CAN error definitions 2022-01-05 18:32:46 +08:00
chao.an
4603d108be net/usrsock: add support for CONFIG_NET_ALLOC_CONNS
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-01-05 12:39:00 +08:00
chao.an
cbe9352f41 net/usrsock: remove the connections limit
replace xid type to uint64_t to avoid connections limit

Signed-off-by: chao.an <anchao@xiaomi.com>
2022-01-05 12:38:42 +08:00
chao.an
504f1d1b5f net/misc: add support for CONFIG_NET_ALLOC_CONNS
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-01-04 14:36:07 +08:00
chao.an
a1bf9ca88b net/icmp[v6]: add support for CONFIG_NET_ALLOC_CONNS
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-01-04 14:36:07 +08:00
raiden00pl
6185377eec net/devif/devif_cansend.c: fix assertion for max data len 2022-01-03 08:52:49 -03:00
raiden00pl
649619b8f8 net/can/can_recvmsg.c: fix warning 2022-01-03 08:52:49 -03:00
Xiang Xiao
43c28c4456 net/usrsock: Fix the compile warning
In file included from usrsock/usrsock_bind.c:32:
usrsock/usrsock_bind.c: In function ‘usrsock_bind’:
usrsock/usrsock_bind.c:183:13: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘ssize_t’ {aka ‘long int’} [-Wformat=]
  183 |       nwarn("usrsock_setup_request_callback failed: %d\n", ret);
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ~~~
      |                                                            |
      |                                                            ssize_t {aka long int}
usrsock/usrsock_bind.c:183:54: note: format string is defined here
  183 |       nwarn("usrsock_setup_request_callback failed: %d\n", ret);
      |                                                     ~^
      |                                                      |
      |                                                      int
      |                                                     %ld
CC:  usrsock/usrsock_connect.c
CC:  usrsock/usrsock_dev.c
In file included from usrsock/usrsock_dev.c:37:
usrsock/usrsock_dev.c: In function ‘usrsockdev_handle_event’:
usrsock/usrsock_dev.c:488:19: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘size_t’ {aka ‘long unsigned int’} [-Wformat=]
  488 |             nwarn("message too short, %d < %d.\n", len, sizeof(*hdr));
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ~~~
      |                                                    |
      |                                                    size_t {aka long unsigned int}
usrsock/usrsock_dev.c:488:40: note: format string is defined here
  488 |             nwarn("message too short, %d < %d.\n", len, sizeof(*hdr));
      |                                       ~^
      |                                        |
      |                                        int
      |                                       %ld
In file included from usrsock/usrsock_dev.c:37:
usrsock/usrsock_dev.c:488:19: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘long unsigned int’ [-Wformat=]
  488 |             nwarn("message too short, %d < %d.\n", len, sizeof(*hdr));
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~       ~~~~~~~~~~~~
      |                                                         |
      |                                                         long unsigned int
usrsock/usrsock_dev.c:488:45: note: format string is defined here
  488 |             nwarn("message too short, %d < %d.\n", len, sizeof(*hdr));
      |                                            ~^
      |                                             |
      |                                             int
      |                                            %ld
In file included from usrsock/usrsock_dev.c:37:
usrsock/usrsock_dev.c: In function ‘usrsockdev_handle_datareq_response’:
usrsock/usrsock_dev.c:657:13: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘size_t’ {aka ‘long unsigned int’} [-Wformat=]
  657 |       nwarn("%dth buffer not large enough (need: %d, have: %d).\n",
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......
  660 |             conn->resp.datain.iov[iovpos].iov_len);
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                          |
      |                                          size_t {aka long unsigned int}
usrsock/usrsock_dev.c:657:61: note: format string is defined here
  657 |       nwarn("%dth buffer not large enough (need: %d, have: %d).\n",
      |                                                            ~^
      |                                                             |
      |                                                             int
      |                                                            %ld
In file included from usrsock/usrsock_dev.c:37:
usrsock/usrsock_dev.c:678:17: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘size_t’ {aka ‘long unsigned int’} [-Wformat=]
  678 |           nwarn("%dth buffer not large enough "
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......
  682 |                 conn->resp.datain.iov[iovpos].iov_len);
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                              |
      |                                              size_t {aka long unsigned int}
usrsock/usrsock_dev.c:679:45: note: format string is defined here
  679 |                 "(need: %" PRId32 ", have: %d).\n",
      |                                            ~^
      |                                             |
      |                                             int
      |                                            %ld
In file included from usrsock/usrsock_dev.c:37:
usrsock/usrsock_dev.c: In function ‘usrsockdev_handle_req_response’:
usrsock/usrsock_dev.c:745:13: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘size_t’ {aka ‘long unsigned int’} [-Wformat=]
  745 |       nwarn("message too short, %d < %d.\n", len, hdrlen);
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ~~~
      |                                              |
      |                                              size_t {aka long unsigned int}
usrsock/usrsock_dev.c:745:34: note: format string is defined here
  745 |       nwarn("message too short, %d < %d.\n", len, hdrlen);
      |                                 ~^
      |                                  |
      |                                  int
      |                                 %ld
In file included from usrsock/usrsock_dev.c:37:
usrsock/usrsock_dev.c: In function ‘usrsockdev_write’:
usrsock/usrsock_dev.c:858:17: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘size_t’ {aka ‘long unsigned int’} [-Wformat=]
  858 |           nwarn("message too short, %d < %d.\n", len,
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ~~~
      |                                                  |
      |                                                  size_t {aka long unsigned int}
usrsock/usrsock_dev.c:858:38: note: format string is defined here
  858 |           nwarn("message too short, %d < %d.\n", len,
      |                                     ~^
      |                                      |
      |                                      int
      |                                     %ld
In file included from usrsock/usrsock_dev.c:37:
usrsock/usrsock_dev.c:858:17: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘long unsigned int’ [-Wformat=]
  858 |           nwarn("message too short, %d < %d.\n", len,
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  859 |                 sizeof(struct usrsock_message_common_s));
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                 |
      |                 long unsigned int
usrsock/usrsock_dev.c:858:43: note: format string is defined here
  858 |           nwarn("message too short, %d < %d.\n", len,
      |                                          ~^
      |                                           |
      |                                           int
      |                                          %ld
CC:  usrsock/usrsock_getpeername.c
In file included from usrsock/usrsock_getpeername.c:32:
usrsock/usrsock_getpeername.c: In function ‘usrsock_getpeername’:
usrsock/usrsock_getpeername.c:190:13: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘ssize_t’ {aka ‘long int’} [-Wformat=]
  190 |       nwarn("usrsock_setup_request_callback failed: %d\n", ret);
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ~~~
      |                                                            |
      |                                                            ssize_t {aka long int}
usrsock/usrsock_getpeername.c:190:54: note: format string is defined here
  190 |       nwarn("usrsock_setup_request_callback failed: %d\n", ret);
      |                                                     ~^
      |                                                      |
      |                                                      int
      |                                                     %ld
CC:  usrsock/usrsock_event.c
CC:  usrsock/usrsock_getsockname.c
In file included from usrsock/usrsock_getsockname.c:32:
usrsock/usrsock_getsockname.c: In function ‘usrsock_getsockname’:
usrsock/usrsock_getsockname.c:190:13: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘ssize_t’ {aka ‘long int’} [-Wformat=]
  190 |       nwarn("usrsock_setup_request_callback failed: %d\n", ret);
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ~~~
      |                                                            |
      |                                                            ssize_t {aka long int}
usrsock/usrsock_getsockname.c:190:54: note: format string is defined here
  190 |       nwarn("usrsock_setup_request_callback failed: %d\n", ret);
      |                                                     ~^
      |                                                      |
      |                                                      int
      |                                                     %ld
CC:  usrsock/usrsock_getsockopt.c
CC:  usrsock/usrsock_poll.c
CC:  usrsock/usrsock_recvmsg.c
In file included from usrsock/usrsock_recvmsg.c:32:
usrsock/usrsock_recvmsg.c: In function ‘usrsock_recvmsg’:
usrsock/usrsock_recvmsg.c:321:21: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘ssize_t’ {aka ‘long int’} [-Wformat=]
  321 |               nwarn("usrsock_setup_request_callback failed: %d\n", ret);
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ~~~
      |                                                                    |
      |                                                                    ssize_t {aka long int}
usrsock/usrsock_recvmsg.c:321:62: note: format string is defined here
  321 |               nwarn("usrsock_setup_request_callback failed: %d\n", ret);
      |                                                             ~^
      |                                                              |
      |                                                              int
      |                                                             %ld
In file included from usrsock/usrsock_recvmsg.c:32:
usrsock/usrsock_recvmsg.c:343:24: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘ssize_t’ {aka ‘long int’} [-Wformat=]
  343 |                   nerr("net_timedwait errno: %d\n", ret);
      |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~  ~~~
      |                                                     |
      |                                                     ssize_t {aka long int}
usrsock/usrsock_recvmsg.c:343:47: note: format string is defined here
  343 |                   nerr("net_timedwait errno: %d\n", ret);
      |                                              ~^
      |                                               |
      |                                               int
      |                                              %ld
In file included from usrsock/usrsock_recvmsg.c:32:
usrsock/usrsock_recvmsg.c:384:17: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘ssize_t’ {aka ‘long int’} [-Wformat=]
  384 |           nwarn("usrsock_setup_request_callback failed: %d\n", ret);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ~~~
      |                                                                |
      |                                                                ssize_t {aka long int}
usrsock/usrsock_recvmsg.c:384:58: note: format string is defined here
  384 |           nwarn("usrsock_setup_request_callback failed: %d\n", ret);
      |                                                         ~^
      |                                                          |
      |                                                          int
      |                                                         %ld
CC:  usrsock/usrsock_sendmsg.c
In file included from usrsock/usrsock_sendmsg.c:32:
usrsock/usrsock_sendmsg.c: In function ‘usrsock_sendmsg’:
usrsock/usrsock_sendmsg.c:302:21: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘ssize_t’ {aka ‘long int’} [-Wformat=]
  302 |               nwarn("usrsock_setup_request_callback failed: %d\n", ret);
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ~~~
      |                                                                    |
      |                                                                    ssize_t {aka long int}
usrsock/usrsock_sendmsg.c:302:62: note: format string is defined here
  302 |               nwarn("usrsock_setup_request_callback failed: %d\n", ret);
      |                                                             ~^
      |                                                              |
      |                                                              int
      |                                                             %ld
In file included from usrsock/usrsock_sendmsg.c:32:
usrsock/usrsock_sendmsg.c:324:24: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘ssize_t’ {aka ‘long int’} [-Wformat=]
  324 |                   nerr("net_timedwait errno: %d\n", ret);
      |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~  ~~~
      |                                                     |
      |                                                     ssize_t {aka long int}
usrsock/usrsock_sendmsg.c:324:47: note: format string is defined here
  324 |                   nerr("net_timedwait errno: %d\n", ret);
      |                                              ~^
      |                                               |
      |                                               int
      |                                              %ld
In file included from usrsock/usrsock_sendmsg.c:32:
usrsock/usrsock_sendmsg.c:364:17: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘ssize_t’ {aka ‘long int’} [-Wformat=]
  364 |           nwarn("usrsock_setup_request_callback failed: %d\n", ret);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ~~~
      |                                                                |
      |                                                                ssize_t {aka long int}
usrsock/usrsock_sendmsg.c:364:58: note: format string is defined here
  364 |           nwarn("usrsock_setup_request_callback failed: %d\n", ret);
      |                                                         ~^
      |                                                          |
      |                                                          int
      |                                                         %ld

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-01-03 11:19:32 +08:00
Alexander Lunev
e9ab3adf23 net/tcp(unbuffered): advance sndseq by +1 because SYN and FIN occupy one sequence number (RFC 793) 2022-01-03 12:18:44 +09:00
Alexander Lunev
0afb1d8dbb net/tcp(unbuffered): fast retransmit on duplicate acknowledgments 2022-01-02 23:25:09 +08:00
chao.an
f345f3dc2e net/devif_callback: add support for CONFIG_NET_ALLOC_CONNS
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-01-02 01:25:14 +08:00
chao.an
3b490d4e3a net/icmp: post the semaphore if multiple references
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-01-02 01:23:23 +08:00
chao.an
26370cd2f7 net/udp: add support for CONFIG_NET_ALLOC_CONNS
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-01-01 20:40:02 +08:00
chao.an
38b7b3d26a net/tcp: add support for CONFIG_NET_ALLOC_CONNS 2022-01-01 20:40:02 +08:00
chao.an
581b67ade3 net: add config to support allocate connect dynamically
add config CONFIG_NET_ALLOC_CONNS to support allocate connect.
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.

Signed-off-by: chao.an <anchao@xiaomi.com>
2022-01-01 20:40:02 +08:00
Alexander Lunev
2b60468845 net/tcp(unbuffered): removed excessive overwrites of conn->sndseq
(conn->sndseq was updated in multiple places that was unreasonable and complicated).
2021-12-29 05:35:23 -06:00
Norman Rasmussen
48311cc61f Fix unaligned memory access when creating ICMP Port Unreachable messages
commit 3b69d09c80 corrected the
unreachable handling for net/udp/icmp but introduced an unaligned store.
This splits the uint32_t data field into a two element uint16_t data
field to avoid the unaligned store.
2021-12-28 03:51:53 -06:00
Petro Karashchenko
3ccb657dc2 nuttx: remove space befone newline in logs
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2021-12-27 21:01:19 -06:00
Alexander Lunev
e68ffb9f99 net/tcp(unbuffered): fixed an issue with unackseq calculation.
Wrong unackseq calculation locked conn->tx_unacked at non-zero values
even if all ACKs were received. Thus unbuffered psock_tcp_send() never completed.
2021-12-27 20:59:48 -06:00
Alexander Lunev
19dc121a4f net/tcp(unbuffered): fixed an issue with tx_unacked overflow that occurred if NET_TCP_WINDOW_SCALE option was enabled.
If the remote TCP receiver advertised TCP window size greater than 64 KB
and TCP ACK packets returned to the NuttX TCP sender with a significant delay,
tx_unacked variable overflowed and further TCP send stalled forever
(until TCP re-connection).
2021-12-27 11:05:01 -06:00
Xiang Xiao
dfcb3cea59 Replace self defined macros with NET_SOCK_[FAMILY|TYPE|PROTOCOL]
NET_SOCK_* is defined by nuttx/net/netconfig.h and then can be shared

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-12-21 11:02:33 -03:00
Juha Niskanen
422ceec99b Fix typos in comments and Kconfig files
Signed-off-by: Juha Niskanen <juha.niskanen@haltian.com>
2021-12-21 03:26:16 -06:00
chao.an
1e83c83bf3 net/usrsock: increase the send/recv() length limit to UINT32_MAX
change request type to uint32_t to the impove the throughput

Signed-off-by: chao.an <anchao@xiaomi.com>
2021-12-21 03:14:25 -06:00
Xiang Xiao
c562263205 net: Move if_nametoindex and if_indextoname to libc
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-12-19 10:08:57 -06:00
chao.an
b10dcf7c0d net/udp: fix the invaild udp destination address
If the udp socket not connected, it is possible to have
multi-different destination address in each iob entry,
update the remote address every time to avoid sent to the
incorrect destination.

Signed-off-by: chao.an <anchao@xiaomi.com>
2021-12-17 11:25:06 -06:00
chao.an
0ee7400fdf net/tcp: fix send deadlock if disconnect
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-12-16 01:29:10 -06:00
Petro Karashchenko
51a2db6ffc Kconfig: improve uniformity
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2021-12-14 07:32:48 -06:00
ligd
5c5bd7161c socket_rpmsg: fix ept_cb crash on server side
after correct:
client:                 server
connect                 ns_bind --> create new conn --> create_ept
                        accept  --> set conn->psock to newpsock

Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-12-13 21:15:59 -06:00
ligd
4a5d577483 socket_rpmsg: add socket_rpmsg_ioctl support
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-12-13 21:15:59 -06:00
ligd
aab5d3d390 rpmsg_socket: handle block/nonblock while send/recv
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-12-13 21:15:59 -06:00
ligd
be70ab2ebb rpmsg_scoket: handle race condition on ept_cb RPMSG_SOCKET_CMD_SYNC
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-12-13 21:15:59 -06:00
ligd
d0486be2a3 socket_rpmsg: fix conn->psock NULL in ept_cb
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-12-13 21:15:59 -06:00
ligd
68bbcf74c4 local_socket: filename use "/var/socket/xx" instead of "/var/socketxx"
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-12-13 02:37:11 -06:00
songlinzhang
22df553443 net/arp: clean the arp table when netdev carrier off
Fix the arp address changed if netdev renew, since the
arp table should be cleared when the netdev carrier off

Signed-off-by: songlinzhang <songlinzhang@xiaomi.com>
2021-11-27 06:19:50 -06:00
chao.an
3b69d09c80 net/udp/icmp: correct the unreadchable handling
Reference RFC1122:
https://datatracker.ietf.org/doc/html/rfc1122
----------------------------------------------

4.1.3  SPECIFIC ISSUES

  4.1.3.1  Ports

    If a datagram arrives addressed to a UDP port for which
    there is no pending LISTEN call, UDP SHOULD send an ICMP
    Port Unreachable message.

Signed-off-by: chao.an <anchao@xiaomi.com>
2021-11-26 08:47:54 -06:00
Alin Jerpelea
4ca25d8a4d net: usrsock: Haltian Ltd: update licenses to Apache
Gregory Nutt has submitted the SGA
Haltian Ltd has submitted the SGA

as a result we can migrate the licenses to Apache.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-11-15 06:49:32 -06:00
Alexander Lunev
1e07b6d528 net/tcp(unbuffered): retransmit only one the earliest not acknowledged segment
(according to RFC 6298 (5.4)).
2021-11-10 12:21:07 -06:00
YAMAMOTO Takashi
ecd6a3572b net/tcp/Kconfig: Remove NET_TCP_SPLIT
While it's a neat idea, it doesn't work well in reality.

* Many of modern tcp stacks don't obey the "ack every other packet"
  rule these days. (Linux, macOS, ...)

* Even if a traditional TCP implementation is assumed, we can't
  predict/control which packets are acked reliably. For example,
  window updates can easily mess up our strategy.
2021-11-04 13:32:57 -05:00
YAMAMOTO Takashi
28d168e1b8 tcp_send_unbuffered.c: Fix nxstyle errors 2021-11-04 13:32:57 -05:00
YAMAMOTO Takashi
1550a525e9 tcp_send_unbuffered.c: unifdef -UCONFIG_NET_TCP_SPLIT 2021-11-04 13:32:57 -05:00
ligd
022c06766a socket_rpmsg: use ns_bound to send SYNC packet
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-11-04 13:29:51 -05:00
ligd
883d66b906 socket_rpmsg: fix save rp_name error when accept
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-11-04 13:29:51 -05:00
ligd
00ef4fca51 rpmgs_socket: set RPMSG_SOCKET_NAME_SIZE to 16 for handing prefix
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-11-04 13:29:51 -05:00
ligd
59ae421314 socket_rpmsg: support SOCK_SEQPACKET
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-11-04 13:29:51 -05:00
ligd
bb41af3935 rpmsg_socket: move rpmsg_send out of lock
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-11-04 13:29:51 -05:00
ligd
391ccdc42b local_socket: recv should return 0 NOT -ECONNRESET if remote closed
ref:
https://man7.org/linux/man-pages/man2/recv.2.html

Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-11-02 08:59:06 +01:00
ligd
1970ce5116 local_socket: set lc_peer when accept() instead of connect()
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-11-02 08:59:06 +01:00
Alexander Lunev
1e25602678 net/can,icmp,icmpv6,tcp,tcp_timer,udp: device should poll only those connections that are bound to the device.
tcp_timer: eliminated false decrements of conn->timer in case of multiple network adapters.
The false timer decrements sometimes provoked TCP spurious retransmissions due to premature timeouts.
2021-10-11 23:09:00 -07:00
Jiuzhu Dong
887ec01f3e net: limit NET_NACTIVESOCKETS to 4 when enable DEFAULT_SMALL
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2021-10-10 19:59:28 -07:00
Jiuzhu Dong
93bdecf2c3 net: always compile listen.c and accept.c when enable CONFIG_NET
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2021-10-10 19:59:02 -07:00
chao.an
1b5d6aa068 net/local: add socket message control support
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-09-24 08:09:28 -07:00
chao.an
ea82a0b638 net/local: add local_peerconn helper
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-09-24 08:09:28 -07:00
chao.an
1e078795fb net/local: split the waiter node from lc_node
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-09-24 08:09:28 -07:00
chao.an
1ba922a826 net/local: replace the listener list to global
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-09-24 08:09:28 -07:00
chao.an
c132e5bed4 net/tcp: sanity check for the listen address
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-09-23 23:07:57 -07:00
chao.an
5a2510d48d net/dup: only start tcp monitor on INET domain
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-09-23 19:02:03 -07:00
Alexander Lunev
4ac7945676 net/devif/devif_callback.c: made the connection event list doubly linked.
The resulting time complexities are as follows:
* devif_callback_alloc() time complexity is O(1) (i.e. O(n) to fill the whole list).
* devif_callback_free() time complexity is O(1) (i.e. O(n) to empty the whole list).
* devif_conn_event() time complexity is O(n).
2021-09-21 03:51:06 -07:00
Alexander Lunev
36fbedcbfc net/devif/devif_callback.c: corrected the connection event list to work as FIFO instead of LIFO.
In case of enabled packet forwarding mode, packets were forwarded in a reverse order
because of LIFO behavior of the connection event list.
The issue exposed only during high network traffic. Thus the event list started to grow
that resulted in changing the order of packets inside of groups of several packets
like the following: 3, 2, 1, 6, 5, 4, 8, 7 etc.

Remarks concerning the connection event list implementation:
* Now the queue (list) is FIFO as it should be.
* The list is singly linked.
* The list has a head pointer (inside of outer net_driver_s structure),
  and a tail pointer is added into outer net_driver_s structure.
* The list item is devif_callback_s structure.
  It still has two pointers to two different list chains (*nxtconn and *nxtdev).
* As before the first argument (*dev) of the list functions can be NULL,
  while the other argument (*list) is effective (not NULL).
* An extra (*tail) argument is added to devif_callback_alloc()
  and devif_conn_callback_free() functions.
* devif_callback_alloc() time complexity is O(1) (i.e. O(n) to fill the whole list).
* devif_callback_free() time complexity is O(n) (i.e. O(n^2) to empty the whole list).
* devif_conn_event() time complexity is O(n).
2021-09-18 21:01:39 -05:00
Gregory Nutt
04c9079954 Back in 2007, an early network implementation was developed for NuttX. This early development was inspired largely by uIP 1.0 and recognition of that was noted in the then BSD license headers. Over the next 14 years, a new, much more advanced, original network was developed for NuttX. However, some references to Adam Dunkels were still present in the file headers.
Because of this, it will take some time to detangle the licensing under net/.  Many new features, original features were added to the NuttX network.  Clearly, any references to Adam Dunkels in the files that implement these new features that have no counterpart in uIP 1.0 are errors.

This PR removes the references and converts the license headers to Apache 2.0 where possible.  The affected files include only (1) the implementation of IPv6 (including neighbor support under ICMPv6) and (2) Raw sockets.  Neither of these features are present in uIP 1.0 and the licenses can be freely updated.
2021-09-17 21:49:44 -05:00
Alin Jerpelea
91a5f90a7f author: UVC Ingenieure : update licenses to Apache
Gregory Nutt has submitted the SGA
UVC Ingenieure has submitted the SGA
Max Holtzberg has submitted the ICLA

as a result we can migrate the licenses to Apache.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-09-15 15:57:55 +08:00
chao.an
b991b75e87 net/local: add FIONSPACE support
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-09-15 12:11:32 +08:00
chao.an
e10b546006 net/udp: fix buffer release handling on failed buffer alloc
Attempt to release write buffer on failed UDP write I/O buffer
alloc and tryalloc failed to wrb->wb_iob assertion.

Signed-off-by: chao.an <anchao@xiaomi.com>
2021-09-15 12:03:21 +08:00
Jiuzhu Dong
ce4b79d554 rpmsg_socket: add prefix "rpmsg-socket" for the name of rpmsg endpoint
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2021-09-12 11:32:05 +08:00
Masayuki Ishikawa
3330543fe6 net: utils: Remove critical section for SMP in net_lock.c
Summary:
- The critical section was added in Mar 2018 to improve
  stability in SMP mode
- However, I noticed that this critical section is no longer
  needed

Impact:
- None

Testing:
- Tested with spresense:wifi_smp and spresense:rndis_smp

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2021-09-06 14:57:08 +08:00
buyuer
001eb7786b net/local: Return the partial write size.
Signed-off-by: buyuer <dingddding@163.com>
2021-08-26 13:28:11 +08:00
YAMAMOTO Takashi
42f1851ca6 tcp_send_buffered.c: Fix snd_wnd
snd_wnd is an offset from the acked sequence number.
2021-08-25 20:56:05 +08:00
YAMAMOTO Takashi
1b82f1c749 tcp_input: snd_wnd processing
* Do not accept the window in old segments.
  Implement SND.WL1/WL2 things in the RFC.

* Do not accept the window in the segment w/o ACK bit set.
  The window is an offset from the ack seq.
  (maybe it's simpler to just drop segments w/o ACK though)

* Subtract snd_wnd by the amount of the ack advancement.
2021-08-25 20:56:05 +08:00
chao.an
efaf72a1b1 net/local: correct the return length of sendmsg
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-08-21 14:59:59 +08:00
chao.an
c19edbd08e net/rpmsg: add nonblock connect(2) support
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-08-19 22:25:44 -07:00
chao.an
498830d3f4 net/rpmsg: fix typo in comment
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-08-19 22:25:44 -07:00
chao.an
afef9c2044 net/rpmsg: move the sync handshark to ns_bind callback
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-08-19 22:25:44 -07:00
chao.an
64e95dc1f5 net/rpmsg: simplify the socket timeout of connect
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-08-19 22:25:44 -07:00
chao.an
9701a678bd net/tcp: add nonblock connect(2) support
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-08-19 19:19:05 -07:00
chao.an
1a55d933ef net/local: add nonblock connect(2) support
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-08-19 19:18:52 -07:00
SPRESENSE
9732334b5d net/socket: Fix bug that sendto did not return an error
When `tolen` is not 0 and `to` is NULL, it causes illegal buffer access.
Add a parameter check in this condition.
2021-08-19 01:31:05 -07:00
SPRESENSE
d17d877764 net/local: Fix receive data size calculation for local_recvmsg
In psock_dgram_recvfrom function, fix code logic.
2021-08-19 01:31:05 -07:00
YAMAMOTO Takashi
b815a2c3a8 tcp_input: Don't put back sndseq on an old ack 2021-08-06 21:17:25 -07:00
YAMAMOTO Takashi
e53f989997 tcp_rexmit: advance conn->sndseq
Otherwise, we use an old sequence number when sending
non-data segment. (eg. window update)
The peer might consider such a segment stale and ignore.
2021-08-06 21:17:25 -07:00
YAMAMOTO Takashi
0272a16010 net_ioballoc: remove redundant critical section 2021-08-05 23:50:46 -07:00
YAMAMOTO Takashi
b5bb0d56ad tcp: fix an assertion in "fix iob allocation deadlock" commit
Fix a wrong assertion in:

```
commit 98ec46d726
Author: YAMAMOTO Takashi <yamamoto@midokura.com>
Date:   Tue Jul 20 09:10:43 2021 +0900

    tcp_send_buffered.c: fix iob allocation deadlock

    Ensure to put the wrb back onto the write_q when blocking
    on iob allocation. Otherwise, it can deadlock with other
    threads doing the same thing.
```

I forget to submit this with https://github.com/apache/incubator-nuttx/pull/4257
2021-08-05 23:50:06 -07:00
YAMAMOTO Takashi
1d3594ba07 tcp_send_buffered.c: Fix broken retransmit
With an applictation using mbedtls, I observed retransmitted segments
with corrupted user data, detected by the peer tls during mac processing.

Looking at the packet dump, I suspect that a wrb which has been put back
onto the write_q for retransmission was partially sent but fully acked.
Note: it's normal for a retransmission to be acked before sent.

In that case, the bug fixed in this commit would cause the wrb have
a wrong sequence number, possibly the same as the next wrb. It matches
what I saw in the packet dump. That is, the broken segments contain the
payload identical to one of the previous segment.
2021-08-02 11:30:01 -07:00
YAMAMOTO Takashi
98ec46d726 tcp_send_buffered.c: fix iob allocation deadlock
Ensure to put the wrb back onto the write_q when blocking
on iob allocation. Otherwise, it can deadlock with other
threads doing the same thing.
2021-08-02 11:25:55 -07:00
Xiang Xiao
a262eebe34 libc: Rename match to fnmatch
specified here:
https://pubs.opengroup.org/onlinepubs/007904875/functions/fnmatch.html

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-08-02 08:23:35 -03:00
jordi
b87333bae8 Kconfig: remove empty help sections
To avoid the setconfig warning: "has 'help' but empty help text"
2021-07-23 02:32:19 -07:00
chao.an
a48513ad65 local/stream: remove preamble header in stream mode
Preable sync header is no necessary in stream mode

Signed-off-by: chao.an <anchao@xiaomi.com>
2021-07-21 23:43:10 -07:00
chao.an
cc5c7ee088 net/local: remove unused client lc_remaining
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-07-21 23:43:10 -07:00
chao.an
7d4502aca6 net/socket: add SO_SNDBUF support
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-07-20 20:24:58 -07:00
chao.an
f52757f90a net/wrb: add tcp/udp_inqueue_wrb_size() interface
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-07-20 20:24:58 -07:00
ligd
38c5837d2b socket_rpmsg: add lock to bind list, reject if list more than backlog
Change-Id: Ibdbe3d931d1b14601d9c5f3fb95cd87aacb4e5e1
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-07-19 22:47:34 -03:00
ligd
92eec01f56 socket_rpmsg: fix recv block when remote close early
MIRTOS-849

Change-Id: Id9ff88099bdc0efb27d64ffa8e407f5a9dd40e33
Signed-off-by: ligd <liguiding1@xiaomi.com>
(cherry picked from commit 85b917e20869f415c847c37731c5745c7942a9fd)
2021-07-19 22:47:34 -03:00
Peter Bee
b10905015a net/rpmsg: add multi-iov support
N/A

Add multi-iov support for rpmsg sockets

Change-Id: I188e41972be2942799fd06d4b530e292125fbf33
Signed-off-by: Peter Bee <bijunda1@xiaomi.com>
2021-07-17 08:52:40 -03:00
Xiang Xiao
663104a2e9 fs: Simplify sendfile implementation
and avoid call nx_ file API in the kernel space

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Id951ca161df2c2ee267dc4b5a0d7dfa67df4c1e6
2021-07-17 07:39:15 -03:00
YAMAMOTO Takashi
09f3a1ec8e tcp_send_buffered: throttle IOB allocations for send
Consider a bi-directional TCP connection:

1. we use all IOBs for tx queue
2. we advertize zero recv window because we have no free IOBs
3. if the peer tcp does the same thing,
   both sides advertize zero window and can not drain the tx queue.

For a similar stall to happen, the peer doesn't need to be
a naive tcp implementation like nuttx. A naive application blocking
on send() without draining its read buffer is enough.
(Probably such an application should be fixed to drain rx even
when tx is full. However, it's another story.)

This commit avoids the situation by prevent tx from grabbing
the all IOBs in the first place. (assuming CONFIG_IOB_THROTTLE > 0)
2021-07-14 15:08:18 +08:00
chao.an
83f7c08f65 net/tcp: only print the error when disable the TCP_NODELAY
Since we do not have the Nagle's algorithm,
the TCP_NODELAY socket option is enabled by default.

Change-Id: I0c8619bb06cf418f7eded5bd72ac512b349cacc5
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-07-13 09:44:19 -03:00
Huang Qi
e5c278981a net: Rename IP_TTL to IP_TTL_DEFAULT
Since a SOL option IP_TTL exist, we should rename this IP_TTL
in netconfig.h to avoid confusion.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
Change-Id: Ib04c36553f23bce8d362e97294a8b83eaa050cf3
2021-07-12 16:30:37 -03:00
Xiang Xiao
906cb8b0f4 net/tcp: tcp_sendfile need restore the file location at the end
quote from https://man7.org/linux/man-pages/man2/sendfile.2.html:
If offset is not NULL, then it points to a variable holding the
file offset from which sendfile() will start reading data from
in_fd.  When sendfile() returns, this variable will be set to the
offset of the byte following the last byte that was read.  If
offset is not NULL, then sendfile() does not modify the file
offset of in_fd; otherwise the file offset is adjusted to reflect
the number of bytes read from in_fd.
If offset is NULL, then data will be read from in_fd starting at
the file offset, and the file offset will be updated by the call.

The change also align with the implementation at:
libs/libc/misc/lib_sendfile.c

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I607944f40b04f76731af7b205dcd319b0637fa04
2021-07-12 05:20:45 -07:00
chao.an
1dbe8de750 net/local: add AF_[UNIX|LOCAL] socketpair support
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-07-08 03:05:43 -05:00
chao.an
940a07e1e5 net/socketpair: move socketpair implement into socket internal
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-07-08 03:05:43 -05:00
chao.an
9f3f4fb558 net/local: extern local_generate_instance_id() interface
Change-Id: I14273d11b1fe4d6bdc15b14e32da609cc7883713
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-07-08 03:05:43 -05:00
chao.an
d4ce70979e net/tcp: change all window relative value type to uint32_t
1. change all window relative value type to uint32_t
2. move window range validity check(UINT16_MAX) before assembling TCP header

Signed-off-by: chao.an <anchao@xiaomi.com>
2021-07-07 03:55:41 -05:00
chao.an
aab03ef86d net/tcp: add window scale support
Reference here:
https://tools.ietf.org/html/rfc1323

Signed-off-by: chao.an <anchao@xiaomi.com>
2021-07-07 03:55:41 -05:00
chao.an
a5cdc4e69b net/tcp: change the tcp optdata to dynamic arrays
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-07-07 03:55:41 -05:00
chao.an
87bffc190c net/tcp: remove the invalid break during tcp option loop
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-07-07 03:55:41 -05:00
chao.an
e506b2a52c usrsock/recv: guarantee all data is received before close
adjust the close sequence to avoid data discard

Signed-off-by: chao.an <anchao@xiaomi.com>
2021-07-07 08:40:55 +09:00
chao.an
b901f22c27 net/socket: add SO_RCVBUF support
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-07-06 01:44:55 -05:00
chao.an
eabe535de7 net/inet: add support of FIONREAD
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-07-05 06:20:52 -05:00
Anthony Merlino
a885b24cc1 Attempt to fix race condition reported in issue #3647 2021-07-04 08:54:15 -05:00
ligd
b83b974e92 rpmsg_socket: fix rpmsg_socket_device_destroy() multi-access
Reason:
When user call rpmsg_socket_close() at the same time
rpmsg_socket_ns_unbind() is called by remote CPU,
then will meet multi-access to rpmsg_socket_device_destroy()

Fix:
reuse recvlock to handle this

Change-Id: I8f33658f19c56a4000382ff9355ff052c45afea0
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-07-04 06:23:07 -05:00
YAMAMOTO Takashi
669619a06a tcp_close: Fix a race with passive close
tcp_close disposes the connection immediately if it's called in
TCP_LAST_ACK. If it happens, we will end up with responding the
last ACK with a RST.

This commit fixes it by making tcp_close wait for the completion
of the passive close.
2021-07-02 13:54:15 +09:00
Virus.V
94f45d5c06 netlink: fix compile error when enable netlink
Signed-off-by: Virus.V <virusv@live.com>
2021-07-01 06:55:57 -05:00
YAMAMOTO Takashi
c7ba75697c tcp_recvwindow.c: Use iob_tailroom to replace the home grown one 2021-06-30 06:40:13 -05:00
YAMAMOTO Takashi
52c237cb5f net/tcp/tcp.h: Update a comment about readahead 2021-06-30 06:40:13 -05:00
YAMAMOTO Takashi
08e9dff0e9 tcp_close: disable send callback before sending FIN
This fixes connection closing issues with CONFIG_NET_TCP_WRITE_BUFFERS.

Because TCP_CLOSE is used for both of input and output for tcp_callback,
the close callback and the send callback confuses each other as
the following. As it effectively disposes the connection immediately,
we end up with responding to the consequent ACK and FIN/ACK from the peer
with RSTs.

tcp_timer
    -> tcp_close_eventhandler
        returns TCP_CLOSE (meaning an active close)
    -> psock_send_eventhandler
        called with TCP_CLOSE from tcp_close_eventhandler, misinterpet as
        a passive close.
        -> tcp_lost_connection
            -> tcp_shutdown_monitor
                -> tcp_callback
                    -> tcp_close_eventhandler
                        misinterpret TCP_CLOSE from itself as
                        a passive close
2021-06-30 06:39:13 -05:00
YAMAMOTO Takashi
326a8ef0a2 tcp_close_disconnect: don't nullify sndcb
It isn't necessary and I plan to use the value later in
the close processing.
2021-06-30 06:39:13 -05:00
YAMAMOTO Takashi
8472430f22 tcp_close: replace scaring comments 2021-06-30 06:39:13 -05:00
YAMAMOTO Takashi
1ce13ee731 tcp_reset: Don't copy the peer window
The current code just leave the window value from the segment
from the peer. It doesn't make sense.

Instead, always use 0.
This matches what NetBSD and Linux do.
(As far as I read their code correctly.)
2021-06-29 22:23:48 -05:00
YAMAMOTO Takashi
98e7c6924d tcp: always responds to keep-alive segments
* It doesn't make sense to have this conditional on our own
  SO_KEEPALIVE support. (CONFIG_NET_TCP_KEEPALIVE)
  Actually we don't have a control on the peer tcp stack,
  who decides to send us keep-alive probes.

* We should respond them for non ESTABLISHED states. eg. FIN_WAIT_2
  See also:
  https://github.com/apache/incubator-nuttx/pull/3919#issuecomment-868248576
2021-06-30 11:52:08 +09:00
YAMAMOTO Takashi
4878b7729c tcp: simplify readahead
Do not bother to preserve segment boundaries in the tcp
readahead queues.

* Avoid wasting the tail IOB space for each segments.
  Instead, pack the newly received data into the tail space
  of the last IOB. Also, advertise the tail space as
  a part of the window.

* Use IOB chain directly. Eliminate IOB queue overhead.

* Allow to accept only a part of a segment.

* This change improves the memory efficiency.
  And probably more importantly, allows less-confusing
  recv window advertisement behavior.
  Previously, even when we advertise N bytes window,
  we often couldn't actually accept N bytes. Depending on
  the segment sizes and IOB configurations, it was causing
  segment drops.
  Also, the previous code was moving the right edge of the
  window back and forth too often, even when nothing in
  the system was competing on the IOBs. Shrinking the
  window that way is a kinda well known recipe to confuse
  the peer stack.
2021-06-30 06:22:14 +09:00
YAMAMOTO Takashi
0886257eb4 tcp_input: Accept segments spanning over rcvseq 2021-06-30 06:22:14 +09:00
YAMAMOTO Takashi
eeafe070ec tcp.h: Add TCP_SEQ_ADD 2021-06-30 06:22:14 +09:00
YAMAMOTO Takashi
022a2490d1 tcp: Change the way to advance rcvseq
* Move the code to advance rcvseq for user data from tcp_input
  to receive handlers.
  Motivation: allow partial ack.

* If we drop a segment, ignore FIN as well. Note than tcp FIN bit is
  logically after the user data in the same segment.
2021-06-30 06:22:14 +09:00
Xiang Xiao
20f5a28e49 net: Add if_nameindex and if_freenameindex API
Specified here:
https://man7.org/linux/man-pages/man3/if_nameindex.3.html

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ia5daed775bd11fa5978d54860632554da8f7b416
2021-06-26 22:37:12 +01:00
Xiang Xiao
232d65c232 net: Fix: left shift of 1 by 31 places cannot be represented in type 'long int'
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Id2daa60834f7b1917b15bbad89b091b59311e988
2021-06-23 05:24:15 -07:00
YAMAMOTO Takashi
1448de4451 tcp_should_send_recvwindow: Remove function name from ninfo()
ninfo() itself usually prefixes the function name
automatically for us.
2021-06-18 00:47:47 -05:00
Xiang Xiao
d8769cb4f0 net/local: Remove all HAVE_LOCAL_POLL reference
since HAVE_LOCAL_POLL always hardcode to 1

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-06-17 07:09:10 -03:00
YAMAMOTO Takashi
ca0f2bdb95 tcp_get_recvwindow: Make this match the reality (tcp_datahandler)
It doesn't make much sense to advertize more than we can actually
accept, especially when we don't queue partial segments.
2021-06-15 01:17:38 -05:00
YAMAMOTO Takashi
af64912833 tcp_get_recvwindow: use tcp_rx_mss
Just to reduce code duplication.
No functional changes are intended.
2021-06-15 01:17:38 -05:00
YAMAMOTO Takashi
64676641cb tcp_datahandler: try throttled=false on iob_trycopyin failure as well
I assume this was just an oversight because I couldn't
find any obvious reason to special-case only the first IOB.

The commit message of the original commit is cited below.

```
commit bf21056001
Author: chao.an <anchao@xiaomi.com>
Date:   Fri Nov 27 09:50:38 2020 +0800

    net/tcp: fallback to unthrottle pool to avoid deadlock

    Add a fallback mechanism to ensure that there are still available
    iobs for an free connection, Guarantees all connections will have
    a minimum threshold iob to keep the connection not be hanged.

    Change-Id: I59bed98d135ccd1f16264b9ccacdd1b0d91261de
    Signed-off-by: chao.an <anchao@xiaomi.com>
```
2021-06-15 01:17:38 -05:00
YAMAMOTO Takashi
0347cd3f09 tcp_should_send_recvwindow: Add a few ninfo() 2021-06-13 21:20:24 -05:00
YAMAMOTO Takashi
14ec75e7fc tcp: window update improvements
* Fixes the case where the window was small but not zero.

* tcp_recvfrom: Remove tcp_ackhandler. Instead, simply schedule TX for
  a possible window update and make tcp_appsend decide.

* Replace rcv_wnd (the last advertized window size value) with
  rcv_adv. (the window edge sequence number advertized to the peer)
  rcv_wnd was complicated to deal with because its base (rcvseq) is
  also moving.

* tcp_appsend: Send a window update even if there are no other reasons
  to send an ack.
  Namely, send an update if it increases the window by
    * 2 * mss
    * or the half of the max possible window size
2021-06-13 21:20:24 -05:00
YAMAMOTO Takashi
1f6fdf04b7 tcp: Extract MSS calculation from tcp_synack
I plan to use it for recv window update decision logic.
2021-06-13 21:20:24 -05:00
chao.an
b6bf9cf44b net/accept: alloc the accept fd after accept success
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-06-11 05:00:21 -05:00
chao.an
0d8e5b66fd net/sock: move the psock calloc out of sockfd_allocate
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-06-11 05:00:21 -05:00
YAMAMOTO Takashi
7d82e7a7c4 tcp_input: fix a confusing variable name and a comment
It looks like a copy-and-paste mistake.
2021-06-10 22:47:04 -05:00
YAMAMOTO Takashi
eb00e00e48 tcp: Use the tcp seq macros in some obvious places 2021-06-10 22:47:04 -05:00
YAMAMOTO Takashi
433a2b27d9 tcp: add macros to deal with sequence number wraparound 2021-06-10 22:47:04 -05:00
chao.an
805d3a2061 net/local: add local_nextconn() helper
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-06-10 13:57:32 -03:00
Xiang Xiao
5b2a17b892 Include assert.h in necessary place
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-06-08 13:06:08 -07:00
chao.an
39245f63fe net/icmp: fix race condition in icmp recvmsg
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-06-07 22:17:50 -05:00
chao.an
ae613446c8 net/icmp: add nonblocking support
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-06-07 22:17:50 -05:00
chao.an
9c1fb4c04b net/icmp: consume the data length to avoid duplicate packet
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-06-07 22:17:50 -05:00
chao.an
b0ac97adab net/icmp: fix invalid condition comparison
up_assert: Assertion failed at file:
  icmp/icmp_recvmsg.c line: 175 task: net_tasklet

Signed-off-by: chao.an <anchao@xiaomi.com>
2021-06-07 22:17:50 -05:00
YAMAMOTO Takashi
69b3f034a4 tcp: Move buffered/unbuffered common code to tcp_send.c 2021-06-03 21:33:10 -05:00
YAMAMOTO Takashi
7d33c01a0a tcp_get_recvwindow: Add a revisit comment 2021-06-03 21:32:34 -05:00
Xiang Xiao
2e54df0f35 Don't include assert.h from public header file
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-06-03 08:36:03 -07:00
Xiang Xiao
d7f96003cf Don't include debug.h from public header file
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-06-01 06:42:02 +09:00
chao.an
70f6eb232a net/dev: link the net device as order of registration
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-05-31 01:38:38 -05:00
YAMAMOTO Takashi
7ac6c0a8de tcp_data_event: Add a comment 2021-05-31 01:37:51 -05:00