Fix SMP related bugs
* sched/sched: Fix a deadlock in SMP mode
Two months ago, I introduced sched_tasklist_lock() and
sched_tasklist_unlock() to protect tasklists in SMP mode.
Actually, this change works pretty well for HTTP audio
streaming aging test with lc823450-xgevk.
However, I found a deadlock in the scheduler when I tried
similar aging tests with DVFS autonomous mode where CPU
clock speed changed based on cpu load. In this case, call
sequences were as follows;
cpu1: sched_unlock()->sched_mergepending()->sched_addreadytorun()->up_cpu_pause()
cpu0: sched_lock()->sched_mergepending()
To avoid this deadlock, I added sched_tasklist_unlock() when calling
up_cpu_pause() and sched_addreadytorun(). Also, added
sched_tasklist_lock() after the call.
Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
* libc: Add critical section in lib_filesem.c for SMP
To set my_pid into fs_folder atomically in SMP mode,
critical section API must be used.
Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
* mm: Add critical section in mm_sem.c for SMP
To set my_pid into mm_folder atomically in SMP mode,
critical section API must be used.
Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
* net: Add critical section in net_lock.c for SMP
To set my pid (me) into fs_folder atomically in SMP mode,
critical section API must be used.
Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
Approved-by: Gregory Nutt <gnutt@nuttx.org>
net/tcp: Add logic to send probes when SO_KEEPALIVE is enabled.
net/tcp: TCP socket should not have to be connected to configure KeepAlive.
net/: Add a separate configuration to enable/disable KEEPALIVE socket options.
net/tcp: Arguments to TCP keep-alive timing functions probably should be struct timeval as are the times for other time-related socket options.
net/tcp: Fix a backward conditional
net/tcp: Add some more checks and debug output to TCP-protocol socket options.
net/tcp: Cosmetic changes to some alignment.
net/: Adds socket options needed to manage TCP-keepalive and TCP state machine logic to detect if that the remote peer is alive. Still missing the timer poll logic to send the keep-alive probes and the state machine logic to respond to probes.
binfmt/, configs/, grahics/, libc/, mm/, net/, sched/: OS references to the errno variable should always use the set_errno(), get_errno() macros
arch/arm/src/stm32 and stm32f7: Architecture-specific code is not permitted to modify the errno variable. drivers/ and libc/: OS references to the errno variable should always use the set_errno(), get_errno() macros
Squashed commit of the following:
net/udp: Address most of the issues with UDP write buffering. There is a remaining issue with handling one network going down in a multi-network environment. None of this has been test but it is certainly ready for test. Hence, the feature is marked EXPERIMENTAL.
net/udp: Some baby steps toward a corrected write buffering design.
net/udp: Remove pesky write buffer macros.
Eliminate trailing space at the end of lines.
net/udp: A little more UDP write buffering logic. Still at least on big gaping hole in the design.
net/udp: Undefined CONFIG_NET_SENDTO_TIMEOUT.
net/udp: Crude, naive port of the TCP write buffering logic into UDP. This commit is certainly non-functional and is simply a starting point for the implementatin of UDP write buffering.
net/udp: Rename udp/udp_psock_sendto.c udp/udp_psock_sendto_unbuffered.c.
fs: Add truncate() support for userfs
fs/unionfs: Add truncate() support to the unionfs
fs/tmpfs: Add ftruncate() support to tmpfs
syscall/: Add system call support for ftruncate()
net/route: Adding ftruncate() support eliminates an issue in file-based routing table management.
fs: Add basic framework to support truncate() and ftruncate(). The infrastructure is complete. Now, however, the actual implementation of ftruncate() will have to be done for each file system.
net/tcp: Introduce tcp receive window control based on I/O buffer
NOTE: The algorithm is still experimental but useful for http streaming.
Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
Approved-by: Gregory Nutt <gnutt@nuttx.org>
sixlowpan: Support sending to a router that is on-link and may be able to forward the packet for us if the destination is not reachable directly
Approved-by: Gregory Nutt <gnutt@nuttx.org>
As a policy, all internal OS implementations must use "detached" files which are valid in any context and do not depend on the validity of a file descriptor at any point in time. This commit converts the usage of file descriptors to detached files throughout the local socket implementation.
Squashed commit of the following:
net/local: Finish change to eliminate use of file descriptors.
net/local: A little more of the conversion.
net/local: Beginning of chnages to eliminate use of file descriptors in the local socket implementeation. poll() will be a problem.
ieee802154: Simplifies notify() and rxframe() calls to a single notify() call. dataind's and all other "notifs" are now "primitives" which aligns with standard terminology
* mac802154: Adds missing breaks from case statement
* sixlowpan: Fixes bad logic where ACK is not requested if address is not a broadcast
* ieee802154: Simplification of "notifs" and "datainds" to generic primitives passed via a single notify call to the layer above the MAC
* Directories.mk should reference CONFIG_WIRELESS instead of CONFIG_DRIVERS_WIRELESS
* xbee_netdev: Network must be locked when calling sixlowpan_input
* sixlowpan: Reassembly buffer can't be freed if provided by radio driver
* sixlowpan: Don't free IOB if there is an error processing it as the MAC will try to pass it along to another receiver
* ieee802154: Adds basic logging to ieee802154_primitive.c
* Minor fixes after rebase
* xbee: Adds AT query timeout to retry if XBee doesn't respond to request
* same70-xplained: Adds Xbee support. Makes mikroBus slot Kconfig 'choice'
* mac802154: Removes unused function declaration
* drivers/mrf24j40: Fixes compilation error using . operator rather than -> operator
* mac802154_device: Changes a few mac802154_primtive_free's to ieee802154_primitive_free() and changes notif to primitive in a couple places.
* mac802154: Adds promiscous mode logic to bypass parsing of incoming frames. MAC char device also checks for promiscous mode and passes whole frames including header and FCS to the application if promiscous mode is enabled.
* sixlowpan: Fixes logic to correctly check if packet is large enough to include header. This would cause packets to be considered too small when they are sufficiently sized.
* sixlowpan: Fixes forwarding logic to use forwarding device rather than received device to look up destination link layer address
* net/ipforward: Fixes typo that caused build error when IP forwarding was enabled with CONFIG_NET_ICMPv6_NEIGHBOR enabled as well.
* configs/same70-xplained: Simple spelling fix
Approved-by: Gregory Nutt <gnutt@nuttx.org>
Squashed commit of the following:
net/icmpv6: IPPROT_ICMP6 socket logic now builds without error.
net/icmpv6: Add support for read-ahead and poll(). Initial commit is just cloned from ICMP with the appropriate name changes.
configs/: All defconfig filess that include CONFIG_NET_ICMPv6_SOCKET=y need to select CONFIG_SYSTEM_PING6=y and deselect CONFIG_DISABLE_POLL.
Update NSH documention to show that ping6 is now a built in command.
net/icmpv6: Add icmpv6_sendto.c and icmpv6_recvfrom.c. Initial versions are just clones from icmp/ with appropriate name changes.
net/icmpv6: Clone some ICMP socket logic as the beginning of support for ICMPv6 socket support.
Rename CONFIG_NET_ICMPv6_PING to CONFIG_NET_ICMPv6_SOCKET. Move prototype for icmpv6_ping from include/nuttx/net/icmpv6 to net/icmpv6/icmpv6.h
Squashed commit of the following:
net/icmp: Finishes off icmp_recvfrom().
net/icmp: Add readahead support for IPPROTO_ICMP sockets.
net/icmp: Add poll() support for IPPROTO_ICMP sockets.
net/icmp: Add a connection structure for IPPROTO_ICMP sockets.
net/icmp: Implements sendto for the IPPROTO_ICMP socket.
net/icmp: Move icmp_sendto() and icmp_recvfrom() to separate files. They are likely to be complex (when they are implemented).
net/icmp: Hook IPPROTO_ICMP sockets into network. Fix some naming collisions. Still missing basic ICMP send/receive logic.
configs: apps/system/ping current need poll() enabled.
configs: All defconfig files that use to enable low-level support must now enabled CONFIG_SYSTEM_PING.
net/icmp: Adds basic build framework to support IPPROTO_ICMP sockets.
This commit backs out most of commit b4747286b1. That change was added because sem_wait() would sometimes cause cancellation points inappropriated. But with these recent changes, nxsem_wait() is used instead and it is not a cancellation point.
In the OS, all calls to sem_wait() changed to nxsem_wait(). nxsem_wait() does not return errors via errno so each place where nxsem_wait() is now called must not examine the errno variable.
In all OS functions (not libraries), change sem_wait() to nxsem_wait(). This will prevent the OS from creating bogus cancellation points and from modifying the per-task errno variable.
sched/semaphore: Add the function nxsem_wait(). This is a new internal OS interface. It is functionally equivalent to sem_wait() except that (1) it is not a cancellation point, and (2) it does not set the per-thread errno value on return.
sched/semaphore: Add nxsem_post() which is identical to sem_post() except that it never modifies the errno variable. Changed all references to sem_post in the OS to nxsem_post().
sched/semaphore: Add nxsem_destroy() which is identical to sem_destroy() except that it never modifies the errno variable. Changed all references to sem_destroy() in the OS to nxsem_destroy().
libc/semaphore and sched/semaphore: Add nxsem_getprotocol() and nxsem_setprotocola which are identical to sem_getprotocol() and set_setprotocol() except that they never modifies the errno variable. Changed all references to sem_setprotocol in the OS to nxsem_setprotocol(). sem_getprotocol() was not used in the OS
libc/semaphore: Add nxsem_getvalue() which is identical to sem_getvalue() except that it never modifies the errno variable. Changed all references to sem_getvalue in the OS to nxsem_getvalue().
sched/semaphore: Rename all internal private functions from sem_xyz to nxsem_xyz. The sem_ prefix is (will be) reserved only for the application semaphore interfaces.
libc/semaphore: Add nxsem_init() which is identical to sem_init() except that it never modifies the errno variable. Changed all references to sem_init in the OS to nxsem_init().
sched/semaphore: Rename sem_tickwait() to nxsem_tickwait() so that it is clear this is an internal OS function.
sched/semaphoate: Rename sem_reset() to nxsem_reset() so that it is clear this is an internal OS function.
psock_close() and net_close() are internal OS functions and should not set the errno variable.
psock_ioctl() and netdev_ioctl() are internal OS functions and should not set the errno variable.
net_dupsd() and net_dupsd2() are internal OS functions and should not set the errno variable.
net/ and fs/: net_vfcntl(), file_fcntl(), file_dup(), and file_dup2() are all internal OS interfaces and should not modify the errno value.
net/: psock_recvfrom() is an internal interface and should not set the errno nor should it be a cancellation point.
net/: psock_accept() is not a cancellation point.
net/: psock_getsockopt() and psock_socket*9 are an internal interfaces and should not set the errno.
net/: psock_getsockopt() is an internal interface and should not set the errno.
net/: psock_listen() is an internal interface and should not set the errno.
net/: psock_connect(( is an internal interface and should not set the errno nor should it be a cancellation point.
net/: psock_bind() is an internal interface and should not set the errno.
net/: psock_accept() is an internal interface and should not set the errno.
Squashed commit of the following:
net/route: Flush in cache when any entry is deleted from the routing table. When a router matching an IP address is found, add the routing table entry to the cache.
net/route: Add utility functions to manage an in-memory cache to improve performance when use a file-based routing table.
There are two issues with it however:
1. Reading from file system on a per packet basis could be slow. I think it probably should have a small, in-memory cache of most frequently used routes for good problem.
2. Currently the delroute logic is disabled due to a problem with the design. NuttX does not currently support truncate(). Therefore, it is not possible to delete entries from the routing table file.
In this current implementation, that leaves the last entry intact at the end of the file. An alternative design might include a tag on each record to indicate if the record is valid or not. That would work but would add complexity to the other routing table functions.
The existing implementation is available for testing purposes only if CONFIG_EXPERIMENTAL=y.
Squashed commit of the following:
net/route: The current delroute design depends on file truncation. However, NuttX does not currently support truncate. Alternative, more complex designs are possible but not implemented. At present the file routing table are otherwise functional but the delroute logic is disabled via CONFIG_EXPERIMENTAL. Enable it only if you plan to fix it.
net/route: Fix some issues with locking routing table files.
net/route: Add partial implementation of delroute for the case where the routing table is in a file.
net/route: Add support for seeking to positions in the routing table.
net/route: Add net_addroute_ipv4/6() using a file-based routing table.
net/route: Add net_foreach_ipv4/4() using a file-based routing table.
net/route: Initial build, configuration, and fs utilies to support routing tables in a file.
This would be particularly useful, for example, in the case where there is only a single network adaptor and you want all output packets to go to the single adaptor in all cases. So for that behavior you could add a read-only routing table to the board-specific long that contains a single entry, the default route: 0.0.0.0/0.
Squashed commit of the following:
net/route: RAM and ROM routing tables build correctly in all IPv4 and IPv6 configurations.
net/route: Verify IPv6 ROM route build; Make number of ROM routes a variable, not a configuration item.
net/route: Add initial support for ROM-base, read-only routing tables.
net/route: Adjust and generalize some structures, rename some functions, and add configuration and build support that will eventually support read-only routing tables.
net/route: Some initial though experiments on use of a fixe, read-only routing table
net/socket/recvfrom.c: Check fromlen integrity before using it.
net/socket/net_sockets.c: Always check for valid psock before using.
net/tcp/tcp_send_unbuffered.c: Avoid using psock beforing checking its integrity.
sched/timer/timer_create.c: Fix watchdog resource leak if cannot allocate a new timer.
From: Sakari Kapanen <sakari.kapanen@optofidelity.com>
Date: Sun, 24 Sep 2017 13:19:25 +0300
Subject: [PATCH] ICMPv6: fix router advertisement
Fixes several errors preventing icmpv6_radvertise.c from being compiled. Fixes conversions to network byte order (namely vlifetime, plifetime, mtu).
IPv6 source address is set to link-local IP address instead of the address in the netdev structure. This is in compliance to RFC 4861. RA didn't work on Linux before this change.
Finally, router prefix and prefix length are derived from the IPv6 address and netmask in the netdev structure. This seems to make more sense than using a predefined, separate prefix from the config.
Networking: Add implementation of logic for SIOCGIFCONF and SIOCGLIFCOF IOCTL commnds.
Networking: Add definitions and stuctures to support SIOCGIFCONF and SIOCGLIFCONF IOCTL commands.
commit 5b7b6e6e616c475c782e9883ada9f4a3b7cb4e2c
Author: Gregory Nutt <gnutt@nuttx.org>
Date: Sun Aug 20 11:13:17 2017 -0600
IEEE 802.15.4 network device: Make same changes as per loopback device so that it will build with PF_IEEE802154 but without 6LoWPAN.
commit d656a98cf8eab2f20e884224b52cd47ec35df4cc
Author: Gregory Nutt <gnutt@nuttx.org>
Date: Sun Aug 20 10:31:28 2017 -0600
PF_IEEE802154: More fixes to device registration and to IEEE 802.15.4 loopback driver for PF_IEEE802154 without 6LoWPAN.
commit 866bb9cbb0c5af79734bbd434c07fa2560b6608f
Author: Gregory Nutt <gnutt@nuttx.org>
Date: Sun Aug 20 09:58:13 2017 -0600
Network: Reorganize some Kconfig selections.
commit 230b4cb48008cba5fccdafa22340df1d43584829
Author: Gregory Nutt <gnutt@nuttx.org>
Date: Sun Aug 20 09:19:53 2017 -0600
Changes to conditional compilation so that PF_IEEE802154 can build without 6LoWPAN
commit d96cbd6520d40590a740f695c4cd72208ce872da
Author: Gregory Nutt <gnutt@nuttx.org>
Date: Sun Aug 20 09:17:02 2017 -0600
configs/sim/pf_ieee802154: Disable 6LoWPAN, IPv6, TCP, and UDP. Now things do not build
commit 2a3ab1652a2c95bcfc8be8380fc7cbdcb6472938
Author: Gregory Nutt <gnutt@nuttx.org>
Date: Sat Aug 19 08:44:31 2017 -0600
PF_IEEE802154: Finish some missing bind() logic. Add configs/sim configuration for testing.
commit 59be4b846a6e3bfe82087a888e3fdac9c3c414e5
Author: Gregory Nutt <gnutt@nuttx.org>
Date: Fri Aug 18 19:30:04 2017 -0600
PF_IEEE802154: More renaming to decouple 6LoPAN from radios in general.
commit 69fabb1aea76e54381bdc13de28a3f1441fb42f4
Author: Gregory Nutt <gnutt@nuttx.org>
Date: Fri Aug 18 19:21:11 2017 -0600
PF_IEEE802154: Missed a few renamings.
commit ff0af1bb25567720934cc1c2a721ccd92cc35f89
Author: Gregory Nutt <gnutt@nuttx.org>
Date: Fri Aug 18 17:46:58 2017 -0600
PF_IEEE802154: A few bugfixes
commit 01c7c84afd00cf907d280d30cfaf0fb2cf90e02e
Author: Gregory Nutt <gnutt@nuttx.org>
Date: Fri Aug 18 17:01:31 2017 -0600
PF_IEEE802154: A few bugfixes
commit dcef4056d1c1488c93151135f3b7106977faa903
Author: Gregory Nutt <gnutt@nuttx.org>
Date: Fri Aug 18 16:31:05 2017 -0600
PF_IEEE802154: Bring in framework for sendto/recvfrom. Currently just a crude port of functions from net/pkt and do not provide the implemenation needed.
commit 68c5b7b6dd3ab7eb2d0c19890abb38e6561b140e
Author: Gregory Nutt <gnutt@nuttx.org>
Date: Fri Aug 18 15:18:31 2017 -0600
Trivial fix to typo in comment
commit fd0af534c089569ccdbd59f13b85453de0a653ad
Author: Gregory Nutt <gnutt@nuttx.org>
Date: Fri Aug 18 15:07:20 2017 -0600
PF_IEEE802154: Add device lookup logic; Rename some things that used to be used only by 6LoWPAN but now must be shared with PF_IEEE802154 and need more generic naming.
commit 4fc80a1659f1c699b050775cefc7f6b631b46114
Author: Gregory Nutt <gnutt@nuttx.org>
Date: Fri Aug 18 13:49:54 2017 -0600
PF_IEEE802154: Add driver poll logic.
commit d83f71992df8764faa93f9425f1a7602a758f730
Author: Gregory Nutt <gnutt@nuttx.org>
Date: Fri Aug 18 13:28:59 2017 -0600
PF_IEEE802154: Add frame input function.
commit 77561b8c4d5d7be1f8d8eb62cf1a07229afe2048
Author: Gregory Nutt <gnutt@nuttx.org>
Date: Fri Aug 18 12:46:29 2017 -0600
PF_IEEE802154: Socket type should be SOCK_DGRAM. Hook in socket interface.
commit c0f90350282e9905d7f26a1b30f04cc6d6794648
Merge: 8b518abfd0 169c55e546
Author: Gregory Nutt <gnutt@nuttx.org>
Date: Fri Aug 18 09:36:32 2017 -0600
Merge remote-tracking branch 'origin/master' into pf_ieee802154
commit 8b518abfd07d492f5148f2c5fdf65604de9822da
Author: Gregory Nutt <gnutt@nuttx.org>
Date: Fri Aug 18 09:35:39 2017 -0600
PF_IEEE802154: Add initialization and connection management logic.
commit 98b62620b3cb420041d8ad14204f9410a8aace8c
Author: Gregory Nutt <gnutt@nuttx.org>
Date: Fri Aug 18 07:52:51 2017 -0600
PF_IEEE802154: Add basic build support and socket interface framework.