https://tools.ietf.org/html/rfc4862#section-5.4.2 :
"""
Before sending a Neighbor Solicitation, an interface MUST join the
all-nodes multicast address and the solicited-node multicast address
of the tentative address.
"""
So, joining should happen before sending DAD packets, and it should
happen for each unicast address added. This is achieved by joining
from net_if_ipv6_addr_add() call. Note that we already leave
solicited-node group from net_if_ipv6_addr_rm(). In particular, we
leave it if DAD fails (as that function is called in this case).
Fixes#5282.
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
The reachable calculation for ND is using fractions combined with
integers and getting rounded to very small results (1ms or 0ms).
Let's split up the fraction into it's numerator and denominator
and perform the math in a better way to get the correct results.
Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
The maximum data length that can be appended using net_pkt_append()
should be set to TCP send_mss only if it is smaller than allowed
payload length in net_pkt.
Signed-off-by: Vakul Garg <vakul.garg@nxp.com>
For calculating amount of payload data that can be added in a packet,
we need to subtract IPv6 or IPv4 header lengths from MTU.
Signed-off-by: Vakul Garg <vakul.garg@nxp.com>
When net debugging is enabled, the count variable is initialized to -1.
This may cause division by zero if there is only one fragment in pkt.
Solve this by setting the count to 0 and checking the value before the
print at the end of the function.
Successfully tested on STM32F407 SoC.
Signed-off-by: Ding Tao <miyatsu@qq.com>
Compute the length of the TX payload that is transported in one
IPv4 or IPv6 datagram taking into account UDP, ICMP or TCP
headers in addition to any IPv6 extension headers added by RPL.
The TCP implementation in Zephyr is known to currently carry at
maximum 8 bytes of options. If the protocol is not known to the
stack, assume that the application handles any protocol headers
as well as the data. Also, if the net_pkt does not have a
context associated, length check on the data is omitted when
appending.
Although payload length is calculated also for TCP, the TCP MSS
value is used as before.
Define IPv4 minimum MTU as 576 octets, See RFC 791, Sections 3.1.
and 3.2.
Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
- Renaming NET_L2_RAW_CHANNEL to NET_RAW_MODE
- Create a generic IEEE 802.15.4 raw mode for drivers
- Modify the IEEE 802.15.4 drivers so it passes the packet unmodified,
up to code using that mode to apply the necessary changes on the
received net_pkt according to their needs
- Modify wpanusb/wpan_serial relevantly
Fixes#5004
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Previously, the connection will be reset easily due to a forged TCP
reset with a random sequence number.
As described in RFC793 p.69, we should check if the sequence number
falls into the receiver window at first.
Signed-off-by: Aska Wu <aska.wu@linaro.org>
Add in6addr_any and in6addr_loopback which are defined in RFC2553 Basic
Socket Interface Extensions for IPv6.
Signed-off-by: Aska Wu <aska.wu@linaro.org>
Previously, if passive close is peformed, the net context is released
after FIN is received and FIN,ACK is sent. The following last ack from
the peer will be treated as an improper packet, RST is sent to the peer.
This patch refines tcp_established() by centralizing the tcp state
transition and releases the net context only if NET_TCP_CLOSED is
reached.
Besides, the logic that releases the net pkt without appdata (i.e. ACK
or FIN) is moved from packet_received() to tcp_established(). This makes
packet_received() less dependent on the protocol and make the usage of
net pkt more clear in tcp_established().
Fixes: #4901
Signed-off-by: Aska Wu <aska.wu@linaro.org>
If we cannot send a DHCP message, then unref the net_pkt
in order to avoid a buffer leak. Earlier we tried to
unref NULL net_pkt which is not correct.
Signed-off-by: june li <junelizh@foxmail.com>
The original fragment chain of incoming packet will be lost and leaked
in case of early error, add frag back to packet and
let the caller do unref.
Fixes#4323
Signed-off-by: june li <junelizh@foxmail.com>
No need to do any IPv6 neighbor checks if the packet is routed back
to us by loopback driver.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If there is loopback interface, then let it handle all local
traffic. Loopback interface is only needed for test applications.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If the packet is too short, the TCP header pointer might be
NULL. In this case we just need to bail out.
Coverity-CID: 178787
Fixes#4787
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
802.15.4, as other radio tech, works in little endian on network level.
To keeps things simple, the inner context per-interface, stores the
extended address that way. But it can be confusing in shell then, so
let's work handle these addreses through EUI-64 format there.
Fixes#4936
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
The ping command was not checking if the user gave target
host as a parameter. This would lead to NULL pointer access.
Fixes#4827
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If we were asked to add 10KB to a packet, adding it won't help -
such packet won't be even sent by hardware on our side, and if
it is, it will be dropped by receiving side. So, make sure we
never add more data than MTU as set for the owning interface.
This actually gets a bit tricky, because we need also to account
for protocol header space. Typically, when net_pkt_append() is
called, protocol headers aren't even added to packet yet (they
are added in net_context_send() currently), so we have little
choice than to assume the standard header length, without any
extensions.
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
When sending a packet with AR flag set, the ACK frame that should be
replied to it must holp the same sequence number, so let's verify this
properly.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
There will be place where validating only this part of the frame will be
necessary. This will avoid to run the little bit heavier
ieee802154_validate_frame().
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Introducing CMake is an important step in a larger effort to make
Zephyr easy to use for application developers working on different
platforms with different development environment needs.
Simplified, this change retains Kconfig as-is, and replaces all
Makefiles with CMakeLists.txt. The DSL-like Make language that KBuild
offers is replaced by a set of CMake extentions. These extentions have
either provided simple one-to-one translations of KBuild features or
introduced new concepts that replace KBuild concepts.
This is a breaking change for existing test infrastructure and build
scripts that are maintained out-of-tree. But for FW itself, no porting
should be necessary.
For users that just want to continue their work with minimal
disruption the following should suffice:
Install CMake 3.8.2+
Port any out-of-tree Makefiles to CMake.
Learn the absolute minimum about the new command line interface:
$ cd samples/hello_world
$ mkdir build && cd build
$ cmake -DBOARD=nrf52_pca10040 ..
$ cd build
$ make
PR: zephyrproject-rtos#4692
docs: http://docs.zephyrproject.org/getting_started/getting_started.html
Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
Add a generic function for TCP option parsing. So far we're
interested only in MSS option value, so that's what it handles.
Use it to parse MSS value in net_context incoming SYN packet
handler.
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
Calculates full TCP header length (with options). Macro introduced
for reuse, to avoid "magic formula". (E.g., it would be needed to
parse TCP options).
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
MSS is Maximum Segment Size (data payload) of TCP. In SYN packets,
each side of the connection shares an MSS it wants to use (receive)
via the corresponding TCP option. If the option is not available,
the RFC mandates use of the value 536.
This patch handles storage of the send MSS (in the TCP structure,
in TCP backlog), with follow up patch handling actual parsing it
from the SYN TCP options.
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
The commit 971da9d0 ("net: pkt: adjust_offset: Simplify and optimize
code") changed the adjust_offset() function but left the error print
intact. This print is now invoked even if there is no error which
looks bad in debug prints.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The expire function can call net_context_unref() which tries to
get a semaphore with K_FOREVER. This is not allowed in interrupt
context. To overcome this, run the expire functionality from
system work queue instead.
Fixes#4683
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
An edge condition was handled in a special way, even though the main
condition covered it well. More code, more jumps == slower code,
bigger binaries.
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
Create http library that uses net-app instead of net_context
directly. The old HTTP API is deprecated.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The code parsing received net pkt to get source or destination
sockaddr repeats multiple times in net_context.c.
Eliminate the duplication by net_pkt_get_src_addr() and
net_pkt_get_dst_addr() which can handle different internet protocol
(i.e. ipv4 or ipv6) and transport protocol (i.e. tcp or udp)
Fixes: #4421
Signed-off-by: Aska Wu <aska.wu@linaro.org>
Rename net_pkt_get_src_addr() to net_pkt_get_addr() and make it able to
handle source or destination address.
Signed-off-by: Aska Wu <aska.wu@linaro.org>
Previous max range value for RTO was 2 seconds, increase to 60 seconds
as setting larger values can be useful when debugging retransmission
issues on slow networks.
Signed-off-by: Ricardo Salveti <ricardo@opensourcefoundries.com>
Add option to set initial Retransmission Timeout value. The value is
different from NET_TCP_ACK_TIMEOUT since latter affects TCP states
timeout when waiting for ACK for example.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
The call to net_context_recv() with timeout returned -ETIMEDOUT
even when data was returned properly and there was no timeout.
Fixes#4565
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
In bind_default(), a local variable is passed to find_available_port().
However, the port number is unpredictable as it's not initialized and
will be used directly if not zero. This will lead to problems if the
port number is already used.
This patch makes find_available_port() always returns an available port
regardless of the port number in the sockaddr parameter.
Signed-off-by: Aska Wu <aska.wu@linaro.org>
This rework commit 77b8f5c1f6
Comparing it to BT IPSP is a the wrong comparison: BT IPSP does specify
6lo/ipv6 for it to work. Whereas 802.15.4 does not.
Instead of selecting 6lo from 802.15.4's Kconfig, let's do the reverse
way. If the user enabled 802.15.4 and IPv6 as well (to which 6lo
depends on), then 6lo is enabled by default as using IPv6 on 15.4
without it does not make much sense.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Oftentimes, 15.4 PAN IDs are specified in hex. For example, that's
how Zephyr config specifies the default value. So, print them also
in hex, to avoid confusion.
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
There were decrements of TCP sequence numbers, inherited from FNET
stack implementation, as was used as an initial base. RFC793 does
not specify conditions for decrementing sequence numbers, so such
decrements are an artifact of FNET implementation. In Zephyr code,
we had to compensate for these decrements by extra increments
(including an increment-by-2). So, remove decrements and associated
extra increments to simplify the code.
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
If we receive a neighbor solicitation which does not have any
options, then there is no need to assert this condition as that
is a perfectly valid use case.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If IEEE 802.15.4 reassembly function ieee802154_reassemble() returns
anything other than NET_CONTINUE, then drop that packet. Earlier
it only dropped the packet if NET_DROP was returned but the reassembly
might also return NET_OK. In that case the pkt is freed already and
pkt->frags pointer is NULL. This caused NULL pointer access in L2 when
packet was received.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
This is similar to how few commands already behave if they can
provide additional info to the user if particular config options
are enabled.
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
net_pkt_tcp_data() and net_pkt_udp_data() simply returns the start
address of the header. However the header may span over multiple
fragments, unexpected data or memory corruption might happen when
reading or writing to the pointer directly.
Use net_tcp_get_hdr() and net_udp_get_hdr() instead.
Signed-off-by: Aska Wu <aska.wu@linaro.org>
The net_tcp_get/set_hdr() and net_udp_get/set_hdr() documentation
was not clear in corresponding header file. Clarify how the return
value of the function is supposed to be used.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
udp.h is out-of-date as it accesses net buf directly. In 3604c391, it
has been replaced by net/udp.h and udp_internal.h
Signed-off-by: Aska Wu <aska.wu@linaro.org>