Commit Graph

182 Commits

Author SHA1 Message Date
Gregory Nutt
254924029b net/udp: Restore some legacy behavior that was lost with the implementation of CONFIG_NET_UDP_BINDTODEVICE: If no device has a local address when the broadcast packet is sent and the UDP socket is not bound to a device, there select some arbitrary device. This is certainly lunacy in the case where there are multiple network devices registered because the wrong device will probably be returned. It works find, however, for the legacy case where only a single network device is registered. 2018-07-04 07:35:51 -06:00
Gregory Nutt
cf3dd19352 Fix a typo. 2018-06-26 07:01:27 -06:00
Gregory Nutt
8e6afb958a net/udp: If the interface index of the device bound to a UDP socket is no longer valid because the device has been unregistered, then un-bind the UDP socket. 2018-06-26 06:53:13 -06:00
Gregory Nutt
c439b93627 net/procfs and netdev: Fix some problems with ifconfig introduced with last changes. Also picks up one of Sebastien's changes that did not make it it before. net/udp: Fixes a DEBUGASSERT. 2018-06-25 17:06:11 -06:00
Sebastien Lorquet
65be13bffe net/udp: Finish support for the UDP_BINDTODEVICE protocol socket option 2018-06-25 15:07:53 -06:00
Gregory Nutt
c65e1aa3df Squashed commit of the following:
syscalls/:  Add syscall support for if_nametoindex() and if_indextoname()
    net/: Update some comments.
2018-06-25 12:41:28 -06:00
Gregory Nutt
7c1394d814 Squashed commit of the following:
net/netdev:  Add implementation of if_nametoindex() and if indextoname().
    net/pkt:  Raw AF_PACKET sockets now depend on CONFIG_NETDEV_IFINDEX.
    net/procfs:  Tweak to handle traversal of interfaces if CONFIG_NETDEV_IFINDEX is not defined.
    net/netdev.h:  Update netdev_findbyaddr() to use the assigned device index.
    Trivial typo fix
    net/netdev:  Add support for assigned an interface index to a device when it is regisgtered.
2018-06-25 12:08:10 -06:00
Gregory Nutt
589e3aa54e net/udp: Fix a whole in the address lookup logic. 2018-06-25 07:51:21 -06:00
Gregory Nutt
a0e169ad7b net/: Fix a sixlowpan typo bug recently introduced; Rename g_ipv6_allzeroaddre with the more meaning g_ipv6_unspecaddr since the all-zero address is the IPv6 unspecified address (sometime IN6_ADDR_ANY). Remove more inline tests for IPv6 multicast with tcommint net_is_addr_mcast() macro. Update some comments. 2018-06-23 12:53:27 -06:00
Gregory Nutt
5bb216fb90 net/: There are many different checks for IPv6 multicast addresses. Most of the checks are different. RFC 3513 clearly specifies how to detect an IPv6 multilcast address: they should begin with 0xffxx. I did not change some of the checks in ipv6_input.c, however. In that file, the comments indicate that the code should only pick of certain mulicast address that begin withi 0xff02. 2018-06-23 10:13:38 -06:00
Gregory Nutt
706a6a2c19 Trivial typo fixes 2018-06-23 06:20:25 -06:00
Gregory Nutt
daa04c2eae net/udp: Fix yet another confusion between raddr and laddr introduced in a recent change. 2018-06-22 10:14:47 -06:00
Gregory Nutt
66db9f09f6 Fix a typo introduced in 1b6990b69f. Also some minor design improvment. 2018-06-22 10:09:47 -06:00
Gregory Nutt
1b6990b69f net/udp: When sending a broadcast (or multicast) packet do not attempt to look up the device by the destination IP address. Rather, use the locally bound address for these cases to select the correct network device. 2018-06-22 08:19:17 -06:00
Gregory Nutt
8fdbb1e0a4 Elimate use of the non-standard type systime_t and replace it the equivalent, standard type clock_t
Squashed commit of the following:

    sched:  Rename all use of system_t to clock_t.
    syscall:  Rename all use of system_t to clock_t.
    net:  Rename all use of system_t to clock_t.
    libs:  Rename all use of system_t to clock_t.
    fs:  Rename all use of system_t to clock_t.
    drivers:  Rename all use of system_t to clock_t.
    arch:  Rename all use of system_t to clock_t.
    include:  Remove definition of systime_t; rename all use of system_t to clock_t.
2018-06-16 12:16:13 -06:00
Gregory Nutt
a186383f2a Recent changes to UDP in order to correct problems with UDP connection mode introduced a new bug: The 'to' address passed to sendto() must now be NULL in connection mode. But there are errors because there was one place where the 'to' address was still being used.
This commit adds logic to first check for UDP connection mode.  If the UDP socket is connected, then the NULL 'to' address is ignored and saved connection address is used instead.
2018-05-17 07:46:09 -06:00
Gregory Nutt
4e8e726ca3 net/udp: Trivial correct in comments due to copy-paste. 2018-05-14 06:36:59 -06:00
Gregory Nutt
3ee61fb890 net/udp: Associated with last commit. Make sure that the new connection flag is cleared when a new UDP connection structure is allocated. 2018-05-13 10:03:55 -06:00
Gregory Nutt
fb8cf9373c net/udp: Resolve race condition in connection-less UDP sockets with read-ahead buffering.
In connection-mode UDP sockets, a remote address is retained in the UDP connection structure.  This determines both there send() will send the packets and which packets recv() will accept.

This same mechanism is used for connection-less UDP sendto:  A temporary remote address is written into the connection structure to support the sendto() operation.  That address persists until the next recvfrom() when it is reset to accept any address.

When UDP read-ahead buffering is enabled, however, that means that the old, invalid remote address can be left in the connection structure for some time.  This can cause read-ahead buffer to fail, dropping UDP packets.

Shortening the time between when he remote address is reset (i.e., immediately after the sendto() completes) is not a solution, that does not eliminate the race condition; in only makes it smaller.

With this change, a flag was added to the connection structure to indicate if the UDP socket is in connection mode or if it is connection-less.  This change effects only UDP receive operations:  The remote address in the UDP connection is always ignored if the UDP socket is not in connection-mode.

No for connection-mode sockets, that remote address behaves as before.  But for connection-less sockets, it is only used by sendto().
2018-05-13 09:57:34 -06:00
Gregory Nutt
efed1b6aa1 net/udp: Remove an unused variable warning. Add some comments. 2018-04-27 18:26:38 -06:00
Gregory Nutt
119ce8730f net/udp: Fix a backward conditional test added in commit 434da18cd7. 2018-04-27 06:35:51 -06:00
Gregory Nutt
434da18cd7 net/udp: Correct an error introduce in recent fixes for UDP connected sockets. The interaction between psock_udp_send() and psock_udp_sendto() was perverse: It should always pass a NULL destinatino address. 2018-04-26 21:58:09 -06:00
Gregory Nutt
091e3f732e net/udp: Fix several issues using connected UDP sockets: sendto() should not accept and address. Normally send() should be used instead. recvfrom() is no longer necessary. recvfrom() and poll() should not reset to accept any addresses but should, instead, only accept inputs and events from the connected remore peer. On of these issues was noted by 李桂丁 <liguiding@pinecone.net>. Changes were made as summarized here: http://www.masterraghu.com/subjects/np/introduction/unix_network_programming_v1.3/ch08lev1sec11.html 2018-04-25 08:43:38 -06:00
Gregory Nutt
57f7677128 net/udp: Fix another related error in UDP condition compilatino (was actually using TCP setting, not UDP setting). 2018-03-30 15:30:45 -06:00
Gregory Nutt
51ee2cdd86 net/udp: Fix some errors in conditional compilation. 2018-03-30 12:08:53 -06:00
Gregory Nutt
b54ffe858a Standardization of some function headers. 2018-03-13 09:52:27 -06:00
Dmitriy Linikov
a8c58607e9 Merged in hardlulz/modem-3.0-nuttx/fix-sem-EINTR (pull request #603)
Added ECANCELED condition to DEBUGASSERT-s checking sem_wait result

Approved-by: Gregory Nutt <gnutt@nuttx.org>
2018-02-20 18:24:53 +00:00
Gregory Nutt
7cf88d7dbd Make sure that labeling is used consistently in all function headers. 2018-02-01 10:00:02 -06:00
Gregory Nutt
82cb799bb6 net/udp: Fix memory leak with UDP + write buffer is closed. Also update TODO and comments and refresh a configuration. 2018-01-23 11:54:03 -06:00
Gregory Nutt
f2017bded8 net/udp: UDP write buffering is basically functional but needs a lot more verification. 2018-01-23 07:32:17 -06:00
Gregory Nutt
289e4dde06 net/udp and tcp: Yet another (cosmetic) change to UDP and TCP write buffer macro naming. 2018-01-22 19:33:14 -06:00
Gregory Nutt
2d4fa19a54 net/udp: Resolves final design issues with UDP write buffering. 100% code complete but also 100% untested. 2018-01-22 19:27:05 -06:00
Gregory Nutt
fa3ad46897 net/udp: In sendto(), return EHOSTUNREACH if if the network is down. 2018-01-22 18:46:58 -06:00
Gregory Nutt
fef255e5be This commit adds an as-of-yet untested implemented of UDP write buffering.
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.
2018-01-22 18:32:02 -06:00
Gregory Nutt
0406fff888 net/udp: Remove some conditional logic that was true if there is only a single network device, but not true in the multi-device context. 2018-01-22 14:14:32 -06:00
Gregory Nutt
cccc86da09 This change adds support for semi-standard IPPROTO_ICMP AF_INET datagram sockets. This replaces the old ad hoc, nonstandard way of implementing ping with a more standard, socket interface.
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.
2017-10-23 08:45:12 -06:00
Gregory Nutt
cf5cba953d There was a possible recursion that could eventually overflow the stack. The error occurred when closing the socket with inet_close() while a socket callback was still queued. When the socket callback was executed by devif_conn_event(), this resulted in a call to psock_send_eventhandler() with TCP_CLOSE flag set which then called tcp_lost_connection(). tcp_shutdown_monitor() then called tcp_callback() again, which again called psock_send_eventhandler(), and so on.... Noted by Pascal Speck. Solution is also similar to a solution proposed by Pascal Speck. 2017-10-19 11:55:51 -06:00
Gregory Nutt
9568600ab1 Squashed commit of the following:
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.
2017-10-04 15:22:27 -06:00
Gregory Nutt
42a0796615 Squashed commit of the following:
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
2017-10-03 15:35:24 -06:00
Gregory Nutt
83cdb0c552 Squashed commit of the following:
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.
2017-10-03 12:52:31 -06:00
Gregory Nutt
80412df0b1 UDP Networking: Fix unitialized variable problem found by Coverity 2017-09-13 12:12:57 -06:00
Jussi Kivilinna
547733cbb0 Update net_timedwait() and net_lockedwait() call sites to handle negated errno in return value 2017-09-04 07:56:51 -06:00
Gregory Nutt
8ffb103adb networking: IGMP: Remove special support for interrupt level processing (there is none) and fix some timer cancellation logic. In many files, correct comments. There is no interrupt level processing in the networking layer. 2017-09-02 10:27:03 -06:00
Gregory Nutt
0b2a4eb4bd Networking: A little more wording changes related to interrupts vs. events 2017-08-29 15:08:38 -06:00
Gregory Nutt
04ad162540 Networking: Clean up some naming that has bothered me for a long time... There are no interrupts and no interrupt handlers in the network. There are events and event handler (there used to to be interrupt logic in there years ago but that is long, long gone). 2017-08-29 14:08:04 -06:00
Gregory Nutt
969d7c5814 Networking: Remove driver based backlog support. This affects the entire network, but is used by only one driver. The only supported with of supported RX backlog is via common read-ahead buffering. 2017-08-21 06:28:59 -06:00
Gregory Nutt
bd7c84b23e Remove CONFIG_NETDEV_MULTINIC. This increases code size by a little, but greatly reduces the complexity of the network code. 2017-08-08 14:24:12 -06:00
Gregory Nutt
572cf51fa4 Networking: Rethink IPv6 all-nodes packet routing. 2017-08-08 07:48:07 -06:00
Gregory Nutt
835ae2999d networking: Move a little more to the inet/ subdirectory. 2017-08-07 13:03:23 -06:00
Gregory Nutt
2ada7d5892 IPv6: Remove comparisons to the address with all ones set. IPv6 does not support broadcast addresses and certainly not in that form. Replace with multicast addresses beginning with 0xff02. 2017-08-07 11:50:50 -06:00