Commit Graph

148 Commits

Author SHA1 Message Date
Gregory Nutt
0fb035f76b Standardize some naming in code section comments 2016-02-21 18:09:04 -06:00
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
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
6209c51206 net/: More clean-up of spacing/alignment issues 2015-10-08 15:10:04 -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
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
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
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
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
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
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
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
e672bcebfd UDP Networking: Add support for device event notification for UDP transfers. 2015-05-29 10:21:06 -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
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
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
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
1f3ee83134 Increase the size of the number of bytes sent from uint16_t to uint32_t in order to avoid TCP errors with long sessions. For exmple:
int hello_main(int argc, char *argv[])
{
   uint32_t i;
   for(i = 0; i < 65536; i++)
    {
      printf("Hello, World!!\n");
    }

  printf("press any key!!\n");
  if (getchar()=='t')
    return 0;
  else
    return 1;
}

When ran in a Telnet session, the "press any key" is not displayed because the tcp session closed unexpectedly with:

tcp_input: ERROR: conn->sndseq xx, conn->unacked xx"

This is fixed by increasing the width of conn->sent to 32-bits to prevent overflow.

From Rony XLN
2015-05-11 07:14:25 -06:00
Gregory Nutt
a82b8fd71f Networking: Fix several build errors/warning with IPv4 + IPv6 + multiple networks are enabled. 2015-02-10 06:54:10 -06:00
Gregory Nutt
b756df982d net/: Lots of build problems introduced into multiple NIC support. Many places where conditional logic based on CONFIG_NETDEV_MULTINIC is confused with CONFIG_NET_MULTILINK. Lots of code changed with IPv6 that was never compiled with MULTINIC enabled. Still some problem with parameter passing. 2015-02-09 18:15:34 -06:00
Gregory Nutt
a07a764d42 ICMPv6: Adds basic logic to support verification that we have the IPv6 address in the Neighbor Table. This feature is important because otherwise the first packet sent to a remote peer will fail (it will be replaced with a Neighbor Solicitation). 2015-02-02 13:44:31 -06:00
Gregory Nutt
6d7891c4de Fix compile issues with configs/sim/nettest 2015-02-01 12:00:30 -06:00
Gregory Nutt
52f9a2744c Should fix another warning reported by Travis 2015-01-30 08:57:35 -06:00
Gregory Nutt
a438784054 Forgot to add a file in the last commit 2015-01-30 07:28:30 -06:00
Gregory Nutt
5736cf10af Networking: Separate TCP poll logic out of net/sockets/net_poll.c and move it into the new net/tcp/tcp_netpoll.c. 2015-01-30 07:25:01 -06:00
Gregory Nutt
de91d34a19 Networking: Separate out UDP poll logic from socket/net_poll.c into a new udp/udp_netpoll.c; Create a skeleton local/local_netpoll.c for future poll support on Unix domain sockets. 2015-01-30 07:09:25 -06:00
Gregory Nutt
ccc72edc0b Networking: Add UDP read-ahead support and support for poll/select on UDP sockets. From Macs N. 2015-01-30 06:08:26 -06:00
Gregory Nutt
9c2af5317f Merge remote-tracking branch 'origin/master' into afunix 2015-01-28 12:03:43 -06:00
Gregory Nutt
371a9fd84c Networking: Fix another deadlock condition. tcp_write_buffer_alloc() calls sem_wait() with network locked. That worked if CONFIG_NET_NOINTS was not defined because interrupts are automatically restored when the wait happens. But with CONFIG_NET_NOINTS=y, the wait blocks with the network locked -- bad style and also can lead to a deadlock condition 2015-01-28 11:56:11 -06:00
Gregory Nutt
5f9837dcc8 Merge remote-tracking branch 'origin/master' into afunix
Conflicts:
	nuttx/ChangeLog
2015-01-27 21:47:12 -06:00
Gregory Nutt
c4bd6f52b5 Networking: The are issues with the TCP write-ahead buffering if CONFIG_NET_NOINTS is enabled: There is a possibility of deadlocks in certain timing conditions. I have not seen this with the Tiva driver that I have been users but other people claim to see the issue on other platforms. Certainly it is a logic error: The network should never wait for TCP read-ahead buffering space to be available. It should drop the packets immediately.
This was fixed by duplicating most of the IOB interfaces:  The versions that waited are still present (like iob_alloc()), but now there are non-waiting verisons of the same interfaces (like iob_tryalloc()).  The TCP read-ahead logic now uses only these non-waiting interfaces.
2015-01-27 21:23:42 -06:00