Commit graph

7,037 commits

Author SHA1 Message Date
Jani Hirsimäki
f55dacf849 net: ip: new Kconfig NET_MGMT_EVENT_INFO_DEFAULT_DATA_SIZE
The NET_MGMT_EVENT_INFO_DEFAULT_DATA_SIZE is used to set the default
size of the data field in the net_mgmt_event_info structure. This
change allows the user to configure the size of the data field
according to their needs.

Signed-off-by: Jani Hirsimäki <jani.hirsimaki@nordicsemi.no>
2025-11-14 10:30:35 +02:00
Robert Lubos
4453bfd1c9 net: context: Allow datagram socket rebinding
Rebinding of UDP sockets works just fine and there's really no reason to
disallow it. Keep the restriction for stream sockets only (as our TCP
implementation doesn't support rebinding).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-11-14 10:27:12 +02:00
Julien Vermillard
4e54e9a806 net: lwm2m: get cache free slots
Add function to query LwM2M cache free slots on a given path.

Signed-off-by: Julien Vermillard <julien@clunkymachines.com>
2025-11-14 09:20:59 +01:00
Triveni Danda
b4e2cd139b net: l2: wifi: Handle domain match and suffix match parameters
Add support to handle domain match and suffix match parameters
for proper server certification validation.

Signed-off-by: Triveni Danda <triveni.danda@nordicsemi.no>
2025-11-13 20:42:52 -05:00
Cristian Bulacu
4520215968 net: l2: openthread: border_router: Delete multicast route by iface
This commit makes use of #98464 and deletes a multicast route by
specified interface.

Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
2025-11-13 23:21:04 +02:00
Cristian Bulacu
5b8b5df90e openthread: platform: udp: init udp fds before external net connection
When OpenThread iface is brought up `ot ifconfig up` there are several
modules that will attempt to open a platform socket and perform bind
and bind to netif operation.
Since now, `sockfd_upd` structure was initialized after the backbone
interface announced connectivity, but this implies that OpenThread
interface will always be brought up only after this event, which is not
true, or imposed.

Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
2025-11-13 23:19:38 +02:00
Seppo Takalo
c309869305 net: l2: ppp: Allow PPP to transtition ESTABLISH->DEAD
When remote peer have closed the PPP link normally, the
PPP stack on Zephyr side switches back to ESTABLISH phase
to be ready for next handshake.

When calling net_if_down() on the interface, it should not
try to initiate LCP link termination, but instead go directly
to DEAD phase.

See https://datatracker.ietf.org/doc/html/rfc1661#section-3.2

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2025-11-13 23:17:10 +02:00
Jukka Rissanen
820cd34dbb net: Replace Posix eventfd by zvfs_eventfd API
No need to use Posix eventfd API in core network code as zvfs_eventfd
is compatible with it and we can now avoid using Posix headers
unnecessarily.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-11-13 23:12:04 +02:00
Jukka Rissanen
2c0cf4ac3f net: midi2: Do not use poll from posix
As midi2 is provided by networking subsystem it should not
depend on any features provided by Posix. Convert Posix poll
API calls to zsock poll ones. There is no functionality changes,
only naming changes.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-11-13 23:09:47 +02:00
Robert Lubos
77d461c4c0 net: tcp: Reduce the log level for active close
The log level was elevated by mistake as a leftover from debugging,
should remain DBG.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-11-13 15:34:20 +02:00
Ofir Shemesh
b933bf5e08 net: dhcpv4: fix incorrect RFC2131 section reference to 4.4.1
Corrected the RFC2131 section reference in DHCPv4 comments and help text.
The random delay before sending the initial DHCPDISCOVER message is
defined in Section 4.4.1 of RFC2131, not in 4.1.1 as previously stated.

Signed-off-by: Ofir Shemesh <ofirshemesh777@gmail.com>
2025-11-13 12:01:31 +02:00
Robert Lubos
9e6256e853 net: iface: Prevent iface/TCP mutexes deadlock
In rare occasions iface and TCP mutexes could cause a deadlock. As
notifying the interface readiness takes place just before the iface
mutex is released, it should be not harm to release it just before the
TCP is notified about interface going down to avoid the deadlock.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-11-12 19:00:20 -05:00
Robert Lubos
ba6387fcd6 net: tcp: Close the connection unconditionally on forced close
The current approach was buggy, for example the TCP context could be
unrefed twice in case of forced close. Or in case of a race, when the
application closed the socket first, the TCP context wouldn't be
dereferenced at all.

Calling the tcp_conn_close() unconditionally in case of forced close
solves all those issues.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-11-12 19:00:20 -05:00
Robert Lubos
7fe33a5d5a net: tcp: Fix error reporting on listening socket on iface down
A listening TCP context has no active connection therefore it has no a
second ref from the TCP stack. Thereby, when shutting down connections
when interface goes down, net_tcp_put() should not be called on a
listening socket to release the ref on the TCP stack behalf.

Instead, report the error via the registered accept_cb callback no
notify the application about the error, which should then close the
socket and release the associated TCP context.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-11-12 19:00:20 -05:00
Robert Lubos
3e537db71e net: lwm2m: Fix SenML CBOR resource instance encoding
Consecutive resource instance name should be encoded regardless of
whether timestamp is present or not.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-11-12 12:57:30 +02:00
Benjamin Cabé
bdb314d036 net: lib: ocpp: fix misnamed State of Charge (SoC) measurand
As per OCPP 1.6, "State of charge of charging vehicle in percentage" is
"Soc", not "SoCState".

Fixes: zephyrproject-rtos/zephyr#98870

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-11-06 13:53:53 -05:00
Nicolas Pitre
408da59cc4 net: lwm2m: fix format specifiers for size_t in LOG_DBG
Fix incorrect format specifiers in lwm2m_read_cached_data() where
size_t variables were printed using %u and %d instead of %zu. This
caused CI failures on ARM64 platforms where size_t is long unsigned
int, triggering -Werror=format warnings.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2025-11-05 15:35:38 -05:00
Robert Lubos
587d9e6a4a net: icmp: Verify the address family before calling the callback
Check the address family of the packet before passing it to a ICMP
handler, to avoid scenarios where ICMPv4 packet is paseed to a ICMPv6
handler and vice versa.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-11-05 13:19:03 -05:00
Tim Pambor
a4d99f5de2 net: core: only set l2_processed flag for NET_CONTINUE
If verdict is NET_OK net_pkt may already be unreferenced and reutilized,
so that setting the `l2_processed` flag would be set on a different
packet, corrupting its state. Avoid this situation by only setting the
l2_processed flag for NET_CONTINUE.

Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
2025-11-04 16:54:14 +02:00
Jordan Yates
25269118b5 net: lib: sockets: add socket service fd requirement
The net socket service implementation permanently opens a file
descriptor, which should be taken into account by the build system.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-11-03 10:42:06 +02:00
Cristian Bulacu
c341838502 net: ip: route: Add support to search mcast route by iface
This commit adds the possibility to check for a multicast route on a
given interface

Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
2025-10-31 20:01:55 -04:00
Jukka Rissanen
60f83dca7d net: Do not access possibly freed net_pkt
As the net_pkt might have already been sent by net_if_try_send_data()
function, the pkt might already contain garbage data. So do not try
to access if after that send call but remember the used iface and family
and use them to update the statistics.

The issue was seen with qemu_x86_64 and qemu_cortex_a53 when CONFIG_SMP
was enabled.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-10-31 22:41:07 +02:00
Jukka Rissanen
73315dd73d net: shell: stats: Fix undefined function call
If CONFIG_NET_STATISTICS_PER_INTERFACE is not set, then the
net_shell_print_statistics_all() function was not found and
the compilation was failing.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-10-31 10:33:47 -04:00
Simon Walz
fd780ae34e net: lwm2m: fix missing name entries for time-serialized resource instances
The LwM2M SENML JSON/CBOR decoder expects a name entry for every
time-serialized record. While this was already the case for resources,
resource instances were missing their corresponding name entries. This
change ensures consistency by adding name entries for resource instances
as well.

Signed-off-by: Simon Walz <simon.walz@autosen.com>
2025-10-29 20:18:30 +02:00
Jukka Rissanen
a02414a9bc net: zperf: Use %zd when printing size_t variable
Wrong printf format was using for size_t variable which caused
compiler warning and a failure.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-10-29 13:47:21 +02:00
Anas Nashif
303af992e5 style: fix 'if (' usage in cmake files
Replace with 'if(' and 'else(' per the cmake style guidelines.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-10-29 11:44:13 +02:00
Cristian Bulacu
ecb5db6c92 samples: net: openthread: border_router: Fix packet forwarding bug
This commit fixes an issue introduced in #97531. Multicast routes added
by application are now set to have a prefix length of 16 bits instead of
128. This will allow multicast routing to all IPv6 addresses from those
groups.

For the OpenThread multicast listener callback, route length will be set
to 128 bits, as a MLD event is expected when an address is subscribed.
Route lookup has been removed since one will always be found as the
application registers multicast routes with same scope, but with a
smaller prefix length.

Fixed issue regarding packet forwarding and BBR state. Previously, code
was covering only the case wehn BBR was secondary and packet was
received from backbone interface. A secondary BBR should not forward a
multicast packet from OT interface to backbone interface and vice versa.

Improved unicast forwarding function to return from the beginning if the
packet has a multicast destination.

Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
2025-10-29 10:32:42 +02:00
Pan Gao
40256a919d net: l2: wifi: Fix btwt_setup command parameter count
command btwt_setup maximum support max 12 optional parameters.

Signed-off-by: Pan Gao <pan.gao@nxp.com>
2025-10-28 11:50:02 +02:00
Jukka Rissanen
ec3bcd3930 net: tcp: Close all connections when interface goes down
If the network interface goes down, close all TCP connections
that are bound to that interface. The reasoning here is that we
need a way to remove IP address from the interface and it might
not be possible if there is a TCP socket that is bound to that address.
If the interface comes back on, we might get the same IP address in
which case the socket closure was not really needed but it is not
possible to know in advance.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-10-27 07:32:28 -04:00
Jukka Rissanen
1f5c285279 net: tcp: Allow immediate connection tear down
If the network interface goes down, then we do not have any time
to tear down TCP connection gracefully because there is no more
a connection to send data to. In this case the TCP connection is
forcefully closed without going into FIN_WAIT_1 state.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-10-27 07:32:28 -04:00
Valerio Setti
fa911df90c modules: mbedtls: rename MBEDTLS_DTLS
Align Kconfig name to the Mbed TLS build symbol.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2025-10-24 13:27:59 -04:00
Valerio Setti
f960db846c modules: mbedtls: rename MBEDTLS_TLS_VERSION_1_2
Align Kconfig name to the Mbed TLS build symbol.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2025-10-24 13:27:59 -04:00
Valerio Setti
e1117f18fc modules: mbedtls: rename MBEDTLS_MD
Align Kconfig name to the Mbed TLS build symbol.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2025-10-24 13:27:59 -04:00
Pieter De Gendt
d43b48daf5 net: l2: wifi: mgmt: Fix auto-connect with multiple saved credentials
Using the Wi-Fi credentials system, we need to stop connecting with stored
credentials once a connection has been successful.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-10-24 13:19:21 -04:00
Valerio Setti
9c13bfd5d7 net: ip: ipv6: replace legacy crypto with PSA API
Zephyr's long term goal for crypto support is to use only PSA API. This
commit replaces usages of MD with proper PSA API for HMAC.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2025-10-23 18:02:56 +02:00
Jordan Yates
51b424e2f0 tests: modem: ppp: test custom ACCM's
Test the wrapping functions with custom asynchronous command character
maps.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-10-23 08:02:28 +02:00
Jordan Yates
fbb84c7c0c net: l2: ppp: lcp: accept ASYNC_CTRL_CHAR_MAP option
Accept the `ASYNC_CTRL_CHAR_MAP` option in configuration messages from
the peer. The map is reset to the default value each time the interface
comes up.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-10-23 08:02:28 +02:00
Jordan Yates
13d35288bd net: l2: ppp: expose the peer ACCM
Expose the currently configured value for the PPP peers Asynchronous
Control Character Map through a public function.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-10-23 08:02:28 +02:00
Michael Zimmermann
4b2cbe8d4d net: mqtt_sn: fix returning address from zsock_recvfrom
The fix in 1264a923f3 was incomplete, because
it doesn't initialize the variable. To quote from opengroup [1]:
address_len
    Either a null pointer, if address is a null pointer, or a pointer to a
    socklen_t object which on input specifies the length of the supplied
    sockaddr structure, and on output specifies the length of the stored
    address.

This caused the returned address to be incomplete, because it got truncated
depending on what addrlen_local got initialized with implicitly. This broke
talking to discovered MQTT-SN gateways.

I intend to implement integration tests for the MQTT-SN UDP transport to
prevent such issues in future, but that will be done in a separate PR.

[1] https://pubs.opengroup.org/onlinepubs/9699919799/functions/recvfrom.html

Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
2025-10-22 18:05:41 -04:00
Cla Mattia Galliard
80d00b5ec1 net: tc-mapping: Fix SKIP_FOR_HIGH_PRIO
Adjust the way the SKIP option worked. Before this patch, a constant
priority offset was considered "high priority" this had the effect, that
the threads assigned to work on the priority were effectively usesless.
To fix it, consider this immediate handling as a pseudo-queue and compute
the tc-thead-mapping based on the effective count (+1 if skipping is
enabled). This makes it so that all threads are usefull and the
high-priority skip-path is considered as a pseudo tc-thread.

Signed-off-by: Cla Mattia Galliard <clamattia@gmail.com>
2025-10-22 18:33:43 +03:00
Cla Mattia Galliard
27effdb727 net: tc_mapping: Use preprocessor
Avoid token pasting and use preprocessor more for additional flexibility.

Signed-off-by: Cla Mattia Galliard <clamattia@gmail.com>
2025-10-22 18:33:43 +03:00
Cristian Bulacu
5cd223bc4b net: l2: openthread: openthread_border_router: Update address events
This commit refactored IPV6 and IPV4 address events. Events have been
defined independently for each installed callback.
Previously, IPV6 address event was not triggered due to a mix of IPV4
and IPV6 flags.

Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
2025-10-22 18:32:49 +03:00
Robert Lubos
f7e51d7b5c net: sockets: tls: Remove leftover todo comment
Logs were added, but the todo comment about this was overlooked,
remove it.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-10-21 22:51:49 +03:00
Alberto Escolar Piedras
499aa995f6 net: lib: shell: dns: Fix field precission specifier type
Explicitly cast down the string width to int, as otherwise it is
size_t which may have a bigger size.

Avoids the following build error:

subsys/net/lib/shell/dns.c:496:67: error: field precision specifier
‘.*’ expects argument of type ‘int’, but argument 4 has type ‘size_t’
{aka ‘long unsigned int’}

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2025-10-21 12:21:37 -04:00
Cla Mattia Galliard
f3b6d77ad4 net: shell: filter: Update table
Adjust table to print newly available information.

Signed-off-by: Cla Mattia Galliard <clamattia@gmail.com>
2025-10-21 17:25:56 +03:00
Cla Mattia Galliard
4e3024b110 net: tc: allow to spread threads by more then 1 priority level
Allow to spread tc threads by more then one priority level and cleanup the
computation of the priority.

Signed-off-by: Cla Mattia Galliard <clamattia@gmail.com>
2025-10-21 17:25:56 +03:00
Cla Mattia Galliard
8d38e720a4 net: pkt_filter: Filters to modify priority to incoming packets
To enable quality-of-service (QoS) applications, allow filters to modify
the priority of an incoming packet. This allows that processing can be
done on tc-queue-threads with different priorities.

Signed-off-by: Cla Mattia Galliard <clamattia@gmail.com>
2025-10-21 17:25:56 +03:00
Jukka Rissanen
dbe59a5faf net: sockets: tls: Add ZVFS_OPEN_ADD_SIZE_TLS to count TLS sockets
Make sure that the CONFIG_NET_SOCKETS_TLS_MAX_CONTEXTS will
reflect the number of required file descriptors in the system.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-10-21 17:22:03 +03:00
Jukka Rissanen
bc44a27b26 net: context: Make sure to allocate enough sockets
The number of net_context now determines the minimum amount
of network sockets that are to be allocated.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-10-21 17:22:03 +03:00
Jukka Rissanen
1cfdf7c8d1 lib: Introduce a way to set minimum file descriptors count
Instead of user trying to figure out what is the amount of file /
socket descriptors in the system, let the various subsystems etc.
specify their need using a Kconfig option. The build system will
then add these smaller values together and set a suitable file
descriptor count in the system.

This works the same way as the heap size calculation introduced
in commit 3fbf12487c

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-10-21 17:22:03 +03:00