Commit graph

7,343 commits

Author SHA1 Message Date
Yangbo Lu
dbdc3939e6 net: qbv_shell: fix variable without initialization
Some variables were used without initialization causing
command failure. Fixed them.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2026-04-03 23:10:23 +09:00
Zafer SEN
54de0d3d0f lwm2m: connmon: add Link Utilization resource support
Introduce the CONNMON_LINK_UTILIZATION resource to the Connection
Monitoring object. Add backing storage, initialize it during instance
creation, and register it in the resource table.

Signed-off-by: Zafer SEN <zafersn93@gmail.com>
2026-04-01 11:52:48 -05:00
Jani Hirsimäki
a85db98380 net: iface: longest-prefix match for net_if_ipv6_addr_onlink()
Select the interface whose on-link prefix has the greatest length when
multiple prefixes match the same address. Fixes wrong iface selection
when a host has several interfaces whose on-link prefixes overlap (e.g.
a shorter prefix on one link and a longer, more specific prefix on
another). Callers that pass iface == NULL still get a boolean only; no
interface pointer is written.

Signed-off-by: Jani Hirsimäki <jani.hirsimaki@nordicsemi.no>
2026-04-01 09:18:32 -05:00
Jukka Rissanen
97e96f2957 net: Remove experimental status from pre-emptive network threads
The support for running network TX/RX threads in pre-emptive way
was introduce in 2020. The experimental status is no longer valid
as the feature has been there for quite some time and it is being tested
also regularly by CI.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-04-01 09:17:53 -05:00
Mikhael Skvortsov
01586032e4 net: wireguard: fix PSA slot leak
Free any leftover ephemeral key from a previous unanswered initiation.

Signed-off-by: Mikhael Skvortsov <mikhael.skvortsov@gmail.com>
2026-03-31 13:55:23 -05:00
Sebastiaan Merckx
03bff638ac net: dns: dns_sd: fix incorrect use of buffer size
The functions that add DNS records (PTR, SRV, TXT, AAAA, A) all use a
buf_size argument which represents the size of the whole buffer, not the
remaining size. The higher function that calls these did not provide the
correct argument: it passed the remaining size in the buffer.

Signed-off-by: Sebastiaan Merckx <sebastiaan.merckx@verhaert.com>
2026-03-31 10:36:36 -05:00
Ofir Shemesh
218aa7e19f net: dhcpv6: log received address at info level
The DHCPv4 client logs the received address with NET_INFO when an
address is successfully obtained from the server. The DHCPv6 client
had no equivalent log message, making it difficult to confirm that
DHCPv6 address assignment succeeded.

Add a NET_INFO log when a DHCPv6 address is successfully configured,
consistent with the DHCPv4 client behavior.

Signed-off-by: Ofir Shemesh <ofirshemesh777@gmail.com>
2026-03-30 15:06:15 -05:00
Ofir Shemesh
4398087c3e net: config: fix IPv6 event callback not registered for DHCPv6-only setups
In setup_ipv6(), the net management event callback registration was
placed after the early exit for empty CONFIG_NET_CONFIG_MY_IPV6_ADDR.
This means that in DHCPv6-only configurations (no static IPv6 address),
the callback was never registered, and the IPv6 address and lifetime
were never printed when DHCPv6 obtained an address.

This is inconsistent with setup_ipv4(), which correctly registers the
callback before the empty address check, allowing DHCPv4 address
events to be handled even without a static IPv4 address.

Move the event callback registration and router flag check before the
empty address goto, and always include NET_EVENT_IPV6_ADDR_ADD in the
event mask so that DHCPv6 address additions are always captured.

Signed-off-by: Ofir Shemesh <ofirshemesh777@gmail.com>
2026-03-30 15:06:15 -05:00
Ofir Shemesh
9ed81aacb5 net: context: set sa_family before ephemeral port allocation
In net_context_get(), contexts[i].local is memset to zero before
find_available_port() is called. This leaves sa_family as 0, which
causes check_used_port() to skip both the IPv6 (sa_family ==
NET_AF_INET6) and IPv4 (sa_family == NET_AF_INET) collision-detection
branches, unconditionally returning "port available".

When the PRNG produces the same random port for two consecutive
socket() calls, the collision is not detected and both contexts are
assigned the same ephemeral port. The duplicate is only caught later
during listen() → net_conn_register(), which finds the identical
connection handler and returns -EADDRINUSE (errno 112).

Fix by setting sin6_family / sin_family on the local address
immediately after the memset and before find_available_port() is
called, so that check_used_port() enters the correct address-family
branch and properly detects port collisions.

Signed-off-by: Ofir Shemesh <ofirshemesh777@gmail.com>
2026-03-30 10:10:59 -05:00
Nikhil Namjoshi
83d4a298f0 net: ipv6: Fix extention length header validation
The exthdr_len was previously validated against the total
packet length, which did not account for the header's offset.
This could allow a crafted packet to cause an out-of-bounds
read by claiming a length that exceeds the remaining buffer.

Fixes https://github.com/zephyrproject-rtos/zephyr/issues/106331

This commit:
1. Validates exthdr_len against (pkt_len - start_offset).
2. Adds strict bounds checking for sub-options (PADN/others)
   to ensure they do not exceed the extension header boundary.
3. Validates the return value of net_pkt_skip().

Signed-off-by: Nikhil Namjoshi <nikhilnamjoshi@google.com>
2026-03-30 10:08:20 -05:00
Tomi Fontanilles
7109043090 modules: mbedtls: stop including Mbed TLS configuration header file
Standard Mbed TLS header files already take care of doing it properly.

Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
2026-03-26 07:19:32 -04:00
Tomi Fontanilles
c6e6f3e638 modules: mbedtls: rename CONFIG_(MBEDTLS|TF_PSA_CRYPTO)_CFG_FILE
To align with Mbed TLS by replacing CFG with CONFIG.

Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
2026-03-26 07:19:32 -04:00
Robert Lubos
4f09d6bcbc net: wifi: Fix static SSID logging
When logging statically configured network SSID, use the Kconfig string
instead of a SSID buffer where it was copied to, as the latter is not
guarantee to be NULL terminated.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-03-25 15:05:53 -04:00
Robert Lubos
90d9d8e12d net: wifi: credentials: Verify statically configured SSID and password
In case CONFIG_WIFI_CREDENTIALS_STATIC is used, verify the statically
configured SSID/password lengths to guarantee they don't exceed the
allowed SSID and password character limits and thus overflow credential
buffers.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-03-25 15:05:53 -04:00
Fin Maaß
7b7a87c8c4 net: ethernet: do net_if_set_link_addr() in net_mgmt
do net_if_set_link_addr() for
NET_REQUEST_ETHERNET_SET_MAC_ADDRESS
in ethernet_set_config(), that way drivers don't have
to do it themself.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-03-24 10:49:59 -05:00
Markus Becker
1ac99e8ae0 net: ocpp: fix statically allocated string variables are free'd
Writable string entries in ocpp_cfg_info are free'd if non NULL in
ocpp_set_cfg_val(). Thus they should not be statically allocated.
Initialise with NULL instead.

CFG_SUPPORTED_FEATURE_PROFILE is not writable and should be fine.

Signed-off-by: Markus Becker <markushx@gmail.com>
2026-03-24 10:48:00 -05:00
Markus Becker
b49498507a net: ocpp: Properly copy ocpp_cp_info from cpi to cp
BootNotification did not transport Serial Number and other information,
because the NULL check is wrong.

Signed-off-by: Markus Becker <markushx@gmail.com>
2026-03-24 10:48:00 -05:00
Fin Maaß
27cec4c935 net: net_if: make addr in net_if_set_link_addr() const
When providing a addr in net_if_set_link_addr() it should be
constant, as this function should not change the address
in the pointer.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-03-24 07:05:38 -04:00
Fin Maaß
062facbab2 net: dsa: remove NET_DSA_DEPRECATED
remove the deprecated NET_DSA_DEPRECATED.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-03-23 15:01:57 -05:00
Jukka Rissanen
f611a4e4d4 net: shell: wg: Add setup command
Add a way to add private key, peer endpoint and keepalive
when setting up the wireguard connection using the shell.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-03-23 13:58:58 -04:00
Jukka Rissanen
3af900c600 net: shell: wg: Use SHELL_HELP() macro for help texts
This can save flash usage by allowing string sharing.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-03-23 13:58:58 -04:00
Jukka Rissanen
6c27239865 net: wg: Make remaining PSA crypto helpers static
Couple of PSA crypto helper functions were not static so fix that.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-03-23 13:58:58 -04:00
Jukka Rissanen
688d84b59a net: wireguard: Make blake2s private
Make blake2s private so that it cannot be used (easily) by other parts
of Zephyr codespace. The blake2s is part of the code until PSA will
have support for it. At that point the code will be removed and
replaced by the PSA calls.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-03-23 13:58:58 -04:00
Jukka Rissanen
684653fd04 net: wireguard: Use PSA key management
Instead of using buffers for keys, use PSA key management to
store the keys. This is more safe than handling buffers in
the code directly.

Do some cleanup of the code structure and make the functions
in wg_psa.c static to disallow use outside of Wireguard.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-03-23 13:58:58 -04:00
Jukka Rissanen
dbcf7ef5e2 net: wireguard: Support RTC with native_sim board
If running wg in native-sim, use the host clock to get the
current time. This helps to have a proper handshake when
connecting even after restarting the zephyr.exe process.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-03-23 13:58:58 -04:00
Jukka Rissanen
984ddc51c1 net: wireguard: Make getting current time extensible
Allow user to provide a function that will need to get
the current time from a RTC or SNTP or similar.
Wireguard handshake replay prevention needs a monotonic
time so the application should get it from somewhere.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-03-23 13:58:58 -04:00
Jukka Rissanen
7a8348af4b net: wireguard: Send network events for VPN activity
Send peer add/del network event when the peers is either added
to the system or deleted from the system.
Send VPN connected / disconnected event when a VPN connection
is successfully established or the peer connection is disconnected.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-03-23 13:58:58 -04:00
Jukka Rissanen
d09cee002f net: shell: wg: Print detailed peer information
The "net wg show 1" will show detailed information of the peer
id 1. This is useful when debugging connectivity issues.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-03-23 13:58:58 -04:00
Jukka Rissanen
d4020814e2 net: shell: wg: Add VPN statistics support
Show VPN statistics support if enabled.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-03-23 13:58:58 -04:00
Jukka Rissanen
14ced6a59f net: wireguard: stats: Add statistics support
Collect Wireguard VPN statistics and allow user to fetch it.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-03-23 13:58:58 -04:00
Jukka Rissanen
cf40236791 net: shell: Add Wireguard VPN support
Add commands to manipulate Wireguard connectivity.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-03-23 13:58:58 -04:00
Jukka Rissanen
bcffe6a0e1 net: wireguard: Add crypto support
The crypto code is taken from wireguard-lwip project at
https://github.com/smartalock/wireguard-lwip
and is BSD-3-Clause licensed code.

The Blake2 RFC 7693 and XChaCha20 (from
https://datatracker.ietf.org/doc/html/draft-arciszewski-xchacha-03)
cannot currently use PSA APIs.

The XChaCha20 is found in PSA 1.2 but Zephyr is not yet using that
version.

All the other crypto usage is converted to use PSA APIs.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-03-23 13:58:58 -04:00
Jukka Rissanen
598806fe26 net: wireguard: Add DiffServ DSCP values
As described in https://www.wireguard.com/protocol/
set DSCP to AF41 for handshake messages. The transport data
DSCP is set to 0.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-03-23 13:58:58 -04:00
Jukka Rissanen
a239800f1a net: wireguard: Add initial implementation
Wireguard is a VPN implementation. See https://www.wireguard.com/
for details.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-03-23 13:58:58 -04:00
Chaitanya Tata
449ad67f19 net: l2: wifi: Add band info to set channel
With 6GHz band, channel numbers are not unique anymore, channel 1 can
mean both 2.4GHz or 6GHz, so, take the band info as the argument from
the user.

Keep auto-detection for backwards compatibility sake.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
Assisted-by: Cursor:Auto
2026-03-23 12:32:25 -05:00
Savo Saicic
e7038cb864 net: lwm2m: add IPSO Magnetometer object support
Add support for the IPSO Magnetometer object version 1.0 (Object ID
3314) which allows an LwM2M server to read magnetic field values from
a 1-3 axis magnetometer.

The object is enabled in tests/net/all/prj.conf to ensure it is
built as part of the CI all-in networking build.

Signed-off-by: Savo Saicic <savo.saicic@gmail.com>
2026-03-23 08:48:35 -04:00
Robert Lubos
b9ad6b17c7 net: sockets: Check for overflows in recvmsg/sendmsg syscalls
When calling zsock_recvmsg()/zsock_sendmsg() system calls, check if
provided msg->msg_iovlen is valid, i.e. does not cause size_t overflow
when calculating memory needed for msg->msg_iov vector.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-03-20 12:38:00 -05:00
Valerio Setti
e9b5feb797 net: lib: sockets: tls: do not specify random function to be used
Both PK and TLS now rely on PSA generate random to get random data
so end users (i.e. sockets_tls in this case) don't need to manually
specify this anymore.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2026-03-20 12:32:52 -05:00
Fin Maaß
af0f6394e0 net: l2: ethernet: simplify use of net_if_get_device()
when using net_if_get_device() save the pointer
and use the pointer again.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-03-19 14:56:23 -05:00
Pieter De Gendt
9a75818c6d net: lib: sntp: Make sockaddr const for sntp_ctx
Both sntp_init and sntp_init_async shouldn't modify the socket address
passed.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-03-19 17:02:11 +01:00
Andreas Ålgård
2f6289d792 net: dhcpv4_server: Allow application to reject an address
This is useful if the application may wish to reject an address.
This works well alongside the address_provider callback, this way
you can enforce static leases based on the client id (MAC address).

Signed-off-by: Andreas Ålgård <aal@ixys.no>
2026-03-19 11:35:22 +00:00
akshay bansod
baa6058b08 net: sockets: add missing net_log.h header
compilation of socket_obj_core.c fails due to missing
net_log.h header. Fixes #105692

Signed-off-by: akshay bansod <akbansd@gmail.com>
2026-03-19 11:34:38 +00:00
Jjateen Gundesha
33b29cb4ef net: config: fix race in check_interface() causing indefinite block
- NET_EVENT_IF_UP can fire between the net_if_is_up() check and
net_mgmt_add_event_callback() in check_interface(). When this
happens (e.g. with CONFIG_SHELL_BACKEND_TELNET=y which starts a
same-priority thread that brings the interface up concurrently),
the event is missed and net_config_init_by_iface() blocks forever.

- Fix by always registering the callback first, then checking
net_if_is_up() after registration. If the interface came up in
the race window, remove the callback and signal the semaphore
immediately. Move the NET_INFO print to only fire when we are
genuinely going to wait.

Signed-off-by: Jjateen Gundesha <jjateen97@gmail.com>
2026-03-18 15:27:54 -05:00
Fin Maaß
a3a39e1cf9 net: config: improve help of NET_CONFIG_CLOCK_SNTP_INIT
as we now have the sys_clock api that is
used for the system time, mention that api
in help too.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-03-18 10:58:30 +09:00
Fin Maaß
9784bf1d4b net: config: fix help of NET_CONFIG_SNTP_INIT_USE_CONNECTION_MANAGER
fix help of NET_CONFIG_SNTP_INIT_USE_CONNECTION_MANAGER

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-03-18 10:58:30 +09:00
Alberto Escolar Piedras
aadb23a188 net: Include correct header in all users of net logging macros
The net logging helper macros are now in a separate header.
Let's have all net users to include this new header.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2026-03-17 18:21:28 -04:00
Chaitanya Tata
277dad84c9 net: lib: shell: Add static ARP support
Add shell command to add a static ARP entry, useful in testing.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
Assisted-by: Cursor:Auto clang-format
2026-03-17 18:21:10 -04:00
Fin Maaß
8843c50f3e net: ethernet: lldp: use sys_timepoint_* api
use sys_timepoint_* api.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-03-17 18:17:46 -04:00
Fin Maaß
061e7ff951 net: ethernet: lldp: simplify of changed vlan ifaces
as there is now a 1:1 relationship beween
struct ethernet_context and struct net_if
we can simplify the logic here,.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-03-17 18:17:46 -04:00
Fin Maaß
d089a201dc net: ethernet: lldp: use net_if_oper_state to check up ifaces
use `NET_IF_OPER_UP` to check if the iface is
already up, this is also the state that corespondes with
NET_EVENT_IF_UP.

Also move `net_if_foreach(iface_cb, NULL);`
after `net_mgmt_add_event_callback()`, so we won't
miss any up event.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-03-17 18:17:46 -04:00