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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
DHCP client support provided for IPv4 over ethernet.
Change-Id: Ia89bc4123842cf109813b80a90b70cf50cc52e0a
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
Earlier default was 8, new default is 4.
Change-Id: I99c9d2aae465fd0feb968efa7417cd28bafd73b8
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Earlier default was 10, new default is 2.
Change-Id: I307a4abaad34223254fd32e1fd4357892a04a2d0
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Earlier default was 10, new default is 2.
Change-Id: I938449d840a244a13e9b9b954648577b76db00bc
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
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>
The application can initiate TCP connection when using IPv4.
Change-Id: I264270d013f567dd0c429783c47506d9c38f0509
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The application can initiate TCP connection when using IPv6.
Change-Id: I632fa2559d5deb40d71288762bd13fbc2aac9cc7
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
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>
This will be used in following commit.
Change-Id: Ie4fccd72471c285b68a6df6970babe562e5e6258
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
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>
These are internal functions needed when initiating a TCP
connection.
Change-Id: Ide5d59ac9854ec8bdea3baa97b3cde3ffa6a5e0f
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>