Commit Graph

519 Commits

Author SHA1 Message Date
Jukka Rissanen 28255628f8 net: rpl: Add RPL option to IPv6 HBHO extension header
See RFC 6553 for details.

Change-Id: I2448f6fa03819e797c4825238ff3e125d2f92bbf
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:11 +02:00
Jukka Rissanen 314068d924 net: Avoid compiler warning when compiled for Arduino 101 ARC
There is something wrong with Arduino 101 ARC compiler.

Sanitycheck runs ethernet tests for this board basically using
this command:

cd tests/drivers/build_all
make pristine && make CONF_FILE=ethernet.conf BOARD=arduino_101_sss

Which then gives following warning

warning: missing braces around initializer [-Wmissing-braces]

which is then converted to error in sanitycheck.

Change-Id: I822c599cb172825a79b5b8e4a71cb9252757a435
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:11 +02:00
Tomasz Bursztyka 7a11439020 net: ieee802154: Fix current stack to completely drop CRC handling
The 802.15.4 frame has a header and in the end after the payload a CRC.
Overall MTU is 127 bytes, but CRC is most likely going to be generated
by the device itself (offloading). Because the limitation of current
nbuf, it's not possible to keep this CRC in the buffer because it
require a user data size of 127 bytes but if we do so, IP stack will
fill in as much as it can as packet data, thus occupying the 2 last
bytes. This generates bugs. A perfect solution would be to generalize a
better handling of MTU and head or tail reserve data into nbuf, but
this will probably be solved in the future.

Change-Id: I1a0fee4d555e2717c1edd5afba399a1f17d9c7a9
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:11 +02:00
Jukka Rissanen c4cec90f68 net: shell: Add IPv4 ping support
User is able to send ICMPv4 Echo Request to destination
address.

Change-Id: Ie32d5970e5f3e75e925c283947f97e096e509555
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:10 +02:00
Jukka Rissanen 137e34a795 net: Fix net_addr_pton() IPv4 address parsing
Change-Id: Ib84067b66e3e417561045a4746408cecb6c2c67a
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:10 +02:00
Jukka Rissanen 23d32722e8 net: Check loopback and unspecified address in sending
If the destination IP address is loopback, then bypass
the L2 layer and directly feed the IP packet back to us.

If the destination IP address is unspecified, then
drop the packet.

All this is only done if CONFIG_NET_IP_ADDR_CHECK is
set as this extra processing can be unnecessary if
it is always known what addresses the device is going
to use. By default the address checking is enabled.

Change-Id: I323cce97a72533c75b0424870f08729479024ebf
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:10 +02:00
Jukka Rissanen b9d2113f02 net: Add util to send IPv4 ICMP Echo Request packet
Change-Id: I879eec03bc93cbf8935d62be9bff3e6cb03a8d72
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:10 +02:00
Jukka Rissanen 5db9bc8895 net: ipv4: Add utils to create IPv4 network packet
Create utility functions to create IPv4 packet if the
network context is not known.

Change-Id: I982830d09f3b91e23b75e6b63a5d97bfea0e8d4e
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:10 +02:00
Jukka Rissanen 9c99fbe601 net: shell: Fix hostname parsing for ping command
If the user uses set_module command, then the target host
name pointer will be wrong. This is fixed so user can
either say "net ping 2001:db8::2" or if set_module command
is used "ping 2001:db8::2"

Change-Id: I708c53e329a11a18fcb448b34213e4b2f19c6390
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:10 +02:00
Tomasz Bursztyka 7e8ebf4733 net: ieee802154: Fix and use pkt_hexdump relevantly
Use frag->data as a reference, not net_nbuf_ll or net_nbuf_ip_data.

Print out packet before compression/fragmentation, so it will help to
spot issues after such process.

Make sure as well no coloration is done if frag reserver is not set.

Change-Id: I7f1bdc9e5c39913b8d7f62b5ffacb9ba3e11ecc8
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:09 +02:00
Tomasz Bursztyka fa678cfdb6 net: ieee802154: Fix some debug output
Do not color the packet hexdump if there is no reserve set.
Do not print the ll part after 6lo compression/fragmentation.
Print out the actual frag being sent in radio driver.

Change-Id: I43118203c37fc76f60673c046732c8655ab7067b
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:09 +02:00
Tomasz Bursztyka 094ef65130 net: 6lo: LL content is set after 6lo compression/fragmentation
Thus no need to copy anything from there.

Change-Id: I1090f42f7fa5429748c973a656f9d25333ff16af
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:09 +02:00
Jukka Rissanen a9673d9f56 net: Replacing TICKS_UNLIMITED by K_FOREVER
Unified kernel uses K_FOREVER so use it instead.

Change-Id: I24ae75e99cf54d6959c014b8a848e22a33848657
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:09 +02:00
Leandro Pereira 2bfc42610d net: tcp: Reduce some of the boilerplate to send control segments
Move most of the code to send a control segment to a single function to
avoid copies of boilerplate code in a few functions.

Change-Id: Id2d4770b6bec3f10b4eb786af3eb2a25482d953d
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2016-12-02 12:41:09 +02:00
Leandro Pereira 6154e3c809 net: tcp: Implement the rest of active close machinery
This implements the active close state set (FIN_WAIT_1, CLOSING,
FIN_WAIT_2, TIME_WAIT).

Change-Id: Id146ba3d6a774bfeac93401779a246fd32e2c523
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2016-12-02 12:41:09 +02:00
Leandro Pereira 79b9e1413d net: Allow changing the callback of a connection
For certain scenarios, such as handling TCP active close, where the
state group {FIN_WAIT_1, FIN_WAIT_2, CLOSING, TIME_WAIT} can be reached
from more than one state (ESTABLISHED and SYN_RCVD respectively), it's
cleaner to handle all the transitions inside a single callback
function.

Change-Id: I3d4d210dd667fef5cf81d5174d626adbf8675019
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2016-12-02 12:41:09 +02:00
Leandro Pereira 3b2dabec2b net: tcp: Implement part of active connection close
This transitions a connection to FIN_WAIT_1 state if it was in either
SYN_RCVD or ESTABLISHED states and the local peer decided to close the
connection.

A timer is started to close the connection after 2 MSL (which is 120
seconds; this might be easily tunable through kconfig).  No transition
from this state to FIN_WAIT_2, CLOSING, or TIME_WAIT are implemented on
this change: oncoming changes will implement the rest of this
machinery.

Change-Id: Ic9e2eceef81a82fb37c0a829860cfcf52f424475
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2016-12-02 12:41:09 +02:00
Leandro Pereira f3d5a36940 net: tcp: On error, dispose of net_buf when sending control segment
The net_buf structs were being dereferenced when the packet was
correctly sent by the underlying layers, and never on error.  This
could lead to crashes, double unrefs, and buffer leaks.

Change-Id: I81b280f9d108c18ebe0e5914b73da4656afbd6ae
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2016-12-02 12:41:08 +02:00
Leandro Pereira 264b93c736 net: tcp: Implement passive close (FIN packets in ESTABLISHED state)
If a packet with the FIN flag is received while in ESTABLISHED estate,
transition to CLOSE_WAIT and send the ACK as usual.

The act of preparing a segment in CLOSE_WAIT state will automatically
transition the TCP context to the LAST_ACK state.  Next time a packet
comes in with the ACK flag set, put the context.

Change-Id: I245c8b7755f9db140b85ffad52e2e10cc74e7781
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2016-12-02 12:41:08 +02:00
Leandro Pereira 6b9b9a6f75 net: tcp: Provide NET_TCP_FLAGS macro
Instead of having to write "NET_TCP_BUF(buf)->flags & NET_TCP_CTL"
every single time, provide a NET_TCP_FLAGS macro that expands to this
expression.

Change-Id: Ie876c538599fabae6b800a53613b6ad17dc45620
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2016-12-02 12:41:08 +02:00
Jukka Rissanen 57e565855a net: Fix IPv6 router lifetime handling
Create a timer when router is added, update it if needed after
receiving Router Advertisement, and then delete the router lifetime
timer when the router is removed from the system.

Change-Id: I784e0534da300fdcb43349d9cf40354ebe109e07
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:08 +02:00
Jukka Rissanen b650b758c9 net: Add util to remove an IPv6 router from the network interface
Change-Id: Ie9cc461187a25355819e685cec68b04d4eba8c87
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:08 +02:00
Jukka Rissanen 5092b3c555 net: Add util to update router lifetime
Change-Id: I38ecf574f2a0c69348ed73efb9b26aadab4344aa
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:08 +02:00
Jukka Rissanen 83219eeefb net: ipv6: RA messages were incorrectly handled
Received Router Advertisement messages were incorrectly received
and handled which could cause hanging or crashing of the system.

Jira: ZEP-1267

Change-Id: I05b57221581e9f671825dbc147adb0a55bea091e
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:08 +02:00
Jukka Rissanen 4a7c146e24 net: ipv6: Print info about unknown RA options
Print information about every unknown RA option we receive.
These options need to be implemented later.

Change-Id: Ic2d189e4a130162569a81ca58d38b8129183b2fd
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:08 +02:00
Jukka Rissanen 0ea0fe3f75 net: ipv6: Fix network interface address lifetime handling
Setup IPv6 address lifetime timer if needed and start Duplicate
Address Detection procedure for every IPv6 address added to
the network interface. If the IPv6 address is removed from
network interface, cancel any pending lifetime timers.

Change-Id: I5b6ffd97836cfe78ddb9ff8fdb78d8be0bb81348
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:08 +02:00
Jukka Rissanen 41e547673a net: Add util to update IPv6 address validity time
Change-Id: I951c9e781c74724c69fbd700ef738dd487ec15a7
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:08 +02:00
Jukka Rissanen a1ea8ef642 net: ipv6: Validity time is already in host byte order
The validity time is already converted to host byte order
when reading the field from the Router Advertisement message.
No need to use ntohl() here.

Change-Id: If1106748f268a245871510563c7e7849020e3b3a
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:08 +02:00
Jukka Rissanen 3d363db33c net: Remember IPv6 extension header len when packet is received
This is needed in other part of the stack in order to able to
parse packets properly.

Change-Id: I8082860333bdcb2c6114d517ff0b782b9ba526a0
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:08 +02:00
Tomasz Bursztyka 4438278133 net: ieee802154: Fix a double ll address swap
Commit 7bdd30d99d447b89b89c7fb0c76d52586744176f was properly swapping
incoming ll address, but in case of sending, frame creation logic is
already doing the job properly.

Change-Id: I864abba9b09f9176b3f1efec6055c193f3fbabc9
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:07 +02:00
Tomasz Bursztyka 85a8f8e6fa net: trickle: Using unified kernel API
Dropping legacy API. This commit also contains updated
unit tests in order to pass the test.

Change-Id: Ibc7426837e2f4f23bb5f3ed3719635c5c3d0ed0f
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:07 +02:00
Tomasz Bursztyka 8e075eb469 net: route/rpl: Using unified kernel API
Dropping legacy API.

Change-Id: If9f52f88c77e4e5ef19b9c0cc66c0d4e31efbe98
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:07 +02:00
Tomasz Bursztyka 500cc706b1 net: dhcpv4: Using unified kernel API
Dropping legacy API.

Change-Id: I0f1a04d0f9a19696ddb50d976beba00a19a830cd
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:07 +02:00
Tomasz Bursztyka 799c57b261 net: nbuf: Using unified kernel API
Dropping legacy API.

Change-Id: I8766a27f90c99aca0aa222833018a4dd8d65b885
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:07 +02:00
Tomasz Bursztyka 92700ee8ef net: tcp: Using unified kernel API
Dropping legacy API.

Change-Id: Ia1eecd5d6dad07f3e9272d7b62c0b7a4b939317b
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:06 +02:00
Tomasz Bursztyka 1aaf5aaa93 net: l2: Using unified kernel API
Dropping legacy API.

Change-Id: Icf24ecef714a9d6ddbe16aff6422b4fcc6c428e2
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:06 +02:00
Tomasz Bursztyka 710e6c327e net: ipv6: Using unified kernel API
Dropping legacy API.

Change-Id: I6e7887d8212ec59214b1c28dd9a3320b1a8fff1f
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:06 +02:00
Tomasz Bursztyka aa9a552012 net: if: Using unified kernel API
Dropping legacy API.

Change-Id: I46eb30f691f5e0a9e9156f8b4dab3c00e64ffb9b
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:06 +02:00
Tomasz Bursztyka bd293e4dd9 net: mgmt: Using unified kernel API
Dropping legacy API.

Change-Id: Ifcada6513cf57bf2b73809bd9ed886f2c623baab
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:06 +02:00
Tomasz Bursztyka ea13cf8575 net: context: Using unified kernel API
Dropping legacy API.

Change-Id: I2f98ec39906bd8c0a8979171904d244b6a82a5e7
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:06 +02:00
Tomasz Bursztyka f3cb3ff40e net: core: Using unified kernel API
Dropping legacy API.

Change-Id: I756e47855cc979aa130ad0de4fd527c4a79e8d71
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-12-02 12:41:06 +02:00
Jukka Rissanen aa438d10fe net: Add more debugging when receiving invalid packet
Also fix typo in debug print when discarding a packet.

Change-Id: I3ac41e86d7b2dc05b9d92cde93a646f2dc49d8c0
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:06 +02:00
Jukka Rissanen 40508b1747 net: nbuf: Add more debugging if ref count is wrong
Change-Id: I0fc77456c20b6ecd4066e8a70c1df4ecab9a689d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:06 +02:00
Leandro Pereira 0596472772 net: Fix connection-in-use test while unregistering connection
The bitwise and operator was being applied to a boolean operand because
of lack of parenthesis in the expression.

Change-Id: Ibfbdd8acce9db95f9274f48fd145f4d8467508e2
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2016-12-02 12:41:06 +02:00
Leandro Pereira 90f324869f net: Print more debug messages when processing corrupted buffers
Change-Id: I62fa8cd05b1b4598dfefc7a82b28467072b06ae3
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2016-12-02 12:41:05 +02:00
Jukka Rissanen 89a00ada23 net: Replace deprecated kernel init level
Replace NANOKERNEL by POST_KERNEL in the net stack.

Change-Id: Iaad7cdbe849741bc1cf18b0ccf7264417a9495d6
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:05 +02:00
Luiz Augusto von Dentz 59dfdf7c72 net: l2: Make NET_DEBUG_L2_BLUETOOTH depend on NET_L2_BLUETOOTH
Change-Id: I6244cb48304562d7430535c7df9fe2206c2c84b3
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-12-02 12:41:05 +02:00
Luiz Augusto von Dentz cfef21d13c net: l2: Enable security for bluetooth driver
IPSP spec states other security level can be used depending on the use
case:

  7.1 Node Security Considerations
  This section describes the security requirements for the Node.
  The Node may use the SM Slave Security Request procedure to request
  an LE Security Mode other than LE Security Mode 1 Level 1 if required
  by the use case.

Change-Id: I24c6676bdb05099a7e222085ee41539994eea77f
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-12-02 12:41:05 +02:00
Luiz Augusto von Dentz f2f96bc6f5 net: l2: Fix warning when building Bluetooth driver
Bluetooth driver requires BLUETOOTH_SMP in order to build properly since
BLUETOOTH_L2CAP_DYNAMIC_CHANNEL depend on it.

Change-Id: I7878c0c26ebf688b2a7321eb37025a9ebde6c6b8
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-12-02 12:41:05 +02:00
Jukka Rissanen c5f8dc4748 net: ipv4: Move broadcast address getter to ipv4.c
More logical place for net_ipv4_broadcast_address() is in ipv4.c
instead of net_if.c.

Change-Id: I069f5030963bcb809df34e874054e2b7826ff868
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-12-02 12:41:04 +02:00