Commit graph

6489 commits

Author SHA1 Message Date
Rait Rääk
220c4fffd3 net: ethernet: arp: Fix incorrect adding to the pending queue
k_fifo_put is a macro that expands the call to net_pkt_ref(pending)
multiple times when CONFIG_TRACING is enabled thus causing extra
reference for the pending packet and a memory leak.
Fix by moving the referencing call to a separate line.
Signed-off-by: Rait Rääk <raitraak@gmail.com>
2024-12-06 22:21:31 +01:00
Robert Lubos
3163325e01 net: sockets: tls: Fix connect timeout error code
In case TLS connect timed out during the handshake, errno was set to
EAGAIN which is unexpected and confusing. Fix this and set the errno
to ETIMEDOUT instead.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-12-06 18:19:54 +01:00
Gang Li
5a383919a0 net: wifi: change the acquisition of wifi interface
For WiFi interface, uniformly use net_if_get_wifi_sta() and
net_if_get_wifi_sap() APIs to replace net_if_get_first_wifi().

Signed-off-by: Gang Li <gang.li_1@nxp.com>
2024-12-06 06:50:19 +01:00
Matt Rodgers
ddaeb1379a net: http_server: fix header capture on concurrent http2 streams
Concurrent HTTP POST requests on different HTTP2 concurrent streams
require that the client's header_capture_context is re-used to capture
headers on a second stream before all of the body data has been received
(and sent to the application) on the first stream.

As a result, any captured headers must be sent to the application
callback before any headers can be received on a different stream. In
practice this means that for HTTP2 the application callback is called
for the first time on receiving a headers frame, before any data frames
are received. All subsequent application callbacks will not include the
request header data.

While this mechanism is not necessary for HTTP1, it is also updated to
only send headers in the first application callback for consistency.

Fixes #82273

Signed-off-by: Matt Rodgers <mrodgers@witekio.com>
2024-12-04 14:13:24 -05:00
Matt Rodgers
f050e0bdb1 net: http_server: store current resource detail at an http2 stream level
To correctly handle concurrent HTTP POST requests via different http2
streams on the same client context, it is necessary to store the
resource detail at an HTTP2 stream level rather than at an HTTP client
level, otherwise only one resource detail can be stored.

Signed-off-by: Matt Rodgers <mrodgers@witekio.com>
2024-12-04 14:13:24 -05:00
Hui Bai
ae7613b2c9 wifi: add hidden SSID configuration support for SoftAP
Added hidden ssid support configuration for AP mode.

Signed-off-by: Hui Bai <hui.bai@nxp.com>
2024-12-04 12:09:59 +01:00
Jukka Rissanen
abad505bde net: sockets: Remove deperecated CONFIG_NET_SOCKETS_POSIX_NAMES
The deprecated CONFIG_NET_SOCKETS_POSIX_NAMES option is removed.
If one wishes to use POSIX API socket calls, then CONFIG_POSIX_API
option needs to be enabled.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-12-04 12:09:51 +01:00
Arkadiusz Balys
6464ea88fe net: openthread: Allow a platform to select a Settings backend.
Removed implying of NVS by the NET_L2_OPENTHREAD, and from now a
platform can choose between ZMS and NVS as a settings backend.
NET_L2_OPENTHREAD still requires NVS or ZMS backend so the config
depends on one of those.

Signed-off-by: Arkadiusz Balys <arkadiusz.balys@nordicsemi.no>
2024-12-02 18:18:20 +01:00
Steven Poon
30b30c29a3 net: lib: lwm2m: Fix missing mutex unlock
lwm2m_engine_set() and lwm2m_engine_get() locks
the registry_lock mutex, but this is not unlocked
when setting or getting a time resource where the buffer
lengths are invalid resulting in an early return without
unlocking the mutex. This results in a deadlock when
attempting to lock the registry in another thread.

Signed-off-by: Steven Poon <steven-github@outlook.com>
2024-12-02 14:24:17 +01:00
Steve Boylan
48b70cf180 net: ipv6: Fix unaligned access to IPv6 address
Add UNALIGNED_GET() to prevent alignment fault when
reading parts of the IPv6 address.

Signed-off-by: Steve Boylan <stephen.boylan@beechwoods.com>
2024-12-02 01:33:45 +01:00
Chaitanya Tata
619cdb64f4 wifi: Fix current PHY rate handling
Fix the name to include TX and also add units to the shell display.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-11-29 11:45:58 +01:00
Robert Lubos
a32d339c34 net: ipv4: Specify default netmask for IPv4 addresses registered
When IPv4 address is added, currently the netmask remains empty. This
makes it impossible to use the address now that the netmask is
considered during address selection if the application does not
specify the netmask manually. Therefore specify a default netmask for
IPv4 addresses added to an interface with Kconfig.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-11-29 11:44:39 +01:00
Robert Lubos
68241fb1e2 net: ipv4: Filter the subnet part of the IPv4 addr when choosing src
Bit-wise comparing of the entire IPv4 addresses doesn't make much sense
as when selecting the source address for communication, what really
matters is the subnet part.

Doing so may actually lead to unexpected results, i. e. two addresses
within the same subnet should be considered equally good for
communication within the subnet, yet comparing the unique part of
the address (beyond the netmask) may lead to different results.
This is a problem for the mechanism of preferring the default interface
for LL communication if two interfaces have LL addresses with the
default subnet mask.

Fix this by filtering out the subnet from the IPv4 address before
passing it to net_if_ipv4_get_best_match() function.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-11-29 11:44:39 +01:00
Robert Lubos
a909b538dc net: ipv4: Rework source address matching for LL addresses
Currently we blindly return the LL address found on the default
interface or else on the first interface that has a valid LL address
configured.

This doesn't work well, if different interfaces have LL addresses
configured with a different subnet mask. Therefore, instead of blindly
selecting the address based on the first LL address encountered, use
net_if_ipv4_get_best_match() function for LL addresses to find the best
match for the given interface.

The rework takes into account current behavior, i. e. default interface
still gets the preference if there is no better candidate.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-11-29 11:44:39 +01:00
Chaitanya Tata
9762c32115 wifi: Update help/notes for forcing regulatory domain
With recent changes the regulatory domain is handled via the hostap
rather than by passing and going through the driver and hostap doesn't
have any option for forcing the regulatory domain, so, add a note to
reflect that this is implementation dependent to cover both hostap as
well other offloaded implementations.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-11-29 05:42:03 +01:00
Jukka Rissanen
6e7fcff579 net: dns: Check DNS answer properly
The dns_unpack_answer() did not check the length of the message
properly which can cause out of bounds read.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-11-28 20:52:20 +01:00
Jukka Rissanen
43c2b9cfe8 net: dns: Validate source buffer length properly
Make sure that when copying the qname, the source buffer is large
enough for the data.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-11-28 20:52:20 +01:00
Jukka Rissanen
eb2550a441 net: dns: Check parsing error properly for response
If the packet parsing fails in dns_unpack_response_query(), then
do not continue further but bail out early.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-11-28 20:52:20 +01:00
Jukka Rissanen
3c59bd4fb5 net: wifi_cred: Decrease flash usage for error print strings
As the error print strings are very similar, construct the final
output at runtime to save some flash space.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-11-28 20:52:06 +01:00
Jukka Rissanen
8deebcec21 net: wifi_cred: Remove extra empty lines
Follow net coding style and remove extra new lines between
variable set and checking its value.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-11-28 20:52:06 +01:00
Jukka Rissanen
b2056e0966 net: wifi_cred: Introduce variables at the start of function
Follow the net coding style and declare the variables at the start
of the function.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-11-28 20:52:06 +01:00
Jukka Rissanen
3aa0c8670e net: wifi_cred: Check null before access
We must do null check before trying to access the fields.

Fixes #81980
Coverify-CID: 434549

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-11-28 20:52:06 +01:00
Robert Lubos
df79f10513 net: lib: http_server: Verify fs_read result for filesystem resources
Verify the result of the fs_read() operation when handling filesystem
resources, and abort processing the resource in case of errors.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-11-28 15:43:32 +00:00
Stig Bjørlykke
95333705e5 net: lwm2m: Reset server timestamps after bootstrap
Reset the server timestamps after bootstrap to handle a case
where a new server instance has replaced the bootstrap server
instance.

Signed-off-by: Stig Bjørlykke <stig.bjorlykke@nordicsemi.no>
2024-11-28 15:43:18 +00:00
Robert Lubos
35820f23f6 net: lwm2m: Add missing NULL pointer check in shell
In case lwm2m_get_engine_obj_field() fails to find a corresponding
object field when iterating resource instances, simply skip that
resource instance when printing object instance contents.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-11-28 15:43:04 +00:00
Stig Bjørlykke
48de0fcd73 net: lwm2m: Fix index for default disabled_until
Use correct index to set disabled_until default value in
server_create().

Signed-off-by: Stig Bjørlykke <stig.bjorlykke@nordicsemi.no>
2024-11-28 15:42:54 +00:00
Stig Bjørlykke
633269a913 net: lwm2m: Accept OMA TLV in LwM2M 1.1
Support write OMA TLV resource instance in LwM2M 1.1.
Accept OMA TLV as default content format.

Signed-off-by: Stig Bjørlykke <stig.bjorlykke@nordicsemi.no>
2024-11-28 15:42:42 +00:00
Jukka Rissanen
3bd4000712 net: dns: mdns_responder: Interface name might miss terminating null
The network interface name that is copied to if_req struct might
be missing terminating null for IPv4.

This is fixing the IPv4 issue which was missed in previous fix attempt.

Fixes #74795
Coverity-CID: 368797

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-11-28 15:42:32 +00:00
Jukka Rissanen
bf091fc909 net: ipv6: Check return value from mbedtls_md_setup
Bail out if mbedtls_md_setup() returns an error.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-11-28 15:42:08 +00:00
Jukka Rissanen
26d033b790 net: ipv6_pe: Check return value from mbedtls_md_setup
Bail out if mbedtls_md_setup() returns an error.

Fixes #81950
Coverify-CID: 434626

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-11-28 15:42:08 +00:00
Stig Bjørlykke
7d20d3a28c net: lwm2m: Make BinaryAppDataContainer instances configurable
Add Kconfig variables for BinaryAppDataContainer instance count
and data instance count.

Signed-off-by: Stig Bjørlykke <stig.bjorlykke@nordicsemi.no>
2024-11-28 15:41:52 +00:00
Ravi Dondaputi
11dae0e9eb net: l2: wifi: Add checks for cert header creation
Execute certificate headers creation rules only if Wi-Fi Enterprise mode
is enabled.

Signed-off-by: Ravi Dondaputi <ravi.dondaputi@nordicsemi.no>
2024-11-28 12:52:34 +01:00
Jukka Rissanen
c6a1af5c17 net: ethernet: bridge: Drop the cloned packet in error
We need to drop the cloned packet that was fed to the bridge instead of
returning directly from the function. Without this change we have a
buffer leak.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-11-28 12:50:36 +01:00
Jukka Rissanen
ed0dcca2fb net: ethernet: bridge: Avoid null pointer access
If the packet cloning failed, bail out in order to avoid
null pointer access.

Fixes #81992
Coverity-CID: 434493

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-11-28 12:50:36 +01:00
Jamel Arbi
70add85f9f drivers: openthread: nxp: Add a HDLC RCP communication
Add a HDLC RCP communication with its hdlc_api interface APIs
and a NXP driver.

Signed-off-by: Jamel Arbi <jamel.arbi@nxp.com>
2024-11-27 10:37:21 -05:00
Pisit Sawangvonganan
08fe69cc3c net: wifi: shell: enhance consistency in __wifi_args_to_params
Several arguments were added but have not yet been aligned with others
in the same function. Hence, use `getopt_state` to access `optarg`,
offering a better alternative to direct global access.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-11-27 08:17:15 +01:00
Jukka Rissanen
34ed76b185 net: prometheus: Add way to format output by a metric
Instead of requiring one big buffer for formatting the output,
have a walk function that can be used to generate output by
one metric at a time.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-11-26 15:42:40 -05:00
Jukka Rissanen
6803e343ef net: prometheus: collector: Add more debugging info
Print also metric name together with type when registering.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-11-26 15:42:40 -05:00
Jukka Rissanen
7e881d22a1 net: stats: Add prometheus support
Allow user to update prometheus metrics from network statistics.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-11-26 15:42:40 -05:00
Jukka Rissanen
c7989b5747 net: prometheus: Add more parameters to metric macros
Add collector parameter to metric creation macros so that it
is possible to bind the metric to collector already at built
time.

Also add optional user_data to metric macro calls so that user
can add optional data there. This will be used by network statistics
Prometheus support in subsequent commits.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-11-26 15:42:40 -05:00
Jukka Rissanen
8e83cf0797 net: prometheus: Configure max number of labels from Kconfig
Allow user to configure the label count from Kconfig.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-11-26 15:42:40 -05:00
Jukka Rissanen
d3efcbd316 net: prometheus: Remove need to have separate metric struct
Embed "struct prometheus_metric" to individual metric like
counter, gauge, histogram and summary. This way we avoid having
a separate base pointer in specific metrict struct. We also do
not need to search the specific metric from base metric as
we can simply use CONTAINER_OF() macro to get the base metric.

This embedding means that the counter, gauge, histogram and summary
metric define macros are changed as user does not need to create a
separate "struct prometheus_metric".

Convert the tests and sample to use the new macros.

Remove also the static from metric creation macros so that user
can decide whether it needs collector to be static or not.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-11-26 15:42:40 -05:00
Jukka Rissanen
90fb4b38ca net: prometheus: Use linked list for metrics
Save same memory and store metrics into a linked list inside
a collector entry.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-11-26 15:42:40 -05:00
Jukka Rissanen
460e2f86d7 net: prometheus: summary: Add set function to summary metric
Add prometheus_summary_observe_set() function to summary metric.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-11-26 15:42:40 -05:00
Jukka Rissanen
0ec8385bec net: prometheus: counter: Add function to set the counter value
This is similar function as add, but will add the difference of
previous value and the new one. This can be used if we want to
periodically update the value with a new one but don't want to
keep track of the old one.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-11-26 15:42:40 -05:00
Jukka Rissanen
d94bcd2566 net: prometheus: counter: Add function to add a value
Add function to increase the counter value with arbitrary value.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-11-26 15:42:40 -05:00
Chen Xingyu
de1643d8fb net: mqtt: Fix error of size_t formatting with PRIu16
This addresses the following warning building with `CONFIG_64BIT=y`:

    error: format '%hu' expects argument of type 'int', but argument X has
    type 'size_t' {aka 'long unsigned int'}

Signed-off-by: Chen Xingyu <hi@xingrz.me>
2024-11-26 10:37:20 +00:00
Yong Cong Sin
b1def7145f arch: deprecate _current
`_current` is now functionally equals to `arch_curr_thread()`, remove
its usage in-tree and deprecate it instead of removing it outright,
as it has been with us since forever.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2024-11-23 20:12:24 -05:00
Rex Chen
b4035e83d4 net: wifi: shell: add enterprise support for sap
Add EAP-TLS, EAP-PEAP-MSCHAPv2, EAP-PEAP-GTC, EAP-TTLS-MSCHAPv2,
EAP-PEAP-TLS, EAP-TLS-SHA256 enterprise wpa2 and wpa3 suiteb
support for sap.

Signed-off-by: Rex Chen <rex.chen_1@nxp.com>
2024-11-22 13:03:53 -06:00
Maochen Wang
13f473d7eb hostap: add WPS PBC and PIN for AP mode
add WPS PBC and PIN for AP mode.

Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
2024-11-22 17:44:08 +01:00