Commit Graph

103 Commits

Author SHA1 Message Date
Xiang Xiao
b5f429c88b Fix nxstyle warning
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-08-22 17:37:21 -06:00
Xiang Xiao
ae356001cf Change all files come from Xiaomi/Pinecone to Apache License 2.0
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-08-22 17:37:21 -06:00
Peter van der Perk
55d9e5f7af net: Add SocketCAN support 2020-06-15 08:07:19 -06:00
Jukka Laitinen
17e45820c6 net/inet/inet_sockif.c: Fix long lines
Signed-off-by: Jukka Laitinen <jukka.laitinen@intel.com>
2020-06-01 21:54:06 +08:00
Jukka Laitinen
1f8de344dd net/inet/inet_sockif.c: Fix debugassert compilation
Should derefer addrlen pointer, instead of comparing whether
the pointer itself is > 0

Signed-off-by: Jukka Laitinen <jukka.laitinen@intel.com>
2020-06-01 21:54:06 +08:00
patacongo
861efdf8a3
net/: Whenever the network initializes an IPv4 address, it must clear sin_zero. 2020-02-25 15:53:39 +01:00
Xiang Xiao
cde88cabcc Run codespell -w with the latest dictonary again
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-02-23 22:27:46 +01:00
chao.an
c65d8e6a23 net/socket: add MSG_DONTWAIT support
MSG_DONTWAIT (since Linux 2.2)
  Enables nonblocking operation; if the operation would block, the
  call fails with the error EAGAIN or EWOULDBLOCK. This provides
  similar behavior to setting the O_NONBLOCK flag (via the fcntl(2)
  F_SETFL operation), but differs in that MSG_DONTWAIT is a per-call
  option, whereas O_NONBLOCK is a setting on the open file description
  (see open(2)), which will affect all threads in the calling process
  and as well as other processes that hold file descriptors referring
  to the same open file description.
2020-02-19 12:21:28 -06:00
Xiang Xiao
6e6c670190 Move _SF_BOUND and _SF_CONNECTED modification to common place 2020-01-31 13:45:14 -06:00
Xiang Xiao
0b860726db Ensure psock_socket and psock_accept initialize s_crefs to 1
This simplifies the caller usage
2020-01-31 13:45:14 -06:00
Xiang Xiao
68951e8d72 Remove exra whitespace from files (#189)
* Remove multiple newlines at the end of files
* Remove the whitespace from the end of lines
2020-01-31 09:24:49 -06:00
Xiang Xiao
e75b5e9d86 net/tcp and udp: Move tcp/udp recvfrom into tcp/udp folder
Move tcp/udp recvfrom into tcp/udp folder and remove inet_recvfrom.c
2020-01-21 08:30:39 -06:00
Xiang Xiao
e869a10c18 net/tcp, udp: Move tcp/udp close operation into tcp/udp folder
Move tcp/udp close operation into tcp/udp folder and remove inet_close.c
2020-01-21 08:30:39 -06:00
Xiang Xiao
677536ccf5 net/udp: Rename udp_psock_sendto_xxx.c to udp_sendto_xxx.c like TCP
Rename udp_psock_sendto_xxx.c to udp_sendto_xxx.c like TCP and remove udp_psock_send.c
2020-01-21 08:30:39 -06:00
Xiang Xiao
3e230ca9eb net/inet/inet_recvfrom.c: Correct the return value (#121)
NuttX follows OpenGroup.org: https://pubs.opengroup.org/onlinepubs/009695399/functions/recv.html :

[EAGAIN] or [EWOULDBLOCK]
The socket's file descriptor is marked O_NONBLOCK and no data is waiting to be received; or MSG_OOB is set and no out-of-band data is available and either the socket's file descriptor is marked O_NONBLOCK or the socket does not support blocking to await out-of-band data.

ETIMEDOUT is not a valid error to be returned from recv() or recvfrom().
2020-01-17 11:26:47 -06:00
chao.an
2d0baa779d net/udp: break the network lock to avoid deadlock
Author: chao.an <anchao@xiaomi.com>

    net/udp: break the network lock to avoid deadlock

      network deadlock when udp sendto() storm is coming

    net/close: force wait tx drain to complete

      atomic send() and close() will causes data to be discarded directly

Signed-off-by: chao.an <anchao@xiaomi.com>
2020-01-16 14:26:48 -03:00
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
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
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
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
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
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
Gregory Nutt
3b275fcf4e net/: Run nxstyle against all C files. 2019-10-25 11:31:42 -06:00
Gregory Nutt
93452d70ef net/inet/inet_close.c: Fix a warning found in build testing. 2019-09-28 12:57:26 -06:00
Gregory Nutt
0b9416a40c net/inet/inet_close.c: Still fussing with f3ab9abe51. Re-analyze all disconnection events, update comments, removed one of two non-standard return values. A failure is returned only in cases where the socket was not actually closed. 2019-09-25 08:16:37 -06:00
Gregory Nutt
8e079d73d9 Update a comment. 2019-09-25 07:39:49 -06:00
Gregory Nutt
f3ab9abe51 net/inet/inet_close.c: Fixes two problems, both noted by Bernd Walter:
1) The change of commit ed9fe70024 left some dangling logic and incorrect, confusing comments.  Prior to that commit the 'pstate' variable was non-NULL only when doing a lingering close.  Comments to this effect as well as tests of pstate should also have been updated.  These are confusing and inappropriate, but do not lead to incorrect behavior.

2) Eliminate an incomplete test when a disconnection event. When a disconnection event occurs, the close logic MUST always terminate the wait.  The conditional test was not incorrect, however, it lacked 'else' logic and would simply ignore that disconnection event in some cases.  That is bad because there may not be another disconnection event and that can lead to hangs (or at least very, very long delays).
2019-09-25 07:24:20 -06:00
zhangyuan7
b33fc302f0 net/inet and net/tcp: Fix tcp close flow; free the connection after all tcp close process finished. 2019-08-30 06:44:43 -06:00
Anthony Merlino
70404ed0dc Merged in antmerlino/nuttx/iobinstrumentation (pull request #1001)
Iobinstrumentation

* mm/iob: Introduces producer/consumer id to every iob call. This is so that the calls can be instrumented to monitor the IOB resources.

* iob instrumentation - Merges producer/consumer enumeration for simpler IOB user.

* fs/procfs: Starts adding support for /proc/iobinfo

* fs/procfs: Finishes first pass of simple IOB user stastics and /proc/iobinfo entry

Approved-by: Gregory Nutt <gnutt@nuttx.org>
2019-08-16 22:42:25 +00:00
Gregory Nutt
1346f29151 net/: Fix alignment and spacing problems found by tools/nxstyle. 2019-07-02 18:02:23 -06:00
Gregory Nutt
8774977f4d Fix warnings found in build testing. 2019-07-01 15:22:42 -06:00
Gregory Nutt
077d164b14 /net/inet: Simplify design of change in last commit. 2019-07-01 14:07:12 -06:00
Gregory Nutt
de5a6163d5 This commit implements a proper version of SO_LINGER. Not sufficiently tested on initial commit.
Squashed commit of the following:

    net/: Fix some naming inconsistencies, Fix final compilation issies.

    net/inet/inet_close():  Now that we have logic to drain the buffered TX data, we can implement a proper lingering close.

    net/inet,tcp,udp:  Add functions to wait for write buffers to drain.

    net/udp:  Add support for notification when the UDP write buffer becomes empty.

    net/tcp:  Add support for notification when the TCP write buffer becomes empty.
2019-07-01 12:25:32 -06:00
Gregory Nutt
ded1900927 include/nuttx/net/net.h: Fix some long lines. 2019-07-01 09:18:38 -06:00
Gregory Nutt
b0f751897c net/inet/inet_close.c: Extend some comments. 2019-07-01 08:24:39 -06:00
Gregory Nutt
5e36627366 Update TODO list and fix an error in conditional compilation that I introduced with the last commit. 2019-07-01 08:12:51 -06:00
Gregory Nutt
5af5fc4409 net/inet/inet_close.c: Last PR remove SO_LINGER socket option. SO_LINGER was always enabled is CONFIG_NET_SOLINGER was selected. 2019-07-01 07:37:41 -06:00
Masayuki Ishikawa
ed9fe70024 Merged in masayuki2009/nuttx.nuttx/fix_tcp_active_close (pull request #923)
net/inet: Fix tcp active close in inet_close.c

In previous implementation, FIN packet was not sent when a socket
is actively closed (e.g. telnetd or webserver) without SO_LINGER.
This issue happens because the socket closing sequence waits for
the status.cl_sem only if lingering timeout is set. However,
in many server use-cases, SO_LINGER is not usually set and even
in these cases, FIN packet must be sent correctly.

This PR changes the logic in inet_close.c so that it can wait
for status.cl_sem regardless of SO_LINGER. Instead, if SO_LINGER
is set, it waits for the semaphore with timeout option.

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>

Approved-by: Gregory Nutt <gnutt@nuttx.org>
2019-07-01 13:25:47 +00:00
Gregory Nutt
b49be4bb20 Squashed commit of the following:
arch/:  Removed all references to CONFIG_DISABLE_POLL.  The standard POSIX poll() can not longer be disabled.
    sched/ audio/ crypto/:  Removed all references to CONFIG_DISABLE_POLL.  The standard POSIX poll() can not longer be disabled.
    Documentation/:  Removed all references to CONFIG_DISABLE_POLL.  The standard POSIX poll() can not longer be disabled.
    fs/:  Removed all references to CONFIG_DISABLE_POLL.  The standard POSIX poll() can not longer be disabled.
    graphics/:  Removed all references to CONFIG_DISABLE_POLL.  The standard POSIX poll() can not longer be disabled.
    net/:  Removed all references to CONFIG_DISABLE_POLL.  The standard POSIX poll() can not longer be disabled.
    drivers/:  Removed all references to CONFIG_DISABLE_POLL.  The standard POSIX poll() can not longer be disabled.
    include/, syscall/, wireless/:  Removed all references to CONFIG_DISABLE_POLL.  The standard POSIX poll() can not longer be disabled.
    configs/:  Remove all references to CONFIG_DISABLE_POLL.  Standard POSIX poll can no longer be disabled.
2019-05-21 18:57:54 -06:00
Gregory Nutt
f6b00e1966 tools/nxstyle.c: Fix logic error that prevent detecion of '/' and '/=' as operators. net/: Minor updates resulting from testing tools/nxstyle. 2019-03-11 12:48:39 -06:00
Gregory Nutt
b0ba5b69c4 net/udp/Kconfig: Auto-select CONFIG_WQUEUE_NOTIFIER when CONFIG_UDP_READAHEAD_NOTIFIER is selected. 2018-11-10 09:43:44 -06:00
Xiang Xiao
d2cfd398ba Fix compiler error and warning when CONFIG_NET_SENDFILE=y 2018-11-09 11:17:43 -06:00
Gregory Nutt
9a75a14800 net/mld: Implement MLDv1 compatibility mode. This completes coding of MLD. MLD is, howeer, still completely untested. 2018-11-04 14:07:27 -06:00
Gregory Nutt
a4dc759b4d net/mld: Defer all timeout-related operations to the work queue vs. handling within the timer interrupt. Need to notify the device driver for an immediate poll when there are MLD packets waiting to be sent. 2018-11-03 16:47:08 -06:00
Gregory Nutt
6c0ab0e077 Squashed commit of the following:
include/nuttx/net/ipv6ext.h:  Fix some terminology:  Hop-by-hop, not Hop-to-hop or Hop2hop.

    net/devif/ipv6_input.c and net/icmpv6/icmpv6_input.c:  Add logic to skiip over the variable number of IPv6 extension headers that may be present between the IPv6 header and the transport layer header.  The extension headers are simply ignored.  This is necessary because with MLD, certain incoming messages may have, at a mimimum, a Router Alert Hop-by-hop extension header.

    net/inet/ipv6_setsockopt.c:  Implement the IPV6_JOIN_GROUP and IPV6_LEAVE_GROUP socket options.
2018-11-02 12:06:57 -06:00
Gregory Nutt
5b7ef856a0 Squashed commit of the following:
net/mld:  The MLD logic now compiles and is much less toxic.  It still is not a proper MLD implementation:  (1) It is basically a port of IGMP, tweaked to work with IPv6 and ICMPv6 MLD messages, (2) it needs a proper analysis and comparison with RFC 3810, and (3) it is completely untested.  For this reason, it will remain EXPERIMENTAL for some time.
    net/mld:  Add some missing macros, more fixes related to IPv6 vs IPv4 types,
    net/mld:  More compilation cleaning.  Most fixups for IPv6 vs IPv4 types.
    net/mld:  Hook crudely converted .c files into build system and resolve a few of the many, many compilation/design problems.
    net/mld:  Add support for MLD statistics.
    net/mld:  Hook in MLD poll and packet transmission logic.
    net/mld:  Change references to IPv4 definitions to IPv6 definitions; Remove mld_input() since MLD piggybacks on ICMPv6 input.  Add functions to catch MLD messages dispatched by ICMPv6 input logic.
    net/mld:  As a starting point, copy all net/igmp/*.c files to net/mld/. and change all occurrences of igmp (or IGMP) to mld (or MLD).
    net/mld:  More compilation cleaning.  Most fixups for IPv6 vs IPv4 types.
    net/mld:  Hook crudely converted .c files into build system and resolve a few of the many, many compilation/design problems.
    net/mld:  Add support for MLD statistics.
    net/mld:  Hook in MLD poll and packet transmission logic.
    net/mld:  Change references to IPv4 definitions to IPv6 definitions; Remove mld_input() since MLD piggybacks on ICMPv6 input.  Add functions to catch MLD messages dispatched by ICMPv6 input logic.
    net/mld:  As a starting point, copy all net/igmp/*.c files to net/mld/. and change all occurrences of igmp (or IGMP) to mld (or MLD).
2018-11-01 15:19:47 -06:00
Gregory Nutt
f5ed6bf672 net/inet/ipv4_setsockopt.c: Add implementation for all IPv4 socket options that have implemented IOCTL command counterparts. 2018-10-31 17:15:23 -06:00
Gregory Nutt
0330743a9d net/inet: Add framework to support IPv4 and IPv6 protocol socket options (i.e., SOL_IP and SOL_IP6). This is build framework only (not actual socket options are yet handled). Handling of these socket options is a necessary step on the way to future ICMPv6 MLD support. 2018-10-31 15:59:05 -06:00