The "net iface" net-shell command printed "<unknown type>" for
OpenThread based technology. After this commit, the network
interface type is set to "OpenThread".
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The previous commit replaced the net_pkt element ref with an element
atomic_ref. CI tests turned up more places where ref was used directly.
This commit converts them to use the new element.
Signed-off-by: Daniel Glöckner <dg@emlix.com>
It has been observed that some network drivers, f.ex. the SAM E70 GMAC,
call net_pkt_unref from inside the interrupt that signals the successful
transmission of a packet. This conflicts with the net_pkt_unref call
made by ethernet_send after the packet has been given to the driver.
We fix this by using an atomic_t to hold the reference count as there
might be other, difficult to find cases of net_pkt_(un)ref being used
across threads and interrupts.
The name of the element has been changed from "ref" to "atomic_ref" to
cause a compile error when code still has not been converted to use the
atomic_* functions.
Fixes#12708
Signed-off-by: Daniel Glöckner <dg@emlix.com>
This commit introduces a concept of mesh-local IPv6 addresses. Such
addresses should only be used for mesh-local communication, therefore
should not be used to communicate with different subnets (i. e.
destinations outside the mesh).
As `addr_type` field already holds different kind of information
(whether address was created automatically/manually) it was not used in
this case.
Instead a mesh_local flag was added, so that we do not lose information
on how address was created. Address with such flag set will only be
selected as a source address automatically if the destination address
is within the same subnet it belongs to.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Each time a successfully TCP connection is done, the number of dropped
TCP packets increases by 2. This is happens because when receiving an
initial SYN packet, or an ACK packet following a SYN+ACK packet,
NET_DROP is returned even if there is no error.
Fix that by replacing the two corresponding "return NET_DROP" by
"net_pkt_unref(pkt)" followed by "return 0".
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Connecting to a non-open port causes connect() to hang forever.
This patch releases connect() to return error to the caller.
Signed-off-by: Björn Stenberg <bjorn@haxx.se>
Accepting broadcast echo request and replying to it could provide an
attack vector.
Fixes#12162
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
The NET_LOG_LEVEL is enabled also when allocation debugging is
enabled but when net_pkt debugging is not. Thus we need to use
the CONFIG_NET_PKT_LOG_LEVEL when printing normal debug log
prints.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
net_frag_linearize() is just a wrapper for net_buf_linearize(). As
the latter was refactored to never return error, and instead just
return actual copied length, update the former and its usages too.
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
No declar 'count',Enable CONFIG_NET_DEBUG_HTTP_CONN will build error.
Using http_monitor_count replace count.
Fixed#12329
Signed-off-by: Frank Li <lgl88911@163.com>
shell_fprintf() doesn't work in callback handlers.
To fix that, set shell state to SHELL_STATE_COMMAND before using it.
Fixed: #12347
Signed-off-by: Frank Li <lgl88911@163.com>
Introduced by commit id de78a7af28.
If the sum is 0xffff, a ~sum will give 0.
Fixes#12164
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
The patch allows to enable logs for NET_RAW configuration.
For example using wpanusb currently breaks build with logging enabled.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
The slab2str function which is used in the debug log call is not defined
unless NET_LOG_PKT_LOG_LEVEL >= LOG_LEVEL_DEBUG.
It looks like this change was accidentally introduced in #11374.
Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
Fragmentation has nothing to do with 6lo. Up to the bearer to do so.
This change is required for futur serialization of 15.4 fragmentation.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
ll reserve is of no use as the l2 is allocating what it needs for
filling in its header.
This is another step forward to removing ll reserve concept.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
The net-shell "net allocs" command should print network buffer
allocations even if network packet debugging is not enabled.
This is how it used to work earlier but the behaviour got lost
at some point. So user needs to set CONFIG_NET_DEBUG_NET_PKT_ALLOC
in order to see the buffer allocations. The option will be enabled
by default if network packet log level is set to DBG.
The reason for a separate option is that the network packet debug
logging prints just too much data and it is very difficult to
track allocations when that happens.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
All IPv4 destination address related drop reasons in one place.
This helps also to have one unique call of net_conn_input().
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
As for IPv4, net_conn_input() can be called at one place for udp/tcp.
It will anyway check if given protocol is enabled so no need to check
such support here.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
It was weird to pre-parse ICMPv6 headers in IPv6. Moreover parsing
failure of such header would not generate the right statistic.
Instead, centralizing all into net_icmpv6_input relevantly, and adapting
the test cases which were using that function. In RPL test, removing the
dummy dio test was simpler since dio is anyway tested later on.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
If relevant configs are not enabled shell allocs command would print
wrong info:
"Enable CONFIG_NET_DEBUG_NET_PKT to see allocations"
CONFIG_NET_DEBUG_NET_PKT is obsolete and an undefined symbol, setting it
causes cmake to fail. This patch fixes this issue by printing up-to-date
information on how to enable allocs command
Signed-off-by: Ruslan Mstoi <ruslan.mstoi@intel.com>
Just recalculate the chksum without resetting its value to 0, and test
if return value is 0.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
The net_dhcpv4_stop() function stops the event listener for any IF_UP
events previously. In case multiple interfaces are used and optionally
being switched over, it could result in disabling dhcp unintentionally.
The callback is initialized at the init function and added/removed in
the start/stop function based on the interface list being empty
or not. (first added, last removed)
The event handler checks if the interface is in the list before acting
on it.
Signed-off-by: Vincent van der Locht <vincent@vlotech.nl>
In case "net_dhcpv4_stop(..) is called when the interface is
in NET_DHCPV4_RENEWING state, the address is not removed.
When deleting the address in the NET_DHCPV4_RENEWING state
means the status is always equal to the moment before _start
is called.
Signed-off-by: Vincent van der Locht <vincent@vlotech.nl>
Remove network specific default and max log level setting
and start to use the zephyr logging values for those.
Remove LOG_MODULE_REGISTER() from net_core.h and place the
calls into .c files. This is done in order to avoid weird
compiler errors in some cases and to make the code look similar
as other subsystems.
Fixes#11343Fixes#11659
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Removed printing command help from help handler. It is now
realized by the shell engine. This change saves a lot of flash
but still allows to print help in command handler with function
shell_help_print.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
Removing help "options" from shell API.
Currently SHELL_OPT macro is not used by users. What is more
commit: a89690d10f ignores possible options created in
command handler by the user. As a result they are not printed
in help message.
Second, currntly implemented "options" in command handlers options are
implemented without SHELL_OPT macro.
And last but not least this change will allow to implement
help handler in a way that user will not need to think about calling
functions printing help in a command handler.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
No need to store/reset/recompute the chksums, only compute it again and
if it's not 0: drop the packet.
RFC 1071:
"To check a checksum, the 1's complement sum is computed over the
same set of octets, including the checksum field. If the result
is all 1 bits (-0 in 1's complement arithmetic), the check succeeds."
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
IPv4, ICMPv4/6, UDP, TCP: all checksums are meant to be one's complement
on a calculated sum. Thus return one's complement already from the right
place instead of applying it in each and every place where
net_calc_chksum is called.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
1. Clarify message telling that the actual packet length fed by the
driver differs from what specified in IPv4 header, and that leads to
drop.
2. Debug log any dropped packets in general.
These changes come from the experience of developing a networking
driver, where figuring out why packets get dropped may require
quite a head-scratching.
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
If we receive extra data at the end of the IP message, then
discard that data and accept the packet.
Fixes#11649
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Such sent flag is in a union in net_pkt, shared with a gptp flag.
Tweaking it when the family is not AF_INET or AF_INET6 will generate
corrupted gptp packets.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Now instead of such path:
net_if_send_data -> L2's send -> net_if tx_queue -> net_if_tx -> driver
net_if's send
It will be:
net_if_send_data -> net_if tx_queue -> net_if_tx -> L2's send -> driver
net_if's send
Only Ethernet is adapted, but 15.4 and bt will follow up.
All Ethernet drivers are made compatible with that new scheme also.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
As per RFC1112 sec 6.2 "A host group address must never be
placed in the source address field or anywhere in a source
route or record route option of an outgoing IP datagram."
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
Networking stack sometimes try to find source address based
on destination address. If interface could not find best match
then it returns unspecified address (0.0.0.0). Host should not
send these packets.
IPv4 reply related issues fixed.
Fixes#11329
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
net_rpl_get_interface() function which returns always NULL is
defined if NET_RPL is not enabled. so remove deprecated tag to
this particular function. Otherwise it will cause unnecessary
compilation warnings.
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>