Commit graph

7,343 commits

Author SHA1 Message Date
Jukka Rissanen
49b4ac35d3 net: quic: Initial commit
QUIC is described in RFC 9000. It is UDP based transport
used for example in HTTP/3.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-04-21 17:48:04 +01:00
Philipp Steiner
a7cdc70c64 net: fix PTP TX timestamping on native_tap and AF_PACKET
native_tap only queued TX timestamp callbacks for gPTP packets, which
left PTP SO_TIMESTAMPING socket traffic without TX timestamps.

Add host-clock packet timestamp updates in native_tap TX/RX paths, queue
TX timestamp callbacks when net_pkt_is_tx_timestamping() is set (while
preserving gPTP behavior without double-queueing), and propagate
SO_TIMESTAMPING TX/RX flags for AF_PACKET packets in net_context.

Signed-off-by: Philipp Steiner <philipp.steiner1987@gmail.com>
2026-04-20 13:22:07 +02:00
Philipp Steiner
35dec1cd90 net: shell: add net ptp status and per-port diagnostics command
Add a new `net ptp` shell command to inspect PTP runtime state from
the Zephyr shell.

Signed-off-by: Philipp Steiner <philipp.steiner1987@gmail.com>
2026-04-20 13:22:07 +02:00
Philipp Steiner
d5b4078389 net: ptp: add IEEE 802.3 transport support
Add Layer-2 (EtherType 0x88F7) transport support and the PTP stack
updates needed for L2 operation.

Use recvmsg() RX timestamping on IEEE 802.3 sockets and fall back to
recvfrom() when ancillary timestamp data is unavailable, retrying
recvmsg() later so L2 reception keeps working across runtime and driver
limitations. Register Delay_Req TX timestamp handling for both UDP and
L2 paths and suppress expected UDP parse warnings while L2 is enabled.

Also wake the PTP worker when pollfd or state-decision changes require
it, and clear pending Sync, Delay_Req, and foreign clock state when a
port is disabled so stale state is not carried across reopen or link
transitions.

Signed-off-by: Philipp Steiner <philipp.steiner1987@gmail.com>
2026-04-20 13:22:07 +02:00
Philipp Steiner
43f5bc142f net: if: avoid deadlock in TX timestamp callback dispatch
Timestamp callbacks can unregister themselves or other callbacks while
net_if_call_timestamp_cb() is iterating the callback list. That path
runs under the timestamp callback lock, so immediate unregister can
re-enter the same lock and stall the TX timestamp thread.

Handle unregister requests from the dispatch thread by marking callbacks
inactive, skip inactive entries during iteration, and prune them after
dispatch completes.

Signed-off-by: Philipp Steiner <philipp.steiner1987@gmail.com>
2026-04-20 13:22:07 +02:00
Philipp Steiner
01fe77b2ec net: sockets: fix inet recvmsg ancillary buffer accounting
Use NET_CMSG_SPACE() when checking ancillary buffer capacity and
account for aligned cmsg storage in msg_controllen.

This keeps recvmsg() control-data handling consistent with cmsghdr
layout and avoids under-reporting consumed control-buffer space.

Signed-off-by: Philipp Steiner <philipp.steiner1987@gmail.com>
2026-04-20 13:22:07 +02:00
Philipp Steiner
e7ec73aa3c net: sockets: packet: add recvmsg timestamping support
Implement AF_PACKET recvmsg() support and deliver ancillary
SO_TIMESTAMPING data to packet socket users.

Signed-off-by: Philipp Steiner <philipp.steiner1987@gmail.com>
2026-04-20 13:22:07 +02:00
Philipp Steiner
c9bb31e67a net: ptp: fix foreign master handling and BTCA tie-break
Store the first foreign Announce and compare it against the previous entry.
Fix the BTCA receiver-port tie-break to avoid false role decisions.

Signed-off-by: Philipp Steiner <philipp.steiner1987@gmail.com>
2026-04-20 13:22:07 +02:00
Nikhil Namjoshi
d2aec6ab1e net: tcp: Validate TCP header before connection search in tcp_recv
Moved the TCP header validation in tcp_recv() before the connection
lookup to prevent processing malformed packets and improve efficiency.

Signed-off-by: Nikhil Namjoshi <nikhilnamjoshi@google.com>
2026-04-18 12:37:34 -04:00
Nikhil Namjoshi
77aa045b19 net: tcp: Invert invalid condition check in tcp_input
Inverted the condition in tcp_input() to correctly process
valid packets and drop invalid ones.

Signed-off-by: Nikhil Namjoshi <nikhilnamjoshi@google.com>
2026-04-18 12:37:17 -04:00
Jordan Yates
a29c14aeec net: conn_mgr: binding configuration check
Add an optional function to connectivity bindings that communicates
whether the binding has the configuration it needs in order to attempt
a connection. This is then used by the connectivity API for
non-persistent interfaces to determine whether it makes sense for the
interface to be powered up.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2026-04-17 15:52:09 -05:00
David Boullie
ba3984a658 net: ieee802154: move ieee802154_frame.h to common location
Move header for IEEE 802.15.4-2020 constants from subsystem
location to common for usage by 15.4 radio device drivers.

Signed-off-by: David Boullie <David.Boullie@silabs.com>
2026-04-17 15:51:19 -05:00
Kapil Bhatt
31866086a5 net: wifi: Set frequency default value as zero for P2P Connect
For P2P connect set frequency default value as 0.
Let wpa_supplicant choose channel. User can override with -f option.

Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
2026-04-17 16:42:16 +01:00
Maochen Wang
8cb5ac07f4 net: l2: wifi: reject invalid PSK/SAE password length in AP mode
Add input validation for PSK and SAE password length in wifi_ap_enable().
Invalid lengths could trigger driver-side assertions during AP startup.
Return -EINVAL when parameters are out of range instead of letting the
AP enable flow proceed.

Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
2026-04-17 12:37:30 +01:00
Arthur Gay
f1dfc3744b net: http_client: Handle body of 5xx reponses
In the http client, the body of 5xx was skipped, leading to a parse error
in the http parser when it reaches the body.

Signed-off-by: Arthur Gay <arthur.gay@marshmallow.kids>
2026-04-16 14:47:07 +02:00
Tim Pambor
aaed8332a6 net: ipv6: nbr: fix use-after-free
Avoid accessing the packet after sending it, as the driver may
have already unreferenced or freed it. Use iface argument instead
of calling net_pkt_iface() on a potentially freed packet when
updating packet statistics.

Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
2026-04-15 17:16:36 -04:00
Tim Pambor
3159c53e8e net: ipv6: mld: fix use-after-free
Avoid accessing the packet after sending it, as the driver may
have already unreferenced or freed it. Store the iface before
sending instead of calling net_pkt_iface() on a potentially
freed packet when updating packet statistics.

Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
2026-04-15 17:16:36 -04:00
Tim Pambor
0223e5e3ec net: ip: igmp: fix use-after-free
Avoid accessing the packet after sending it, as the driver may
have already unreferenced or freed it. Store the iface before
sending instead of calling net_pkt_iface() on a potentially
freed packet when updating packet statistics.

Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
2026-04-15 17:16:36 -04:00
Tim Pambor
09c8578c66 net: ip: icmpv6: fix use-after-free
Avoid accessing the packet after sending it, as the driver may
have already unreferenced or freed it. Store the iface before
sending instead of calling net_pkt_iface() on a potentially
freed packet when updating packet statistics.

Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
2026-04-15 17:16:36 -04:00
Tim Pambor
86e21665d4 net: ip: icmpv4: fix use-after-free
Avoid accessing the packet after sending it, as the driver may
have already unreferenced or freed it. Store the iface before
sending instead of calling net_pkt_iface() on a potentially
freed packet when updating packet statistics.

Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
2026-04-15 17:16:36 -04:00
Alberto Escolar Piedras
4f2e63556a net: coap: mark function as possibly unused
encode_be32() is only used in some configurations.
Let's mark it as possibly unused so the compiler does not warn us about
it

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2026-04-15 15:39:01 +02:00
Benjamin Cabé
700c42c4aa net: coap: remove unused insert_be32 function
Commit b9d3344fd4 introduced this static
helper function that is effectively unused and makes clang unhappy.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-04-15 13:50:00 +02:00
Rithic Chellaram Hariharan
1fcdeffa95 net: sockets: tls: make session cache prefix configurable
Turn the hardcoded TLS_SETTINGS_PREFIX into a Kconfig symbol
CONFIG_NET_SOCKETS_TLS_SESSION_CACHE_PERSISTENT_PREFIX so users
can choose a different settings key prefix if needed.

Signed-off-by: Rithic Chellaram Hariharan <gr8rithic@gmail.com>
2026-04-15 05:48:42 -04:00
Rithic Chellaram Hariharan
93eb99a2e4 net: sockets: tls: add persistent session cache via settings
Add persistent TLS/DTLS session cache support using the settings
subsystem. Sessions are saved after each successful handshake and
restored during tls_init(), enabling session resumption across
device reboots without a full handshake.

Backend-agnostic: works with any settings backend (NVS, ZMS, FCB,
filesystem).

Signed-off-by: Rithic Chellaram Hariharan <gr8rithic@gmail.com>
2026-04-15 05:48:42 -04:00
Sanjay Vallimanalan
208a2d3fa8 net: ocpp: Add TLSv1.3 support
Added support for TLSv1.3 to the OCPP subsystem by enabling
TLS secure sockets. This allows secure WebSocket
connections over TLSv1.3 during OCPP communication.

Signed-off-by: Sanjay Vallimanalan <sanjay@linumiz.com>
2026-04-15 05:37:57 -04:00
Kapil Bhatt
df9a974782 modules: hostap: Display WEP Open/Shared in status
Instead of WEP show WEP-OPEN and WEP-SHARED in status.

Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
2026-04-14 22:37:55 -04:00
Pieter De Gendt
85a0e87743 net: lib: coap: client: Improve timeout check for multicast requests
Multicast requests should only check mcast_timeout in timeout_expired.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-04-14 22:37:40 -04:00
Pieter De Gendt
139e2f269d net: lib: coap: client: Calculate next resend timeout
Instead of waiting the full socket poll period, calculate the next timeout
to resend messages.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-04-14 22:37:40 -04:00
Pieter De Gendt
76c7c84daf net: lib: coap: client: Reset canceled requests instead of release
Clear the request slot if we cancel them. release_internal_request is
wrong for cancel: Its purpose is to keep token/MID data so late responses
can be matched. But handle_response just silently drops responses for
released slots anyway.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-04-14 22:37:40 -04:00
Egill Sigurdur
50cf2ba410 net: sockets: support FIONWRITE ioctl for TCP
Add support for getting the number of bytes queued for TCP TX
that have not yet been acknowledged. Follows FreeBSD's API.

Signed-off-by: Egill Sigurdur <egill@egill.xyz>
2026-04-14 22:34:42 -04:00
Nikhil Namjoshi
d619f4e501 net: Add net_pkt_set_data API return error handling
There some more instances of net_pkt_set_data API
whose return code is not being checked.

Signed-off-by: Nikhil Namjoshi <nikhilnamjoshi@google.com>
2026-04-14 22:31:56 -04:00
Nikhil Namjoshi
87bab421db net: Add net_pkt_write API return error handling
There some more instances of net_pkt_write API
whose return code is not being checked.

Signed-off-by: Nikhil Namjoshi <nikhilnamjoshi@google.com>
2026-04-14 22:31:56 -04:00
Nikhil Namjoshi
79f363da92 net: Add net_pkt_acknowledge_data API return error handling
There some more instances of net_pkt_acknowledge_data
API whose return code is not being checked.

Signed-off-by: Nikhil Namjoshi <nikhilnamjoshi@google.com>
2026-04-14 22:31:56 -04:00
Nikhil Namjoshi
2a055077dc net: Add net_pkt_skip API return error handling
There some more instances of net_pkt_skip API whose
return code is not being checked.

Signed-off-by: Nikhil Namjoshi <nikhilnamjoshi@google.com>
2026-04-14 22:31:56 -04:00
Yangbo Lu
bb599be0b3 net: ptp: handle GRAND_MASTER state properly in state machine
In IEEE 1588 standard, there was actually no GRAND_MASTER port state.
We should treat GRAND_MASTER as same as MASTER state (TIME_TRANSMITTER)
in code.

So, added the case PTP_PS_GRAND_MASTER handling same with
PTP_PS_TIME_TRANSMITTER. Otherwise port entering PTP_PS_GRAND_MASTER
won't go out of the state. Also removed switching PTP_PS_TIME_TRANSMITTER
to PTP_PS_GRAND_MASTER which was useless.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2026-04-14 22:30:42 -04:00
Ofir Shemesh
cd85e0e890 net: tcp: fix use-after-free in net_tcp_foreach()
net_tcp_foreach() drops tcp_lock before the callback and re-acquires
it afterwards. A concurrent tcp_conn_release() can free the next
node cached by SYS_SLIST_FOR_EACH_CONTAINER_SAFE during this window,
causing the iterator to follow a dangling pointer on the next
iteration.

Move context teardown in tcp_conn_release() inside the tcp_lock
critical section and keep tcp_lock held across the callback in
net_tcp_foreach(). No current callback acquires tcp_lock.

Signed-off-by: Ofir Shemesh <ofirshemesh777@gmail.com>
2026-04-14 22:28:30 -04:00
Muhammad Waleed Badar
ab32cd6fb8 net: shell: add HTTP client shell commands
Add HTTP client shell commands under the 'net http' subcommand group.
Supports GET, POST, PUT, and DELETE methods.

Commands:
  net http get <url>
  net http post <url> <body>
  net http put <url> <body>
  net http delete <url>

Signed-off-by: Muhammad Waleed Badar <walid.badar@gmail.com>
2026-04-14 22:22:41 -04:00
Savo Saicic
10d7d7ddd5 net: lwm2m: add IPSO Time object support
This Object allows an LwM2M server to read and synchronize the device
current time.

Signed-off-by: Savo Saicic <savo.saicic@gmail.com>
2026-04-14 22:20:52 -04:00
Marcus Penate
b9d3344fd4 net: coap: add support for CoAP over reliable transports
Add CoAP over TCP/TLS framing, parsing, and client support as
specified in RFC 8323. This includes:

- TCP message framing with variable-length header encoding
- CSM (Capabilities and Settings Message) exchange
- Signaling codes: Ping/Pong, Release, Abort
- CoAP TCP client with blockwise transfer support
- New Kconfig options under CONFIG_COAP_OVER_RELIABLE_TRANSPORT
- Documentation update for CoAP client API

Signed-off-by: Marcus Penate <marcus.penate@ellenbytech.com>
2026-04-14 22:06:34 -04:00
Robert Lubos
8588b08808 net: tcp: Fix TCP context cleanup during async handshake
In case socket is closed during an async TCP handshake, the TCP context
should be closed immediately, otherwise the connection could be
established after the socket was closed, causing TCP context leak.
To avoid race between socket close and resend timer (i.e. socket being
closed at the same time as the retransmission limit is reached), add
extra state checks before attempting to close the TCP context.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-04-07 11:38:18 -05:00
Vytautas Virvičius
1ea30bf774 net: http_client: Fix body_frag_len overcounting with chunked TE
body_frag_len was computed using a raw buffer offset formula:

  body_frag_len = data_len - (body_frag_start - recv_buf)

This is correct for Content-Length responses: the recv buffer contains
only decoded body bytes after the headers, so the offset arithmetic
gives the exact body byte count.

It is broken for Transfer-Encoding: chunked.  RFC 7230 §3.3.2 makes
the two mutually exclusive, so chunked TE never comes with a
Content-Length.  With chunked TE, the recv buffer contains both the
decoded body bytes and the chunk framing bytes (chunk-size line, CRLF
body-terminator, terminal chunk "0\r\n\r\n") side by side.  The
formula counts everything from body_frag_start to the end of the
buffer fill, so it includes the framing bytes that follow the body,
causing body_frag_len to overcount.

http_parser already knows the exact decoded body byte count: it passes
it as the length argument to on_body(). Use that instead.

Add a regression test that sends a single chunked 206 response from a
raw loopback TCP server in one write, so the chunk terminator and
terminal chunk land in the same recv buffer as the body.  The test
asserts body_frag_len equals the decoded body size, not body size + 7
framing bytes.

Signed-off-by: Vytautas Virvičius <vytautas@virvicius.dev>
2026-04-07 11:37:19 -05:00
Cristian Bulacu
2952c2478d net: dns: Forward all DNS packets if callback is installed
This PR enables the DNS packet forwarding without taking into account
the return value of `dns_validate_msg` function.
This is to accomodate scenarios like where ANCOUNT is set to 0, or other
cases in which internal DNS implementation will not validate the
message.

Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
2026-04-07 08:41:50 -05:00
David J. Leach, Jr.
e3645486d1 net: ocpp: replace RPC type magic numbers with symbolic constants
Replace the hardcoded WAMP RPC type values used when encoding OCPP
messages with their corresponding symbolic constants.

- Replace '2' with OCP_WAMP_RPC_REQ
- replace '3' with OCP_WAMP_RPC_RESP

This removes magic numbers and improves human readability.

Signed-off-by: David J. Leach, Jr. <tasmar@gmail.com>
2026-04-04 10:55:08 -05:00
David J. Leach, Jr.
a1585cd5e9 net: ocpp: Protect against static analysis issue generation
Static analysis has a difficult time tracing whether a call to
ocpp_send_to_server() needs to initialize sndlock and rspsig because
the message type is set very much earlier in the program logic flow.
Note that coverity is creating a single issue for sndlock and for rspsig
in each function that calls ocpp_send_to_server() without initializing
them.

Adding a NULL test will prevent future static analysis false positives.

Fixes #100026
Fixes #100025
Fixes #100024
Fixes #100017
Fixes #100015
Fixes #100013
Fixes #100011
Fixes #100010
Fixes #100008
Fixes #100006

Signed-off-by: David J. Leach, Jr. <tasmar@gmail.com>
2026-04-04 10:55:08 -05:00
Nikhil Namjoshi
41082f40fc net: Initialize chksum variable to avoid clang build errors
This addresses clang build failure seen in
https://github.com/zephyrproject-rtos/zephyr/runs/69856219528

after PR #106578 was merged.

Signed-off-by: Nikhil Namjoshi <nikhilnamjoshi@google.com>
2026-04-03 14:58:06 -05:00
Zafer SEN
5f01a3d236 lwm2m: remove redundant NULL check in _INIT_OBJ_RES_INST
Drop the unnecessary _ri_ptr NULL check, as multi-instance resources
always provide a valid instance array when _ri_count > 0. This
simplifies the initialization logic and prevents compile time warrning
messages/noice.

Signed-off-by: Zafer SEN <zafersn93@gmail.com>
2026-04-03 14:56:14 -05:00
Taha Benderli
517cfd37d8 net: l2: ethernet: fix order of address check
ethernet_update_tx_stats checks the multicast address first and then the
broadcast which causes the broadcast address to be treated as multicast
and not counted correctly.Fix this by checking broadcast address first,
followed by the multicast address.

Signed-off-by: Taha Benderli <taha.benderli@analog.com>
2026-04-03 23:18:26 +09:00
Nikhil Namjoshi
c12f7b566c net: Add net_pkt_skip error handling
There are several areas in the networking stack where this is missing.
So make sure we add it.

Signed-off-by: Nikhil Namjoshi <nikhilnamjoshi@google.com>
2026-04-03 23:14:47 +09:00
Nikhil Namjoshi
f98624455c net: Update net_calc_chksum to return err code on failure
`net_calc_chksum` is designed to return uint16_t checksum.
Its current behavior is to return 0 checksum on error
(or on an empty payload) and a valid non zero checksum for non empty
payloads. 0 could be a valid checksum for empty payload.

So update the `net_calc_chksum` and its wrapper's definition to
return error codes.

Signed-off-by: Nikhil Namjoshi <nikhilnamjoshi@google.com>
2026-04-03 23:14:47 +09:00
Nikhil Namjoshi
86fd0944c5 net: tcp: Fix potential underflow in tcp data length
tcp_options_len calculation in tcp_data_len can underflow
if th_off(th) is less than 5. This can lead to a huge
tcp_options_len value and subsequently a wrong data length calculation.
Add the checks in tcp_recv() which is a top API, so that the checks
are covered at the entry point.

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

Signed-off-by: Nikhil Namjoshi <nikhilnamjoshi@google.com>
2026-04-03 23:13:33 +09:00