Commit Graph

277 Commits

Author SHA1 Message Date
Anas Nashif 45616f24e7 Revert "net: fetch valid conn. to determine MSS in data_is_sent_and_acked()"
This reverts commit 627feb92d4.

This patch breaks TCP/IPv4 support in echo_server.

Change-Id: Ia1e2cf8dfa94f845d3a8282c83bba40b36ee782c
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-10-14 07:12:06 +00:00
Rohit Grover f809c84de2 net: fix a potential refcount leak of SYN buffers
net_send() is meant to release the refcount for the SYN buffer once
a connection is established, but this assumes that the application
uses net_send() for all outgoing buffers. It is possible to setup a
connection (and therefore generate an outgoing SYN) by calling
net_context_tcp_init(), which has the side-effect of overwriting
connection_status . Using such an API would then break the
assumption around net_send() reclaiming the refcount of the SYN buf.

A test case which exposes the problem:
* As a client, setup a connection with an HTTP server.
* Send an HTTP request contained in a buf using net_send()
* The server responds, and then tears down the connection.
* The test client then re-establishes another connection using
  net_context_tcp_init()--this overwrites connection_status, causing
  a refcount leak.

With this change, we remove the dependency on net_send() being called.

Change-Id: I96516cbca3e231ed7fb509a7c03c0ceebf80e03a
Signed-off-by: Rohit Grover <rohit.grover@arm.com>
2016-10-08 21:20:28 +00:00
Rohit Grover 627feb92d4 net: fetch valid conn. to determine MSS in data_is_sent_and_acked()
Packets sent out through net_tx_fiber go through psock_send() where
they wait for data_is_sent_and_acked() to process them.
data_is_sent_and_acked() looks at the underlying connection's
MSS (maximum segment size) before putting them on the wire through
uip_send(). The trouble is that that linkage between the outgoing
buffer and the connection hasn't been established at the point
data_is_sent_and_acked() is called--this normally happens through
a call to uip_set_conn().
So data_is_sent_and_acked() fetches an invalid connection handle
and makes its choice using an arbitrary MSS. In my particular case,
this arbitrary value was 0, and so packets weren't being sent out.

Change-Id: I42e8ae104ac20f8df8780c8aee6964ed37113ba0
Signed-off-by: Rohit Grover <rohit.grover@arm.com>
2016-10-08 21:20:28 +00:00
Jukka Rissanen 33d92af1cf net: Initial trickle algorithm support for legacy IP stack
This commit only provides the Trickle algorithm support.
Some other entity must call its functions in order to be
useful.

Fixes: ZEP-627

Change-Id: Ice1fcfe9c57269309eeab06eab000622662e2929
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-09-12 02:00:12 +00:00
Rohit Grover 769e2541d1 net: revert tcpip_poll_tcp() to not require a data_buf
tcpip_poll_tcp() was changed with commit 61edc68c to take on a
data_buf parameter, which was then processed as the primary
buffer. That change led to incorrect behaviour where the handling
of the first data buffer on a connection got mixed with the SYN buf.
It is no longer clear why tcpip_poll_tcp() was modified with the
change 61edc68c originally. Reverting the modification to
tcpip_poll_tcp() leads to much better handling of TCP data; and
also obviates another pull-request submitted recently:
https://gerrit.zephyrproject.org/r/#/c/4226.

Change-Id: I947c0991495c538c41e6581c8d360526b1bb89ad
Signed-off-by: Rohit Grover <rohit.grover@arm.com>
2016-09-06 15:11:03 +00:00
Marcus Shawcroft 01f59b6d9e net: uip: Fix udp_socket_process receive data callback buffer handling.
Adjust the data pointer passed to a udp_socket_register() registered
callback to point to the udp data contents rather than the header
information.

Change-Id: Ib90eee91e0ec4d0290517fee7b929d39ce3e07c6
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-09-06 15:10:33 +00:00
Marcus Shawcroft b92d10d879 net: uip: Fix compile fail with stats enabled, tcp disabled.
Add missing preprocessor conditional around statistics update.

Change-Id: I3e55b1512e913b2e9a60d0ab56264439ca417a23
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-09-06 15:09:58 +00:00
Tomasz Bursztyka 8a574fdd67 net: contiki: simplerdc: Fix an uninitialized variable warning
If retries are 0 (which should never be), ret will not be initialized.

Change-Id: I8ef9a2ccbf89191e48d407fdb1292554fa8f15d9
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-09-06 09:05:37 +00:00
Jaakko Hannikainen a8cd2ff368 net: Add NULL check to eventhandler
The eventhandler gets called with NULL buf, but it can't handle it. Add
a NULL check to prevent crashing.

Change-Id: Id16c2aa093a145e0442dfc61dd0b6e1b81b701f5
Signed-off-by: Jaakko Hannikainen <jaakko.hannikainen@intel.com>
2016-08-12 15:43:14 +03:00
Jaakko Hannikainen f77191976a net: contiki: Fix timer callback condition
etimer_expired will return true only once. This means periodic timers in
the netstack won't get to run since etimer_process calls etimer_expired
for all timers in the stack.

Jira: ZEP-475

Change-Id: I28da638789b0604f9dd0a0598a7fa590e6b0a746
Signed-off-by: Jaakko Hannikainen <jaakko.hannikainen@intel.com>
2016-08-10 15:25:59 +00:00
Leyi Rong e72a71a53d net: uip: Fix uip_udp_conns traverse loop in uip_process
the traverse step length should be sizeof(struct uip_udp_conn)
in uip_process when matching the right uip_udp_conn for net_buf

Change-Id: I33c0499582a96e5031ba94f147ff2376726b3f9c
Signed-off-by: Leyi Rong <leyi.rong@intel.com>
2016-08-10 14:57:02 +00:00
Jaakko Hannikainen 2652c0e5a9 net: contiki: Add NULL check to neighbor polling
The function is getting called with NULL bufs, so uip_len cannot be
called on them. The stack further down handles NULL buffers correctly.

Jira: ZEP-474

Change-Id: I85fb045ec76bea2a83c64d0f72eabba4e661f5f4
Signed-off-by: Jaakko Hannikainen <jaakko.hannikainen@intel.com>
2016-08-02 05:25:59 +00:00
Jaakko Hannikainen 0766d3b921 net: contiki: Prevent a null dereference
When first starting the board, uip_connr may be NULL. This causes an
invalid pointer dereference. Add a NULL check.

Change-Id: Ia5d9897038a22fe44aab5106dd6b84c5a358512d
Signed-off-by: Jaakko Hannikainen <jaakko.hannikainen@intel.com>
2016-07-29 18:05:45 +00:00
Ravi kumar Veeramally b325989ede net: Fix incorrect IP app data length
When application wants to send zero length data, packet is dropped.
And uip_appdatalen is wrongly assigned with total IP packet length.

Jira: ZEP-575

Change-Id: I7f714cbef74dc28b83db7a776ef80a3026ae120e
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-07-28 20:58:01 +00:00
Jaakko Hannikainen 51e517c08b net: contiki: Fix compiling with ipv4
ip_buf_sent_status is only available for TCP, but uip_send_udp is only
called for UDP. Remove the else block.

Change-Id: I9695b33f975042ec15fde718d91ab901617437f2
Signed-off-by: Jaakko Hannikainen <jaakko.hannikainen@intel.com>
2016-06-27 11:46:50 +00:00
Ravi kumar Veeramally 803de8d14e net: Fix return value from uip_udp_packet_sendto
udp_socket_sendto returns always datalen irrespective of
uip_udp_packet_sendto return value.

Change-Id: Ib1c5a25ae89ddaa0826d35d4fd53f9c2ccea7b93
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-05-31 08:06:37 +00:00
Ravi kumar Veeramally 0de956d53f net: dhcp: Add DHCP client support.
DHCP client support provided for IPv4 over ethernet.

Change-Id: Ia89bc4123842cf109813b80a90b70cf50cc52e0a
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-05-27 11:09:30 +00:00
Jukka Rissanen 655eb4b75e net: ipv6: Allow user to select number of neighbors
Earlier default was 8, new default is 4.

Change-Id: I99c9d2aae465fd0feb968efa7417cd28bafd73b8
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-05-27 06:15:21 +00:00
Jukka Rissanen 798d3511c1 net: ip: Allow user to select number of TCP connections
Earlier default was 10, new default is 2.

Change-Id: I307a4abaad34223254fd32e1fd4357892a04a2d0
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-05-27 06:15:21 +00:00
Jukka Rissanen a2004cc70f net: ip: Allow user to select number of UDP connections
Earlier default was 10, new default is 2.

Change-Id: I938449d840a244a13e9b9b954648577b76db00bc
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-05-27 06:15:21 +00:00
Ravi kumar Veeramally 5e99b14ad4 net: 6lowpan: Fix 6lowpan fragmentation
IP packet passing through 6lowpan compression and 802.15.4
fragmentation has an issue. (RFC 6282 and 4944) RFC4944, 5.3
says "fragment header's datagram_size and datagram_offset
values as the size and offset of the IPv6 datagram before
compression".

At the moment datagram size and offset values are after
compression. Due to multiple bearer (15.4 and bluetooth) support
and multiple incoming buffers support functionality is divided
to compression and fragmentation parts. And datagram size and
offset values for BT are after compression. Small packet (which
doesn't need fragmentation) doesn't go through this. So cacheing
compressed and uncompressed header lengths and with hdr difference
preparing fragments as per original buffer (total buf size and offset).

Change-Id: I9d3b0433e64964c68519d7c007cc06ec6035b573
Jira: ZEP-208
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-05-19 14:18:38 +00:00
Jukka Rissanen 133aa5c026 net: tcp: Supporting TCP client functionality when using IPv4
The application can initiate TCP connection when using IPv4.

Change-Id: I264270d013f567dd0c429783c47506d9c38f0509
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-05-17 09:57:29 +03:00
Jukka Rissanen 61edc68c9e net: tcp: Supporting TCP client functionality when using IPv6
The application can initiate TCP connection when using IPv6.

Change-Id: I632fa2559d5deb40d71288762bd13fbc2aac9cc7
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-05-17 09:57:28 +03:00
Jukka Rissanen 2881cb122b net: Add support for re-sending initial TCP SYN
If we are initiating a TCP connection, then make sure that
we try to re-send initial SYN packet (max 8 times) if it is lost.

Change-Id: I9fbc39bdaef3a535c480eb5433eb7ef3ad60d604
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-05-17 09:57:28 +03:00
Jukka Rissanen 276d066cd5 net: Add utility func to re-send TCP SYN packet
This will be used in following commit.

Change-Id: Ie4fccd72471c285b68a6df6970babe562e5e6258
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-05-17 09:57:28 +03:00
Jukka Rissanen a1716c4760 net: Enable Zephyr to initiate a TCP connection
These changes are needed so that Zephyr host can initiate
a TCP connection to another host.

Change-Id: I46b92bf978e2dd04993951f2215d179a5cf1bd55
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-05-17 09:57:28 +03:00
Jukka Rissanen 662ce340be net: Add functions to return connection status needed in TCP
These are internal functions needed when initiating a TCP
connection.

Change-Id: Ide5d59ac9854ec8bdea3baa97b3cde3ffa6a5e0f
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-05-17 09:57:28 +03:00
Jukka Rissanen f499624f7c net: tcp: Enable active connection support by default
Application can by default do a connection request. If this is
not needed (app is only working in server role i.e., only
listening connection attempts), then some memory can be saved
by disabling client role support.

Change-Id: I33ed95ad0cf099a70563465beff555ec4adab958
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-05-17 09:57:28 +03:00
Ravi kumar Veeramally 77a807cdf7 net: 6lowpan: Fix include header files path in null_compression
Change-Id: Ia6fa191e59cb632a4a960d2838357237149b8713
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-05-16 14:51:55 +00:00
jgarcia 5b6175d00c net: configure TCP receive window size
Tweak TCP receive window size from Kconfig.

Change-Id: I0d43809d5f36727a86d68b45a38ec136ca0b69cf
Signed-off-by: jgarcia <jeremie.garcia@intel.com>
2016-05-10 05:15:23 +00:00
Sebastien Griffoul 3a5eb1c742 net: timer_expired may not return the right value when called twice
timer_expired uses the nano_timer_test API to determine whether a
timer has expired. This API calls the private function
_nano_timer_expire_wait which returns the timer user data if this
timer has expired. Unfortunately _nano_timer_expire_wait clears the
user data pointer after returning it.
Therefore if timer_expired is called several times for the same timer
and if this timer has already expired then only the first call returns
the expected value (true). Other calls always return false.

In ipv6 this bug can be seen with the uip_ds6_periodic timer. Indeed
when expired this timer is going to be checked at least twice by
etimer_process function and the tcpip eventhandler function. Thus the
final uip_ds6_periodic callback is never called.

The fix consists in adding a expired field in the timer struct and
make timer_expired retain the nano_timer_test result when the timer
has expired.

Change-Id: I3c6aceaa0627be264b6d9913b629e7b619888938
Signed-off-by: Sebastien Griffoul <sebastien.griffoul@intel.com>
2016-05-04 13:37:10 +00:00
Jukka Rissanen e2692eba6f net: 802.15.4: Do not compress TCP packets
The IPv6 header compression is temporarily turned off for TCP
packets because of stack limitations when a packet needs to
be resent.

Change-Id: I572f177c727aa39757afebdc594cc07c8d8a1bd5
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-04-25 09:40:34 +03:00
Jukka Rissanen 9e172defc5 net: tcp: Disable client role
Currently we can only be a server that listens TCP data and
can send back data.

Change-Id: If009b7cb608029a8fb3889772fe15e45a154679d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-04-25 09:40:34 +03:00
Jukka Rissanen ad2e661569 net: Enable TCP support
User can enable TCP server (listening socket) support in the
IP stack. This commit does not yet have TCP client (connecting
socket) support.

Change-Id: I75dd02a81addc1d1e026463b53631d56378157df
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-04-25 09:40:32 +03:00
Jukka Rissanen d0ba82a581 net: Initial TCP support
Initial import for some new TCP related files from Contiki.
Fixed the compilation of imported TCP code but actual TCP
support comes in following commits.

Origin: Contiki
Change-Id: I0b42e2fa11de15f9b4da53e369cf114fcfd6cd21
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-04-25 09:18:24 +03:00
Jukka Rissanen 3e12469c38 net: rdc: Debug print missing \n in simplerdc plugin
Change-Id: I44e6f170e2928dc72cd17a71f382d63d7100aac9
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-04-18 13:42:44 +00:00
Tomasz Bursztyka 8475956600 net: rdc: Make simplerdc a full replacement against nullrdc
Removing nullrdc altogether.

Change-Id: Ic8e73c57c3d469a3ca70a60fe10f5e2aed0ca118
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-04-18 07:40:56 +00:00
Tomasz Bursztyka 62fd66e240 net: ieee802154: Add a simpler but working default RDC driver
The legacy nullrdc driver is not meant to be power efficient, and
supports requesting ACK on all packets. However, it's logic was based on
former Radio API which let it to read packet synchronously. That's not
working anymore as the new cc2520 driver does not support any
synchronous packet reception.
Thus a new driver, simplerdc, is provided. It supports the same features
as nullrdc, is of course not power efficient and fits properly with
the new driver.

- simplerdc is selected by default.
- to enable ack request on all packet, Kconfig proposes a
  NETWORKING_WITH_15_4_ALWAYS_ACK option.
- simplerdc retransmissions is set to 3, as for nullrdc

Change-Id: I53880fcce5ce00f53831eaeb15d51329121314ec
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-04-18 07:40:55 +00:00
Jeremie Garcia 5e6da236cb net: fix uip_udp_conn leak
On each net_receive() call with different destination and/or port,
µIP stack consumes a uip_udp_conns[UIP_UDP_CONNS] entry.
As net_context_put() doesn't free it up, Zephyr applications can very
quickly reach the point where it can no more create new UDP connection
(default UIP_UDP_CONNS value is 10).

This patch is both IPv4 and IPv6 compliant.
It modifies net_context_put() so that it frees up such entries if
a UDP connection is registered for the context provided as argument.

Change-Id: I9abe686c81368231d4443fc53da9038761a1787d
Signed-off-by: Jeremie GARCIA <jeremie.garcia@intel.com>
2016-04-12 12:40:41 +00:00
Ravi kumar Veeramally ee858020dc net: Fix ip_buf_len after removing extra header
After removing extra header from IP packet, only uip_len is
updated not ip_buf_len. uip_len parameter is set to zero
at some point after handover to net_core. From net_core
only ip_buf_len holds the actual length. So update ip_buf_len
after removing extra header.

Change-Id: I2cc03ed1125df5216a0fa6e94eebfeee0a343481
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-04-08 13:38:07 +00:00
Ravi kumar Veeramally f27af5afb7 net: Add Kconfig debug option for simple udp and udp packet
User can activate debugging in simple UDP and UDP packet by
setting CONFIG_NETWORK_IP_STACK_DEBUG_SIMPLE_UDP and
CONFIG_NETWORK_IP_STACK_DEBUG_UDP_PACKET option in config file.

Change-Id: I581d4b33204f26119c5b194cb367adad8c6505c2
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-04-08 13:38:06 +00:00
Jukka Rissanen 01771500ee net: contiki: Fix the timer expiration check
We need to check the timer expiration properly. The nano_timer_test()
will return user data to caller if the timer is expired.

The issue that is fixed by this commit started to appear after
the commit 9b2452047d which combined
nano_timers and nano_timeouts.

Change-Id: I9cf10e605f1c4767caa1aad9dcf29a159af55e28
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-04-08 11:33:19 +00:00
Jukka Rissanen 24911b81bd net: contiki: Enhance the IPv6 prefix calculation routine
The routine does not check prefixes properly which are not
multiple of 8.

Change-Id: I421456720541894eb4d9a2839361095a50587513
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-04-08 11:33:18 +00:00
Dmitriy Korovkin 9b2452047d kernel: Combine nano_timers and nano_timeouts
To avoid code duplication nano_timers use nano_timeout
mechanism.

Change-Id: I916bffd2b86e29ee7b7ff7bbb009cd4c844e2a44
Signed-off-by: Dmitriy Korovkin <dmitriy.korovkin@windriver.com>
2016-03-26 09:20:10 +00:00
Jukka Rissanen 3f9e87c318 net: contiki: Check IPv6 extension header length
If the received packet is corrupted and the IPv6 extension
header is too big, then just discard the packet.

Change-Id: I5071fc48a927d14f02ed3dda199f67c095d05b91
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-03-21 15:40:29 +00:00
Jukka Rissanen 746f81be1b net: 6lowpan: Check packet size before accepting fragment
If the fragment is corrupted and tells that the total packet
size is too big, then we must discard the packet.

Change-Id: I6257d677d1d2cfc30f37ad6fe4d59051d0e041ef
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-03-21 15:40:29 +00:00
Jukka Rissanen 580eddbe6a net: 6lowpan: Add more sanity checks in compression code
It is possible that the packet contains some garbage even
after 802.15.4 framer and fragmenter have passed it as a
valid packet. So we do here a final check so that the
memmove() call will have a sane value.

Weird crashes were happening without this sanity check because
uip length was smaller than the packet header length.
So the code tried to call
memmove (d=0xa80088a0 <rx_buffers+1472>,
         s=0xa8008889 <rx_buffers+1449>,
         n=3328002866)
at .../zephyr/net/ip/contiki/sicslowpan/sicslowpan_compression.c:998
and the length became too large and caused the device to crash.

Change-Id: Ibc4f1c211ec2f6d98506b89c6c3f001e20e51ea6
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-03-17 14:42:02 +00:00
Jukka Rissanen 51e30e64e6 net: 6lowpan: Fix debug prints in compression and fragmentation
Removed PRINTFO() and PRINTFI() macros as those are useless
here. Changed also packet printing macros to use temp
variable from stack instead of using a global variable.

Change-Id: I0fcc04960a5ff997e2390ef0cbc80ee0c3e020c2
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-03-17 14:42:02 +00:00
Jukka Rissanen 3a8655a34d net: rpl: Print the IPv6 prefix value when checking it
We did not know what IPv6 prefix the stack was using if the
prefix was the same as last time. It is easier to debug
things if the prefix is printed even if it was the same
value as last time.

Change-Id: Ic4bf11df0d8cb588ff0784f044d7702980d8152e
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-03-17 14:42:02 +00:00
Ravi kumar Veeramally 09ce826789 net: contiki: Improve uip_packetqueue debug statements
Add more debug statements to uip_packetqueue and improve
some of them.

Change-Id: I43040f6ba1051feb9aa311036faee4476c6bc80f
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-03-17 14:40:57 +00:00