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>
Increase the net_buf length in proper places. So when gPTP
header is added, increase the buf->len properly, and then
when gPTP packet type is added, increase it again properly.
This way the net_buf length is updated in more logical way.
Signed-off-by: Jukka Rissanen <jukka.rissanen@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>
This commit reworks socket poll implementation to support multiple
socket implementations.
To achieve that, two ioctl poll helper requests were added:
ZFD_IOCTL_POLL_PREPARE and ZFD_IOCTL_POLL_UPDATE. The poll
implementation calls ioctl with these requests for each socket
requested in the fds table.
The first request is responsible for preparing k_poll_event objects
for specific socket. It can request to skip waiting in k_poll by
returning EALREADY through errno.
The latter request is responsible for processing outcome of k_poll for
each socket. It can request to retry the k_poll by returning EAGAIN
through errno.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Implement extended socket vtable for TLS sockets, therefore allowing to
integrate the implementation with socket subsystem.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit extends socket vtable, allowing to redirect socket calls to
alternate implementations (e.g. TLS sockets).
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The state2str() function should only be used if debugging
is enabled thus add some pre-processor checks there.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Print function and line number when changing state and when
debugging is enabled. Otherwise it is a bit difficult to follow
the program logic and locate the state change operation.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
As the msg parameter for PRINT_INFO() is always a const string
that is not coming from stack, there is no need to use
log_strdup() here. This helps to avoid the
"<log_strdup alloc failed>" messages.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Common statistics should be updated in one centralized place and
ethernet_send is the right place for tx stats, as well as ethernet_recv
for rx stats.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.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>
Add missed out helper functions to update the errors.tx and error.rx
in the stats structure.
Signed-off-by: Fadhel Habeeb <fadhel@zilogic.com>
Signed-off-by: Nirav Parmar <niravparmar@zilogic.com>
Signed-off-by: Vijay Kumar B <vijaykumar@zilogic.com>
gPTP subsystem was calling pow(x,y) function with X and Y being
constants; these are replaced with the pre-computed values.
Signed-off-by: Andrei Laperie <andrei.laperie@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>
Instead of redoing what Ethernet L2 already does, let just create the
gptp message without any Ethenet header. Which one will be done as
sending phase by Ethernet L2 relevantly.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
As for Ethernet, up to ieee802154 L2's send to actually sent the packet.
It's currently unoptimized as 6lo compression, 15.4 fragmentation and so
on will reallocate net_buf etc... but it's the first step towards
removing ll reserve space and more.
Applying changes to Openthread L2 as well.
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>
Now that sending is done at last time, in one pass, no need to go
through net_if_send_data here.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Currently, first part is done in L2's send, then the next one in
ethernet device driver net_if send function. That last one was already
moved to a L2 based implementation. Let's just move forward and place
the whole logic of the L2's send in that second function.
This is the first step, ethernet centric only, to move towards a
one-pass sending logic in net stack. In future, net_if's send will
disappear.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Current code generating Ethernet header is scattered all over the place,
sometimes in functions that are supposed to check something (and not
filling the header). Not to say about innefficiency.
Src ll address does not need to be set in L2 as net_if.c handles that
already.
Broadcast dst ll address is the same in ipv4 or ipv6, thus factorizing.
In each case, multicast is filled in only at the relevant place.
This is the first step towards changing L2 sending logic, when L2 send
API function will be the only point of sending. The redirection from
driver to L2 again (which finally uses the right device API function to
send) it a temporary hack.
This simplifies the code but will also enable using statically
allocated net_buf and ethernet header payload buffer afterwards.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This is currently unoptimized, as all frags are allocated with relevant
ll reserve for such header space. However, this is the first step
towards getting rid of that ll reserve concept everywhere.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
MQTT packet_length_encode function accepts NULL buf argument, therefore
it cannot be dereferenced without a check.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
mqtt_connect was not releasing mutex after successfull connection.
Reworked the code to have a single exit path with mutex unlock.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Remove an unnecessary local variable to store the
return value, instead return directly thereby saving
few bits of memory.
Found using Coccinelle.
Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>