Commit Graph

916 Commits

Author SHA1 Message Date
Andrew Webster
49e5cc5a6f TCP: check for an active connection before cleaning it up
If there is no active connection (e.g. it is waiting in accept), then
the connection object, which doesn't yet exist, should not be cleaned
up when the socket is closed.
2016-01-22 16:22:09 -06:00
Andrew Webster
5e3023bef1 TCP: return from write when there is no buffer space
During a write, if there is no more buffer space for the user data,
return the amount that was written instead of waiting until there
is free space.  If nothing has been written yet, then block as before.

This solves a deadlock that occurs if the user data is too large to
fit in the available buffer:  the write thread will block before any
data is added to the write queue, leaving no possibility that more
buffers will free up when they are ACKed (since they have not yet been
sent).  The write thread will then block forever and hold all of the
buffers.
2016-01-22 16:19:20 -06:00
Andrew Webster
e221777a7a TCP: post buffer semaphore before re-acquiring both
TCP uses two semaphores for buffers, one for the entire buffer pool,
and one for the number of allowed buffers for readahead.  To avoid
double taking a semaphore under heavy load, release the semaphore
after waiting before trying to acquire both again.
2016-01-22 16:15:10 -06:00
Andrew Webster
4875c6bbe3 TCP: check for connection before deleting it
It is possible for a socket to have no connection, for example if a TCP
socket is waiting in accept.  This checks for this condition in case the
socket is closed from a different thread.
2016-01-22 15:59:15 -06:00
Andrew Webster
f1ef2c6cde TCP: attempt to flush the write buffers before closing
When a socket is closed, it should make sure that any pending write
data is sent before the FIN is sent.  It already would wait for all
sent data to be acked, however it would discard any pending write
data that had not been sent at least once.

This change adds a check for pending write data in addition to unacked
data.  However, to be able to actually send any new data, the send
callback must be left.  The callback should be freed later when the socket
is actually destroyed.
2016-01-22 15:58:02 -06:00
Andrew Webster
cdd187a7f3 TCP: check for sndcb before using it 2016-01-22 15:54:45 -06:00
Andrew Webster
df211ee46a TCP: add writable check during poll
When a poll requesting POLLOUT happens, the poll should return
immediately if a write will not block.  This change adds that, as
opposed to the old behaviour of blocking until a timer from the
Ethernet driver eventually triggers the poll to complete.

This is only implemented for buffered TCP.  Unbuffered TCP should
behave as before.
2016-01-22 15:52:14 -06:00
Andrew Webster
99f5fcda70 iTCP: use lowlevel syslog to avoid infinte recursion
If stdout is a socket (e.g. telnet), then the debug message will cause
more TCP data to be sent, which generates another message, and so on
2016-01-22 15:41:48 -06:00
Gregory Nutt
f348e68069 Update to use 64-bit timer when available 2016-01-21 11:54:26 -06:00
Gregory Nutt
8e9f884eb7 Step 1 in /etc/resolv.conf support 2016-01-13 15:06:44 -06:00
Gregory Nutt
f87358faf9 correct some conditional compilation; update some comments 2016-01-12 07:05:50 -06:00
Gregory Nutt
1608b7c33f Some networking logic was used helpers from apps/netutils. Not good. Quick fix is to duplicate logic 2016-01-09 15:56:08 -06:00
Gregory Nutt
795ddd7e80 OS modules: Add basic procfs support. A module registry that will eventually be used to support lsmod 2015-12-12 17:42:25 -06:00
Gregory Nutt
59b912477e Fix some warnings: Mismatched prototypes 2015-12-05 10:36:00 -06:00
Gregory Nutt
c16648b3fd Most cosmetic but also includes a fix for a compile problem from Ken Pettit 2015-12-01 12:54:57 -06:00
Gregory Nutt
6af3ba78b9 Remove CONFIG_NET_PINGADDRCONF. This was a uIP way of assigning IP addresses, but is not standard and not a appropriate feature in general. 2015-12-01 07:48:56 -06:00
Gregory Nutt
eb8668b0f7 net/: Add procfs support for network device status 2015-11-27 16:39:14 -06:00
Gregory Nutt
9d8462aa23 net/: Move net_procfs.c to net/procfs/. Partition logic a little better to make space to support net device procfs as well 2015-11-27 13:53:33 -06:00
Gregory Nutt
e4236941c6 net/net_procfs.c: Add basic support for networking procfs entries 2015-11-27 12:33:58 -06:00
Gregory Nutt
2a93c66948 include/nuttx/net/netdev.h and several Ethernet drivers in arch/: Most network drivers to not support statistics. Those that do only support them when DEBUG is enabled. Each driver collects an architecture specific set of statistics and there is no mechanism in place to view those statistics. Thus, the driver feature was mostly useless. This change standardizes the driver statistics and puts the definition in the common network device structure defined in netdev.h where they can be accessed by network applications. All Ethernet drivers that collect statistics have been adapted to use these common statistics. 2015-11-26 12:08:09 -06:00
Gregory Nutt
6209c51206 net/: More clean-up of spacing/alignment issues 2015-10-08 15:10:04 -06:00
Gregory Nutt
af086c40ff Remove dangling whitespace 2015-10-04 15:28:54 -06:00
Gregory Nutt
0b12dbf95d Fix some spacing problems 2015-10-04 15:04:00 -06:00
Gregory Nutt
cb9e27c3b0 Standardize naming used for public data and function groupings 2015-10-02 16:30:35 -06:00
Gregory Nutt
fec3d2cf62 recvfrom: Fixes for compilation with only raw, packet sockets 2015-09-14 09:06:08 -06:00
Gregory Nutt
a7e43c7fdb Eliminate some warnings 2015-09-08 09:20:18 -06:00
Gregory Nutt
d700793077 Fix a compile error when IPv6 is enabled 2015-09-07 16:34:25 -06:00
Alan Carvalho de Assis
f10a103108 Fix tcp_send_unbuffered when NET_ETHERNET is not defined. 2015-09-07 13:31:35 -06:00
Gregory Nutt
9c66bde5b0 Fix typo in pre-processor command noted by Pierre-noel Bouteville. Also move # of pre-processior command to column 1 2015-09-05 09:10:48 -06:00
Gregory Nutt
14297afb83 Cosmetic fix to break up long line 2015-09-03 07:33:50 -06:00
Gregory Nutt
36f4d0e9fc Fix a error in some comments 2015-09-02 20:03:28 -06:00
Gregory Nutt
0e2986f131 net/tcp: The logic that binds a specific networkd device to a connection was faulty for the case of multiple network devices. On bind(), the local address should be used to associate a device with the connection (if the local address is not INADDR_ANY); On connect(), the remote address should be used (in case the local address is INADDR_ANY). On accept(), it does not matter but the remote address is the one guarenteed to be available. 2015-09-02 19:48:31 -06:00
Gregory Nutt
9fcad39a45 Trivial typo fix 2015-09-02 10:09:33 -06:00
Paul A. Patience
3b89eabd50 Correct #if to #ifdef when the macro can be undefined. Fix bug in AT24XX driver: it should compare AT24XX_ADDRSIZE to 2. 2015-09-01 13:52:29 -04:00
Gregory Nutt
63071a563a Costmetic changes 2015-08-27 10:38:43 -06:00
Gregory Nutt
b1e09d4847 net/socket and net/tcp: Fix a problem in whent there are multiple network devices. Polls were being sent to all TCP sockets before. This is not good because it means that packets may sometimes be sent out on the wrong device. That is inefficient because it will cause retransmissions and bad performance. But, worse, when one of the devices is not Ethernet, it will have a different MSS and, as a result, incorrect data transfers can cause crashes. The fix is to lock into a single device once the MSS is locked locked down. 2015-08-27 09:06:46 -06:00
Gregory Nutt
3bcdb218ff Networking: Get rid of the tcp_mss macro. It is confusing and only obfuscates what is really going on 2015-08-27 08:39:17 -06:00
Gregory Nutt
007aabc46f Fix a badly formatted comment 2015-08-26 19:18:04 -06:00
SaeHie Park
a268e0aeb9 Fix a typo from an earlier commit 2015-08-26 18:12:58 -06:00
Saehie ParK
e6dbd3d903 Networking: Fix network device name assignment logic for the case of the local loopback device. There is only one local loopback network device and it is unnumbered 2015-08-25 20:03:25 -06:00
Anton D. Kachalov
b125c36849 Field `d_sndlen' is unsigned. It is always >= 0.
Signed-off-by: Anton D. Kachalov <mouse@yandex-team.ru>
2015-08-26 00:16:52 +03:00
SaeHie Park
e983e547e1 Networking: Correct return value from psock_tcp_accept(). From SaeHie Park 2015-08-25 07:15:21 -06:00
Gregory Nutt
79aa3d40b0 Kconfig: CONFIG_NET_MULTILINK and CONFIG_NET_MULTINIC must be support if the loopback device and any real network device are selected 2015-08-25 06:51:15 -06:00
Gregory Nutt
3c5f817513 Networking: Local loopback is basically functional and is no longer EXPERIMENTAL 2015-08-24 13:58:57 -06:00
Gregory Nutt
933d74e5c1 Networking: With these changes, I can ping the local loopback device from the simulator 2015-08-24 13:49:12 -06:00
Gregory Nutt
0b012c7978 Fix some initial loop back device compilation errors; mark configuration as EXPERIMENTAL 2015-08-24 11:29:54 -06:00
Gregory Nutt
07bdff9ef7 Networking: Add NetDB support for the local loopback device 2015-08-24 10:08:26 -06:00
Gregory Nutt
e21501c699 Merge remote-tracking branch 'origin/master' into localhost 2015-08-24 08:29:36 -06:00
Gregory Nutt
569ff602ea Networking: Remove bogus references to PPP as a link layer protocol 2015-08-24 08:29:07 -06:00
Gregory Nutt
ea2fafb024 Add definitions to support a local loopback link layer 2015-08-24 08:25:08 -06:00
Gregory Nutt
89b5ef8d35 wdogs: Fix counting of free, pre-allocated wdog timers. The could could get decremented below zero in some situations 2015-08-21 11:30:22 -06:00
Pavel Pisa
12b1c04508 recvfrom(): Correct wait for new data when NET_UDP_READAHEAD is enabled. Fix size accounting when recvfrom_udpreadahead() sets state.rf_recvlen == -1. I have not checked if data are accumulated to the right position in the buffer however.
Signed-off-by: Pavel Pisa <ppisa@pikron.com>
2015-08-21 09:15:06 -06:00
Gregory Nutt
4c4868c69f More cosmetic changes: Fix some errors in comments and some indentation problems 2015-08-11 19:23:51 -06:00
Gregory Nutt
850225223d Costmetic fix to a comment 2015-08-11 19:21:15 -06:00
Gregory Nutt
530d229361 net/udp: Add support for send() with connected UDP sockets 2015-08-11 19:17:55 -06:00
Max Neklyudov
7d04104485 Networking: Allow receipt of empty UDP packets. From Max Neklyudov 2015-08-11 08:34:16 -06:00
Gregory Nutt
f94fe747ae Undo part of a previous change. Move get/sethostname back from net/netdb to libc/unistd 2015-07-08 11:11:52 -06:00
Gregory Nutt
fca919f3d2 Networking: Fix some compilation issues noted with network is build with CONFIG_BUILD_KERNEL 2015-07-05 11:18:56 -06:00
Gregory Nutt
6380832ab7 Move the header of set/sethostname from libc/unisted to net/netdb. This is OS internal stuff 2015-07-05 10:43:37 -06:00
Stavros Polymenis
701509f9bd Add implementations of uname() and gethost(). From Stavros Polymenis. 2015-07-03 07:50:27 -06:00
Gregory Nutt
09c7373f24 Fix misc. compilation error/warning detected by tools/testbuild.sh 2015-07-01 14:33:37 -06:00
Gregory Nutt
342f5fe33d Fix references to the no-longer-existent misc/ directory in comments, README files, and documentation 2015-06-28 08:08:57 -06:00
Gregory Nutt
0ad53183e1 Networking: Fix a compile problem introduced in NuttX-7.6 when CONFIG_NET_SENDFILE=y 2015-06-24 14:52:57 -06:00
Gregory Nutt
ed9c45bcef Networking: Fix compilation error if IPv6 is enabled 2015-06-17 15:00:04 -06:00
Gregory Nutt
8f7752d956 Networking: Modify how callback structures are stored to avoid another potential use of a stal pointer. 2015-06-03 08:11:57 -06:00
Gregory Nutt
edbb5d0840 networking: Correct a typo introduced with recent networking changes 2015-06-02 15:04:02 -06:00
Gregory Nutt
e22deff1ab TCP connect. Move the location where the socket is marked as connected in order to avoid a potential race condition 2015-05-31 12:24:24 -06:00
Gregory Nutt
b493dde4cf TCP networking: In the TCP connection operation, it was trying to setup the network monitor BEFORE the socket was successfully connected. This, of course, has ALWAYS failed because the socket is not yet connected and the TCP state is not yet correct for a connected socket. However, because of other changes net_startmonitor(0 no returns a failure condition that causes worse problems when trying to connect. The fix is to move the logic that starts the network monitor to AFTER the socket has been successfully connected. 2015-05-31 11:35:28 -06:00
Gregory Nutt
a47a0d237c Costmetic changes to networking logic 2015-05-31 10:29:53 -06:00
Gregory Nutt
33085cb309 Networking: The network device list was protected by a re-entrant semaphore. With the recent change to support network device callback, the network stack needs to access the network device list too. Some drivers, however, run the network stack from the interrupt level -- this is bad but a fact in the current state. Of course,those drivers are unable to take the semaphore and will assert.
The solution here is to eliminate the device devices semaphore altogether.  This eliminates netdev_semtake() and netdev_semgive() and replaces them with net_lock() and net_unlock() which have larger scope as needed for this purpose.
2015-05-31 08:34:03 -06:00
Gregory Nutt
6687e156e6 Revamp last change. IFF_UP only required when allocating callback, not freeing. 2015-05-30 21:13:58 -06:00
Gregory Nutt
28b46c7bfa To be valid, a network device must not only exist, but be in the UP state 2015-05-30 12:54:18 -06:00
Gregory Nutt
cc340aaa92 TCP networking: Since the network monitor now allocates a callback structure, it is critical to make sure that the networking monitor is stopped when the socket is closed or any other loss of connection. What was innocuous before would now be a memory leak 2015-05-30 11:49:55 -06:00
Gregory Nutt
8b029fbbee TCP networking: Hook the network monitor into the device event notification logic 2015-05-30 11:29:47 -06:00
Gregory Nutt
933b95ac80 Forgot to add a file in the last commit 2015-05-30 09:17:46 -06:00
Gregory Nutt
04a661a97c TCP networking: Add support for network driver events 2015-05-30 09:12:27 -06:00
Gregory Nutt
ab50e9d04d Networking: Get rid of g_ipv4_allzeroaddr and g_ipv4_alloneaddr. It is more efficient and more intuitive to use INADDR_ANY and INADDR_BROADCAST 2015-05-29 15:16:11 -06:00
Gregory Nutt
34509a9ad5 UDP should use dev=NULL if the address in the lookup is INADDR_ANY 2015-05-29 14:56:44 -06:00
Gregory Nutt
0bdf2d5360 UDP Networking: Misc fixes to get the last changes working + cleanup 2015-05-29 14:32:56 -06:00
Gregory Nutt
fa8b7c19b7 Forgot to add a file in the last commit 2015-05-29 11:03:02 -06:00
Gregory Nutt
f10fdf7ad4 Networking: Add a test to see a device pointer is still valid 2015-05-29 11:01:03 -06:00
Gregory Nutt
2102892e7b Fix missing file and some compilation errors from the last UDP committ 2015-05-29 10:45:41 -06:00
Gregory Nutt
e672bcebfd UDP Networking: Add support for device event notification for UDP transfers. 2015-05-29 10:21:06 -06:00
Gregory Nutt
e28a8b1416 Raw sockets: Correct some compile issues; better modularized device-related logic 2015-05-29 08:47:21 -06:00
Gregory Nutt
988fbf0dcc Merge branch 'master' of ssh://git.code.sf.net/p/nuttx/git into multinic
Conflicts:
	nuttx/ChangeLog
2015-05-29 08:15:17 -06:00
Gregory Nutt
5337176cdf Networking: setsockopt() fails when setting timeouts to values less that an 100 msec. That is because the timeout is limited to stops of 1 decisecond and because the conversion of structure timeval was truncating the microsecond remainder. The utility net_timeval2dsec now accespts and option to determin how it handles the remainder: truncate, discarding the remainder, use the remainder to round to the closed decisecond value, or use any non-zero remainder to the next larger whole decisecond value.
For the setsockopt() case, it will always use the final option.  This means that a time of zero (i.e., not timeout) can only occur if the value zero was explicated provided to setsockopt().
2015-05-29 07:17:15 -06:00
Gregory Nutt
0595d54470 Correct some comments 2015-05-28 19:44:04 -06:00
Gregory Nutt
4747c04c94 Trivial correction to some comments 2015-05-28 19:43:35 -06:00
Gregory Nutt
b5c005d5a4 Merge remote-tracking branch 'origin/master' into multinic
Conflicts:
	nuttx/ChangeLog
2015-05-28 19:30:48 -06:00
Gregory Nutt
7ec0725533 Missed a couple of function headers 2015-05-28 19:28:41 -06:00
Gregory Nutt
d319b7c6f0 Networking: PKT logic now uses the device event list 2015-05-28 12:40:05 -06:00
Gregory Nutt
e81f279315 Networking: Modify event list handling: Now there are two event lists each device structure: (1) One is for ARP and ICMP data related evetns, the other is for device related events. Callback allocation/free routines no accept a device paramter as well as a list: If the device paramter is added, then the callback goes into both the connection-related liast AND the device event list. Thus each socket type can received both custom data-related events as well as common device related events. 2015-05-28 12:01:38 -06:00
Gregory Nutt
3606d05888 Merge branch 'multinic' 2015-05-28 09:07:18 -06:00
Gregory Nutt
3260db7dbe Reorder some network events bitset to make the event class clearer 2015-05-28 08:55:36 -06:00
Gregory Nutt
01d176af76 net_startmonitor.c always returned zero. In the case where a socket has already been closed, it correctly handled the disconnetion event but still returned OK. Returning OK causes the callers of net_startmonitor to assume that the connection was okay, undoing the good things that net_startmonitor did and causing the socket to be marked as connected. This behavior was noted by Pelle Windestam. 2015-05-28 08:23:51 -06:00
Gregory Nutt
0e2b6929b4 Add function headers to prototypes in net/socket/socket.h 2015-05-28 07:26:03 -06:00
Gregory Nutt
d6c3ed1c6f Networking: Fixes an important TCP bug: 16-bit flags was being converted to 8-bits in a few locations, causing loss of status indications 2015-05-27 17:17:42 -06:00
Gregory Nutt
4fd0192a3e Networking: No that ARP, ICMP, and ICMPv6 reside in the same list we need to make the definitions of ARP_POLL, ICMP_POLL, and ICMPv6_POLL different because there are small differences in the context for each. 2015-05-27 15:04:51 -06:00
Gregory Nutt
390eeaae69 Add function headers to netdev.h header file 2015-05-27 14:34:15 -06:00
Gregory Nutt
2ecff2a432 Add some missing NETDEV_DOWN support for ICMPv6 auto configuration and router support 2015-05-27 12:49:39 -06:00