Commit graph

808 commits

Author SHA1 Message Date
Paul Sokolovsky cdea2bfab7 net: tcp: Add support for TCP options parsing
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>
2017-11-08 16:19:57 +02:00
Paul Sokolovsky 3c652996ff net: tcp: Add NET_TCP_HDR_LEN(hdr) macro for reuse
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>
2017-11-08 16:19:57 +02:00
Paul Sokolovsky bc88ad750b net: tcp: Handle storage of TCP send MSS
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>
2017-11-08 16:19:57 +02:00
Jukka Rissanen 517caef5a4 net: pkt: Remove unnecessary error print in adjust_offset
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>
2017-11-07 15:18:02 +02:00
Tomasz Bursztyka c968e102e6 net/ieee802154: Add a choice on which packet to print-out
All, RX only or TX only

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-11-06 21:01:35 +02:00
Tomasz Bursztyka b181dc6791 net/ieee802154: Isolate packet display debugging option
Let's enable packet hex dump display without requiring the whole 15.4
stack debug option.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-11-06 21:01:35 +02:00
Jukka Rissanen dd7b4bae28 net: tcp: Do not run expire function in ISR context
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>
2017-11-06 17:16:46 +02:00
Paul Sokolovsky 971da9d011 net: pkt: adjust_offset: Simplify and optimize code
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>
2017-11-06 17:03:48 +02:00
Jukka Rissanen 2486694eb9 net: http: Create HTTP library that uses net-app
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>
2017-11-06 09:33:00 -05:00
Aska Wu 1bdd80f8db net: context: Replace net pkt parsing by helper functions
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>
2017-11-06 14:09:46 +02:00
Aska Wu 2d7ff75f60 net: pkt: Add net_pkt_get_dst_addr()
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>
2017-11-06 14:09:46 +02:00
Paul Sokolovsky 4641f88623 net: pkt: net_frag_read: Typo fix in comment
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-11-02 10:05:07 +02:00
Andrei Emeltchenko 90721238c7 net: tcp: Print retry count in retransmission attempts
Print also retry count when retransmitting packets.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2017-11-01 10:00:02 +02:00
Ricardo Salveti 03b801321b net: increase retransmission timeout (RTO) config range
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>
2017-11-01 09:54:29 +02:00
Andrei Emeltchenko 86272907d8 net: Add initial retransmission timeout config option
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>
2017-10-31 13:09:30 +02:00
Jukka Rissanen 0e7c8edc92 net: context: Make sure we honor timeout when waiting data
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>
2017-10-30 17:18:11 +02:00
Aska Wu 60a8e7843e net: context: Fix find_available_port()
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>
2017-10-30 12:01:43 +02:00
Tomasz Bursztyka 0d760d36e7 net/6lo: Enable it by default if IEEE 802.15.4 is enabled
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>
2017-10-28 14:28:02 -04:00
Paul Sokolovsky 87c4515f5c net: ieee802154_shell: get_pan_id: Print ID in hex too
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>
2017-10-26 09:30:32 +03:00
Paul Sokolovsky c469b7fc9f net: tcp: Avoid spurious seqno decrements
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>
2017-10-25 14:19:04 +03:00
Jukka Rissanen 5da4639067 net: ipv6: Remove invalid assert when receiving NS
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>
2017-10-24 11:30:41 +03:00
Jukka Rissanen 41f44ad8e0 net: ieee802154: Check reassembly return value properly
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>
2017-10-24 11:30:10 +03:00
Paul Sokolovsky 91ac13d87d net: shell: stacks: Print config option needed for full info
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>
2017-10-23 15:13:35 +03:00
Aska Wu 311c5ea56a net: pkt: Fix net_pkt_get_src_addr()
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>
2017-10-23 15:04:59 +03:00
Jukka Rissanen 363ccaf663 net: Clarify UDP and TCP header getter and setter documentation
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>
2017-10-23 15:04:23 +03:00
Aska Wu 898036d892 net: udp: Remove subsys/net/ip/udp.h
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>
2017-10-23 15:03:43 +03:00
Paul Sokolovsky 09b967366f net: pkt: Use standard macros to define system pkt slabs/pools
Previously net_pkt.h, defined macros NET_PKT_TX_SLAB_DEFINE,
NET_PKT_DATA_POOL_DEFINE, but advertised them as intended for
"user specified data". However, net_pkt.c effectively used the
same parameters for slabs/pools, but this wasn't obvious due
to extra config param redirection. So, make following changes:

1. Rename NET_PKT_TX_SLAB_DEFINE() to NET_PKT_SLAB_DEFINE()
as nothing in its definition is TX-specific.
2. Remove extra indirection for config params, and use
NET_PKT_SLAB_DEFINE and NET_PKT_DATA_POOL_DEFINE to define
system pools.
3. Update docstrings for NET_PKT_SLAB_DEFINE and
NET_PKT_DATA_POOL_DEFINE.

Overall, this change removes vail of magic in the definition of
system pkt slabs/pools, making obvious the fact that any packet
slabs/pools - whether default system or additional, custom - are
defined in exactly the same manner (and thus work in the same manner
too).

Fixes #4327

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-10-23 13:58:11 +03:00
Jukka Rissanen 4fe8d17bca net: ieee802154: Add more information when hexdumping the pkt
When hexdumping the packet, print also information if we
received / transmitted packet. Also print information if the
hexdump is before compression or not.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-10-21 18:14:56 -04:00
Paul Sokolovsky a3eb4fcd3e net: pkt: net_pkt_tcp/udp_data: Better document caveats
Explicitly note that while these functions return pointers to
headers, the headers themselves may be fragmented into different
data fragments. 1a2f24f920 is an example where this might have
been overlooked.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-10-20 11:01:48 +03:00
Ravi kumar Veeramally 13480f3992 net: 6lo: Fix 6lo uncompression issue
When source address is unspecified then SAC is 1 and SAM is 00.
Uncompression does not process because context based compression
is not enabled.
Special case (SAC:1 and SAM:00) should be handled without context
based compression support.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-10-20 10:33:28 +03:00
Jukka Rissanen 73b0d2d084 net: shell: Print system workqueue information
Add system workqueue information prints to "net stacks" command.
This helps debugging when figuring out which stack is running out
of space.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-10-20 10:31:33 +03:00
Jukka Rissanen a499d9ffd1 net: shell: Add multi connection net-app monitoring support
Enhance existing "net app" command so that it can be
used to show information about multiple connections.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-10-19 22:21:25 -04:00
Tomasz Bursztyka 8dd04742a0 ieee802154: Make packet display enablement via a Kconfig option
Such option should be use carefully. Printing out in/out packets is
extremely verbose.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-10-19 05:33:23 -04:00
Tomasz Bursztyka 70fb09548a net/ieee802154: Use common net_hexdump_frags instead of local function
Now that net_hexdump_frags can print out the link-layer reserve part,
let's use it.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-10-19 05:33:23 -04:00
Tomasz Bursztyka 81b9c8fcf6 net/utils: Make net_hexdump_frags being able to print ll reserve
If requested only and with colors with right SYS_LOG Kconfig options.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-10-19 05:33:23 -04:00
Jukka Rissanen 4463035c45 net: 6lo: Drop pkt if it is too short
If the pkt is corrupted and the offset would be larger than
the actual packet length, then print information about that and
drop the packet.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-10-19 11:17:22 +03:00
Jukka Rissanen e2c5b07f90 net: ipv4: Accept multicast packets for processing
We dropped received IPv4 multicast packet.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-10-17 08:36:39 -04:00
Jukka Rissanen 13e69512da net: shell: Print hostname information
When printing network interfaces, print also current hostname
if it has a valid value.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-10-17 08:36:39 -04:00
Jukka Rissanen e3adbf845c net: Add hostname setting to Kconfig
User can configure hostname of the device in Kconfig. This can
be used by mDNS responder to answer <hostname>.local queries.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-10-17 08:36:39 -04:00
Jukka Rissanen 2b9e736f66 net: shell: Add command to flush ARP cache
The "net arp flush" can be used to remove all entries from
ARP cache.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-10-16 17:13:22 +03:00
Paul Sokolovsky f45c4e1c8e net: shell: mem: Use better config define and terminology
It's possible to get number of free pkts/buffers with just
CONFIG_NET_BUF_POOL_USAGE, whereas CONFIG_NET_DEBUG_NET_PKT
depends on CONFIG_NET_LOG and adds quite a bunch of other
overhead. Also, give a hint that this option should be enabled
to get free buffer numbers.

Additionally, use unambiguous "Total" wording to represend the
maximum capacity of data structures, instead of previous "Count".
"Count" (or at least counter) is intuitively something which can
change, so not seeing any other numbers, it's very easy to assume
that it's actually number of free buffers (because that's the
information a user may be interested in in many cases).

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-10-16 11:00:11 +03:00
Jukka Rissanen 059959c83e net: tcp: Do not unref caller allocated net_pkt
If the caller has passed net_pkt to prepare_segment(), then
it is caller responsibility to unref it in a case of error.

Fixes #4292

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-10-13 17:23:25 -07:00
Tomasz Bursztyka 7f04af8f7a net/ieee802154: Add a hw capability for handling ACK request on TX
Some chips are smart enough to handle the ACK request flag on
transmitted frames, so it's unneccessary for the L2 to wait for it.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-10-13 13:48:32 +03:00
Tomasz Bursztyka 811db9ac6a net/ieee802154: Expose a function to test for AR flag in net_pkt
This is both required in L2's radio part as well as it might be useful
on some ieee802154 radio drivers.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-10-13 13:48:32 +03:00
Tomasz Bursztyka 07f5bde3ed net/ieee802154: Stop using old radio API's functions
These are now fully replaced by set_filter() thus removing their usage
by the L2 layer.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-10-13 13:48:32 +03:00
Tomasz Bursztyka c65c2a1130 net/ieee802154: Apply hw filters when applicable
If the hw supports filtering, L2 will apply the ieee address, short
address or PAN ID filters.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-10-13 13:48:32 +03:00
Tomasz Bursztyka eee33cf888 net/ieee802154: Add support for hw driven CSMA
Using radio's get_capabilities, it is possible to know if the driver can
get CSMA work handed-over.

For now, up to device drivers to use
CONFIG_NET_L2_IEEE802154_RADIO_CSMA_CA_* parameters.

Let's see if it will be interesting at some point to enable runtime
modification of these parameters.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-10-13 13:48:32 +03:00
Tomasz Bursztyka aedece5240 net/ieee802154: Use lqi from net_pkt relevantly
This only affects beacon handling logic, not really used feature for
now.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-10-13 13:48:32 +03:00
Jukka Rissanen cab505f0c2 net: tcp: Use real MTU size for MSS for IPv6
Instead of hard coded 1280 bytes MSS, use the MTU of the link
for MSS. The minimal MSS is still 1280 which is mandated by
IPv6 RFC.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-10-10 10:53:00 -04:00
Tomasz Bursztyka efab82232b net/mgmt: Cleanup a bit Kconfig
Remove "depends on" and replace with an if/endif.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-10-09 10:53:17 +03:00
Tomasz Bursztyka 8e25695937 net/mgmt: Make event notifiers able to pass info to listeners
Adding net_mgmt_event_notify_with_info() which lets the event notifier
to pass dedicated data along with the event. The size of data that can
be passed must be limited to the biggest data passed (which will be
currently IPv6 + prefix).

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-10-09 10:53:17 +03:00
Tomasz Bursztyka 743e50751f net/ieee802154: Always set ACK flag to 0 on data broadcast
commit d02fe29616 did not manage this
case.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-10-08 16:38:32 +03:00
Paul Sokolovsky 77b8f5c1f6 net: l2: ieee802154: Automatically select CONFIG_NET_6LO
802.15.4 IP-based networking requires 6LoWPAN layer and won't work
correctly without it. So, if NET_L2_IEEE802154 is select,
automatically select NET_6LO. This is similar to what BLE L2
does (NET_L2_BT causes selection of NET_6LO).

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-10-06 18:26:51 +03:00
Tomasz Bursztyka 02cf1ab390 net/ieee802154: Fixing a typo in ieee15_4 shell module
Obviously unset ACK requires NET_REQUEST_IEEE802154_UNSET_ACK request.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-10-05 11:13:08 +03:00
Jukka Rissanen e9eb128895 net: shell: Use correct network interface instead of default one
When the net-shell needs to send something to network interface,
it will check if the target address is found in neighbor cache and
then use that network interface. If the address is not found in nbr
cache, then the default interface is used.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-10-04 10:58:18 +03:00
David B. Kinder f00f58517b doc: replace UTF-8 chars
Some our Zephyr tools don't like seeing UTF-8 characters, as reported in
issue #4131) so a quick scan and replace for UTF-8 characters in .rst,
.h, and Kconfig files using "file --mime-encoding" (excluding the /ext
folders) finds these files to tweak.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-10-03 20:03:57 -04:00
Aska Wu 379771e2eb net: context: Bind default address for UDP
This patch makes net_context_sendto() work independently without calling
net_context_connect() first. It will bind default address and port if
necessary.

Also, since receive callback should be provided before sending data in
order to receive the response, bind default address and port to prevent
providing an unbound address and port to net_conn_register().

Signed-off-by: Aska Wu <aska.wu@linaro.org>
2017-10-03 14:40:05 +03:00
Aska Wu 1a2f24f920 net: pkt: Add net_pkt_get_src_addr()
Introduce net_pkt_get_src_addr() as a helper function to get the source
address and port from the packet header.

Signed-off-by: Aska Wu <aska.wu@linaro.org>
2017-10-03 14:40:05 +03:00
KaSroka 94c0d23691 net: Log drop reason when UDP or TCP checksum mismatch occurs
Signed-off-by: Kamil Sroka <kamil.sroka@nordicsemi.no>
2017-09-29 15:10:35 +03:00
Jukka Rissanen fb32aebd78 net: ipv6: Fix IPv6 address parameters when sending NA
The IPv6 address parameters in net_ipv6_send_na() can be const
as the function will not modify them. This avoids compile warning
about parameter constness.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-09-29 15:09:10 +03:00
Jukka Rissanen 45a46fafaa net: ipv6: Return neighbors in foreach function by interface order
It is useful to return the neighbors in net_ipv6_nbr_foreach()
groupped by network interface. This way the caller has them
already in proper order and does not need to re-group them.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-09-29 15:08:44 +03:00
Jukka Rissanen 274be20ae9 net: shell: Fix command outputs
Some of the net commands had wrong alignments and newlines were
missing.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-09-29 15:08:00 +03:00
Jukka Rissanen d14919ce47 net: if: Add IPv4 multicast add, remove and lookup functions
There was no handler functions for adding, removing and looking up
IPv4 multicast addresses in the network interface.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-09-29 11:34:06 +03:00
Jukka Rissanen 2c6e473c93 net: context: Bind did not check IPv4 multicast address
If the user tried to bind to IPv4 multicast address, then the
operation failed and returned error.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-09-29 11:34:06 +03:00
Jukka Rissanen 604cdb6b6d net: shell: Do not print IPv4 information in some cases
If the network interface does not support IPv4 like IEEE 802.15.4
or Bluetooth, then do not print IPv4 information for those interfaces.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-09-29 11:29:43 +03:00
Jukka Rissanen c798c8293a net: pkt: Allow inserting NULL data
If the data parameter in net_pkt_insert() is NULL, then just
insert amount of data but clear the area instead of copying.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-09-28 12:42:25 +03:00
Jukka Rissanen c50d555c1e net: Allow user to tweak IPv4 TTL per packet
User was able to tweak IPv6 hop-limit so introduce similar
feature for IPv4 Time-To-Live value.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-09-28 12:39:54 +03:00
Jukka Rissanen 4dc2dd87ea net: nbr: Print network interface pointer when adding neighbor
Useful when debugging issues in neighbor management.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-09-26 11:31:57 +03:00
Jukka Rissanen bc4ce8bda8 net: rpl: Neighbor data corrupted when receiving DAO message
The code was accessing wrong neighbor data when it received DAO
message. This corrupted nbr->iface pointer which was clearly seen
by "net nbr" shell command. The corruption then caused random
crashes or hangs when network interface via that pointer was
accessed.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-09-26 11:31:57 +03:00
Jukka Rissanen 9369538642 net: ethernet: Set dest MAC address for IPv4 mcast
If the ethernet packet destination MAC address is NULL when sending
IPv4 multicast or broadcast packet, then we must set it as otherwise
we might to access NULL pointer data.

Fixes #1544

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-09-26 09:36:56 +03:00
Luiz Augusto von Dentz 2e50126f55 net: nbr: Add NET_IPV6_NBR_STATE_STATIC
This adds a new state NET_IPV6_NBR_STATE_STATIC which never timeouts
which is required in case of RFC 7668 which doesn't allow publishing
the address:

https://tools.ietf.org/html/rfc7668#section-3.2.3

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2017-09-26 09:19:32 +03:00
Andrei Emeltchenko c9a60b73a1 net: arp: Always report error for missing gateway
At the moment errors are not always reported depending on
CONFIG_NET_DEBUG_ARP.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2017-09-21 09:39:07 +03:00
Andrei Emeltchenko aedbb8c220 net: arp: Exit early on zero gateway provided
In a case gateway is not set drop packet early otherwise bogus
ARPs for 0.0.0.0 are sent.

...
[net/arp] [DBG] find_entry: (0xa8006720): dst 0.0.0.0
[net/arp] [DBG] find_entry: (0xa8006720): [0] iface 0xa800cd80 dst
0.0.0.0 ll 00:00:00:00:00:00 pending 0xa800a7c0
[net/arp] [DBG] find_entry: (0xa8006720): ARP already pending to
0.0.0.0 ll 00:00:00:00:00:00
[net/arp] [DBG] net_arp_prepare: (0xa8006720): Resending ARP
0xa800a380
...

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2017-09-21 09:39:07 +03:00
Jukka Rissanen bfc583c53f net: pkt: Allow cloning just the net_pkt without any data
It is useful to clone just the net_pkt which does not have any
data fragments linked to it.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-09-20 08:40:34 +03:00
Paul Sokolovsky c7da45f9e2 net: Enable logging in more modules if CONFIG_NET_LOG_GLOBAL defined
This is useful to enable error/warning logging across the net
codebase (less useful for debug level logging, but that's true
for CONFIG_NET_LOG_GLOBAL already).

Implementation-wise, instead of keeping adding to long list of
"select"'s in CONFIG_NET_LOG_GLOBAL and thus introduce component
inter-dependencies, add "default y if NET_LOG_GLOBAL" to
individual components' logging options.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-09-18 08:19:27 -04:00
Andrei Emeltchenko cc4d138438 net: l2: Correct debug message and avoid unneeded assignment
At the moment we print "Sending ARP packet" even if we found ARP entry
and send the packet directly.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2017-09-18 10:27:47 +03:00
Paul Sokolovsky 416711a989 net: arp: Log error if no gateway is set
If no gateway is set, an ARP request for 0.0.0.0 will be sent out,
which is confusing, so log as an error. Of course, logging will
happen only if enabled.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-09-18 10:13:14 +03:00
Jukka Rissanen 91041f9e73 net: ethernet: Fix the multicast IPv4 to MAC address mapping
The IPv4 multicast address to MAC address mapping was missing
the 4th byte high bit clearing.

We also need to have some storage for the multicast MAC address.
This was missing which could cause NULL pointer access.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-09-17 18:02:18 -04:00
Jukka Rissanen 1865b91f97 net: mdns: Add multicast DNS client support
This implements mDNS client from RFC 6762. What this means that
caller is able to resolve "hostname.local" names using multicast DNS.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-09-17 18:02:18 -04:00
Ricardo Salveti 34278a3a56 net: net_pkt: clone pkt from the same slab
Fixes a tx_pkts slab leak since the cloned pkt was referencing the
original pkt slab but was not originated from it (net_pkt_unref uses
pkt->slab when releasing the pkt).

Signed-off-by: Ricardo Salveti <ricardo.salveti@linaro.org>
2017-09-15 15:43:30 +03:00
Paul Sokolovsky 4881fa2a0c net: if: Lack of default interface is an error, not warning.
Because a next networking API call will lead to a crash. Given that
logging can be easily disabled (disabled by default so far!), don't
be shy and call by the name (i.e. error).

Jira: ZEP-2105

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-09-15 12:21:14 +03:00
Jukka Rissanen 7344d64965 net: Do not try to parse empty IP address string
If the IP address string is empty, then it is no use trying
to parse it. This was seen when handling DNS server strings when
user has made a mistake and defined the DNS server addresses
incorrectly.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-09-15 12:20:32 +03:00
Andrei Emeltchenko 681bf1f143 net: icmpv4: Fix ICMPv4 packet size calculation
Adjust length of the packet before setup_ipv4_header() which actually
might increase packet size if there is not enough space available.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2017-09-13 09:28:32 -04:00
Andrei Emeltchenko d55852e3cf net: icmpv4: Fix ICMPv4 checksum calculation
Make calculation after we adjust size.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2017-09-13 09:28:32 -04:00
Jukka Rissanen 93d2df6bf3 net: Introduce multicast group join/leave monitor
Create support for registering a callback that will be called
if the device leaves or joins IPv6 multicast group.

Jira: ZEP-1673

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-09-13 14:15:02 +03:00
Tomasz Bursztyka a86ae5f5ed net/arp: Fixing a leak when there is no pending entries left
Commit cd35742a2 missed one unref too many on pending packet which was
triggering a crash which commit 0b8434f08 tried to fix, but it generates
a leak when there is not pending entries left in arp core. Finally,
fixing what cd35742a2 should have done: removing the extra unecessary
unref after sending the pending packet.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-09-13 11:30:28 +03:00
Jukka Rissanen 0b8434f08f net: ethernet: Do not unref pending ARP request
If the packet is put pending because ARP request need to be
done, then do not unref original packet.

Fixes #1416

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-09-12 17:40:36 +03:00
Jukka Rissanen 13a6acecc3 net: shell: Add ARP cache printing
Add a command "net arp" to net-shell. This new command will
print ARP cache contents if IPv4 and Ethernet are enabled.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-09-12 17:39:29 +03:00
Jukka Rissanen e71a31e22f net: Wrong networking defines used in the code
There were bunch of config options in tests/net, net-shell and
wpan_serial sample, and those options had wrong name so they
were ignored by the code.

Fixes #1428

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-09-12 08:37:53 -04:00
Jukka Rissanen 61abc49c45 net: conn: Print received IPv4 or IPv6 data size
Useful in debugging to match packets seen in wireshark.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-09-10 10:03:58 -04:00
Jukka Rissanen ce41d5f432 net: tcp: Set the TCP context properly when accepting
When new connection is accepted, the TCP context variables like
sequence number etc. were not properly set.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-09-10 10:03:58 -04:00
John Andersen b81b26d8c7 net: Added Ipv4 missing debugging
For IPv6 check_ip_addr in subsys/net/ip/net_core.c makes a
NET_DBG call to report when a net_pkt is missing a destination
address. An analogous NET_DBG call has been added to the IPv4
destination address checking.

Signed-off-by: John Andersen <john.s.andersen@intel.com>
2017-09-08 14:32:35 +03:00
Tomasz Bursztyka cd35742a2b net/ethernet/arp: Let ethernet L2 managing pkt's reference while sending
prepare_arp() was unreferencing original pkt (called pending there) in
case of error.

net_prepare_arp() was always unreferencing pkt, though it could have
been already unreferenced by prepare_arp() as seen previously which is
an extra bogus unref in this case.

And in case it returned NULL, ethernet_send() would return NET_DROP
which in turn would make net_if's tx code to unref again the pkt.

This patch ensures pkt is unrefed only once and at the right place.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-09-08 10:59:11 +03:00
Jukka Rissanen 7e3d30880b net: shell: Fix TCP state printing
The TCP state string is only printed if CONFIG_NET_DEBUG_TCP is
defined. If that is not the case, then the "net conn" command
should not print the "State" column name as the state will not
be printed.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-09-08 10:58:25 +03:00
Jukka Rissanen 025cf55e55 Revert "net: tcp: Queue FIN instead of sending it immediately"
This reverts commit 817245c564.

In certain cases the peer seems to discard the FIN packet we are
sending, which means that the TCP stream is not closed properly.
This needs more work so revert this for time being.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-09-02 04:52:34 -04:00
Jukka Rissanen 532cbacc27 net: Add function to parse IP address string
The net_ipaddr_parse() will take a string with optional port
number and convert its information into struct sockaddr.
The format of the IP string can be:
     192.0.2.1:80
     192.0.2.42
     [2001:db8::1]:8080
     [2001:db8::2]
     2001:db::42

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-08-31 14:33:59 -04:00
Jukka Rissanen 817245c564 net: tcp: Queue FIN instead of sending it immediately
If network context is closed, send FIN by placing it to the end
of send queue instead of sending it immediately. This way all
pending data is sent before the connection is closed.

Jira: ZEP-1853

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-08-31 11:58:24 -04:00
Jukka Rissanen adb1df7f8f net: shell: Do not crash if DTLS is disabled in net app command
The "net app" command was accessing NULL pointer if TLS and UDP were
enabled but DTLS was not.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-08-30 08:12:10 -04:00
Jukka Rissanen 75de00225f net: tcp: Print more info if net_pkt was not sent
Useful in debugging if we get information why the TCP packet was
not sent.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-08-30 08:12:10 -04:00
Jukka Rissanen dcfbc00c51 net: ipv6: Fix fragmented IPv6 packet sending
Earlier we modified the original pkt chain when creating IPv6
fragments. This is not a proper way as the original chain might
still be used in TCP when re-sending a message. So when fragmenting
the packet, clone it first and leave original packet intact. This
occupies litle more memory but is now safe.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-08-30 08:12:10 -04:00