Commit Graph

1836 Commits

Author SHA1 Message Date
chao.an
bb09471d63 inet_close: ensure the TCP_CLOSE can be delivered normally
Change-Id: I657433806d5dc851ce9bd7722f191f467f9ad458
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-01-11 08:24:49 -06:00
Xiang Xiao
5c5c08efcd network: simplify the timeout process logic
1.Consolidate absolute to relative timeout conversion into one place(_net_timedwait)
2.Drive the wait timeout logic by net_timedwait instead of devif_timer
This patch help us remove devif_timer(period tick) to save the power in the future.

Change-Id: I534748a5d767ca6da8a7843c3c2f993ed9ea77d4
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-01-11 08:24:49 -06:00
Xiang Xiao
346336bb9e Make the read ahead buffer unselectable
Here is the email loop talk about why it is better to remove the option:
https://groups.google.com/forum/#!topic/nuttx/AaNkS7oU6R0

Change-Id: Ib66c037752149ad4b2787ef447f966c77aa12aad
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-01-11 08:24:49 -06:00
chao.an
97bead5496 net: complement wireless handling as ethernet
Change-Id: I13cc4cbfc1e305e17c0630f11a1173afe96e8a03
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-01-11 08:04:18 -03:00
Juha Niskanen
260af07717 net/usrsock/usrsock_dev.c: Fix uninitialized return value introduced in 6a3c2ade. 2020-01-09 07:31:40 -06:00
junmin-kim
db3826bf2c Fix typo in the sockfd_socket description 2020-01-09 07:38:02 -03:00
Gregory Nutt
afc2bffb7d net/icmpv6/icmpv6_netpoll.c: Fix two warnings found in build testing
Description:

Fix two warnings found in build testing: (1) Need to include nuttx/semaphore.h
from prototype of nxsem_post() and (2) need to initialize return value of function.
Uninittialized garbage was being returned on success.Fix two warnings found in
build testing: (1) Need to include nuttx/semaphore.h from prototype of
nxsem_post() and (2) need to initialize return value of function.
Uninittialized garbage was being returned on success.
2020-01-07 18:49:55 -03:00
Xiang Xiao
981d7004fa Remove inet_setipid since nobody use it
Change-Id: I8c1ed7308678d9d2e11cadedd78f7755b8f7aa99
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-01-06 07:45:59 -06:00
Nathan Hartman
f9f8c6a79b net/icmp/icmp_netpoll.c: Fix return of uninitialized 'ret' when no error occurs. That is, on what should be a successful return from this function, an uninitialized value was returned, which may indicate an undeserved error. 2020-01-02 14:40:08 -06:00
Nathan Hartman
c854b1f039 net/icmp/icmp_netpoll.c: Fix warning: implicit declaration of nxsem_post(). This appeared after include of nuttx/kmalloc.h was removed recently. 2020-01-02 14:37:14 -06:00
Xiang Xiao
6a3c2aded6 Fix wait loop and void cast (#24)
* Simplify EINTR/ECANCEL error handling

1. Add semaphore uninterruptible wait function
2 .Replace semaphore wait loop with a single uninterruptible wait
3. Replace all sem_xxx to nxsem_xxx

* Unify the void cast usage

1. Remove void cast for function because many place ignore the returned value witout cast
2. Replace void cast for variable with UNUSED macro
2020-01-02 10:54:43 -06:00
Masayuki Ishikawa
6e7c761fc8 net: tcp: Fix compile error in tcp.h 2020-01-02 09:36:25 -06:00
Xiang Xiao
02b652ce1c Minor fix (#23)
* fix ieee802154/ieee802154_input.c:179:7: error: too few arguments to function 'iob_free'
       iob_free(container->ic_iob);
       ^~~~~~~~

ieee802154/ieee802154_input.c:180:7: error: too many arguments to function 'ieee802154_container_free'
       ieee802154_container_free(container, IOBUSER_NET_SOCK_IEEE802154);
       ^~~~~~~~~~~~~~~~~~~~~~~~~

* fix udp/udp_netpoll.c:327:10: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]

* fix local/local_netpoll.c:154:15: warning: implicit declaration of function 'nxsem_post'; did you mean 'sem_post'? [-Wimplicit-function-declaration]
               nxsem_post(fds->sem);
               ^~~~~~~~~~
               sem_post
2020-01-02 09:35:50 -06:00
Xiang Xiao
5fb5a9dfdd psock_udp_sendto should call udp_wrbuffer_tryalloc for nonblock socket (#20)
net/udp/udp_wrbuffer.c:  Add new function udp_wrbuffer_tryalloc()
net/udp/udp_psock_sendto_buffered.c:  If the socket was opened with O_NONBLOCK, then use udp_wrbuffer_tryalloc() so that the caller will not wait for a write buffer.  Return EGAIN if udp_wrbuffer_tryalloc() failes.
2019-12-31 09:52:40 -06:00
Xiang Xiao
90c52e6f8f Squashed commit of the following:
Author: Gregory Nutt <gnutt@nuttx.org>

    Run all .h and .c files modified in last PR through nxstyle.

Author: Xiang Xiao <xiaoxiang@xiaomi.com>

    Net cleanup (#17)

    * Fix the semaphore usage issue found in tcp/udp

    1. The count semaphore need disable priority inheritance
    2. Loop again if net_lockedwait return -EINTR
    3. Call nxsem_trywait to avoid the race condition
    4. Call nxsem_post instead of sem_post

    * Put the work notifier into free list to avoid the heap fragment in the long run.  Since the allocation strategy is encapsulated internally, we can even refine the implementation later.

    * Network stack shouldn't allocate memory in the poll implementation to avoid the heap fragment in the long run, other modification include:

    1. Select MM_IOB automatically since ICMP[v6] socket can't work without the read ahead buffer
    2. Remove the net lock since xxx_callback_free already do the same thing
    3. TCP/UDP poll should work even the read ahead buffer isn't enabled at all

    * Add NET_ prefix for UDP_NOTIFIER and TCP_NOTIFIER option to align with other UDP/TCP option convention

    * Remove the unused _SF_[IDLE|ACCEPT|SEND|RECV|MASK] flags since there are code to set/clear these flags, but nobody check them.
2019-12-31 09:26:14 -06:00
chao.an
8dd4b27973 tcp_conn: Check if the remote address is unspecified
Change-Id: I6f547bb4bfb3bb621573db9097a531ce2260e794
Signed-off-by: chao.an <anchao@xiaomi.com>
2019-12-24 10:48:00 -06:00
Xiang Xiao
87cf5c58ae Correct some problems with network timed events when there are multiple network devices in the configuration.
Squashed commit of the following:

Author: Gregory Nutt <gnutt@nuttx.org>

    Ran nxstyle against many of the affected files.  But this job was too big for today.  Many of the network drivers under arch are highly non-compiant and generate many, many faults from nxstyle.  Those will have to be visited again another day.

Author: Xiang Xiao <xiaoxiang@xiaomi.com>

    This effects all network drivers as well as timing related portions of net/: devif_poll_tcp_timer shouldn't be skipped in the multiple card case.  devif_timer will be called multiple time in one period if the multiple card exist, the elapsed time calculated for the first callback is right, but the flowing callback in the same period is wrong(very short) because the global variable g_polltimer is used in the calculation.  So let's pass the delay time to devif_timer and remove g_polltimer.
2019-12-24 10:37:30 -06:00
liuhuahang
ce634578dd This change implements the SO_ERROR socket option that is used to obtain the last error reported by the network.
Squashed commit of the following:

Author: Gregory Nutt <gnutt@nuttx.org>

    net/: Trivial changes to PR from review.  Biggest difference:  type of s_error changed to int16_t to save a byte or two.

Author: liuhuahang <liuhuahang@xiaomi.com>

    Implement SO_ERROR for getsockopt()
2019-12-24 08:09:55 -06:00
Nathan Hartman
9655730ef8 Fix various typos and spelling errors. 2019-12-12 07:41:51 -06:00
Gregory Nutt
e5e52446ca net/tcp/tcp_send.c: Trival update to some comments. 2019-12-11 11:19:32 -06:00
Gregory Nutt
c2642eef3c net/tcp/tcp_appsend.c: Enhance delayed ACK algorithm with behavior of Windows delayed ACK described at https://support.microsoft.com/en-nz/help/214397/design-issues-sending-small-data-segments-over-tcp-with-winsock: 'If there are data to be sent in the same direction as the ACK before the second data packet is received and the delay timer expires, the ACK is piggybacked with the data segment and sent immediately.' 2019-12-09 08:45:52 -06:00
Gregory Nutt
6a0ab27bd5 net/tcp/tcp_appsend.c: Update some comments. 2019-12-09 06:06:17 -06:00
Gregory Nutt
8cd5e04d53 net/tcp: Minor design improvement to TCP delayed ACKs. 2019-12-08 14:17:55 -06:00
Gregory Nutt
66ef6d143a This commit adds an initial implemented of TCP delayed ACKs as specified in RFC 1122.
Squashed commit of the following:

    net/tmp:  Rename the unacked field of the tcp connection structure to tx_unacked.  Too confusing with the implementation of delayed RX ACKs.

    net/tcp:  Initial implementation of TCP delayed ACKs.

    net/tcp:  Add delayed ACK configuration selection.  Rename tcp_ack() to tcp_synack().  It may or may not send a ACK.  It will always send SYN or SYN/ACK.
2019-12-08 13:13:51 -06:00
Gregory Nutt
16b1c276bd net/netlink/netlink_conn.c: Fix some really basic errors in the redesign of the asynchronous Netlink response logic. 2019-11-28 16:14:59 -06:00
Gregory Nutt
4ae09a3b80 net/netlink: Redesign the logic that handles notifications of when response data is available. Signal handlers are sub-optimal inside the OS (especially after the preceding change which forces the hand). Instead, use the work queue notifiers as is done with all other network notifiers. 2019-11-28 14:20:40 -06:00
Gregory Nutt
69318b1024 Re-implements reverted commit 344f7bc9f6 in a way that should not have the undesired side-effect. include/nuttx/sched.h: Add a bit to the TCB flags to indicat the thread is a user thread in a syscall. sched/nuttx/nxsig_dispatch.c: Delay dispatching to signal handlers if within a system call. In all syscall implementations: Process delayed signal handling when exiting system call. 2019-11-28 12:47:36 -06:00
Gregory Nutt
cbdd590c82 Revert "include/nuttx/sched.h: Add storage for a previous signal mask. arch/: In all syscall implementations, block all signals before dispatching a system call; resotre signal mask when the system call returns."
Using the sigprocmask() for this purpose has too many side-effects.

This reverts commit 344f7bc9f6.
2019-11-28 11:57:54 -06:00
Gregory Nutt
344f7bc9f6 include/nuttx/sched.h: Add storage for a previous signal mask. arch/: In all syscall implemenations, block all signals before dispatching a system call; resotre signal mask when the system call returnes. 2019-11-28 10:51:29 -06:00
Gregory Nutt
d1593bb336 Squashed commit of the following:
net/netlink/netlink_sockif.c:  At implementation of response available signal handler needed for POLLIN logic.
    net/netlink/netlink_sockif.c:  Add logic to set up signal handler to receive the response notification.
2019-11-27 21:30:01 -06:00
Gregory Nutt
a8f3c3651a net/netlink/netlink_conn.c: Use nxsig_queue() instead of nxsig_kill() so that we can pass a reference to the connection structure with the signal. 2019-11-27 19:31:23 -06:00
Xiang Xiao
e1e192fc33 net/: icmp[v6] fix ping[6] complain 'WARNING: Received after timeout'. The root cause is that icmp[v6]_pollsetup monitors ICMP[v6]_NEWDATA, but icmp[v6]_input reports ICMP[v6]_ECHOREPLY. This change lets icmp[v6]_input report report ICMP[v6]_NEWDATA to fix this issue and remove ICMP[v6]_ECHOREPLY to avoid the wrong usage in the future. 2019-11-27 08:09:51 -06:00
Xiang Xiao
250bde034d net/: icmp[v6]_pollsetup should always return POLLWRNORM if the caller requests it since ICMP[v6] doesn't utilize IOB buffer for sending and always needs to wait for an ICMP[v6]_POLL. 2019-11-27 08:04:14 -06:00
Xiang Xiao
ea666877f2 net/devif/devif_callback.c: Restore cf9f2c56cb. That restored change plus the following additional commits reolves the issue raised by Valmantas Palikša. 2019-11-27 07:59:52 -06:00
Gregory Nutt
93ed8b66d9 net/netlink: Add partial support for the NETLINK poll() operation. Still missing is some signal handling logic that actually wakes up the poll() when an asynchronous NETLLINK response is available.
So although the poll() implemenation is still not yet usable, the commit is useful because it (1) does not harm, and (2) incidentally fixes a few other issues in the NETLONK response queuing that I noted in the process.
2019-11-26 18:52:22 -06:00
Xiang Xiao
8214973f80 net/usrsock/usrsock_poll.c: usrsock_pollsetup() doesn't need logic and with fds->events since line 279 will do the same thing:
fds->revents &= (~(POLLOUT | POLLIN) | info->fds->events);
2019-11-25 11:44:58 -06:00
Xiang Xiao
1905e01fda net/: ICMP/ICMPv6/TCP/UDP poll shouldn't set POLLHUP and POLLOUT at the same time the standard require that only report POLLHUP:
https://pubs.opengroup.org/onlinepubs/009695399/functions/poll.html.
2019-11-25 09:59:50 -06:00
Xiang Xiao
34ec7c97eb net/icmp/icmp_netpoll.c and icmpv6/icmpv6_netpoll.c: ICMP/ICMPv6 should always report POLLHUP and POLLERR, regardless of requested 'events'. 2019-11-25 09:57:49 -06:00
Xiang Xiao
af9c67ab58 net/tcp/tcp_netpoll.c and net/udp/udp_netpoll.c: In [tcp|udp]_iob_work fix the wrong condition logic (& vs &&). 2019-11-25 09:32:24 -06:00
Gregory Nutt
f1ffb300da net/devif/devif_callback.c: This commit reverts the core of commit cf9f2c56cb pending further investigation. Valmantas Palikša reports that this change cause timeout errors during pinging. 2019-11-25 07:34:41 -06:00
Xiang Xiao
506b83f8d9 net/inet/inet_close.c: In tcp_close_eventhandler(), check TCP_NEWDATA flag before process and don't eat the flag for TCP_DISCONN_EVENTS 2019-11-24 10:41:11 -06:00
Xiang Xiao
98fc60eb75 [tcp|udp]_poll_eventhandler check psock_[tcp|udp]_cansend before report POLLOUT. Change the unbuffered psock_[tcp|udp]_cansend return OK to unify the code logic and remove the unnecessary [tcp|udp]_poll_txnotify call. 2019-11-24 10:30:48 -06:00
Xiang Xiao
673f812c4e net/tcp/tcp_netpoll.c: Monitor TCP_POLL/TCP_NEWDATA/TCP_BACKLOG per the request like UDP counterpart. 2019-11-24 10:20:01 -06:00
Xiang Xiao
893fc6e1cf net/udp/udp_netpoll.c: Report POLLHUP and POLLERR in 'revents' regardless the requested 'events' set. Per Opengroup.org, these bits must be ignored in the 'events' set. 2019-11-24 10:18:08 -06:00
Xiang Xiao
cf9f2c56cb et/devif/devif_callback.c: devif_event_trigger shouldn't return true if triggers & DEVPOLL_MASK equal zero() 2019-11-24 10:11:19 -06:00
Gregory Nutt
9efadaefc1 net/tcp: Be consistent with units of TIME_WAIT. Units were unspecified in tcp/Kconfig, but assumed to be in units of half seconds in tcp/timer.h. include/nuttx/netconfig does not indicate the units but is apparently assuming seconds. This commit unifies all delays to clearly specified units of seconds. 2019-11-24 09:19:54 -06:00
Xiang Xiao
e0307fcd8f boards/sim/sim/sim/src/sim_bringup.c: Mount tmpfs to CONFIG_LIBC_TMPDIR in sim_bringup if CONFIG_FS_TMPFS is defined. 2019-11-23 07:58:50 -06:00
Gregory Nutt
bc8d964cb9 net/netlink: Add some comments about 'Input Parameters' 2019-11-19 20:46:43 -06:00
Gregory Nutt
b72f7cf47f net/netlink/netlink_route.c: Fix a case where #if was used but #ifdef was intended. 2019-11-19 09:47:57 -06:00
Gregory Nutt
b659c74440 net/netlink/netlink_sockif.c: Netlink sockets may be set to non-blocking. 2019-11-19 07:50:46 -06:00