Commit graph

41120 commits

Author SHA1 Message Date
Vinicius Costa Gomes
4534046ad9 iot/zoap: Ignore non-request packets in zoap_handle_request
For example, when a RESET packet is passed to zoap_handle_request(),
there's nothing it can do, and it's not an error, so it returns
success silently.

Change-Id: I025bb44733521d6132999c219aaa292a3de302d7
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2017-01-20 16:23:19 +02:00
Vinicius Costa Gomes
0e7b9adc5f samples/zoap_server: Add resouce for TD_COAP_BLOCK_03
This allows to verify that the CoAP server is able to handle a
blockwise PUT request.

Change-Id: I801e353a27b10a5266748591d023bcb607db6bb4
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2017-01-20 16:23:18 +02:00
Vinicius Costa Gomes
4c636eef6a iot/zoap: Add response code for Continue status
This status is used when a blockwise transfer should continue with the
next block.

Change-Id: If68c32aea8c0b63efcd929cdff57f0ff235b2792
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2017-01-20 16:23:18 +02:00
Vinicius Costa Gomes
6429b1bf2b samples/zoap_server: Add support for blockwise GET tests
This adds support for TD_COAP_BLOCK_01 and TD_COAP_BLOCK_02 tests,
which test that the CoAP server is able to handle GET requests with
blockwise tranfers.

Change-Id: Id0d1703adcf5d4e76dd1bc489c8bcc94a3fd90bc
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2017-01-20 16:23:18 +02:00
Vinicius Costa Gomes
bcc8f819e1 samples/zoap_server: Add support for the '/separate' resource
This resource is used to verify that the CoAP server is able to send
responses in two steps: 1. only acknowledge that the request was
received and is going to be handled; 2. The actual response, with the
payload.

Change-Id: Ia77cc0ee9805e6cc120c57f4598c68ad364882a0
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2017-01-20 16:23:18 +02:00
Michael Scott
dbd7481274 net: tcp: remove unused semaphore tcp_lock
Change-Id: Ibcd89b063a8bd5f6f7400e0ed73eb6b6d8b86b26
Signed-off-by: Michael Scott <michael.scott@linaro.org>
2017-01-20 16:23:18 +02:00
Ravi kumar Veeramally
4f3a0ef595 net: dhcpv4: Remove dead code
When parser encouter DHCPV4_OPTIONS_END, it immediately returns NET_OK.
No need to maintain end variable here.

Coverity-CID: 157584

Change-Id: I4c8b91f37ae882845c280dab1a8204966aaac00a
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-01-20 16:23:18 +02:00
Ravi kumar Veeramally
0a3ebde216 net: 6lo: Fix dereferencing null pointer
Pointer udp will be NULL when (!(CIPHC[0] & NET_6LO_IPHC_NH_1))
condition is true.

Coverity-CID: 157588

Change-Id: I8aa1eb2e4d4aee8039631d76ad0ecc345247d6b5
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-01-20 16:23:18 +02:00
Ravi kumar Veeramally
c6a006c60b net: 6lo: Handle destination address uncompression properly
When contex information provided and DAC bit is not set and vice versa
are invalid cases.

Coverity-CID: 157569

Change-Id: I1b798703cbbb6155a7bdf734d0fcde9ce48c409c
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-01-20 16:23:18 +02:00
Jukka Rissanen
1bb7b7e99c net: nbuf: Check possible null pointer access
In net_nbuf_get(), check that context pointer value is not
null before accessing data via it.

Coverity-CID: 157600

Change-Id: I7e7ea19a85f6fbef129e9ce699ea740d3be84cb8
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-01-20 16:23:18 +02:00
Jukka Rissanen
ba026941a1 net: ipv6: Fix IPv6 prefix comparision
If the prefix length % 8 is not 0, then the remaining
bit length was calculated incorrectly and the prefixes
were claimed to match even though they might not be the
same.

Adding a test cases for testing this properly.

Coverity-CID: 157591

Change-Id: I9cb5a73d5cc211ec183176400fa5e2dfd209e2da
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-01-20 16:23:18 +02:00
Jukka Rissanen
d3301aae88 net: ipv6: Check neighbor pointer in NS reply timeout
If neighbor is not found, then ignore the timeout.

Coverity-CID: 157583

Change-Id: Ia2199970bd862e43901f5717025271c11c74af5e
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-01-20 16:23:18 +02:00
Jukka Rissanen
66f5dfa04f net: tcp: Allocate space for TCP header
We need to allocate separate fragment to store the IP
protocol headers.

Coverity-CID: 157582

Change-Id: Ib0dd5d28cd6876a0cf2de3b063c030ef64da998c
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-01-20 16:23:18 +02:00
Jukka Rissanen
b5039aa80c net: icmpv6: Removing dead code
Callback cannot be null so no need to check its value.

Coverity-CID: 157572

Change-Id: I26e4b24c41d30aa9007b78895975035e6bf8807f
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-01-20 16:23:18 +02:00
Jukka Rissanen
2eb218c5b7 net: Fix possible null pointer dereference in nbuf
The context parameter might be NULL so we need to check
its value before accessing its content.

Coverity-CID: 157571

Change-Id: I7f75323d9d261a77421688f37a40bb44ff3ca2bd
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2017-01-20 16:23:17 +02:00
Leandro Pereira
06d3ccce96 net: tcp: When retransmitting, hold an extra, temporary reference
The link layer dereferences a buffer right after it is transmitted.

If this extra reference is not held, the second time a buffer is
retransmitted, the reference that TCP holds when keeping the buffer in
the `sent_list` will be taken, and retransmission won't happen reliably
anymore.

As soon as the TCP fragment is acknowledged by the peer, the
`sent_list` reference is taken, and the buffer is freed.

Change-Id: Ie50f9acf02c1dff74248a5dfbec3785a91ff90f7
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-01-20 16:23:17 +02:00
Leandro Pereira
46c0997e8b net: tcp: Reduce size of state member from 32 to 4 bits
No more than 4 bits are necessary to store the state of a TCP connection,
so better pack it using bitfields so that it uses only 4 bits instead of
32, by sharing space with `retry_timeout_shift` and `flags` fields.

There are 12 (or 14, if you count the 2 unused bits in the `flags`
field) bits remaining in the same dword, but I don't know what to to
stuff there yet.

This also changes all direct field access for the `state` field to
function calls.  These functions are provided as `static inline`
functions and they perform only casts, so there's no function call
overhead.

Change-Id: I0197462caa0b71b287c0773ec5cd2dd4101a4766
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-01-20 16:23:17 +02:00
Leandro Pereira
525b51594f net: tcp: Get rid of recv_mss field from TCP struct
This frees up some more memory as well, by computing the maximum segment
size whenever needed.  A flag is set in the TCP context to signal if
the value has been already computed.

Change-Id: Idb228d4682540f92b269e3878fcee45cbc28038a
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-01-20 16:23:17 +02:00
Leandro Pereira
9a558c2aaa net: tcp: Remove unused recv_ack field from TCP context
This value is never set (always zero), so it's safe to remove it from
the net_tcp struct.

Change-Id: Ie4c1d90204a9834f2223b09828af42ee101bd045
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-01-20 16:23:17 +02:00
Leandro Pereira
5de6d084a9 net: tcp: Use an uint8_t for retry timeout instead of an uin32_t
Rename the variable to `retry_timeout_shift`, and shift-right the value
each time there's a timeout.  This saves some memory in that structure
by using the holes left due to alignment.

Change-Id: I18f45d00ecc434a588758a8d331921db902f4419
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-01-20 16:23:17 +02:00
Leandro Pereira
1aee85be4c net: tcp: Ensure all timers are disposed of when releasing context
Cancel all delayed work timers: FIN, ACK, and retry timers.  Also, do
that unconditionally regardless of which state the machine is in, as
that's a no-op if the timer has not been started yet.

Change-Id: Ia36b97c6823943976447fbd6389ae04862c19ff9
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-01-20 16:23:17 +02:00
Leandro Pereira
3587b97845 net: slip: Do not remove fragments when sending data
The rationale for removing fragments while sending them is to free the
memory they're using as soon as possible.  This worked fine because
most protocols implemented initially did not require any
retransmission, so the upper layers were never holding an extra
reference to the buffer (& their fragments).

This is not the case anymore, as the TCP layer holds a reference to
a buffer (& fragments) while confirmation from the peer has not been
received, allowing retransmission.

With this change, the fragments of a buffer are not removed when being
sent by the SLIP layer; however, the buffer is still deferenced when the
transmission is complete.  If nothing else holds a reference, all the
fragments are returned to their respective pools, like before.

Change-Id: I74966d72f6970b66f526ea0b765101077c843de2
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-01-20 16:23:17 +02:00
Ravi kumar Veeramally
0f6990ac4d samples: net: Fix DHCPv4 config options and run on its own thread
DHCPv4 sample was running on main stack. Updated to run on its own
thread. Update config options (removed unnecessary ones and separated
few options for easy readability).

Change-Id: I3be38ca4cd4bcfa62e2613b90b104679cff2517e
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-01-20 16:23:17 +02:00
Flavio Santes
4d93ebf9ec samples/net: Remove legacy configuation variables
This patch removes legacy configuation variables found at the
prj_arduino_101.conf file of the DNS sample application.

Change-Id: I74e370a7be177f809d805525cc18f594a59e38c0
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2017-01-20 16:23:17 +02:00
Flavio Santes
1c21029237 drivers/ethernet: Update default GPIO pin for the ENC28J60 module
All sample applicatons in Zephyr, using the ENC28J60 driver, set
the ETH_ENC28J60_0_GPIO_PIN Kconfig variable to 19.
However, in the Kconfig.enc28j60 file this variable is set to 24.
That default value, 24, was used only during the first iterations
of this driver and never used again.

In this patch, we set the Kconfig variable to 19 and simplify
project configuration files by removing one line.

Change-Id: I3d5fd9da04a3f10845d2a409de56f5b9c235e995
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2017-01-20 16:23:17 +02:00
Flavio Santes
06286f93aa samples/net: Remove redundant configuration variable
Remove CONFIG_GPIO=y for the Arduino 101 board. This configuration
is now set by default in the board configuration file.

See commit 8f96628064.

Change-Id: I6fa73a5785d78c51f03a0af48fc2aa8cc7636c7d
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2017-01-20 16:23:17 +02:00
Andy Ross
d4b9b6c1bf net: tcp: Destroy net_tcp struct at the same time as the context
The net_tcp struct was being cleaned up and destroyed when the
outbound FIN packet is sent on a connection that already received an
inbound FIN.  That's not right, per spec we need to wait for the ACK
(though this would be benign cheating).  And worse: there were code
paths which were themselves spec-compliant where the net_tcp struct
(now a NULL pointer) would be used after this spot leading to
occasional crazy behavior on socket close.

Don't do it this way.  Clean up the TCP struct at the same time we
destroy the net_context.  Much saner that way.

Change-Id: I4bc6b97eb0b71a7fa8faea02c1eb4c4d3bd3ae6d
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2017-01-20 16:23:17 +02:00
Andy Ross
01ae35b58e net: tcp: Pass correct user_data pointers
The TCP stack inherited msot of the user_data management from UDP, but
it doesn't quite work.  It's not possible to have a single pointer in
the general case, as e.g. a net_context_send() call may happen
synchronously underneath a recv callback and clobber the pointer, even
though there will be much more data coming later on the active stream.

Put a recv_user_data field into the TCP struct and use that.  Long
term, it would be good to revisit this and come up with a unified
solution that works for both.  There is yet another "user_data"
pointer in net_connection that seem likely to overlap too.

Change-Id: Id3a8eca64fc680e0e80b74944c4d621d7810a8fe
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2017-01-20 16:23:17 +02:00
Michael Scott
c78c7ac13c net: route: remove extra variable use in net_route_add()
Let's drop the lladdr variable and get the link address and
length from the net_linkaddr_storage variable instead.

Change-Id: I75a5d08527cda7df102db897ade9015d39f10caf
Signed-off-by: Michael Scott <michael.scott@linaro.org>
2017-01-20 16:23:16 +02:00
Michael Scott
f3c66e5205 net: ipv6: fix NULL reference in handle_ra_neighbor
lladdr.addr doesn't point to any storage value when it's
handed off to the net_nbuf_read function.  This results
in a write to an undefined area of memory.

Fix this by pointing lladdr.addr to a net_linkaddr_storage
structure's byte storage array which can handle the maximum
specified length.

Change-Id: I05e0a0420b262ba1e5ac95cebe1f0d91f54878ce
Signed-off-by: Michael Scott <michael.scott@linaro.org>
2017-01-20 16:23:16 +02:00
Michael Scott
7b674cb287 net: linkaddr: introduce net_linkaddr_set function
The net_linkaddr_storage structure contains an array of bytes used
to store the link address.  This array can be different sizes
depending on the CONFIG options used when building.  To facilitate
consistency and error checking let's introduce a new helper function
to copy the addr and len values to this structure.

Also move all uses of memcpy related to net_link_storage structures to
the new helper function.

Change-Id: Ic547d86b07e62e5ac3bc330d4eaeb4508a143200
Signed-off-by: Michael Scott <michael.scott@linaro.org>
2017-01-20 16:23:16 +02:00
Michael Scott
4aad767328 net: linkaddr: calculate linkaddr storage addr size via config
- Introduce NET_LINK_ADDR_MAX_LENGTH which is either 6 or 8
  depending on whether CONFIG_NET_L2_IEEE802154 is used
- Instead of being a placeholder single index array of uint8_t,
  let's use NET_LINK_ADDR_MAX_LENGTH to assign the size of the
  "addr" array field in the net_linkaddr_storage structure.
- Now that the "addr" field of net_linkaddr_storage contains the
  true size of the link address, we can remove "storage" field
  which was hard coded to 8 bytes (2 uint32_t's).
- Fix 2 references to the "storage" field of the net_linkaddr_storage
  structure.

Change-Id: I2ea12058280b289f65085964eb7d503d4fd260c2
Signed-off-by: Michael Scott <michael.scott@linaro.org>
2017-01-20 16:23:16 +02:00
jing wang
64579bc490 tests: add threads customdata api test case with unified kernel
the commit cover basic customdata apis:

k_thread_custom_data_set()
k_thread_custom_data_get()

Change-Id: Ide27cfd59230303767414c7f827d6ad627989a6f
Signed-off-by: jing wang <jing.j.wang@intel.com>
2017-01-20 12:41:56 +00:00
jing wang
6ffe10f50f tests: add pipe test cases which use unified kernel
Add kernel pipe test cases which cover basic pipe apis usage
across thread and isr

Change-Id: I11899411b305535297f2e25056678d5b7df8fb95
Signed-off-by: jing wang <jing.j.wang@intel.com>
2017-01-20 12:09:38 +00:00
jing wang
e49480d590 tests: add fifo/lifo test cases with unified kernel
Add fifo/fifo test cases with unified kernel, which cover
basic apis across differnt contexts - thread and isr

Change-Id: Icb61d3dcd564167b0bd70419c652e0b000869959
Signed-off-by: jing wang <jing.j.wang@intel.com>
2017-01-20 12:09:11 +00:00
Sharron LIU
c570efd63b tests: kernel: added memory pool threadsafe test
TestPurpose: verify API thread safe in multi-threads environment.

Jira: ZEP-1210

Change-Id: I1ff8231db8ebcd5713d6083379d0ebfbdabeeee0
Signed-off-by: Sharron LIU <sharron.liu@intel.com>
2017-01-20 11:45:47 +00:00
Sharron LIU
6ec8c6ef14 tests: kernel: added memory pool configuration options test
TestPurpose: verify memory pool configuration options.
All TESTPOINTs extracted from kernel documentation.
https://www.zephyrproject.org/doc/kernel/memory/pools.html#configuration-options

Jira: ZEP-1210

Change-Id: Ia5379aabd60e490c4566def21eda600c4c1b08dd
Signed-off-by: Sharron LIU <sharron.liu@intel.com>
2017-01-20 11:45:46 +00:00
Sharron LIU
61c53373ee tests: kernel: added memory pool concept test
TestPurpose: verify memory pool concepts.
All TESTPOINTs extracted from kernel documentation.
https://www.zephyrproject.org/doc/kernel/memory/pools.html#concepts

ZEP-1210

Change-Id: I6250e4c26ddf361e74a76c23082cfdb376705560
Signed-off-by: Sharron LIU <sharron.liu@intel.com>
2017-01-20 11:45:45 +00:00
Sharron LIU
415e71e04c tests: kernel: added memory pool api test
TestPurpose: verify memory pool APIs.
All TESTPOINTs extracted from kernel-doc comments in <kernel.h>

ZEP-1210

Change-Id: I7dcc0638e7b9c4d6b5ffe282e4fe41ca520d003f
Signed-off-by: Sharron LIU <sharron.liu@intel.com>
2017-01-20 11:45:45 +00:00
Sharron LIU
d7a9ac21ce tests: kernel: added memory slab threadsafe test
TestPurpose: verify API thread safe in multi-threads environment.
Thread safe test is explained with more details here:
https://gerrit.zephyrproject.org/r/#/c/9464/7/ test_mpool_threadsafe.c
Please comment if you think it necessary as an extensive kernel test.

Jira: ZEP-1209

Change-Id: I52a7ff393d72785622c047289e7d92286e131cc7
Signed-off-by: Sharron LIU <sharron.liu@intel.com>
2017-01-20 04:45:04 +00:00
Sharron LIU
9ebf3dc10c tests: kernel: added memory slab concept test
TestPurpose: verify memory pool concepts.
All TESTPOINTs extracted from kernel documentation.
https://www.zephyrproject.org/doc/kernel/memory/slabs.html#concepts

ZEP-1209

Change-Id: I95c6cd666212218b9928356f9439e67a2fcf9b73
Signed-off-by: Sharron LIU <sharron.liu@intel.com>
2017-01-20 04:44:04 +00:00
Sharron LIU
37402b4161 tests: kernel: added memory slab api test
TestPurpose: verify memory slab APIs.
All TESTPOINTs extracted from kernel-doc comments in <kernel.h>

ZEP-1209

Change-Id: I80bc85e96110e7106b3fc5883b982d71c6a7e50b
Signed-off-by: Sharron LIU <sharron.liu@intel.com>
2017-01-20 04:43:42 +00:00
Sharron LIU
3cb55002b2 tests: kernel: re-path mslab test
tests/kernel/mem_slab --> tests/kernel/mem_slab/test_mslab
For the purpose to hold other mslab test apps.

Jira: ZEP-1209

Change-Id: I4a72b02a0a5095bb7cfbf73396b6d003ea63f92e
Signed-off-by: Sharron LIU <sharron.liu@intel.com>
2017-01-20 12:28:31 +08:00
Anas Nashif
722b429a53 boards: arduino_101: set correct LED pin
Change-Id: Icda0a7952daea5a12b51b27868b130c0ae76c8b1
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-01-20 02:29:54 +00:00
Anas Nashif
c9c36f15de build: have sysgen create SPDX license identifiers
Jira: ZEP-1593
Change-Id: I9b1f1d26f18b0e4da2ab2110416a4e60e3889f29
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-01-20 02:29:41 +00:00
Kuo-Lang Tseng
faecff7e88 drivers: QMSI GPIO: simplify driver reentrancy code using IS_ENABLED macro
This is one of the series of patches that simplifies the driver
code by using the IS_ENABLED macro. This removes the need of the
const variable and the three wrapper functions on semaphore APIs.

Jira: ZEP-1251

Change-Id: I5102e8674663ddbfc65220de72c8b778a9ec726c
Signed-off-by: Kuo-Lang Tseng <kuo-lang.tseng@intel.com>
2017-01-20 01:46:08 +00:00
Kuo-Lang Tseng
dad4127761 drivers: QMSI WDT: simplify driver reentrancy code using IS_ENABLED macro
This is one of the series of patches that simplifies the driver
code by using the IS_ENABLED macro. This removes the need of the
const variable and the three wrapper functions on semaphore APIs.

Jira: ZEP-1251

Change-Id: I2ea0b2d04252d6b28e7d5ca528480234545e6eed
Signed-off-by: Kuo-Lang Tseng <kuo-lang.tseng@intel.com>
2017-01-19 16:48:42 -08:00
Andrew Boie
0e7a5fd0c7 kernel_event_logger: add additional function prototypes
These previously had only been invoked from ASM domain.

Change-Id: Ia20caf1b02a4ceee16d964211874c5f798445fe2
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-01-19 20:17:29 +00:00
Andrew Boie
350f88d525 kernel.h: add prototype for private idle exit function
Had only been called from ASM domain, but upcoming interrupt changes
invoke it from core arch C code as well.

Change-Id: Ifd831826068e130e2936cfa4da6c082c3433a5ae
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-01-19 20:17:07 +00:00
Andrew Boie
b739acf5cd gen_idt: show vector assignments in debug output
Change-Id: I3099e56b480cc0e939a37efbf57e0700251d039a
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-01-19 20:16:08 +00:00