The tcp_backlog is used when there is not process running to accept a new connection, but it is limited by the number of allocated backlog containers. The current error message induces the user to believe there is not free memory to allocate a new container, but actually the containers were allocated during the initialization and were available until the last element of the list has been removed to use.
since usrsock_conn_s::resp::result contain more detailed info and fix the below error in usrsocktest:
Testing group "WakeWithSignal" =>
[TEST ASSERT FAILED!]
In function "do_usrsock_blocking_connect_thread":
line 200: Assertion `(ssize_t)((*get_errno_ptr())) == (ssize_t)((test_abort ? 113 : 4))' failed.
got value: 110
should be: 113
[TEST ASSERT FAILED!]
In function "do_usrsock_blocking_connect_thread":
line 200: Assertion `(ssize_t)((*get_errno_ptr())) == (ssize_t)((test_abort ? 113 : 4))' failed.
got value: 110
should be: 113
[TEST ASSERT FAILED!]
In function "do_usrsock_blocking_connect_thread":
line 200: Assertion `(ssize_t)((*get_errno_ptr())) == (ssize_t)((test_abort ? 113 : 4))' failed.
got value: 110
should be: 113
[TEST ASSERT FAILED!]
In function "do_wake_test":
line 567: Assertion `(bool)((usrsocktest_test_failed)) == (bool)(false)' failed.
got value: 1
should be: 0
Group "WakeWithSignal": [FAILED]
Fix the below error in usrsocktest:
Testing group "WakeWithSignal" =>
[TEST ASSERT FAILED!]
In function "do_usrsock_blocking_socket_thread":
line 122: Assertion `(ssize_t)((*get_errno_ptr())) == (ssize_t)((115))' failed.
got value: 123
should be: 115
[TEST ASSERT FAILED!]
In function "do_wake_test":
line 567: Assertion `(bool)((usrsocktest_test_failed)) == (bool)(false)' failed.
got value: 1
should be: 0
Group "WakeWithSignal": [FAILED]
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.
Historically, the loopback driver used the largest packet size of all enabled link layer protocols. This permitted packets to be forward via the loopbak device with no major loss of performance. However, in experimenting with configurations where no other link layer protocols were enabled, this means the loopback packet size was set to the smallest possible size, to the SLIP minimum of 296 bytes. This resulted in terrible loopback performance.
This commit adds an option to increase the loopback packet size with the option CONFIG_NET_LOOPBACK_PACKETSIZE.
The loopback driver packet buffer should be quite large. The larger the loopback packet buffer, the better will be TCP performance of the loopback transfers. The Linux loopback device historically used packet buffers of size 16Kb, but that was increased in recent Linux versions to 64Kb. Those sizes may be excessive for resource constrained MCUs, however.
The network still enforces the lower limit that is the maximum packet size of all enabled link layer protocols. But this new option permits the loopback packet size to be increased from that.
* net/Kconfig: Adds CONFIG_NET_LOOPBACK_PKTSIZE option
* include/nuttx/net/netconfig.h: Assures that the packet size that is used is at least as large as the largest packet size of other link layer protocols.
* drivers/net/loopback.c: Use that larger packet size.
* boards/sim/sim/sim/configs/tcploop/defconfig: Set the loopback packet size to 1500
Build nucleo-144/f767-netnsh fail with below error:
In file included from igmp/igmp_initialize.c:54:
./igmp/igmp.h:130:3: error: unknown type name 'sem_t'
130 | sem_t sem; /* Used to wait for message transmission */
| ^~~~~
make[1]: *** [igmp_initialize.o] Error 1
Signed-off-by: liuhaitao <liuhaitao@xiaomi.com>
1. Remove the unused and unimplemented ipv6_chksum declaration
2. Update NET_ARCH_CHKSUM description to align with the implementation
3. Declare all checksum function prototype regardless CONFIG_NET_ARCH_CHKSUM
4. Remove the CONFIG_NET_ARCH_CHKSUM guard for tcp_ipv[4|6]_chksum
Author: Gregory Nutt <gnutt@nuttx.org>
net/tcp: Fix errors found in build testing.
Recent re-organization moved some functions from net/inet to net/tcp and net/udp. This include references to nxsem_wait(), SEM_PRIO_NONE, and other internal NuttX semaphore functions. These all failed to compile because nuttx/semaphore.h was not included in any of the files.
Author: Alan Carvalho de Assis <acassis@gmail.com>
Run nxstyle against .c and .h files and fix it
Author: Juha Niskanen <juha.niskanen@haltian.com>
Fix typos and some incorrect comments
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().
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>
* fix warning: format '%x' expects argument of type 'unsigned int', but argument 4 has type 'long unsigned int'
* fix warning: implicit declaration of function 'up_init_exidx'
* tools/nxstyle: Added logic to parse section headers (like Included files, Pre-processor Definitions, etc.) and to assure that the section headers are correct for the file type. Also (1) verify that #include appears only in the 'Included Files' section and that (2) #define only occurs in the Pre-processor definition section.
Right now, there are several places where that rule is not followed. I think most of these are acceptable so these failures only generate warnings, not errors. The warning means that we need to go look at the offending #define or #include and decide if it is a acceptable usage or not.
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>
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>
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.
* 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
* 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
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.
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.
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.
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()
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.
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.
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.
net/netlink/netlink_route.c: Add Netlink socket NETLINK_ROUTE support for getting a snopshot of the Neighbor table.
net/neighbor/neighbor_snapshot.c: Add neighbor_snapshot() that will eventually be used by the Netlink sockets. Also fixed naming violation 'struct neighbor_entry' -> 'struct neighbor_entry_s'.
include/nuttx/net/neighbor.h: Expose format of the IPv6 neighbor table for use with Netlink sockets.
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).
1. For buffered tcp/udp case, if CONFIG_NET_ARP_SEND/CONFIG_NET_ARP_IPIN/CONFIG_NET_ICMPv6_NEIGHBOR isn't enabled and the table doesn't contain ip<->ethaddr mapping yet, the logic will skip the realtransmission and then arp/neighbor can't steal the final buffer to generate arp/icmpv6 packet.
2.for all other case, the tcp layer or user program should already contain the retransmit logic, the check is redundancy and may generate many duplicated packets if arp/icmpv6 response is too slow because the cursor stop forward. If user still concern about the very first packet lost, he could fix the issue by enabling CONFIG_NET_ARP_SEND/CONFIG_NET_ICMPv6_NEIGHBOR at begin.
drivers/ieee802154/xbee: Add configuration option for setting the default prefix to use when bringing up the network and setting the IP address.
# Conflicts:
# drivers/wireless/ieee802154/xbee/xbee_netdev.c
Approved-by: Gregory Nutt <gnutt@nuttx.org>
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>
ieee802154/sixlowpan: Removes unnecessary conversions that were happening due to a misunderstanding of byte ordering with EUI-64
# Conflicts:
# drivers/wireless/ieee802154/xbee/xbee_netdev.c
Approved-by: Gregory Nutt <gnutt@nuttx.org>
net/ipforward: Check if interface is up early on when forwarding to avoid extra work.
As noticed in a previous wireless commit, when forwarding is enabled and a packet comes in, the packet is attempted to be sent on each other netdev without regard for whether it is in the UP state. Of course this is eventually caught, but it can be caught earlier to avoid unnecessary work, especially in the 6LoWPAN case where a useless packet conversion will occur.
Approved-by: Gregory Nutt <gnutt@nuttx.org>
net/udp: Remove net stack dependency from CONFIG_NET_BROADCAST
This change allows us to use CONFIG_NET_BROADCAST without network
stack. (i.e. usrsock application can use broadcast)
Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
Approved-by: Gregory Nutt <gnutt@nuttx.org>
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.
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>
net/usrsock: Fix debug logs and remove DEBUGASSERT from usrsockdev_do_request()
In a client mode, socket() will be the first request for usrsockdev_do_request().
However, in a server mode, the first request to accepted sockets will be recv()
or others which depend on applications. So I think we should remove this
DEBUGASSERT from usrsockdev_do_request().
Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
Approved-by: Gregory Nutt <gnutt@nuttx.org>
ez80: Fixing a few more compile problems. I am afraid that the 5.3.0 compiler it too buggy to use.
ez80: Additional build-related fixed.
eZ80: Updating to use the newest ZDSII 5.3.0 toolchain.
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.
sched/init/nx_start.c: Add support for CONFIG_BOARD_DRIVER_INITIALIZE. If this option is selected then nx_start() will call a board-provided function board_driver_initialize() immediately after calling up_initialize().
Rename CONFIG_BOARD_INITIALIZE to CONFIG_BOARD_LATE_INITIALIZE.
Raname board_initialize() to board_late_initialize()