Commit graph

808 commits

Author SHA1 Message Date
Jukka Rissanen 529a55b6ef net: rpl: Do not probe parent that is not our neighbor
Unlikely to happen but make sure parent neighbor exists when
probing it.

Coverity-CID: 173635

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-08-07 21:32:03 -04:00
Jukka Rissanen a1b6e5495d net: rpl: Make sure parent is found when processing DIO msg
If there is no parent found with a specific dag, then we have
to check this in order not to access NULL pointer.

Coverity-CID: 173637

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-08-07 21:32:03 -04:00
Jukka Rissanen 3a438f159b net: rpl: Do not access NULL parent
If the parent is not found when adding DAG, then just return.
We must check the parent pointer as it can be NULL.

Coverity-CID: 173638

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-08-07 21:32:03 -04:00
Jukka Rissanen 1584bbec48 net: trickle: Do clock wrap check properly
No need to complex overflow checks that are error prone.
Coverity complained that the original diff check was always
false.

Coverity-CID: 173639

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-08-07 21:32:03 -04:00
Jukka Rissanen 4dc236b7dd net: rpl: Remove dead code when updating IPv6 HBHO
There was dead code when handling IPv6 Hop-by-hop option.
The extra option value check can be removed as it is useless.

Coverity-CID: 173642

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-08-07 21:32:03 -04:00
Jukka Rissanen d86ff7255f net: rpl: Comment Coverity false positive when forwarding DAO
Coverity complains about reversed src and dst fields when sending
DAO ack back to originator. This is false positive.

Coverity-CID: 173650

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-08-07 21:32:03 -04:00
Jukka Rissanen 14a87ea9c9 net: if: Check return value of k_poll() when sending data
Check the return value of k_poll() as instructed by Coverity.
If debugging is enabled we print error if this happens, otherwise
this error is ignored. In our case the return value should always
be 0.

Coverity-CID: 173652

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-08-07 21:32:03 -04:00
Jukka Rissanen b14586c3ca net: rpl: RPL route entry was fetched too late
The RPL route entry variable "extra" was resolved inside an
if-statement and the code was always returning from it.
This meant the the later code dealing with "extra" was never
executed. Fixed by moving the resolving of "extra" a bit
earlier so that the "extra" variable has always a proper value.

Coverity-CID: 173659
Coverity-CID: 173654

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-08-07 21:32:03 -04:00
Jukka Rissanen 7182620340 net: rpl: Status code was incorrectly checked in MRHOF link cb
The TX send function will return status < 0 if there is an error
when sending. This status value was incorrectly checked.

Coverity-CID: 173660

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-08-07 21:32:03 -04:00
Paul Sokolovsky 19ff963693 net: tcp: Allow to explicitly manage TCP receive window
This fixes the existing situation that "if application buffers data,
it's the problem of application". It's actually the problem of the
stack, as it doesn't allow application to control receive window,
and without this control, any buffer will overflow, peer packets
will be dropped, peer won't receive acks for them, and will employ
exponential backoff, the connection will crawl to a halt.

This patch adds net_context_tcp_recved() function which an
application must explicitly call when it *processes* data, to
advance receive window.

Jira: ZEP-1999

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-08-05 11:40:50 +03:00
Anas Nashif 09bcd8ee74 Kconfig: make all syslog variables depend on SYS_LOG
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-08-04 14:34:54 -05:00
Luiz Augusto von Dentz cbc4a2b9b0 net: bt: Add advertise management command
This adds NET_REQUEST_BT_ADVERTISE which can be used to advertise
IPSS service so the remote devices can connect to it.

Jira: ZEP-2451

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2017-08-04 18:18:40 +03:00
Jukka Rissanen 6bb620e232 net: shell: Add command to get info about net-apps
A new net-shell command "net app" will print information about
network app users in the system.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-08-01 21:09:59 +03:00
Jukka Rissanen 994f5f2a4d net: shell: Remove net_shell_init() as it is not needed
The net_shell_init() is empty function and there is no use
for it so removing it.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-08-01 14:45:06 +03:00
Jukka Rissanen ca7afdc774 net: tcp: Do not try to print TCP error for 6lo packet
For IPv6 header compressed packet, the IP header offsets will
be wrong. In this case there is no need to print error when
trying to print TCP packet information.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-07-31 11:50:25 +03:00
Jukka Rissanen 6bb446ed8e net: slip: Clarify slip settings in Kconfig
As SLIP TAP is now the default after the commit ca0ad13a61
("net: enable SLIP only on QEMU targets"), clarify the comments
and settings in various Kconfig files that talk about slip.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-07-28 10:45:47 +03:00
Leandro Pereira 732424f065 drivers, net: Clean up semaphore initialization
Change the common "init with 0" + "give" idiom to "init with 1".  This
won't change the behavior or performance, but should decrease the size
ever so slightly.

This change has been performed mechanically with the following
Coccinelle script:

    @@
    expression SEM;
    expression LIMIT;
    expression TIMEOUT;
    @@

    - k_sem_init(SEM, 0, LIMIT);
    - k_sem_give(SEM);
    + k_sem_init(SEM, 1, LIMIT);

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-07-27 15:23:07 -04:00
Jukka Rissanen 77eddf68c4 net: if: Delay IPv6 DAD if network interface is down
If the network interface is down, then IPv6 DAD (Duplicate
Address Detection) cannot be done if new IPv6 address is added
to the network interface. This can happen in Bluetooth, where
network interface is taken up only after there is a BT connection.
The DAD is delayed and done later after the network interface is up.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-07-27 16:03:03 +03:00
Jukka Rissanen f8c5f69780 net: shell: Do not access NULL pointer if interface is down
Normally network interface is always UP, but Bluetooth
interfaces are down until connected. So if this is the case,
then check the interface status before trying to access variables
that are NULL. This was seen with "net iface" shell command when
BT was enabled.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-07-27 15:19:53 +03:00
Luiz Augusto von Dentz 60e34d1032 net: Don't enable SLIP driver if Bluetooth is enabled
In case the application is using NET_L2_BLUETOOTH the SLIP drivr shall
not be selected as bus they cannot coexist since they use the same UART
port:

arch/x86/soc/ia32/Kconfig.defconfig:

config BLUETOOTH_UART_ON_DEV_NAME
        default "UART_1"

config UART_PIPE_ON_DEV_NAME
        default "UART_1"

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2017-07-27 14:08:44 +03:00
Anas Nashif ca0ad13a61 net: enable SLIP only on QEMU targets
In many networking tests we had to configure SLIP in the prj.conf
leaving those configurations Qemu specific. This change enables SLIP for
QEMU targets automatically and allows reuse of prj.conf for multiple
boards.

Additionally, the TUN options is removed. This option was not used
anywhere.

To enable self-contained networking tests that do not depend on SLIP, we
introduce the new option NET_TEST which disables TAP and allows testing
in QEMU without the need for a host interface.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-07-26 10:57:48 -04:00
Jukka Rissanen e75b71ff0a net: trickle: Misc changes
* Fix the indentation which was caused by uint32_t -> u8_t changes.
* Make sure there is no unused variable warning if debugging is
  enabled but debug level is low.
* Add assert that checks that Imax_abs is > 0 which it should be.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-07-26 07:56:51 -05:00
Jukka Rissanen 723a4a5583 net: route: Check null pointer for neighbors and routes
If there are no neighbors or there is no route to one specific
neighbor, then check the NULL pointer before accessing the route.
This issue was seen with "net route" shell command.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-07-26 11:25:06 +03:00
Andrew Boie e8cede7940 net: fix references to stack buffers
The net_stack_analyze function wants to look at the stack buffer,
but it is making assumptions on where this data is that are no
longer valid. Change to use the proper APIs for referencing this.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-07-26 10:31:46 +03:00
Jukka Rissanen 16837f954f net: if: Check in delete addr if delayed work needs cancelling
The address lifetime timer was cancelled always even if the address
timer was never installed.

Jira: ZEP-2397

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-07-19 10:16:54 -07:00
Paul Sokolovsky 9ed716b9b2 net: context: connect: Make sure local end is bound before connecting
Introduce net_context_bind_default() to ensure that local address is
set for context if not yet (via explict bind() call). This fixes
dereferences of NULL pointer to local address which was exposed when
MMU was enabled for qemu_x86.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-07-17 21:12:03 +03:00
Jukka Rissanen 7474553543 net: Fix connectivity issues if only UDP or TCP is enabled
If either UDP or TCP is enabled but not both, then connectivity
fails. This was a side effect of commit 3604c391e ("net: udp:
Remove NET_UDP_HDR() macro and direct access to net_buf")

Jira: ZEP-2380

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-07-14 08:49:45 +03:00
Jukka Rissanen 266792af9c net: ipv6: Fragmentation was accessing NULL pointer
When IPv6 fragments were sent, the last IPv6 fragmented packet
was accessing NULL pointer.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-07-13 15:45:35 +03:00
Ravi kumar Veeramally f73221e5cb net: rpl: Fix invalid config name
Fixes #665

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-07-12 11:06:57 +03:00
Jukka Rissanen 72e73b2bd6 net: arp: Do not try to access NULL pointer
When the ARP message is received when the device is starting up,
the network interface might not yet have IPv4 address setup
correctly. In this case, the IP address pointer could be NULL
and we must not use it for anything.

Fixes #752

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-07-11 20:18:32 +03:00
Paul Sokolovsky 4334144caa net: context: Fix use of k_delayed_work_cancel with SYN backlog
This patch fixes a regression which the original patch introducing
this code (improving concurrent connection handling) had on
*sequential* connection handling. Without this patch, with the
default CONFIG_NET_TCP_BACKLOG_SIZE of 1, after each connection
request, there was 1s (ACK timeout) "dead time" during which new
connection wasn't ptocessed.

This is because k_delayed_work_remaining_get() was checked the
wrong way. But there's no need to use k_delayed_work_remaining_get()
at all, instead just call k_delayed_work_cancel() and dispatch on
its return code.

Note that there's still a problem of synchronizing access to
the global array tcp_backlog, as worker (which modifies it) may
preempt packet handling code (which also modifies it).

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-07-11 11:21:42 +03:00
Jukka Rissanen ee989be286 net: tcp: Fix sequence number validator
The sequence number validator was checking the seq numbers
incorrectly. This caused some valid RST packets to be dropped
and the TCP stream to hang.

Added also a TCP test case that tests the seq validator.

Jira: ZEP-2289

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-07-11 10:35:19 +03:00
Jukka Rissanen ccb9c844b5 net: ipv6: Increase default multicast address count to 3
Usually it is not enough to have just one IPv6 multicast
address defined for the network interface. So allocate three
IPv6 multicast addresses for the network interface as IPv6
by default uses multicast a lot. This hopefully will avoid
some mysterious errors if the addresses run out.

Note that this will increase memory usage a bit so you might
need to lower the count in your conf file if memory is low.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-07-11 10:33:28 +03:00
Jukka Rissanen e663c5df51 net: tcp: Add FIN timer when doing active close
The commit 210c30805b ("net: context: Close connection fast
if TIME_WAIT support is off") was not a proper way of closing
the connection. So if Zephyr closes the connection (active close),
then send FIN and install a timer that makes sure that if the peer
FIN + ACK is lost, we close the connection properly after a timeout.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-07-11 10:30:44 +03:00
Jukka Rissanen ee633595aa net: tcp: Fix passive close ACK timer
The commit 00ac0487b0 ("net: context: Remove tcp struct SYN-ACK
timer handling") removed also the passive close ACK timer.
Adding that ACK timer back so that we can close the connection
properly even if the last ACK from peer is lost.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-07-11 10:30:44 +03:00
Andrew Boie 65a9d2a94a kernel: make K_.*_INITIALIZER private to kernel
Upcoming memory protection features will be placing some additional
constraints on kernel objects:

- They need to reside in memory owned by the kernel and not the
application
- Certain kernel object validation schemes will require some run-time
initialization of all kernel objects before they can be used.

Per Ben these initializer macros were never intended to be public. It is
not forbidden to use them, but doing so requires care: the memory being
initialized must reside in kernel space, and extra runtime
initialization steps may need to be peformed before they are fully
usable as kernel objects. In particular, kernel subsystems or drivers
whose objects are already in kernel memory may still need to use these
macros if they define kernel objects as members of a larger data
structure.

It is intended that application developers instead use the
K_<object>_DEFINE macros, which will automatically put the object in the
right memory and add them to a section which can be iterated over at
boot to complete initiailization.

There was no K_WORK_DEFINE() macro for creating struct k_work objects,
this is now added.

k_poll_event and k_poll_signal are intended to be instatiated from
application memory and have not been changed.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-07-10 11:44:56 -07:00
Jukka Rissanen 10eea9bb9a net: Fix NULL pointer access
The networking code was accessing NULL pointer which it should
not do.

Jira: ZEP-2367

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-07-10 09:32:26 -07:00
Luiz Augusto von Dentz 2285f17bea net: bt: Check return of bt_conn_get_info
This fixes coverity CID 171565 which may be valid in case of the
connection is not properly setup, or its memory is corrupted, it
may cause use of invalid addresses to be set using
net_if_set_link_addr.

JIRA: ZEP-2344

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2017-07-10 13:53:01 +03:00
june li cdeee63fbf net: tcp: Recalculate the tcp checksum when changing tcp header.
If the TCP data packet needs to be re-sent after the packet is lost,
then the acknowledgment number will be changed. This then means that
the TCP checksum needs to be recalculated too.

Signed-off-by: june li <junelizh@foxmail.com>
2017-07-10 11:08:07 +03:00
Ravi kumar Veeramally 5f9cf752f4 net: rpl: Ignore consistent DIO messages
When a node receives consistent DIO messages with same data from
Border Router just ignore those messages. Need not to proceed
further.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-07-07 15:49:06 +03:00
Ravi kumar Veeramally ab2dbffc4f net: rpl: Fix invalid access of IPv6 nbr link metric
Link metric is part IPv6 neighbour data struct. But RPL code is
trying to access it from RPL parent table where link metric doesn't
exist. So provided an api to get IPv6 neighbour data from RPL parent
data.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-07-07 15:49:06 +03:00
Ravi kumar Veeramally d971d26f84 net: rpl: Fix byte order conversion while preparing message
DAG rank will be properly written with net_pkt_write_be16() in
network packet. API will take care of endianness. So need
not to convert it using htons().

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-07-07 15:49:06 +03:00
Ravi kumar Veeramally 0aaee54ff0 net: rpl: Fix byte order conversion of sender rank
Sender rank (16 bit uint) was properly read with net_frag_read_be16()
api and need not to convert it again using ntohs().

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-07-07 15:49:06 +03:00
Jukka Rissanen e58bc105dc net: Avoid printing non-error cases when parsing packet
We had various asserts when checking network packet length but
printed also error when there was none. Fix this by checking
do we really have a too short message.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-07-07 15:24:00 +03:00
Jukka Rissanen 9c907fca43 net: tcp: Remove NET_TCP_HDR() macro and direct access to net_buf
Remove NET_TCP_HDR() macro as we cannot safely access TCP header
via it if the network packet header spans over multiple net_buf
fragments.

Fixed also the TCP unit tests so that they pass correctly.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-07-07 15:24:00 +03:00
Jukka Rissanen 3604c391e6 net: udp: Remove NET_UDP_HDR() macro and direct access to net_buf
Remove NET_UDP_HDR() macro as we cannot safely access UDP header
via it if the network packet header spans over multiple net_buf
fragments.

Fixed also the UDP unit tests so that they pass correctly.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-07-07 15:24:00 +03:00
Jukka Rissanen 8476da9d9b net: icmp: Remove NET_ICMP_HDR() macro and direct access to net_buf
Remove NET_ICMP_HDR() macro as we cannot safely access ICMP header
via it if the network packet header spans over multiple net_buf
fragments.

Jira: ZEP-2306

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-07-07 15:24:00 +03:00
Jukka Rissanen 7e259e7526 net: ipv6: Handle PAD1 extension header properly
The IPv6 HBH option PAD1 ext header was not parsed properly
as the code read one extra byte from the ext header. The
PAD1 length is only 1 byte.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-07-07 15:24:00 +03:00
Jukka Rissanen a6e876ef5b net: utils: Helper to check if protocol header fits in fragment
Add utility function that helps to figure out if the
protocol headers can be directly accessed when they fit one
net_buf fragment, or if they need to accessed using various
net_pkt helpers that know about reading data from two
different net_buf's.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-07-07 15:24:00 +03:00
Jukka Rissanen 2cf47d1778 net: utils: Rework the IP packet checksum calculation
Instead of directly setting pointer to where to start to calculate
the various IP related checksums, use the net_frag_skip() to first
find out what is the fragment where the calculation should start.

This needs to be like this so that if the IP header + possible
extension are so long that they do not fit the first fragment,
we need to be prepared to look into second fragment.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-07-07 15:24:00 +03:00
june li 054e5453b9 net: tcp: Reset context->tcp to NULL after net_tcp_release.
net_context_unref() is protocol agnostic, after being un-referenced,
the same context might end up being used then for UDP,
if context->tcp is not reset to NULL, calling net_context_unref()
after this UDP usage will again try to release this TCP pointer
which might lead to random error.

Signed-off-by: june li <junelizh@foxmail.com>
2017-07-06 22:35:51 +03:00
Jukka Rissanen f4cc1d10a7 net: route: Do not try to access null link layer address
In some cases the lladdr might not be set, currently this is
seen with RPL unit tests, in which case we must not access
the lladdr.

Jira: ZEP-2330

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-07-06 09:19:11 -07:00
Jukka Rissanen 94f7c4e586 net: route: Do not try to del null route
If there is no route to the neighbor, then do not try to delete
it because the route pointer is NULL.

Jira: ZEP-2329

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-07-06 09:18:41 -07:00
Patrik Flykt 00ac0487b0 net: context: Remove tcp struct SYN-ACK timer handling
The SYN-ACK timer is now handled by the TCP backlog functionality,
while the remaining ACKs for established connections use the tcp
struct ack timer. With this, code setting tcp struct SYN-ACK state
timers can now be removed.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2017-07-06 14:33:55 +03:00
Patrik Flykt 117771e633 net: context: Add TCP SYN-ACK timer handling
Add timer for sent TCP SYN-ACKs. If the timer is already
scheduled to run before canceling it is attempted, set
the cancelled flag and let the callback remove the
delayed work.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2017-07-06 14:33:55 +03:00
Patrik Flykt 864df870f8 net: tcp: Implement TCP backlog for incoming connections
Add an array of configurable size that holds TCP backlog entries.
The array is shared between all incoming TCP connections in order
to make it possible to get away with less memory consumed than
with a connection based approach.

The backlog entries are created when a SYN is received for a
listening TCP socket and removed once the corresponding ACK is
seen. With an incoming RST the corresponding backlog entry is
cleared, if any.

The size of the global backlog array is defined with the
CONFIG_NET_TCP_BACKLOG_SIZE Kconfig variable.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2017-07-06 14:33:55 +03:00
Patrik Flykt 9cc7431b9d net: tcp: Make initial sequence number calculation public
The initial TCP sequence number needs to be assigned when a SYN
is received in net_context.c.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2017-07-06 14:33:55 +03:00
Anas Nashif e32cfe5f09 kconfig: fix typo in Kconfig name: NET_RPL_MC_EXT
Should be NET_RPL_MC_ETX

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-07-05 12:43:13 -04:00
Anas Nashif c2e62f4618 net: kconfig: fix help message for SLIP
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-07-05 12:43:13 -04:00
Jukka Rissanen a1be6a8ba9 net: app: Create support for network application API
The network application API is a higher level API for creating
client and server type applications. Instead of applications
dealing with low level details, the network application API
provides services that most of the applications can use directly.

This commit removes the internal net_sample_*() API and converts
the existing users of it to use the new net_app API.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-06-30 06:13:09 -04:00
Erwin Rol 6e80eb46c8 net: ipv4: fix icmp checksum calculation
If ICMP packets do not fit in 1 net_pkt fragment the checksum
will be calculated incorrectly.

The problem shows up when using ping with the -s option to
create large ping requests. Eventhough the ping command does
accept the reply without complaining, Wireshark warns that
the icmp checksum is incorrect.

Signed-off-by: Erwin Rol <erwin@erwinrol.com>
2017-06-30 11:33:17 +03:00
Patrik Flykt ac07550566 net: context: Go back to LISTEN state when receiving RST
In LISTEN state ignore a TCP RST. In SYN RCVD state, reset TCP
connection state to LISTEN when a valid RST segment is received. In all
other states close the connection - except that these other states will
not be handled in tcp_syn_rcvd() function.

Jira: ZEP-2279

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2017-06-22 13:17:27 +03:00
Jukka Rissanen 210c30805b net: context: Close connection fast if TIME_WAIT support is off
If the CONFIG_NET_TCP_TIME_WAIT support is disabled, then do not
start to wait for reply to sent FIN in active close, but unref
the corresponding net_context in order to close the connection
as soon as possible.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-06-21 10:51:52 +03:00
Anas Nashif 397d29db42 linker: move all linker headers to include/linker
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-06-18 09:24:04 -05:00
Johan Hedberg 9703927f84 net: buf: Move net_buf_pool objects to dedicated linker area
Moving the net_buf_pool objects to a dedicated area lets us access
them by array offset into this area instead of directly by pointer.
This helps reduce the size of net_buf objects by 4 bytes.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-06-16 17:05:06 +03:00
Jukka Rissanen 72567677e7 net: pkt: Fix net_pkt_split()
The net_pkt_split() was incorrectly checking fragA pointer
even before it was allocated.

The unit test is fixed and converted to ztest.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-06-16 17:05:06 +03:00
Leandro Pereira 9e329c7997 net: tcp: Remove fin_queued flag from struct net_tcp
This flag was set but never used.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-06-13 10:33:41 +03:00
Paul Sokolovsky 515788648a net: ip: Make struct in_addr::s_addr compatible with POSIX definition
From
http://pubs.opengroup.org/onlinepubs/7908799/xns/netinetin.h.html:

in_addr_t
    An unsigned integral type of exactly 32 bits.

[] the in_addr structure [] includes at least the following member:

in_addr_t      s_addr

In other words, POSIX requires s_addr to be a single integer value,
whereas Zephyr defines it as an array, and then access as s_addr[0]
everywhere. Fix that by following POSIX definition, which helps to
port existing apps to Zephyr.

Jira: ZEP-2264

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-06-13 10:32:03 +03:00
Jukka Rissanen c0682a9dca net: context: Init context state after unref
When the context is freed, we must set the state to UNCONNECTED.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-06-12 10:23:19 +03:00
Luiz Augusto von Dentz a04d22c6d8 net: shell: Remove code adjust arguments
The shell takes care of removing the module name so it is no longer
necessary to have this adjustment.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2017-06-09 18:54:27 -04:00
Andrew Boie 567c6c7683 misc: use K_THREAD_STACK_DEFINE macros
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-06-09 18:53:28 -04:00
Tomasz Bursztyka 3a025544a1 ieee802154: Realign structure bitfields
Unsigned integer name change messed up the alignement of the size in
bitfields.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-06-09 13:19:50 +03:00
Jukka Rissanen 286139e13b net: tcp: Check pkt before sending RESET
In certain TCP states we should not try to send RESET segment
to peer. So check this and do not try to use NULL pkt to send
a message.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-06-09 13:09:37 +03:00
Jukka Rissanen fc125e0e2c net: shell: Add HTTP server connection monitoring
The "net http monitor" command turns on HTTP monitoring,
which means that for each incoming HTTP or HTTPS request,
a information about source and destination address, and
the HTTP request URL is printed.
User can disable the monitoring by "net http" command.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-06-09 13:09:10 +03:00
Jukka Rissanen e3ba68881d net: shell: Show HTTP connection information
The "net http" command will print currently active HTTP
connections in the HTTP server.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-06-09 13:09:10 +03:00
Jukka Rissanen 447193c959 net: context: Print error code if sending fails
If we cannot send network data, then print the error code when
printing debug information about the issue. This is needed when
debugging the issue.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-06-09 09:56:21 +03:00
Jukka Rissanen 7812569e0f net: context: Add debug print when context is freed
This is useful info to have when debugging.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-06-09 09:56:21 +03:00
Ravi kumar Veeramally 7a01988c64 net: 6lo: Fix source address uncompression
When src and dst addresses are compressed based on context
information, uncompression method should verify CID bit,
SAC and DAC bits and context ID's. But it has missed some
cases which resulted in invalid uncompressed IPv6 header.

e.g. CID is set, SAC is 0 and DAC is 1 and context id's provided.
Uncompression method assumed that src address is compressed based
on context information but it is not.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-06-06 09:06:01 -04:00
Ravi kumar Veeramally 4a8a42f9dd net: rpl: Update RPL header
Empty RPL HBH header will be inserted while finalizing IPv6 packet
but updated after finding nexthop and sent the packet. In case of
Bluetooth or multicast dst address it was missed. Resulted in
empty RPL HBH header and packet dropped at peer node. It should
be updated in all circumstances.

Jira: ZEP-2088

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-06-06 09:06:01 -04:00
Paul Sokolovsky 08a2c6019c net: context: Operations on unused context should lead to EBADF.
Semantics of ENOENT error as used previously is "named entity not
found", whereas for "I/O handle is not valid", there's EBADF. For
example, POSIX/SUSV2 doesn't even list ENOENT as a possible error
for accept(), connect(), recv(), etc. whereas it lists EBADF, e.g.:
http://pubs.opengroup.org/onlinepubs/7908799/xns/connect.html

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-06-05 10:32:28 +03:00
Jukka Rissanen 2b6ebc0876 net: tcp: Timeout memory allocations
Instead of waiting forever for a free net_buf, set a timeout to
the allocations (500 ms). This way the application will not be
blocked by memory exhaustion.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-06-02 12:43:52 +03:00
Leandro Pereira 985d6c3f4b net: tcp: Limit number of segment retransmissions
Defines a new tunable, CONFIG_NET_TCP_RETRY_COUNT, that determines the
number of segment retransmissions that the IP stack will attempt to
perform before resetting the connection.

The default value is 9 retransmissions, which amounts to 1:42 minutes,
as close as possible to the minimum recommended by RFC1122.

Jira: ZEP-1956, ZEP-1957

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-06-02 12:36:05 +03:00
Ruslan Mstoi 39e37ab2ab net: ipv6: Skip unknown options in NA message
If we receive unknown option in neighbor advertisement message,
then skip those properly. Old code did not check the length of
the extension options which could cause infinite loop.

Jira: ZEP-2219

Signed-off-by: Ruslan Mstoi <ruslan.mstoi@intel.com>
2017-06-01 09:36:24 +03:00
Leandro Pereira 111244923c ieee802154_shell: Only accept channels within expected range
Fixes the following issue:
	"In expression 1UL << chan - 1U, left shifting by more than 31
	bits has undefined behavior.  The shift amount, chan - 1U, is
	4294967295."

Coverity-CID: 167140
Jira: ZEP-2131
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-05-31 13:17:14 -04:00
Jukka Rissanen df38a21ad3 net: shell: Enhance IPv6 fragmentation debugging prints
Print also network buffers that are allocated by the IPv6
fragment handler. This is very useful in debugging.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-05-30 11:21:51 +03:00
Jukka Rissanen 150df7dc53 net: ipv6: Make max number of fragmented pkt configurable
If the user really wants, it is possible to increase the
maximum size of the fragmented packet. According to RFC 2460
chapter 5, we do not need to accept larger than 1500 byte IPv6
packets, so the max pkt limit is set to 2. But if really needed
the limit can be raised by defining NET_IPV6_FRAGMENTS_MAX_PKT
to some new value. Currently there is no Kconfig option for
doing this as it is unlikely that this is needed.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-05-30 11:21:51 +03:00
Jukka Rissanen 2872e15c72 net: ipv6: Fix fragmentation cancellation
The cancellation of reassembly did not work as expected because
K_WORK_INITIALIZER() did not setup the timeout function properly.
So do the timer initialization at runtime instead.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-05-30 11:21:51 +03:00
Jukka Rissanen 27d85e6cf7 net: ipv6: Fix the IPv6 packet fragmentation sending
The IPv6 fragmentation was not working properly when the large
IPv6 packet was being sent. There is unit tests in next commit
that will test the IPv6 fragmentation sending.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-05-30 11:21:51 +03:00
Jukka Rissanen cef53bff11 net: ipv6: Memory leak during fragment reassembly
If the fragmented IPv6 packet was very large, we could run out
of resources. When that happened, we leaked the memory for the
pending fragments that were waiting reassembly.

Jira: ZEP-2166

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-05-30 11:21:51 +03:00
Jukka Rissanen 329579f5b1 net: ipv6: Default reassembly timeout set to 5 sec
The previous default 60 seconds is way too long for our limited
amount of memory. It might be that the 5 sec is still too long
but that can be changed in the future.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-05-30 11:21:51 +03:00
Luiz Augusto von Dentz fe168789cc net: shell: Remove extra help command
Shell itself already have a help command, so instead of creating a net
specific help just fill the help description of each command.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2017-05-30 09:18:33 +03:00
Luiz Augusto von Dentz 0c7bf93cc7 net: shell: Move SHELL_REGISTER out of net_shell_init
Shell modules are registered at link time thus it makes no sense to
leave it behind net_shell_init.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2017-05-30 09:18:33 +03:00
Jukka Rissanen cb1873654c net: ipv6: Skip unknown options in NS message
If we receive unknown option in neighbor solicitation message,
then skip those properly. Old code did not check the length of
the extension options which could cause infinite loop.

Jira: ZEP-2174

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-05-29 23:48:53 +03:00
Jukka Rissanen 23676369f7 net: pkt: Handle out-of-mem case properly
If we could not split the packet properly, make sure that the
fragments that we managed to allocate are unreffed and marked
as NULL.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-05-29 23:48:25 +03:00
Jukka Rissanen 3084c889a1 net: Print characters in hexdump
Print also the character when hexdumping a memory area.
This is useful so that one does not need to convert hex
values to characters in head. Unprintable chars are printed
as '.'

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-05-29 23:47:30 +03:00
Jukka Rissanen 6ed7fb05d0 net: dhcpv4: Properly register UDP handler
The address family of the UDP port listener was not set. This
caused weird debug prints in net-shell. Now the listener will
be registering IPv4 any address as it should.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-05-19 14:56:22 +03:00
Jukka Rissanen dea9b2b6c3 net: conn: Check connection address family properly
When a connection handler was registered, the checker function
introduced in commit 43b37cef ("Check duplicate UDP/TCP connection
handlers") did not check the address family (IPv4 or IPv6) of
the local end point properly. This caused duplicate connection
error to be returned to the caller.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-05-19 14:55:40 +03:00
Mateusz Hołenko 634f875e19 net: 6lo: Fix handling SAM_00 mode for packets with context
The uncompressed source address in packets was not handled properly if
NET_6LO_CONTEXT was enabled.

This implementation is identical to the contextless case.

Signed-off-by: Piotr Zierhoffer <pzierhoffer@antmicro.com>
2017-05-18 15:11:05 +03:00
Jukka Rissanen f3c47f29ff net: tcp: Fix comment when ACK timeouts
The comment describing ACK timeout in LAST_ACK state had
typos and was a bit unclear.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-05-18 15:08:12 +03:00
Jukka Rissanen 1725c1efab net: tcp: Print current state when ACK timeouts
For debugging purposes it is important to know what state we
are when ACK timeouts.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-05-18 15:08:12 +03:00
Jukka Rissanen 48f9dccc32 net: tcp: Allow ACK timeout to be configured
The timeout value when waiting ACK in various TCP states can
be configured via Kconfig.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-05-18 15:08:12 +03:00
Jukka Rissanen 27b5540118 net: tcp: Set timer for last ACK
If we do not receive last ACK when the connection is tore down,
then do not wait forever as that would eat all the resources in
the network stack. So when we enter the LAST_ACK state, we setup
a timer that will unref the connection if the last ACK is not
received.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-05-18 10:56:39 +03:00
Paul Sokolovsky d6b93b311f net: tcp: When sending FIN, make sure it goes with ACK and proper seq
Without change to add ACK to FIN, invalid TCP packet is generated,
where ack sequence number is non-zero. Without adjusting sequence
number as done, ACK which we send in response to peer's FIN/ACK is
not recognized by peer, and peer keeps retransmitting its FIN/ACK.

Jira: ZEP-2104

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-05-18 10:56:11 +03:00
Jukka Rissanen 6f25eb097e net: conn: Remove unregistered connection from cache
When connection handler was unregistered, we did not remove
it from cache. This caused invalid connection to be passed to
net_context after connection unregister if connection caching
was enabled.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-05-18 10:55:17 +03:00
Jukka Rissanen 69b25c0788 net: conn: Check UDP and TCP checksum before accepting packet
We did not check UDP or TCP checksum to be valid after receiving
the packet. Fix this so that the checksum is validated when
packet is received in connection handler. As the checksum validation
can be resource intensive, do it after we have verified that
there is a connection handler for this connection.

The checksum calculation can be turned OFF if needed, but it is
ON by default.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-05-18 10:53:39 +03:00
Jukka Rissanen 6c60603a9f net: context: Shorten too long line
The commit "net: tcp: Handle retransmitted packets from peer"
introduced over 80 character line that was missed in review.
Fixing it now.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-05-17 16:55:02 +03:00
Jukka Rissanen bddacf6a7f net: stats: IPv6 multicast listener daemon stats not printed
The MLD statistics were collected but never printed.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-05-17 13:55:21 +03:00
Jukka Rissanen e5257ae790 net: stats: Activate RPL and MLD stats if needed
If user has enabled RPL and STATISTICS, then enable RPL
statistics by default as that is probably what user want.
Same thing for MLD statistics.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-05-17 13:55:21 +03:00
Jukka Rissanen 9f1c7ffa5d net: stats: Add UDP checksum stats update function
A function updating UDP checksum failure statistics was missing.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-05-17 13:55:21 +03:00
Jukka Rissanen e253dcbd3b net: tcp: Add TCP statistics support
We did not collect any TCP statistics before but this commit
changes that.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-05-17 13:55:21 +03:00
Paul Sokolovsky 7a1a9a7946 net: tcp: Handle retransmitted packets from peer.
When we receive a packet with the sequence we already seen (and
processed), the most likely cause of it is that our ACK was lost,
and peer has to retransmit that packet. Then, we should just ACK
it, because otherwise peer will retransmit it again and again,
falling into exponential backoff and hosing the entire TCP
connection.

This makes changes to send_ack(), adding a flag to force sending
an ACK regardless of its cached status, and remove inline modifier,
as the function is big and called from many places.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-05-17 10:34:11 +03:00
Jukka Rissanen c6fcda19a3 net: tcp: Always set ACK bit in RST packet
Set the ACK bit in every RST packet as that seems to be expected
by Linux for example.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-05-17 09:36:02 +03:00
Jukka Rissanen 00b4081da3 net: tcp: Handle case when RST is received in any state
We must check if we receive RST in any of the TCP states.
If we do not do this, then the net_context might leak as it
would never be released in some of the states. Receiving RST
in any TCP state is not described in TCP state diagram but is
described in RFC 793 which says in chapter "Reset Processing"
that system "...aborts the connection and advises the user and
goes to the CLOSED state."

We need to also validate the received RST and accept only those
TCP reset packets that contain valid sequence number.

The validate_state_transitions() function is also changed to
accept CLOSED state transition from various other states.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-05-17 09:34:51 +03:00
Paul Sokolovsky e4a5e35b28 net: if: net_if_get_default: Return NULL if no interfaces configured
net_if_get_default() was documented as returning "Default interface
or NULL if no interfaces are configured.", but actually didn't
return NULL in the latter case. Instead, it effectively returned
a pointer to random area of memory, shared with other system
structures, so calling functions like net_if_ipv4_set_netmask(),
etc. could trash unrelated memory.

Jira: ZEP-2105

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-05-16 14:32:58 +03:00
Paul Sokolovsky 72a30f3843 net: tcp: Add TCP sequence number comparison compliant with RFC793.
RFC793, "Transmission Control Protocol", defines sequence numbers
just as 32-bit numbers without a sign. It doesn't specify any adhoc
rules for comparing them, so standard modular arithmetic should be
used.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-05-16 14:29:17 +03:00
Jukka Rissanen 43b37cef31 net: conn: Check duplicate UDP/TCP connection handlers
When a new UDP or TCP connection handler is to be registered,
we need to check if identical handler has already been created.
If a duplicate is found, the registering call will return -EALREADY.

The earlier code did not check this but allowed two identical
handlers to be created. The latter handler was never called in
this case.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-05-13 14:30:58 -04:00
Jukka Rissanen c77460da53 net: pkt: Add function to linearize a network packet
This helper copies desired amount of data from network packet
buffer info a user provided linear buffer.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-05-13 14:30:58 -04:00
Andrew Boie 7a0782d8ee net: use k_thread_create()
Common code in include/misc/stack.h is now used for analysis.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-05-11 20:24:22 -04:00
xiaorui hu cffb79a4e1 net: context: set tcp app data len when sending packets
When we send TCP data segment, we need to set the length
of the application data by calling net_pkt_set_appdatalen().
This is done so that sequence number can be properly
advanced when we receive ACK to that pending packet.

Signed-off-by: xiaorui hu <xiaorui.hu@linaro.org>
2017-05-08 08:07:41 -04:00
David B. Kinder f930480e16 doc: misspellings in Kconfig files
fix misspelling in Kconfig files that would show up in configuration
documentation and screens.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-05-05 19:38:53 -04:00
Luiz Augusto von Dentz 08eb5fc428 net: bt: Fix not setting lladdr type
When adding link-local address to the cache the type needs to be
properly set as net_ipv6_addr_create_iid will attempt to use it
when generating the IPv6 address.

Jira: ZEP-2077
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2017-05-03 08:48:24 -04:00
Jukka Rissanen 6a52a30b7d net: tcp: Mark ACK timer as cancelled
This is related to commit "net: tcp: Make sure ACK timer is not
run if cancelled" which did not set the cancel flag when the timer
was cancelled from tcp.c.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-05-03 08:48:24 -04:00
Tomasz Bursztyka e0a643591d net/net_if: Do not start TX thread if there is no network interface
And print a warning if that happens.

This will also avoid to raise an ASSERT on net_if_tx_thread()'s k_poll
as this one will be called with no events to work with.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-05-03 08:41:57 -04:00
Paul Sokolovsky ff3b019054 net: shell: Make shell commands non-static to allow reuse.
Some applications may want to reuse implementations of these
commands for debugging/diagnostics purpose even if they don't
use net shell per se, or implement an alternative shell.

Jira: ZEP-2064

Change-Id: I48cb66ccc41bd41a75a4eb8eb3c366316ec5a096
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-04-28 15:01:12 +03:00
Ravi kumar Veeramally ead481a041 net: rpl: Fix invalid usage of router addition api
net_if_ipv6_router_add() will return router pointer on success.
This information must be cached in RPL instance, otherwise RPL
instance doesn't know about default route.

Change-Id: Ic6d80ebfa95c9a64df9adf2621ae2631d9bdb990
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-04-28 15:01:11 +03:00
Ravi kumar Veeramally 5edf55f771 net: rpl: Fix router when it's timer expires
When router or default router timer expired, interface will remove
router from the list. In this case RPL does not know about this.
When RPL node receives DIO messages it only verifies whether parent
exists or not. This extra checks will verify whether router really
in "used" state or not.

Jira: ZEP-2080

Change-Id: I4b36b3a2d495e76a38caddd058451daff08fab0c
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-04-28 15:01:11 +03:00
Ravi kumar Veeramally d9bde9a5ab net: ipv6: Use correct API to remove router
net_if_ipv6_router_rm() is the correct API to remove IPv6 router
from the interface as it also cancels the timer and raises a mgmt
event. The net_if_router_rm() only sets router as unused and
nothing else.

Change-Id: I55114288c9ae748520b67b206edcd4f5e420b1af
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-04-28 15:01:11 +03:00
Luiz Augusto von Dentz 86a72e1ed4 net: bt: Fix leaking TX packets
Bluetooth only cares about the actual payload so net_pkt can be unref
as soon as the data fragments are detached.

Jira: ZEP-2070
Change-Id: Id528d5440f42903378883f5e696b3f663bbfa313
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2017-04-28 15:01:10 +03:00
Paul Sokolovsky 25307d5331 net: net_pkt_append: Refactor to return length of data actually added
For stream-based protocols (TCP), adding less data than requested
("short write") is generally not a problem - the rest of data can
be sent in the next packet. So, make net_pkt_append() return length
of written data instead of just bool flag, which makes it closer
to the behavior of POSIX send()/write() calls.

There're many users of older net_pkt_append() in the codebase
however, so net_pkt_append_all() convenience function is added which
keeps returning a boolean flag. All current users were converted to
this function, except for two:

samples/net/http_server/src/ssl_utils.c
samples/net/mbedtls_sslclient/src/tcp.c

Both are related to TLS and implement mbedTLS "tx callback", which
follows POSIX short-write semantics. Both cases also had a code to
workaround previous boolean-only behavior of net_pkt_append() - after
calling it, they measured length of the actual data added (but only
in case of successful return of net_pkt_append(), so that didn't
really help). So, these 2 cases are already improved.

Jira: ZEP-1984

Change-Id: Ibaf7c029b15e91b516d73dab3612eed190ee982b
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-04-28 15:01:09 +03:00
Jukka Rissanen 3051fc2035 net: rpl: Do not crash if DIO message contains garbage
Instead of just plain assert, check that the packet we receive
is ok before passing it to processing function.

Jira: ZEP-2057

Change-Id: I5754c82d16e1522d8fcee561eea280eadeec31ee
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-28 15:01:09 +03:00
Jukka Rissanen 52d0589c1f net: tcp: Fix TCP trace value debug
The TCP trace values were not printed because of incorrect
config option used. Print also seq and ack values in decimal
in order to make it easier to correlate the values in other
prints in tcp.c.

Change-Id: I44d1535a84dcba8c6c937d348516ba801193ca23
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-28 15:01:09 +03:00
Andrei Emeltchenko 65c002b8ce net: security: Use sys_put_be32() relevantly
Use ready-made utility function which can take care of endianness

Change-Id: I1edd0b2ce1a086dd637e97308145f9b434e48a1f
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2017-04-28 15:01:09 +03:00
june li 3e4faffede net: l2: Clear arp cache when disable interface.
When connect to diffrent router with the same gateway ip address,
need to clear arp cache when disable interface,
or it will use the wrong gateway mac address.
Call net_arp_clear_cache function replace to set arp_table 0.

Change-Id: Ib403a0c0030832ba48824db4d2d3fcb8add63d16
Signed-off-by: june li <junelizh@foxmail.com>
2017-04-28 15:01:08 +03:00
David B. Kinder 61de8f892b spell: Kconfig help typos: /kernel /misc /subsys
Fix misspellings in Kconfig help text

Change-Id: I6eda081c7b6f38287ace8c0a741e65df92d6817b
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-04-22 01:04:56 +00:00
Kumar Gala a509441210 net: convert to using newly introduced integer sized types
Convert code to use u{8,16,32,64}_t and s{8,16,32,64}_t instead of C99
integer types.

Jira: ZEP-2051

Change-Id: I4ec03eb2183d59ef86ea2c20d956e5d272656837
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-21 09:30:38 -05:00
Jukka Rissanen af1e3b9d32 net: shell: Fix compiler error when printing conn handlers
There was compiler error if CONFIG_NET_DEBUG_CONN was set.

Change-Id: Ibb6721c55dd2c56cd0097359a53563c6221859ea
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-21 15:44:22 +03:00
Jukka Rissanen d8dd91d7bf net: context: Connect callback was set too late
We need to set the connect_cb for the context before sending SYN packet.
This is required if we have a loopback connection in which case everything
is happening more or less synchronously and the connect_cb would not be
called in this case because its value would still be null.
For remote network connections this patch makes no difference.

Change-Id: Id7f837cd9e81cd79c4666c98cae84f6cb1a77af0
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-21 15:44:22 +03:00
Jukka Rissanen 1bf14853aa net: tcp: Make sure ACK timer is not run if cancelled
We must not let ACK timer to run if we have already cancelled it.
So keep track that the timer is cancelled and refuse to run it
if it was indeed cancelled. The reason why the timer might be run
in this case is because the timer might be scheduled to be triggered
after which one cannot cancel it.

Change-Id: I1c8b8cee72bc7a644e02db154d9d009b8d98ade2
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-21 14:19:52 +03:00
Jukka Rissanen 137e4e7256 net: context: Set the local port correctly in accept
The local port was set to 0 for IPv6 when registering
the connection handler. For IPv4, the code was not setting
the port in local_addr struct.

Change-Id: I82f0c08641a94d75d255ac306eca7bec6c332fba
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-21 14:19:52 +03:00
Jukka Rissanen a1c4f3fbd5 net: Print debug info if packet is loopback back to us
Without this info it is a bit difficult to notice what is going
on in loopback case.

Change-Id: I8f61330c01d025e41f00d663bd26947b8cafb5c0
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-21 14:19:51 +03:00
Jukka Rissanen a71a9f9ad1 net: conn: Utility to print connection handlers
Add support to print connection handler information in net-shell.
There exists one connection handler for each UDP/TCP port that we
are listening. These prints are only available if CONFIG_NET_DEBUG_CONN
is enabled because the net_context has the same information. Thus the
connection handler info is only printed if debugging is active in order
to verify that handler information is proper.

Change-Id: I0be39a5adb89b2cdbd85524c5d943e4a562b0fde
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-21 14:19:51 +03:00
Jukka Rissanen f498a90b77 net: pkt: Make the debug print eye friendly
Print "pkt" instead of "Pkt" when printing network packet
pointer value.

Change-Id: Id4225be9c55807def3d892d372cdfc5c79c871fc
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-21 14:19:51 +03:00
Jukka Rissanen 52339cdf5a net: tcp: Avoid unused variable compiler warning
If TCP debugging is enabled but if the loglevel is set to lower
than 4, then compiler prints warning about unused flags variable
in net_tcp_trace().

Change-Id: I2e663644b50fe97b75088202e21b286aa010953e
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-21 14:19:51 +03:00
Tomasz Bursztyka f3ff4f7bd3 net_pkt: Let's make all IPv6 related attributes prefixed with ipv6_
Only 2 attributes lacked this prefix, which makes sense to have, so
applying it accordingly and changing the helpers as well.

Change-Id: I095b2729f977f8fb1624eff8801a4a4e21416693
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-04-21 14:19:51 +03:00
Tomasz Bursztyka e5896906f6 net: Rename all *_BUF() macros to *_HDR()
Most of these macros are not exactly exposing a buffer, but a specific
header pointer (ipv6, ivp4, ethernet and so on), so it relevant to
rename them accordingly.

Change-Id: I66e32f7c3f2bc75994befb28d823e24299a53f5c
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-04-21 14:19:51 +03:00
Tomasz Bursztyka c18016b69b net_pkt: Externalize ext_bitmap handling
IPv6 next headers are processed in a way so it is not required to store
which header has been already seen in the net_pkt, as the processing loop
can store internally which one it has seen already.

Change-Id: I266ba8a3a0081a162318cdafb474a0fc44a3185e
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-04-21 14:19:50 +03:00
Tomasz Bursztyka 2e331de690 net_pkt: Removing legacy net_dir
This is actually useless as there is only 1 RX memory slab, and thus can
be removed to reduce net_pkt structure size.

Change-Id: I62d716515120e7356ee1e2d75bbe1ec32e22c35d
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-04-21 14:19:50 +03:00
Tomasz Bursztyka db11fcd174 net/net_pkt: Fully separate struct net_pkt from struct net_buf
- net_pkt becomes a stand-alone structure with network packet meta
  information.
- network packet data is still managed through net_buf, mostly named
  'frag'.
- net_pkt memory management is done through k_mem_slab
- function got introduced or relevantly renamed to target eithe net_pkt
  or net_buf fragments.
- net_buf's sent_list ends up in net_pkt now, and thus helps to save
  memory when TCP is enabled.

Change-Id: Ibd5c17df4f75891dec79db723a4c9fc704eb843d
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-04-21 14:19:50 +03:00
Tomasz Bursztyka bf964cdd4c net: Renaming net nbuf API to net pkt API
There have been long lasting confusion between net_buf and net_nbuf.
While the first is actually a buffer, the second one is not. It's a
network buffer descriptor. More precisely it provides meta data about a
network packet, and holds the chain of buffer fragments made of net_buf.

Thus renaming net_nbuf to net_pkt and all names around it as well
(function, Kconfig option, ..).

Though net_pkt if the new name, it still inherit its logic from net_buf.
'
This patch is the first of a serie that will separate completely net_pkt
from net_buf.

Change-Id: Iecb32d2a0d8f4647692e5328e54b5c35454194cd
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-04-21 14:19:50 +03:00
Andrei Emeltchenko 9bf3ea071a net: shell: Correct print format specifier
Fix warning using incorrect format specifier

Change-Id: Ib6800c40b2cd769612ae6f107e41a941926d8e66
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2017-04-21 14:19:50 +03:00
june li 504b273b85 net: tcp: Do buf ref when resending a segment
We need to check whether buf_sent was true when resending the TCP
segment, and do a buf ref if needed. If this is not done, the buf
will be unref after send, which will cause unpredictable results.

Change-Id: Ibd4490305de88ac6ffd04ec42bba196e57da5c10
Signed-off-by: june li <junelizh@foxmail.com>
2017-04-21 14:19:50 +03:00
Jukka Rissanen 7ce82fea82 net: ipv6: Make sure not to access null pointer
While very unlikely it might happen that fragment pointer is NULL
when going through fragment list.

Coverity-CID: 167148

Change-Id: Ic3dbed7ee29c7b864d4830d726f65d7f62dcea84
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-21 14:19:49 +03:00
Ravi kumar Veeramally 2f73c324aa net: rpl: Fix rpl header update
When net_ipv6_finalize_raw() inserts RPL(HBH) header after IPv6 header,
it updates IPv6 next header as HBH and HBH next header as original IPv6
next header.

Then net_ipv6_prepare_for_send() will update RPL HBH header if it exists.
But net_rpl_update_header() is comparing HBH option and IPv6 next header,
which is wrong. Wrong comparion does not update RPL instance id and
sender rank. Peer nodes drops all the packets due to invalid instance
ID and sender rank.

Change-Id: I91c1870a09c60f8e1ebc73e434dcc208caf6299a
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-04-21 14:19:49 +03:00
Mitul Shah d27ca378b6 net: context: Fixing bug in net context put flow
Following flow does not work:
net_context_get
net_context_bind
..
..
net_context_put
net_context_get
net_context_bind

At instance of call to net_context_bind, conn_handler
is not NULL and returns with EISCONN.

This patch sets conn_handler to NULL in net_context_unref

Change-Id: I56a50839101b22161644b3cd7c5f510fa1abae3e
Signed-off-by: Mitul Shah <mitul.a.shah@intel.com>
2017-04-21 14:19:49 +03:00
Paul Sokolovsky 52e3e5c68d net: shell: conn: Dump local/remote ports for contexts.
Without port numbers, information printed by net shell's "conn" command
is unclear and non-differentiating. Also, improve handling of unknown
address families - don't abort early, still pring context address, iface
address, etc.

Example of "conn" output with these changes from echo_server sample:

net> conn
     Context   	Iface         Flags Local           	Remote
[ 1] 0x001126e0	0x001121a0    6DU   [::]:4242	[::]:0
[ 2] 0x00112738	0x001121a0    4DU   0.0.0.0:4242	0.0.0.0:0
[ 3] 0x00112790	0x001121a0    6ST   [::]:4242	[::]:0
[ 4] 0x001127e8	0x001121a0    4ST   0.0.0.0:4242	0.0.0.0:0

TCP        Src port  Dst port   Send-Seq   Send-Ack  MSS    State
0x00112b00     4242         0  497073352          0  1280
0x00112b98     4242         0  497543793          0  1460

Change-Id: I2f03efd933979b5571f608c28a7a7a4bd7f5346a
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-04-21 14:19:49 +03:00
Kumar Gala 789081673f Introduce new sized integer typedefs
This is a start to move away from the C99 {u}int{8,16,32,64}_t types to
Zephyr defined u{8,16,32,64}_t and s{8,16,32,64}_t.  This allows Zephyr
to define the sized types in a consistent manor across all the
architectures we support and not conflict with what various compilers
and libc might do with regards to the C99 types.

We introduce <zephyr/types.h> as part of this and have it include
<stdint.h> for now until we transition all the code away from the C99
types.

We go with u{8,16,32,64}_t and s{8,16,32,64}_t as there are some
existing variables defined u8 & u16 as well as to be consistent with
Zephyr naming conventions.

Jira: ZEP-2051

Change-Id: I451fed0623b029d65866622e478225dfab2c0ca8
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-20 16:07:08 +00:00
David B. Kinder 0ffb648210 spell: fix doxygen comment typos: /subsys
Fix doxygen comment typos used to generate API docs

Change-Id: I3efff6f5fa26f87d1e658d6336fef01ce45f5bb0
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-04-19 18:44:06 +00:00
Bogdan Davidoaia 290e1d8451 net: use UNALIGNED_GET/PUT to access IP address
Use UNALIGNED_GET and UNALIGNED_PUT throughout the networking stack to
access fields from the IP address structure. These structures can be
mapped directly to buffers and the macros are required for correct
unaligned memory access.

Jira: ZEP-2012

Change-Id: I55f9da7b143a22fa869d5d215c661de988cd9b91
Signed-off-by: Bogdan Davidoaia <bogdan.davidoaia@linaro.org>
2017-04-13 15:21:46 +03:00
Tomasz Bursztyka 987df43ba5 net/ieee802154: Add ieee15_4 shell module functions to set/get tx power
Change-Id: I1245686118daa1c81691694b4b4c1512847beca0
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-04-13 15:21:46 +03:00
Tomasz Bursztyka 3a3636ff7f net/ieee802154/samples: Add a Kconfig option to tweak the TX power
This can be useful to override the default value, for testing.

Change-Id: I23b559152c71955ff5aa6fd3643f1f40f5594194
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-04-13 15:21:46 +03:00
Tomasz Bursztyka 26b5f94a79 net/ieee802154: Add a Kconfig option to set a default tx power
Change-Id: Ife2af22c13954286d8e44c3e0b1f60962c617c52
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-04-13 15:21:46 +03:00
Tomasz Bursztyka 951294f15e net/ieee802154: Expose TX power setting through net mgmt API
This permits to tweak the TX power in dbm.

Change-Id: Idadff397941a39010ce3c374d9ca74b777934626
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-04-13 15:21:46 +03:00
Tomasz Bursztyka 63619b503f net/ieee802154: Fixing a typo in net_mgmt settings accessor
s/SET/GET obviously

Change-Id: Ibaad65f846fef8b1b7839616b2022fad6548612a
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-04-13 15:21:45 +03:00
Jukka Rissanen f8c9439908 net: if: Reshuffle fields in net_if and related structs
This does not save any space but sets the fields in the
structs in more natural order. Move IPv6 related
fields in net_if into internal ipv6 struct so that all
IPv6 fields are located inside one struct. Same thing
is done for IPv4 fields which are now located inside
IPv4 internal struct in net_if.

There is no functionality changes by this commit.

Change-Id: I7d72ec0a28e2b88c79a4c294655d5ef6da6ccb25
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-13 15:21:45 +03:00
Tomasz Bursztyka 62b710384d net/ieee802154: aux sec header frame counter is in little endian
So manipulating it requires to be ready to swap it if the CPU is BE.

Change-Id: I8d657c31cecfc9f3fcd010efbb6d090bf021f5f5
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-04-13 15:21:45 +03:00
Jukka Rissanen 57e128654b net: mgmt: Add IPv6 DAD succeed/failed event
We need a way to know when IPv6 address is successfully set
into network interface.

If IPv6 DAD (Duplicate Address Detection) succeeds or fails,
we send a management event for that. This can be used by
other components to detect when the network interface is in
usable state.

Change-Id: Ifb22415fe21f31f5dba4f55455d6e0f89b414d32
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-13 15:21:45 +03:00
Jukka Rissanen 528a393470 net: ipv6: Fix the constness of function parameters
Some of the IPv6 utility functions were missing const in
one of the parameters that are not modified by the corresponding
function.

Change-Id: Ic9fe53daac288570c14423fd9410dcf15d1c5cfa
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-13 15:21:44 +03:00
Luiz Augusto von Dentz 076ddacca5 net: ipv6: Rework net_ipv6_nbr_add
This makes net_ipv6_nbr_add able to update entries so it can be reused
when receiving RA or NS requests, so it now performs a lookup before
creating a new entry (using nbr_new to reuse more code) and in case it
finds a match attempts to update the lladdr.

Change-Id: I305a67a955e037cbbb862fef947a5fcfe131507c
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2017-04-13 15:21:44 +03:00
Luiz Augusto von Dentz 8b23e3e984 net: ipv6: Fix not initializing delayed work
net_ipv6_nbr_add shall init the delayed work as nbr_new does, so this
unifies both codes into nbr_init which does take care of initializing
the fields properly.

Change-Id: I91746276d346a3dc3c36be20d49bcf1968245fc5
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2017-04-13 15:21:44 +03:00
Jukka Rissanen 07438ead0d net: shell: Fix printk format for multicast routes
Route lifetime was printed using wrong modifier.

Change-Id: Ib503d50b5817491984d51bbdaadf7457fdde178b
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-13 15:21:44 +03:00
Jukka Rissanen d1ac3d6914 net: rpl: Fix compilation if MRHOF is enabled
Make sure the RPL is compiled ok if CONFIG_NET_RPL_MRHOF is
enabled in the configuration.

Change-Id: I51fc0e20f854164c7e0374fa6a1ebf1d4e4dbc5b
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-13 15:21:44 +03:00
Jukka Rissanen 43847e751d net: rpl: Fix compilation if CONFIG_NET_RPL_MOP3 is enabled
If multicast routing is set meaning that MOP3 (Mode of Operation)
is enabled, then the code was not compiling properly.

Change-Id: Ice8a9f7b705c781536d3c2c5ca6cc2bb77a7acc1
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-13 15:21:44 +03:00
Jukka Rissanen c7102c77a2 net: route: Fix compilation error
Change-Id: Ib4ed6fffe637ac9cd67ce4685d540730c26c8339
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-13 15:21:44 +03:00
Jukka Rissanen 42bd36ec77 net: ipv6: Allow user to tweak packet hop limit value
The default hop limit is defined in struct net_if. It is possible
that user might want to tweak it for each network packet. For this
purpose, a net_nbuf_set_ipv6_hop_limit(buf) function is created.

Change-Id: I7568330358f80f0f5007d6d3c411c120b043c04f
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-13 15:21:43 +03:00
Jukka Rissanen 31d3406efa net: rpl: Fix the statistics collection
The Kconfig.rpl file was missing option to actually collect
RPL statistics. Unified the config option name to be
CONFIG_NET_STATISTICS_RPL as there was two conflicting settings
in the code and both of them were missing from Kconfig file.

Change-Id: I4ce4fcbaa317b36cac315ea3b3f710fa7a344b25
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-13 15:21:42 +03:00
Jukka Rissanen dc9f8629b2 net: rpl: Add checks for probing timer
The probing_timer is only available if CONFIG_NET_RPL_PROBING
is defined.

Change-Id: I2835d17e6c3d616f815f8beefd87d2571a5ad94c
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-13 15:21:42 +03:00
june li 961d7fc8f4 net: tcp: Release buf after failing to send
After failing to send the buf we need to release it.
This is not done for Bluetooth or IEEE 802.15.4 links which
create a copy of the sent buf and the failure case is already
checked by net_tcp_send_buf().

Change-Id: Ia556376b58ad74f68accb64eb2221a78d59dc2ec
Signed-off-by: june li <junelizh@foxmail.com>
2017-04-13 15:21:42 +03:00
Bogdan Davidoaia 8f97651d23 net: use UNALIGNED_GET in net_addr_ntop
Use UNALIGNED_GET in net_addr_ntop as the uint16_t pointer used in this
function can point to an unalined address.

Jira: ZEP-2012

Change-Id: Idfbfa8da4c8d4e10299c4ae4d6431b10466cc988
Signed-off-by: Bogdan Davidoaia <bogdan.davidoaia@linaro.org>
2017-04-13 15:21:42 +03:00
Jukka Rissanen 70cdaba202 net: shell: Add IPv6 fragmentation info printing
If the IPv6 fragmentation support is enabled, then print current
status of the IPv6 packet reassembly in "net conn" command.

Change-Id: I384e35928b67dd39ac720c77683b1767e2a1ce88
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-13 15:21:42 +03:00
Jukka Rissanen d8feb0a0e4 net: ipv6: Add helper to get the last extension header
Figure out what is the last extension header in IPv6 packet
and return offset to it. This is needed by IPv6 fragmentation
when fragmentation header is added to the packet.

Change-Id: I925ab806a5de076a425ff354711730d4f4b3c52f
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-13 15:21:41 +03:00
Jukka Rissanen ea17e9d321 net: ipv6: Support fragmented IPv6 packets
This commit adds support for IPv6 packet fragmentation when
receiving (IPv6 reassembly) and when sending larger than 1280 bytes
long IPv6 packet. See RFC 2460 chapter 4.5 for more details.

Jira: ZEP-1718

Change-Id: Ia31c147cce4d456ee48f39276cca99aa09ce81d6
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-13 15:21:41 +03:00
Jukka Rissanen 1b2c16a498 net: nbuf: Add function to split a data fragment
Add net_nbuf_split() function that can be used to split
an existing net_buf fragment into two arbitrary length pieces,
and return the two new fragments to the caller. The data from
the original fragment is copied into these two new fragments.

Existing fragment is not modified.

Change-Id: I463e675232c6e19c2a42929f480893a6d1265873
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-13 15:21:41 +03:00
Jukka Rissanen 7a07f23da7 net: tcp: Store MSS in tcp header correctly
Use UNALIGNED_PUT() to store the MSS value into network packet
because the memory location cannot be guaranteed to be properly
aligned.

Change-Id: I77fd7a70ef45eedb657cac29457b0239b0a1d4c2
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-13 15:21:41 +03:00
Anas Nashif c574dde9a5 kconfig: fixed name of Kconfig option in comment
Change-Id: Iae95d06e3a01bee62ea2160b9640722d2bfc3c41
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-04-10 16:07:22 +00:00
Jukka Rissanen 749b439863 net: icmpv6: Print received packet type as string
This helps debugging as printable string of the ICMPv6 type is
printed when packet is received if debugging is active.

Change-Id: I22b84bb6b28db7fba030699af3e561a0775b53d2
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-07 18:32:19 +03:00
Tomasz Bursztyka 8bbe03f35b net/core: Fix wrong parameter usage for check_unknown_option()
It requires a net_nbuf, so the actual buf, and not a frag here.

Change-Id: I4fd888c9a91f5e3f3dd664ae5e3bf93f90a2f597
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-04-07 18:32:19 +03:00
Jukka Rissanen 3e99c2ea0c net: Move IPv4 packet handling from net_core.c to ipv4.c
This will refactor net_core.c and move IPv4 specific code
into ipv4.c which is a more logical place for it.

Change-Id: Ia60c5bfec488d2d1a664f113dc3df88e7d5badd1
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-07 18:32:18 +03:00
Jukka Rissanen d43494d187 net: Move IPv6 packet handling from net_core.c to ipv6.c
This will refactor net_core.c and move IPv6 specific code
into ipv6.c which is a more logical place for it.

Change-Id: I5bbecbb760111326b9a6bbef5802c53d7f6efda9
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-04-07 18:32:18 +03:00
Tomasz Bursztyka 1ab40390c9 net/arp: Return relevant verdict if the ARP packet was consumed
DROP is only on error case, here it should return NET_OK if it was a
proper ARP packet and it got properly handled.

Change-Id: If347e80a76b3a56a9455b70d11b735c1fd910117
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-04-07 18:32:18 +03:00
Luiz Augusto von Dentz 4d1115ab35 net: Enable context buffer pool in case TCP and 6LO are enabled
The context buffer pool was introduced to deal with TCP holding buffers
when 6LO may modify them, therefore it makes sense to have it enabled
by default when TCP and 6LO are enabled given that the code can deal
with NULL pool in case the application don't implement one.

Change-Id: I600ca31ab40c96ee27937c2e885e332b0cee4995
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2017-04-07 18:32:18 +03:00
Luiz Augusto von Dentz c53b43e4d5 net: ip: Increase RX stack size
RX stack overflow when dealing with TCP over Bluetooth/6lo setup:

RX [rx_stack] stack size 1200/1264 bytes unused 0 usage 1200/1200 (100 %)

Change-Id: I8d5e43faf93f675960e59d9340b97d1ce9fc082a
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2017-04-07 13:33:55 +03:00
Ravi kumar Veeramally 8ce12d5fe8 net: shell: Fix crash when retrieving remaining reachable time
Shell crashes if you try to retrieve IPv6 nbr reachable time
when CONFIG_NET_IPV6_ND is disabled.

Change-Id: I3c5b3b5614abf80373b892943fa1ab936d235f3c
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-04-07 12:35:51 +03:00
Ravi kumar Veeramally 7a6f976725 net: rpl: Return valid verdict
Return proper verdict on handling of DIS messages. Otherwise debug
prints will be confusing that packet dropped.

Change-Id: Ia4e18d6238868e3aed4b17e2c9ea11aa432869be
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-04-07 12:35:51 +03:00
Ravi kumar Veeramally 7ff7f58771 net: rpl: Refactor few rpl functions
No functionality changes, just refactored few rpl functions to
to align nicely.

Change-Id: I05c0397de7a8392cc781de2747802b2dd1bb8146
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-04-07 12:35:51 +03:00
Paul Sokolovsky a745832dc4 net: Elaborate output of net_nbuf_print_frags() to be more useful.
Following changes are made:

1. Output using NET_INFO logging level. This function is not part of
automatic logging, and must be called explicitly by a user application.
But if it outputs using NET_DEBUG, then DEBUG level needs to be
enabled, and the output of this function will be drowned in logging
spam. So, let user to enable just INFO level.

2. Show entire structure of the fragment chain, *including* the head
net_buf which holds net_nbuf structure. It is numbered as -1 in the
output to preserve existing order (and not change existing size
calculations).

3. Show owning pool (and its properties, like buffer size/user_data
size) for each buffer.

4. Check for NULL pointer, e.g. for convenience of calling directly
from net_context receive callback (which will be called with NULL
on TCP peer closed connection event).

With these changes, a newcomer from one look at the output of this
function will be able to have a clear basic picture of network
buffer management in Zephyr, and recurring user will be able to
recall any details at once.

Change-Id: I8f9562748329d749f765cc6af7989a448256d7e0
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-04-07 12:35:50 +03:00
Ravi kumar Veeramally 2a00f418f0 net: rpl: Refactor net_rpl_update_header function
No functionality changes, just refactored net_rpl_update_header
function to align nicely.

Change-Id: I5b3e099593bb964245ca06c9fb2ec85859a0640c
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-04-07 12:35:50 +03:00
Ravi kumar Veeramally 3e78d38f01 net: event: Add events for ROUTE ADD and DEL
Change-Id: I1d8cb1aebe8a6eb224f6103db0679000bb57c187
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-04-07 12:35:50 +03:00
Ravi kumar Veeramally bcc53c6157 net: route: Update IPv6 packet routing mechanism
Search destination address in IPv6 neighbor table. If it doesn't
exist in IPv6 neighbor table then go for routing. Added sanitycheck
to verify destination ll address is not the source ll address of
original packet (that means we are re-routing back to original sender).

Change-Id: I24adace6a0d17fbd1d2a36a5d75c79320de0a883
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-04-07 12:35:50 +03:00
Ravi kumar Veeramally 6cec42d792 net: route: Fix retrieving route nexthop
net_ipv6_nbr_lookup_by_index() will always find first matching entry
in IPv6 nbr table with lladdr index. But there can be multiple neighbors
linked to same lladdr index. So find route nexthop with ipv6_nbr_data
from nbr(ipv6 nbr) data pointer.

Change-Id: I5081d40330f5bc1ef0d96def03f4add4808b2fe9
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-04-07 12:35:50 +03:00
Ravi kumar Veeramally 3ebe644dd5 net: if: Fix missing submission of router lifetime timer
Router lifetime timer initialized in router_init but not submitted.

Change-Id: If5a77f413832db52eff99e7191f82d2a8fc8f081
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-04-07 12:35:50 +03:00
Ravi kumar Veeramally d07ca1d518 net: nbr: Fix miss calculation of nbr size
Extra data size was not considered in nbr size calculation.

Change-Id: Idc572abf55c8f9fd19940edb719f58e02e7f8ecd
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-04-07 12:35:50 +03:00
Ravi kumar Veeramally e0bfa15f8d net: rpl: Move net_route_lookup to proper place
Route lookup is necessary only if life time is
NET_RPL_ZERO_LIFETIME, otherwise lookup not required.

Change-Id: I25fb85c53e2d43cfdce08411af385f3ae26384cc
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-04-07 12:35:50 +03:00
Ravi kumar Veeramally f6af085a4b net: rpl: Add support for DAO retransmissions
If DAO message is routed through different nodes or sent directly
to a parent and ACK lost somewhere in noicy network. Node can not
join RPL mesh network properly. So try re-sending DAO message for
max number of trials (Kconfigurable).

Change-Id: I7f6a065deacd1e3942c89118ce8da4fbaa34af51
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-04-07 12:35:50 +03:00
june li 86cc447f38 net: tcp: Start retry timer when queueing data
When sending TCP data, check if the retry timer needs
to be started.

Change-Id: Iea90716e918dec0b22e60bf32467b11c0d1a296f
Signed-off-by: june li <junelizh@foxmail.com>
2017-04-07 12:35:49 +03:00
Tomasz Bursztyka 8108a608ff net/mgmt: Mask vs event should be verified part by part
It needs to check if current event matches:

- cb's layer
- cb's layer code
- cb's command

If none match, it will not raise the event.

Fixing the unit test as layer must be always != 0.

Jira: ZEP-1940

Change-Id: Iadd63e751fa6e534a10e7da9cae0f5bb5a384461
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-31 12:15:29 +00:00
Tomasz Bursztyka dc7be7c54f net/ieee802154: Disable ACK reply handling by default
Most (if not all) 802.15.4 devices can handle ACK replies by
themselves.

Change-Id: I0319d59de767b20eb67c1592bacaa4a7b7015cad
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-31 11:24:28 +02:00
Tomasz Bursztyka e716b4dcb0 net/ieee802154: Use context instead of interface to reduce stack usage
Now that interface is not directly used in data and mac frame creation,
let's just pass context pointer.

Change-Id: If002e6790d044eeffc57cb5685ac9525fbd6e43c
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-31 11:24:28 +02:00
Tomasz Bursztyka 0948149b92 net/ieee802154: Use context's extended address when generating frame
Now that RFD is default, the extended address can be changed through net
mgmt API, and thus no longer be the same as device's generated mac address.

Change-Id: I07ee647615c2caa1994712147c6c8a2b4306900d
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-31 11:24:28 +02:00
Tomasz Bursztyka 0df2a2fdbe net/ieee802154: Simplify data FS settings function signature
There is no need of interface anymore.
After previous changes, it appears that net_if parameter is not used so
we can remove it.

Change-Id: Id3570f50865696818a9be2280172e2e25fc537f7
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-31 11:24:28 +02:00
Tomasz Bursztyka 5e3354dad5 net/ieee802154: We don't get the MFR from device drivers
commit id 7a11439020 changed this.
Hopefully that changed did not affect anything.

Reducing minimal frame length and applying the change everywhere where
relevant.

Change-Id: I5ae203751bfcf70cef833620106d2c2d0e33b7a5
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-31 11:24:28 +02:00
Tomasz Bursztyka d2f8a5a27f net/samples: Add 802.15.4 link-layer security settings for the samples
And use them accordingly in the common code part.

Change-Id: Id91b76e5baea607c0d68eebcde6f84e4e35ca44c
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-31 11:24:27 +02:00
Tomasz Bursztyka e3c0310d98 net/ieee802154: Remove ORFD choice altogether.
ORFD was a hack, from the beginning of the IEEE 802.15.4 Soft MAC stack,
but is now useless and can therefore be removed.

Change-Id: I74d5e1995993f4a0749b6d9d553406d5ae162bda
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-31 11:24:27 +02:00
Tomasz Bursztyka 26a4df620f samples/net: Uses CONFIG_NET_APP_IEEE802154_* options relevantly
In order to simplify when 802.15.4 is selected on these samples, let's
setup the device through a common code.

For this to work, RFD is now the default.

Change-Id: I46590864442f77d83f681cc0e854c94344648856
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-31 11:24:27 +02:00
Tomasz Bursztyka 35dd54d1d7 net/ieee802154: Rename <SET/GET>_CHAN to <SET/GET>_CHANNEL
It's more readable and along with other part of the system.

Change-Id: Ib4be787d74310d838f38b1f1d5624e7357da8969
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-31 11:24:27 +02:00
Tomasz Bursztyka 1a647613a4 net: Add 802.15.4 useful Kconfig application settings
These should be used by samples to fix basic 15.4 settings.

Change-Id: I31ad1540008ac760b7aef720e520bf8e72d3a805
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-31 11:24:27 +02:00
Tomasz Bursztyka 0f18ce44f9 net: Rename Kconfig.samples and its main option for future changes
s/SAMPLES/APP for name shortening. Applying the change where relevant.

Not only IP addresse will be available as samples settings there but
also IEEE 802.15.4 channel, pan_id, and more for instance.

Change-Id: I05dd24989bd0c804d9588092d67044a3e063bc88
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-31 11:24:26 +02:00
Tomasz Bursztyka 98cace4a96 net/ieee802154: Expose auxiliary security header validation function
This will be needed for Thread/MLE.

Change-Id: Ib421da66cfc4da8111ff131f08cac74a11674928
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-31 10:39:33 +02:00
Tomasz Bursztyka e771f174e5 net/ieee802154: Add net mgmt requests to set/get security settings
These requests are used to set/get the key, the mode and the level of
the IEEE 802.15.4 link layer security.

Only implicit key mode is supported for now.

Change-Id: Ifbc9a5d08f9fbf0d51d6c3e4b650cfdce3d263db
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-31 10:39:33 +02:00
Tomasz Bursztyka 165f8b4d29 net/ieee802154: Integrate link-layer security relevantly
Initialize the ciphers.

Once the header is parsed and validated, we get all the necessary info
to decrypt the frame properly.

Change-Id: I3142fa572c7566b40efe18cf9d4e3f2b4bce0612
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-31 10:39:32 +02:00
Tomasz Bursztyka aa24613347 net/ieee802154: Provide the means to decipher data frames
It's not only about decrypting and authentifying but also setting the
right frag's length after that.

Change-Id: Ifc766b212b37d4e3593c210f6646ee85dff2ab6d
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-31 10:39:32 +02:00
Tomasz Bursztyka 5e115ba935 net/ieee802154: Provide the means to create secured data frames
Take into account the current security context to compute the header
size.

Provide the function to fill-in the aux security header in a frame.

Finally, call the generic encryption function which will process the
frame relevantly according to the given security context.

For now, only implicit key mode is supported.

Change-Id: I5412c32179e70217c0946b1b54d9a752375d522f
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-31 10:39:32 +02:00
Tomasz Bursztyka 9d78dba0a1 net/ieee802154: Add generic support for link layer cipher operations
This provides the means to authentify with/without encryption or
decryption of a frame following a generic 15.4 security context.

Change-Id: Ia5dbb7f43936a8131112fe4b16c9780e30f904c1
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-31 10:39:32 +02:00
Tomasz Bursztyka fb55449882 net/ieee802154: Normalize one parameter to make it clearer
Some call use a boolean for it, and since it's supposed to be 1 or 0
let's ask for a boolean always.

Change-Id: If4fbe5d58d5c25fb2a86719435c59af53ea02445
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-31 10:39:32 +02:00
Tomasz Bursztyka fb0e2d44ee net/ieee802154: Change function signature for future change
When applying security, there will be needs for accessing payload as
well, thus providing the whole frag directly instead of a data pointer
on the ll part.

Change-Id: Ia97a1f07f2a12fc5cdf085c3cc6350d50b419cae
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-31 10:39:32 +02:00
Tomasz Bursztyka 1ee5f3b578 net/ieee802154: Parse and validate auxiliary security header
This will ensure basic auxiliary security header fields are relevantly
filled-in as well as moving the parsing buffer pointer to the right
position for further parsing.

Change-Id: Ib09e312add783b13bf8b59a81a2ffe64eb6f8dc2
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-31 10:39:32 +02:00
Tomasz Bursztyka e089f14427 net/ieee802154: Add Auxiliary Security Header definitions
These will be used to parse and create 802.15.4 frames with security
enabled.

Change-Id: Icad214c8d7aa658b8483bf601b091b266e1b8d77
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-31 10:39:32 +02:00
Jukka Rissanen d593914b17 net: Check if sent packet is meant for us
If the destination IP address is one of our own address,
then reroute it back to us.

Jira: ZEP-1966

Change-Id: I8b93fc5425f3f18b0b9e85ca9a57cb122129c47f
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-03-31 10:58:17 +03:00
Jukka Rissanen 039e215233 net: shell: Fix the connection status output
The fields in "net conn" output were unaligned and looked
generally very ugly.

Change-Id: I56b29982d4f6b984405944d155bbb6c682383318
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-03-31 10:58:17 +03:00
Jukka Rissanen 11305ec928 net: nbuf: Do not crash if context pools are not in use
It is possible that CONFIG_NET_CONTEXT_NBUF_POOL is set but
application has not defined any pools. In this case the tx and
data pool pointers will be NULL in net_context struct and we
must use the default pools instead.

Change-Id: I286f34c87d9182aace71e0a61f038945810e4916
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-03-31 10:58:17 +03:00
Jukka Rissanen 6df4ee9691 net: tcp: Allow tweaking of 2MSL timeout
The default timeout (4 min) is very long. Allow tweaking the
value via Kconfig option.

Change-Id: Iddfd48b96f3612b9bba7caa4d64357505df9644d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-03-31 10:58:17 +03:00
Ravi kumar Veeramally e5183fcf97 net: rpl: Fix invalid nbr lookup
Match neighbour with link layer address. And get RPL parent with
matching ll address. DAG id different which is prefix based address
from the parent.

Change-Id: I75ecdfa7aa63da210676a3f44b8510d24c38d1d5
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-03-31 10:58:17 +03:00
Ravi kumar Veeramally e6fd75c507 net: rpl: Fix DAO ACK reply
Let intermediate node reply DAO ACK only if it can not forward original
DAO messages to it's parent. If DAO forwarding is success let the final
parent sends DAO ACK.

Change-Id: I14ff9b5b110a639cad6415741dde71c2cdd222ef
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-03-31 10:58:17 +03:00
Ravi kumar Veeramally 8b6166e5c9 net: rpl: Fix invalid parsing of DIO message
DIO message suboptions can contain PAD1, PADN, Metric container,
Routing information, DODAG configuration and Prefix information.
Right now we are not skipping PADN and unknown options payload.

Change-Id: I43557962784f68a223ea209eae5ca0367a3d5410
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-03-31 10:58:17 +03:00
Ravi kumar Veeramally ea7d1e138c net: rpl: Fix invalid parsing of DAO message
DAO message suboptions can contain PAD1, PADN, Target, Transit
and Target descriptor. Right now we are not skipping PADN and
Target descriptor payload.

Change-Id: I89a9c3cb59de5397d1430f0fa5de95beee193880
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-03-31 10:58:16 +03:00
Ravi kumar Veeramally b77ad7dd6c net: rpl: Add support for handling of DAO ACK
Parse DAO ACK from parent and analyze it.

Change-Id: I2394bd5e339ff00c87b9b4835dd5a21e2bafb2e5
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-03-31 10:58:16 +03:00
Ravi kumar Veeramally bfb781dd14 net: rpl: Align Kconfig options properly
Indentation is wrong for few options. And few options does not
properly aligned.

Change-Id: Ib4a8a90a17fd20ddd16ec6f29558eb937f035bb9
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-03-31 10:58:16 +03:00
Ravi kumar Veeramally 6280abe372 net: icmpv6: Remove unnecessary cache ptrs for src and dst
Earlier net_nbuf_copy() mangled the original buffer. So cacheing
src and dst address was necessary. Now original buffer does not
get affected by net_nbuf_copy() call. Cacheing is not required.

Change-Id: I25f60bc6db2a75612e562e56024d4459478d80b4
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-03-31 10:58:16 +03:00
Ravi kumar Veeramally 29fb336ccd net: if: Fix triggering interface link call back
Do not call callback if destination ll address is not set. This
happens when dst is multicast or broadcast.

Change-Id: I34dda92799a987d9cff031dc97f4a01b94437561
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-03-31 10:58:16 +03:00
Tomasz Bursztyka 178589fc31 net/net_if: When IPv6 DAD is disabled, added address gets final state
There is no transition from tentative state etc... It should directly go
to preferred.

This is fixing ND processing when DAD is disabled: source address was
never set, as tentative state is not a valid in
is_proper_ipv6_address().

Change-Id: I6f0a0fdd99dd13d28849f9749f89ec21fdd370d8
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-24 17:31:42 +02:00
Tomasz Bursztyka 53b9c45f11 net/ipv6: Fix a NULL dereferencing issue when debug is enabled
Change-Id: If62aa12acfc07d32ae29068537127d245f8af87e
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-24 17:31:42 +02:00
Jukka Rissanen aa11cef227 net: shell: Add DNS query support
Add "net dns <hostname> [A | AAAA]" command support that can be
used to query IPv4 or IPv6 address for a given host name.

Change-Id: I86b2258efa994a67163f9b3b340f44d65767f11b
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-03-24 17:31:42 +02:00
Jukka Rissanen 8dc01261ea net: dns: Initialize DNS resolver if DNS servers are set
If the config file contains DNS server addresses, then
configure the DNS resolver to use them.

Change-Id: Ie7f2bdcf7ac4bb7ee0ecf7fb5b7bd2df3379cdc3
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-03-24 17:31:42 +02:00
Tomasz Bursztyka 850efc270c net/icmpv4: Normalize input function signature with ipv6 counter-part
Length parameter was always useless, only used in debugging, so that can
be removed.

Change-Id: If597f424840f37955202fa5fe827dd992e4cf776
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-24 17:31:42 +02:00
Tomasz Bursztyka e98f2e0b6a net/shell: Add ping reply handlers and a timeout
Thus the ping command is more user-friendly: at least user knows the
ping got a reply or not.

Change-Id: I740a2f77d288f6287ac04c908f3d517a49df57d2
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-24 17:31:42 +02:00
Tomasz Bursztyka 19af4eee4f net/icpmv4: Add dynamically registered ICMPv4 handlers
As it is done for ICMPv6. This will prove to be useful for implementing
an echo reply handler in a ping for instance.

Change-Id: I969a1da60f2a4ea59eee5c9983eb6e340923e2ef
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-24 17:31:41 +02:00
Tomasz Bursztyka 1d361b0507 net/shell: Simplify ping logic
net_addr_pton always returns -EINVAL in case of error, so let's play with
it to factorize the code.

net_icmpv<4/6>_send_echo_request always returns -EIO in case of error.

Change-Id: I89e5ccd4b936701f7dad194089dda845fab5d738
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-24 17:31:41 +02:00
Tomasz Bursztyka 1e3dc0cbb4 net/ipv6: Renaming IPv6 neighbor state related macros and function
Refining the names around IPv6's neighbor states to differentiate them
easily from any net_nbr related names (which are not tighten to IPv6).

Change-Id: Ibc24df2a9485477a53fe5fe1c8f993f0fcd91635
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-24 17:31:41 +02:00
Tomasz Bursztyka 4991499cab net/ipv6: Regroup debugging routines relevantly
Probably some refactoring left-over.

Change-Id: I9715441a54b2e675135ce4072651dcead3216d3b
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-03-24 17:31:41 +02:00
Jukka Rissanen b3e5de641d net: tcp: Invalid transition from FIN_WAIT_1 to CLOSE_WAIT
We incorrectly changed the state from FIN_WAIT_1 to CLOSE_WAIT.
This caused ACK be sent in CLOSE_WAIT state when the connection
was closed by peer. Sending ACK in this state is not allowed
according to RFC. The connection was still closed but slightly
wrong way.

Jira: ZEP-1961

Change-Id: Ie4aa6818128d4190230b679e26ac9630c7d45d69
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-03-24 17:31:41 +02:00
Jukka Rissanen 4de6340fe9 net: shell: Add command for testing TCP connection
User can open a TCP connection (just one at a time) by
using "tcp connect <ip> port" command.
Data can be sent by "tcp send <data>" command.
Connection can be closed by "tcp close" command.

Change-Id: I75aedd873a30575a6f742926b716afb7dbbfb92b
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-03-24 17:31:41 +02:00