Commit Graph

2299 Commits

Author SHA1 Message Date
chao.an 3a0885bafc 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.

Change-Id: Ic77c148c55ded7871d179e321c57bba5ca8e4112
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-08-30 21:50:57 +08:00
丁欣童 07283dffc3 net/local: Return the partial write size
N/A

Fix up that local socket will be endless loop when write data size more
than the fifo size.

Signed-off-by: 丁欣童 <dingxintong@xiaomi.com>
Change-Id: I69d63b7b156f0714333e7103bb266b7fcb1adf03
2021-08-26 10:20:13 +08:00
YAMAMOTO Takashi 95db8bb14f tcp_send_buffered.c: Fix snd_wnd
snd_wnd is an offset from the acked sequence number.
2021-08-25 21:15:14 +08:00
YAMAMOTO Takashi 3f15cd59e8 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 21:15:14 +08:00
chao.an 7c9d73e862 net/local: correct the nonblock send return value
Change-Id: I77b561d748ebb603e275d2fb38c0638093bb1214
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-08-20 21:40:25 +08:00
chao.an bd334d7c96 net/rpmsg: move connect state change to sync callback
Change-Id: I8ef6e4b4b4adc5727c072559239e87853abeab04
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-08-16 23:13:35 +08:00
chao.an 47f784a748 net/rpmsg: fix typo in comment
Change-Id: Icbf8122c5054e01516841b7f0d369992bc967931
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-08-16 21:46:35 +08:00
chao.an 886d567e7d net/rpmsg: add nonblock connect(2) support
Change-Id: I6fe12c7e40d6e4c4353034d4731c24bd6a28225c
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-08-16 21:46:27 +08:00
chao.an b6dbf55271 net/rpmsg: move the sync handshark to ns_bind callback
Change-Id: Ic37671f59fbf08bcbd78cf0221759ee8fed1ed22
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-08-16 21:38:00 +08:00
chao.an 79dd7453ac net/rpmsg: simplify the socket timeout of connect
Change-Id: I9ff5b3e7dad0b73196cfa058f3a55f2ea3086815
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-08-16 21:38:00 +08:00
chao.an 2d597f55df net/local: add nonblock connect(2) support
Change-Id: Iee8250b5011f799c52d667b2593760673378443e
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-08-16 21:37:52 +08:00
chao.an bfeefa09b1 net/tcp: add nonblock connect(2) support
Change-Id: I01b125996a85c9ea0220a24bb3d41d6e75e36554
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-08-16 21:27:08 +08:00
chao.an 3bd2a5b11a 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>
Change-Id: Id269fc09cf877ec6dc42706eb667adfc5362bf7a
2021-08-05 21:14:23 +08:00
chao.an acad830329 net/local: remove unused client lc_remaining
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-08-05 21:14:14 +08:00
Xiang Xiao 400db72d79 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 12:02:39 +08:00
chao.an f246c7e6ad net/socket: add SO_SNDBUF support
Change-Id: Ie7f82afd3a4c053112d15424499797eb046ed413
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-07-21 11:43:00 +08:00
chao.an d58c9f1f47 net/wrb: add tcp/udp_inqueue_wrb_size() interface
Change-Id: Iccf2829e445d4842181cd6b8c0422cdfb35c498a
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-07-21 11:42:11 +08:00
ligd af8530f3fa socket_rpmsg: fix typepo
Change-Id: I7d75efd4f4b3c3ff1b0ecc020e81ac5a972eadb5
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-07-19 23:17:05 +08:00
Xiang Xiao e5c60da2f5 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 04:58:40 -07:00
ligd 37c86a6510 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-16 11:40:37 +08:00
ligd ad829b749b 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-15 23:54:14 +08:00
Xiang Xiao fdf26974c2 Revert "print message with nwarn to avoid constantly printout."
This reverts commit 85d38b9348.

Change-Id: I49cb4b03d652430e3bc58cfa4ac6303701e417d1
2021-07-13 03:16:45 +08:00
Xiang Xiao a977ca1ca3 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-13 03:16:26 +08:00
Xiang Xiao c8f1eeed57 Merge commit '2e43815c929acb818b34a5ff8828494b0c6f6891' into dev
Change-Id: Idcbac12fec435abff01cfb4efd5a26a02eb08f93
2021-07-13 03:14:34 +08: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
chao.an 55c032d061 net/socketpair: move socketpair implement into socket internal
Change-Id: Ibf84671a1d59122ee5a3c5161048ea4f00356b1c
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-07-05 12:13:40 +08: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
Virus.V bb6273d4d1 netlink: fix compile error when enable netlink
Signed-off-by: Virus.V <virusv@live.com>
2021-07-02 14:57:22 +08: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