Commit Graph

1383 Commits

Author SHA1 Message Date
Gregory Nutt
9e73216bf2 net/tcp: Same change to tcp_send_buffered.c probably also applies to sixlowpan_tcpsend.c and inet_recvfrom.c 2017-10-19 16:45:00 -06:00
Gregory Nutt
8d023cb97f tcp_lost_connection() is called from two places in tcp_sendfile.c 2017-10-19 16:36:57 -06:00
Gregory Nutt
8c11a73d33 net/tcp: Same change to tcp_send_buffered.c probably also applies to tcp_sendfile.c. 2017-10-19 16:31:28 -06:00
Gregory Nutt
7d62a74915 Fix an error introduced in last commit. 2017-10-19 16:26:09 -06:00
Gregory Nutt
5a416be95b net/tcp: Same change to tcp_send_buffered.c probably also applies to tcp_send_unbuffered.c. 2017-10-19 16:14:38 -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
bc40403516 There was a reference counting problem in the TPC logic of net_clone(). net_clone() which is the common logic underlying dup() and dup2() for sockets. When net_clone() calls net_start_monitor() and net_start_monitor() returns a failure (because the underlying TCP connection) then net_clone() must back out the reference count on the structure. Problem noted by Pascal Speck and this implementation of the solution is based on his suggestion. 2017-10-19 11:09:23 -06:00
Anthony Merlino
e9fa96258b net/: Fix some build issues noted when both IPv4 and IPv6 are enabled. 2017-10-18 11:08:56 -06:00
Gregory Nutt
5907d3c6b6 The nx example no longer supports single user mode. 2017-10-14 10:54:38 -06:00
Gregory Nutt
2dab490cee 6LoWPAN: Fix a whole in the logic of the previous commit. It turns out that g_uncomp_hdrlen has other usages so it cannot be modified as I was doing. Instead, I needed to add a separate localt variable, protosize, to keep track of the two usages of g_uncomp_hdrlen. 2017-10-13 13:31:53 -06:00
Gregory Nutt
53c0938b53 6LoWPAN: Correct a bug in handling uncompressed frames (IPv6 dispatch) 2017-10-13 11:07:43 -06:00
Gregory Nutt
5ffd034f40 TCP Networking: When CONFIG_NET_TCP_WRITE_BUFF=y there is a situation where a NULL pointer may be dereferenced. In this configuration, the TCP connection's 'semi-permnanent' callback, s_sndcb was nullified in tcp_close_disconnect. However, other logic in tcp_lost_connection() attempt to use that callback reference after it was nullifed. Fixed in tcp_lost_connectino() by adding a NULL pointer change before the access. This was reported by Dmitriy Linikov in Bitbucket Issue 72. 2017-10-13 06:47:40 -06:00
Gregory Nutt
6de41b6cf3 net/local: Missed at least one change from read() to nx_read(). 2017-10-11 12:16:00 -06:00
Jussi Kivilinna
957831d2ba net/socket: psock_send/psock_sendto: remove assert check for null psock and buf input pointers. Removes check as 'psock == NULL' altogether because that checked for later in psock_send and psock_sendto. Change null check for 'buf' so that it is handled same as in recvfrom.c (return -EINVAL instead of
assert).
2017-10-11 11:04:05 -06:00
Gregory Nutt
a00d8e16a1 Adds OS internal function nx_write() which is functionally equivalent to write() except that it does not set the errno variable and do not cause cancellation points. 2017-10-11 10:18:30 -06:00
Gregory Nutt
af072d52bc Adds OS internal functions nx_send(), ns_recv(), and nx_recvfrom() which are functionally equivalent to send(), recv(), and recvfrom() except that they do not set the errno variable and do not cause cancellation points. 2017-10-11 09:25:43 -06:00
Gregory Nutt
6a13faf702 net/local: Need to include nuttx/semaphore.h to eliminate some new warnings. 2017-10-08 13:31:03 -06:00
Gregory Nutt
aeb3944f0a fs/vfs and net/socket: fcntl() is not return success fail for F_SETFL. Reported by Jussi Kivilinna. 2017-10-06 08:27:38 -06:00
Gregory Nutt
29b5b3667f sched/semaphore: sem_timedwait() is a cancellation point and, hence, cannot be called from within the OS. Created nxsem_timedwait() that is equivalent but does not modify the errno and does not cause cancellation. All calls to sem_timedwait() change to calls to nxsem_timedwait() in the OS. 2017-10-05 07:24:54 -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
6ccb974910 net/route: Fix an error in cache list management. 2017-10-02 08:10:12 -06:00
Gregory Nutt
c76774cfb0 net/route: Add logic to mark a route as most-recently-used in the route cache. 2017-10-02 07:29:02 -06:00
Gregory Nutt
c4ab155002 compiler.h: Fix some GCC warnings introduced for SDCC support. Basically a naming collision. 2017-10-02 07:09:31 -06:00
Gregory Nutt
e4dd33280d Squashed commit of the following:
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.
2017-09-30 10:41:21 -06:00
Gregory Nutt
2c2aa94b7d Squashed commit of the following:
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.
2017-09-30 08:18:08 -06:00
Gregory Nutt
054b147114 net/: Versions of psock_send() and pock_sendto() should not set errno. That is taken care of at a higher level in the send()/sendto() implementation as appropriate. 2017-09-30 06:41:56 -06:00
Gregory Nutt
6c5f254a5b psock_send() no longer sets errno, so send() must now set it. 2017-09-30 06:27:37 -06:00
Gregory Nutt
44736b721c net/sockets: psock_send() is an internal OS interface an should not set the errno variable. 2017-09-29 17:48:15 -06:00
Gregory Nutt
9e8529b1d0 net/sockets: psock_sendto() is an internal OS interface an should not set the errno variable. 2017-09-29 17:35:38 -06:00
Gregory Nutt
3963d1c85b net/route: File read/write logic should be able to handle short reads and writes. 2017-09-29 12:46:38 -06:00
Gregory Nutt
c4d03d81e2 Update some comments 2017-09-29 12:10:03 -06:00
Gregory Nutt
ae78a925eb Add support for an in-memory routing table cache in order to improve performance when the routing table is retained in a file. The cache holds the most recently used routing table entries and so can eliminate some file access.
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.
2017-09-29 12:04:45 -06:00
Gregory Nutt
44d88abb83 This commit adds support for routing tables in files in a file system. This might be useful for customized, per-unit routing tables.
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.
2017-09-29 08:33:36 -06:00
Gregory Nutt
e761b80ea7 fs/vfs: file_read() is an internal OS interface and should not errors via the errno 2017-09-28 14:14:32 -06:00
Gregory Nutt
9043b9cb6a fs/vfs: file_seek() is an internal OS interface and should not errors via the errno 2017-09-28 13:55:36 -06:00
Gregory Nutt
ac63ffebb8 More minor cleanup after laster squashed merge. 2017-09-28 12:25:05 -06:00
Gregory Nutt
467c31637f Minor cleanup after laster squashed merge. 2017-09-28 09:23:03 -06:00
Gregory Nutt
3aa18ef56e Addes support for read-only routing tables. Prior to this change, routing tables were only support in RAM and had to be initialized with explicit logic to add the necessary routes to the routing table. With this change, routes may be defined in the pre-initialized, read-only routing table provided by the board-specific logic
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
2017-09-28 09:04:31 -06:00
Louis Mayencourt
b55005669a net/arp/arp_out.c: Fix IGMP Ethernet address computation 2017-09-28 07:50:52 -06:00
Gregory Nutt
d88583ffcf net/route: Permit IPv4 and IPv6 routing tables to be of different sizes 2017-09-27 12:04:51 -06:00
Bruno Herrera
24767a0c66 Fixes for problems found by Coverity in the nuttx repository:
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.
2017-09-25 07:17:09 -06:00
Louis Mayencourt
dfa0574e7b net/igmp/igmp_send.c: Fix incoming IGMP checksum calculation 2017-09-25 06:55:01 -06:00
Sakari Kapanen
d0f72617ef From b7b1826930c7da10416bceebce5d63dc8e4086ca Mon Sep 17 00:00:00 2001
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.
2017-09-24 06:33:05 -06:00
Gregory Nutt
12c4c4c8a6 In some cases, packets are still not sent behind the router. I found that NuttX sends the ARP requests not to the router but to the target. Mistake in file net/route/netdev_router.c. From Aleksandr Kazantsev 2017-09-20 13:19:05 -06:00
Gregory Nutt
2790c3b024 Trivial fix in some comments. 2017-09-20 10:06:26 -06:00
Gregory Nutt
de34b96533 SIOCGIFCONF and SIOCGLIFCONF IOCTL commands should only report on network adatpors in the UP state. 2017-09-20 06:50:21 -06:00
Gregory Nutt
ae2a1d07b3 Networking: drivers/net/loopback.c: Eliminate a warning. net/netdev/netdev_ifconfig.c: Was not returning all of the address info. 2017-09-19 15:00:46 -06:00
Gregory Nutt
7af976c00a Squashed commit of the following:
Networking:  Add implementation of logic for SIOCGIFCONF and SIOCGLIFCOF IOCTL commnds.
    Networking:  Add definitions and stuctures to support SIOCGIFCONF and SIOCGLIFCONF IOCTL commands.
2017-09-19 14:17:05 -06:00