Commit graph

7,037 commits

Author SHA1 Message Date
Jukka Rissanen
d060673658 net: wifi: shell: Convert the code to use SHELL_HELP macro
This will save flash memory by 1489 bytes and make usage help look
uniform in different commands.

Re-order the shell commands to alphabetical order. This has been
done before but has bitrotted over time.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-02-18 10:31:49 +00:00
Jukka Rissanen
0179cce4cd net: shell: Convert the code to use SHELL_HELP macro
This will save flash memory by 646 bytes and make usage help look
uniform in different commands.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-02-17 17:40:49 -06:00
Jukka Rissanen
66812f66a7 net: ipv6: Do packet length checks before starting fragment reassembly
Make sure to check packet length check before starting the
IPv6 fragmentation reassembly process. This way we can drop the
malformed packet without consuming resources.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-02-17 13:21:17 -06:00
Jani Hirsimäki
757b576b65 net: ppp: always set FSM name in ppp_fsm_name_set
Previously the name was only set when CONFIG_NET_L2_PPP_LOG_LEVEL >=
LOG_LEVEL_DBG. NET_ERR/NET_WRN in ipv6cp (and others) use fsm->name
as %s at any log level, which could pass NULL into the logger and
crash in cbprintf/strlen. Always assign the name so logging is safe.

Signed-off-by: Jani Hirsimäki <jani.hirsimaki@nordicsemi.no>
2026-02-17 10:33:02 +01:00
Pieter De Gendt
0a63c65787 net: shell: dns: Use same unsupported command pattern
Update DNS shell commands if the DNS resolver isn't disabled to reduce
flash usage.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-02-13 09:50:47 -06:00
Pieter De Gendt
3c5760b1e6 net: shell: dns: Add browse command
Add the 'net dns browse <service>' command to resolve multiple hosts of a
certain service type.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-02-13 09:50:47 -06:00
Pieter De Gendt
b35a7bc617 net: dns: resolve: Handle DNS_RESPONSE_DATA item in validate
Add an entry to the DNS cache for DNS_RESPONSE_DATA messages, and return
dns_read with DNS_EAI_ALLDONE instead of DNS_EAI_NODATA.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-02-13 09:50:47 -06:00
Pieter De Gendt
4251e01754 net: shell: dns: Make DNS info message queue size configurable
In large networks there can be many DNS responses, make the DNS info queue
size configurable to prevent dropping messages

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-02-13 09:50:47 -06:00
Pieter De Gendt
baba005e03 net: dns: resolve: Take lock before calling dns_resolve_init_locked
The mutex should be held when calling dns_resolve_init_locked as mentioned
in a comment above the function.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-02-12 14:32:19 +00:00
Robert Lubos
5fc367e348 net: coap: Remove invalid 2.00 response code
CoAP response code 2.00 is not defined anywhere in the spec nor
assigned in the IANA registry, therefore it should not be defined
in Zephyr either. Remove the invalid response code and its usage
in tests.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-02-06 08:57:38 -06:00
Robert Eichinger
4a99d8b411 net: http-server: handle OPTIONS for dynamic resources
Allow applications to respond to HTTP OPTIONS requests (e.g. CORS pre-
flight) by routing OPTIONS through the same dynamic handler path
as GET/DELETE.

This enables OPTIONS handling for both HTTP/1.1 and HTTP/2.

Signed-off-by: Robert Eichinger <robert.eichinger@bshg.com>
2026-02-05 10:24:26 +00:00
Benjamin Cabé
718f88d97f net: lwm2m: use proper essential type in boolean variables assignments
As per Zephyr coding guideline #59, "operands shall not be of an
inappropriate essential type". This makes sure boolean variables are
assigned true/false values, not 1/0.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-02-05 10:20:22 +00:00
Alberto Escolar Piedras
ebd86f93b1 net: mdns_responder: Avoid linking to not available code
When building with CONFIG_NO_OPTIMIZATIONS the compiler will not
optimize create_answer() based on the caller, and will try to call
ipv4/6 code even if not built.
Let's add an extra check in the if before those possibly unavailable
calls to ensure those branches are dropped in this case.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2026-02-04 15:17:39 +00:00
Somil Gupta
363591c0db net: wifi: add shell support for SAE password parameter
Extend the Wi-Fi shell connect command to allow passing an SAE
password separately from PSK. Previously, the shell stored all
passwords in the PSK field, preventing proper use of SAE credentials
required for WPA3 connections.

This change adds a dedicated option to populate the SAE password
field so that SAE authentication paths can be exercised correctly
from the shell.

Signed-off-by: Somil Gupta <somil24559@iiitd.ac.in>
2026-02-04 13:55:43 +01:00
Somil Gupta
e8b12b4447 net: wifi: fix SAE password length validation
Replace the hardcoded 64 character limit with WIFI_SAE_PSWD_MAX_LEN.

Signed-off-by: Somil Gupta <somil24559@iiitd.ac.in>
2026-02-04 13:55:43 +01:00
Jukka Rissanen
ac0f0ddd4d net: socket: Add helpers to send all data in a buffer
Add helpers for sending all the data in a buffer. This is
only useful for stream sockets like TCP.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-02-03 14:30:56 -06:00
Robert Lubos
ac80abface net: coap: Use dedicated pointer for resource metadata
CoAP .well-known/core handling routine assumed that the "user_data"
pointer in struct coap_resource will be set to a valid struct
coap_core_metadata pointer, or left NULL. This approach is error
prone (application cannot use "user_data" field freely) and renders the
"user_data" field useless for other cases.

Therefore, introduce a separate "metadata" pointer within the struct
coap_resource specifically to configure the resource-related metadata,
and leave "user_data" for the applications to use freely.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-02-03 14:30:02 -06:00
Robert Lubos
476ae94f31 net: sockets: Fix userspace recvmsg() msg_namelen copying
The recvmsg() msg->msg_namelen was not updated if CONFIG_USERSPACE
was enabled.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-02-02 12:57:28 +01:00
Robert Lubos
6514e7bcf9 net: sockets: Set address in TCP recvfrom()
Sender address and address length were not set in recvfrom() when called
for TCP socket. Fix this by reusing the code used to set source address
on accept().

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-02-02 12:57:28 +01:00
Robert Lubos
5cb214d263 net: ip: Add dependency to NET_NATIVE when reserving FD
Increasing FD count in the system for the network stack (native sockets)
only makes sense if native network stack is enabled. Otherwise, just
make it 0. This makes a difference for example when socket offloading is
used and the offloaded implementation makes its own reservation.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-01-30 18:04:12 +01:00
Cristian Bulacu
a367c439f7 net: l2: openthread: border_router: Split IPV4/IPV6 service init
This commits splits the border router services initialization by
separating the ipv6 related services from ipv4 ones.
As there are cases in which a DHCPv4 server is not present in the
network setup, there is no reason to wait for an IPV4 address before
starting the border router. In this case, only IPV6 functionalities
would be exposed.

Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
2026-01-30 18:03:36 +01:00
Michael Zimmermann
caaa0c696e net: mqtt_sn: udp: fix getting TTL
The length is an input parameter, which tells the kernel how big the
storage is. Depending on the socket implementation in use, not setting this
properly can (and should) fail depending on the value of the stack
variable.

Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
2026-01-30 05:58:15 -06:00
Michael Zimmermann
41f68b6035 net: mqtt_sn: udp: simplify TTL code
5f5db5bf3c added support for IPV6_MULTICAST_HOPS by adding both IPv4 and
IPv6 variants in place where they are used. This made the code a bit
complicated, though. This commit introduces helper functions to solve this.

Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
2026-01-30 05:58:15 -06:00
Robert Lubos
5d0c9391cd net: tcp: Drop redundant depends on NET_TCP in Kconfig
The whole TCP Kconfig options block is already behind "if NET_TCP",
therefore "depends on NET_TCP" on certain options was redundant.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-01-29 17:19:03 +01:00
Robert Lubos
c60f51e2ab net: tcp: Add Kconfig option to preserve TCP contexts on iface down
Zephyr by default closes all TCP contexts associated with a given
network interface when the interface goes down. This leads to
reporting an error on the associated network socket, allowing the
application to reopen sockets (for example in case of a network or
an IP address change).
It's been reported however that in certain cases this behavior is
undesirable. If this option is enabled, the TCP stack won't
close any TCP contexts when the network interface is going down.
Therefore, it is the application's responsibility to monitor the IP
address or network interface state changes, and restart the TCP
sockets when needed. Enable this option only if you can guarantee
that the application handles that properly.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-01-29 17:19:03 +01:00
Robert Lubos
da563ebecd net: tcp: Don't close TCP contexts bound to any address on iface down
Contexts bound to any address are not associated with any specifc IP
address (sockets not connected yet or listening sockets bound to any),
therefore there's no need to shut down the connection context on the
interface down event. Hence, check the local address binding before
shutting down the context.

Note, that there's some extra logic involved when reading the TCP local
address, implemented in net_tcp_endpoint_copy(), therefore I've simply
reused that function for the purpose.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-01-29 17:19:03 +01:00
Yangbo Lu
ab0f29bbd6 net: bridge_input: move debug messages to proper location
Moved forward decision debug messages ahead of interface TX/RX
operations. That's proper to see forward decision debug messages
first, and then interface TX/RX debug messages.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2026-01-29 14:25:09 +00:00
Yangbo Lu
3f7c957db6 net: bridge_shell: add fdb subcommand support
Added fdb subcommand support for bridge FDB entry
add/delete/show operations.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2026-01-29 14:25:09 +00:00
Yangbo Lu
3a6b67ac3a net: bridge_shell: convert to use SHELL_HELP
Converted to use SHELL_HELP.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2026-01-29 14:25:09 +00:00
Yangbo Lu
62d4998b0d net: bridge: add FDB (Forward Database) table support
Added FDB (Forward Database) table support for bridge.
Implemented very basic functions for adding/deleting
static <MAC + iface> FDB entry.

The dynamic FDB entry and hardware FDB configuration is
still TODO work.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2026-01-29 14:25:09 +00:00
Robert Lubos
b422dc272d net: mdns_responder: Fix clang warnings
struct dns_header is packed therefore it fields need to be accessed with
respective helper macro to avoid warnings with clang.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-01-28 10:16:38 +01:00
Michael Zimmermann
7a218e5db5 net: mqtt_sn: udp: tp_udp_recvfrom: store error in errno variable
Returning negative values which are not -1, isn't what POSIX would do and
the API is specifically designed to behave like recvfrom.

Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
2026-01-27 15:22:32 -06:00
Michael Zimmermann
d0a55b6805 net: mqtt_sn: udp: backup errno if it's used in logs
Otherwise, the log might overwrite it.

Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
2026-01-27 15:22:32 -06:00
Michael Zimmermann
8e0a04950a net: mqtt_sn: udp: use ssize_t for return value of zsock_recvfrom
int is simply the wrong type.

Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
2026-01-27 15:22:32 -06:00
Michael Zimmermann
20db4b2f8f net: mqtt_sn: fix types of gw_id and addr
- gw_id is an uint8_t in the protocol, so neither char, nor uint16_t are
  the correct type to use.
- addr is an array of bytes, not a string (of characters).

This also corrects related log messages and makes them more consistent, by
using hex for all gw_id's.

Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
2026-01-27 15:22:32 -06:00
Michael Zimmermann
be80af2cd4 net: mqtt_sn: drop packets with truncated addresses
The address is only used for gateway discovery, but using a truncated
`struct sockaddr` can lead to out of bounds reads.

Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
2026-01-27 15:22:32 -06:00
Michael Zimmermann
50e17d5c3d net: mqtt_sn: remove broadcast handling from recvfrom
I don't know, why this was added originally, but there are many issues with
it:
- You can't really return NULL, because src_addr is a `void*`, not a
  `void**`. The `src_addr = NULL` didn't do anything.
- The code was checking if the src_addr equals to the broadcast address,
  but under normal conditions, that's always a unicast address.
- Even if we would check if the destination address was the bcaddr, I don't
  see how that's useful. Currently, the address is only used for messages
  of types advertise and gwinfo, which use it to create a new entry in the
  gateway list. In that list, you always need the unicast address, never
  the broadcast address.

Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
2026-01-27 15:22:32 -06:00
Robert Lubos
2b5c66b10d net: dns_sd: Include A/AAAA records for all valid addresses
According to RFC 6763, chapter 12.1, PTR responses SHOULD include
"All address records (type "A" and "AAAA") named in the SRV rdata.".

This was not the case, as only one IPv6 and one IPv4 address was added
in the response by Zephyr. This commit changes this behavior, Zephyr
DNS SD responder will now try to include all IPv4/6 addresses configured
on a given network interface. The current approach of choosing one IPv6
and one IPv4 address first to include in the message is retained - this
is to prevent situation where for example IPv6 addresses will consume
all buffer space, leaving no place for IPv4 ones. The DNS responder will
encode those selected IPv6 and IPv4 addresses first, and then attempt to
include remaining IPv6/4 addresses with "best effort" approach, if there
still is a space in the buffer to add those.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-01-27 10:26:37 -06:00
Robert Lubos
bdfce4a045 net: dns_sd: Avoid responses with unspecified IPv4/6 addresses
IPv4/IPv6 source address lookups may return unspecified address in case
there's no valid match (like for example LL address for global
destination). As it makes no sense to include unspecified addresses in
DNS SD replies, verify if that's not the case before adding A/AAAA
record in the response.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-01-27 10:26:37 -06:00
Robert Lubos
94a9b971ec net: mdns_responder: Use struct dns_header to encode response header
Use struct dns_header pointer when encoding the response header to
reduce code complexity.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-01-27 10:26:37 -06:00
Robert Lubos
c5572b1882 net: mdns_responder: Use net_buf APIs when creating response
Instead of manipulating net_buf's data buffer directly, use net_buf APIs
to reduce complexity when creating mDNS response.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-01-27 10:26:37 -06:00
Robert Lubos
51a2c9cf0d net: mdns_responder: Include all IPv4/6 addresses in responses
RFC 6762 Section 6.2 "Responding to Address Queries" specifies that mDNS
responses must include all valid addresses on the interface that is
sending the response. That was not the case for Zephyr's implementation,
which sent only on address in the response (and in some corner cases no
address at all).

This commit fixes this problem. Instead of encoding a single
pre-selected address in the response, mDNS responder will now loop over
all addresses on a given interface, and try to encode them as separate
answer records in the reply.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-01-27 10:26:37 -06:00
Fin Maaß
171954f5a7 net: net_pkt: refactor net_pkt_cursor_operate
refactor net_pkt_cursor_operate and
make checks more explicit.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-01-27 08:40:01 -05:00
Jukka Rissanen
831f6d729f net: mdns_responder: Re-send announce message for bound DHCPv4 address
If we get DHCPv4 bound event, then resend mDNS announce message
for that interface. This way a new address from DHCP server will
get announced properly.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-01-27 08:39:21 -05:00
Jukka Rissanen
564323989c net: mdns_responder: Mark address in use when adding it
If we try to add an already existing IP address to the
address monitor list, then mark the address to be in use.
The address might have been marked as not-in-use before.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-01-27 08:39:21 -05:00
Jukka Rissanen
aa14f612ee net: if: Send IPv4 address DEL event if overriding address
If we override a static address by a DHCPv4 address, then send
address DEL event so that listeners notice it. This happens
for example with mDNS responder that needs to keep track of
what IPv4 addresses it needs to advertise.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-01-27 08:39:21 -05:00
Jukka Rissanen
a296367a27 net: if: Refactor IPv4 ACD cancel function
Allow calling net_ipv4_acd_cancel() without #ifdef protection.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-01-27 08:39:21 -05:00
Jukka Rissanen
073c75e4e1 net: dns: Context initialization flag was incorrectly used
The "init_called" flag needs to be per context and cannot be global
as it is meant to tell whether the context is initialized first time
or not.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-01-27 08:39:21 -05:00
Yangbo Lu
889ac93bb6 include: zephyr: ethernet: fix multicast address checking
Fixed multicast address checking.

- net_eth_is_addr_multicast() should be for multicast address checking
  but not for only IP multicast address. Then net_eth_is_addr_group()
  is no longer needed.

- LLDP and gPTP multicast address checking should not depend on Kconfig
  option.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2026-01-27 10:56:51 +00:00
Valerio Setti
4a7c5f521e net: lib: sockets: remove selection of crypto features from socket TLS
There is no reason for which CONFIG_NET_SOCKETS_SOCKOPT_TLS should select
some crypto features by default. The correct list really depends on the
server/client the device would like to connect to.
For this reason the selection of any crypto feature is removed from
CONFIG_NET_SOCKETS_SOCKOPT_TLS with the idea that the proper ciphersuite
is to be enabled in the final sample/test configuration file.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2026-01-27 08:05:59 +01:00