Commit graph

6489 commits

Author SHA1 Message Date
Chaitanya Tata
7ba5e43cf5 net: lib: tls_credentials_shell: Add a config for heap
The volatile backend stores the credentials on the heap, so, explicitly
add a config option that can be overridden in case there are more certs
than the default.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2025-04-17 17:22:58 +02:00
Chaitanya Tata
b2e7d7fc0c net: l2: wifi: Add support for run-time certificates
Using TLS credentials library add support for run-time certificates where
the installed certs are retrieved from the credential store (as of now
only volatile backend is tested).

This helps in production environments.

Implements #79564.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2025-04-17 17:22:58 +02:00
Kapil Bhatt
a9507729c7 net: lib: Correct the wifi_cred command
Change wifi_cred to wifi cred.

Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
2025-04-16 14:53:54 +02:00
Jukka Rissanen
4c01b37bda net: pkt_filter: Add VLAN support to filtering
The Ethernet matching needs tweaking so that it will also
work with VLAN packets.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-04-16 08:07:34 +02:00
Jukka Rissanen
3232b6190c net: pkt_filter: Add more debug prints when matching packets
Add some more useful debug prints when checking packets.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-04-16 08:07:34 +02:00
Jukka Rissanen
28dca17436 net: shell: Add packet filter support
Add a "net filter" command that will allow user to see the
current network packet filter configuration.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-04-16 08:07:34 +02:00
Jukka Rissanen
f5bac38865 net: pkt_filter: Add enablers for shell support
Add helpers and enablers that allow "net filter" shell command to
work.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-04-16 08:07:34 +02:00
Jukka Rissanen
bd3ce84d91 net: virtual: Hook into packet filter processing
Make sure that we check possible network packet filtering status
before accepting the packet.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-04-16 08:07:34 +02:00
Jukka Rissanen
cde70232b9 net: pkt_filter: Add statistics support to packet filter
As the network packet filter drops packets without any indication
that the packet is dropped, it can be difficult to monitor what
is going on in the system when receiving data. The user can
now monitor the statistics and see if packets are being dropped
because of packet filter activity.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-04-16 08:07:34 +02:00
Jukka Rissanen
c066deb5ef net: pkt_filter: Avoid unused function warning
The get_ip_rules() function is only used if IPv4 or IPv6
filtering is enabled so add checks to avoid unused function
warning.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-04-16 08:07:34 +02:00
Jordan Yates
dfabbee634 net: socketpair: fix allocated number of buffers
According to `f9901e8e` and validated by testing, the supplicant only
use case only requires 4 socket pairs. 6 pairs are required for the
`hostapd` use case.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-04-16 08:05:12 +02:00
Jordan Yates
94583777fd net: socketpair: give allocation strategy option a name
Give the socketpair allocation strategy a name so that users can change
the default.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-04-16 08:05:12 +02:00
Jordan Yates
e803bfb4bb net: ip: net_context: louder warning for no src address
Increase the verbosity of the message when there is no source address
in `net_context_create_ipv4_new`. This is likely the first failure point
when attempting to send data on an interface that has not yet been
assigned an IP address. Burying the fault at the DBG level makes it much
more time consuming to determine the root cause of this error.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-04-16 08:05:03 +02:00
Eric Ackermann
421a7047e5 net: gPTP: Fix pointer type in gptp_add_port
The number of ports in gptp_domain.default_ds.nb_ports is a uint8_t.
A pointer to it is passed to gptp_add_port.
However, in this method, the pointer is cast to an int pointer.
The C compiler generates an int-size store for this.
In addition to potentially overwriting adjacent attributes, on platforms
such as RISC-V that do not support unaligned accesses, this causes an
exception on access.
This commit casts nb_ports to the correct type, uint8_t.

Signed-off-by: Eric Ackermann <eric.ackermann@cispa.de>
2025-04-15 19:10:04 +02:00
Torsten Rasmussen
db6b126e90 zperf: moving declaration of variable to top of function
Declaration of variables after a label inside a switch statement is a
c23 extension, not c99.

This results in the following warning when compiling with clang:
> .../subsys/net/lib/zperf/zperf_shell.c:912:4: warning: label followed
>                by a declaration is a C23 extension [-Wc23-extensions]
>   912 |                      int seconds = parse_arg(&i, argc, argv);
>       |                         ^
> .../subsys/net/lib/zperf/zperf_shell.c:1145:4: warning: label followed
>                by a declaration is a C23 extension [-Wc23-extensions]
>  1145 |                      int seconds = parse_arg(&i, argc, argv);
>       |                         ^
> 2 warnings generated.

There are no practical reasons why the variable should be declared
inside the switch statement, therefore move the declaration and place it
together with declaration of other variables.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2025-04-14 09:47:57 +02:00
Robert Lubos
ab448a88db net: openthread: Fix ignored return values in OT utils
Do not ignore return values of OT functions registering IPv6 addresses.
As this is called from the net_mgmt callback context, which returns
void, there's not much that can be done, other than logging the error.

To simplify the logging code and avoid the need to use extra buffer,
use net_sprint_ipv6_addr() networking utility function within the log
message to convert binary address to string.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-04-11 14:53:59 +02:00
Triveni Danda
b20e87ae7a net: lib: wifi_credentials: Fix security type check while storing creds
Fix credential store corruption issue caused by missing
security type checks. Add support for all valid security
types to ensure credentials are parsed correctly.

Fixes #88261.

Signed-off-by: Triveni Danda <triveni.danda@nordicsemi.no>
2025-04-10 14:44:02 +02:00
Nitin Pandey
0259bf56c8 driver: wifi: siwx91x: Add check for SAE password
- Modified conditions in WIFI_CONNECT()
  function to reject SAE password and
  PSK based on length parameter

Signed-off-by: Nitin Pandey <nitin.pandey@silabs.com>
2025-04-09 19:32:26 +02:00
Gerhard Jörges
9d0d7ad3b8 net: lib: http_server: implement concurrent
only accept new connections until the configured value for concurrent
connections is reached. Also set the backlog of the listening socket
to the configured value.

Signed-off-by: Gerhard Jörges <joerges@metratec.com>
2025-04-09 17:32:50 +02:00
Triveni Danda
b3ea4f8d5c net: Fix Kconfig check for enterprise mode
Fix the kconfig check for enterprise crypto support in AP mode.
Also, remove the unnecessary Hostapd enterprise crypto check in
credentials code.

Signed-off-by: Triveni Danda <triveni.danda@nordicsemi.no>
2025-04-09 12:37:29 +02:00
Robert Lubos
307694f3d9 net: sockets: Remove support for AF_PACKET/IPPROTO_RAW combination
IPPROTO_RAW is not a valid protocol type for AF_PACKET sockets, which
should only use IEEE 802.3 protocol numbers. Therefore remove support
for this type of sockets.

As an alternative, users can use AF_PACKET/SOCK_DGRAM or
AF_INET(6)/SOCK_RAW, depending on the actual use case.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-04-09 12:36:34 +02:00
Robert Lubos
7c87aab783 net: sockets: Add SOCK_RAW support for AF_INET/AF_INET6 sockets
Introduce changes in the networking stack which allow to create raw IP
sockets, so that applications can send and receive raw IP datagrams.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-04-09 12:36:34 +02:00
Robert Lubos
a713d8ea60 net: connection: Register connection type
Register connection type along with family and protocol, so that it's
possible to differentiate between connection listening for raw IP
datagrams and TCP/UDP/other packets.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-04-09 12:36:34 +02:00
Robert Lubos
3449e224b4 net: openthread: Add missing error checks
Some OpenThread functions were called without verifying the return
value, which not only is not the best practice, but also could lead to
build warnings with llvm. This commit fixes it.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-04-08 16:12:17 +02:00
Robert Lubos
cf0b6068d2 net: coap_client: Fix CoAP client thread priority
The default thread priority for the CoAP client thread is set to
NUM_PREEMPT_PRIORITIES which is not a valid thread priority, as the
lowest application thread priority is actually
NUM_PREEMPT_PRIORITIES - 1. Because of this, CoAP client library gave an
assert on boot if assertions were enabled.

Kconfig does not allow for arithmetics when setting integer defaults,
therefore handle this at the preprocessor stage by limiting the actual
priority assigned to the CoAP client thread to a valid range.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-04-04 18:17:30 +02:00
Markus Lassila
392fda02b3 net: Add CONFIG_NET_CONN_PACKET_CLONE_TIMEOUT
Add CONFIG_NET_CONN_PACKET_CLONE_TIMEOUT to allow for longer
timeouts. This can be used to prevent dropping packets when
transmitting large amounts of data (with PPP).

Signed-off-by: Markus Lassila <markus.lassila@nordicsemi.no>
2025-04-04 14:57:06 +02:00
Eric Holmberg
84d3cafbce net: websocket: fix masked data when server sends close
When sending the close command as a server, the data is incorrectly
masked which violates RFC6455 section 5.1.

Use the is_client flag to avoid masking if the close is for a websocket
server.

Signed-off-by: Eric Holmberg <eric.holmberg@northriversystems.co.nz>
2025-04-04 14:56:58 +02:00
Yakun Xu
eddb1af9aa openthread: map Thread network interface state
The current mapping gets the network interface into dormant state when
Thread is not attached. While the node is not capable of doing multi-hop
communication when it's not attached, it should be able to do link-local
communication. This commit changes the mapping to look at OpenThread's
own network interface state instead without further checking Thread's
device role, so that link-local communication is supported when a node
in detached state.

Signed-off-by: Yakun Xu <xyk@google.com>
2025-04-04 12:06:59 +02:00
Jukka Rissanen
43acb93607 net: shell: iface: Do not print DHCPv6 detail info if disabled
No point printing detailed DHCPv6 information if client support
is disabled.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-04-02 05:30:32 +02:00
Jukka Rissanen
5e17f40178 net: shell: iface: Do not print DHCPv4 detail info if disabled
No point printing detailed DHCPv4 information if client support
is disabled.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-04-02 05:30:32 +02:00
Jack Chistyakov
dd6adc7cad net: virtual: Clear multicast bit when generating link address
The least significant bit of the first octet of a MAC address is a
unicast/multicast bit. The bit should be cleared when generating a
random link address for a virtual interface. Any frames from such
interface/address will be dropped by the network as invalid if
the multicast bit is set.

Signed-off-by: Jack Chistyakov <jack.chistyakov@outlook.com>
2025-04-01 11:53:02 +02:00
Jukka Rissanen
137eba4e40 net: dns: Check compression flag properly
Allow only 0xc (0b11) as two highest bit to mark the compression
when parsing the CNAME response. See RFC 9267 ch. 2 for details.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-31 22:00:36 +02:00
Jukka Rissanen
5746f61d4c net: dns: Check recursive pointers for CNAME handling
Make sure that the CNAME handling checks recursive name pointers
and fails the response if recursion is detected.
See RFC 9267 ch. 2 for details.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-31 22:00:36 +02:00
Kapil Bhatt
6f9dbbd54f wifi: utils: Fix crash for scan
The check for index out of bound is missing, It turns into a crash
for input channel more than WIFI_MGMT_SCAN_CHAN_MAX_MANUAL.

Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
2025-03-31 14:33:22 +02:00
Jukka Rissanen
8e908176c7 net: shell: iface: Print VPN public key
If the interface is a VPN interface, then print
the public key of the interface.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-28 21:51:57 +01:00
Jukka Rissanen
4eac955305 net: if: Add special handling for IPv4/6 address check for VPN
This is a hack that is used until we have proper IP routing
in place. The code has now special check that makes sure that
we only route IP packets to VPN interface when the packet is
destined to that subnet. So if destination IP address does
not belong to VPN interface subnet, it is not routed there.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-28 21:51:57 +01:00
Jukka Rissanen
663867dbb0 net: if: Add helper to get src interface and address from dst address
Instead of calling various network interface API functions to get
the network interface and related source IP address, have a single
function that can return both data.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-28 21:51:57 +01:00
Jukka Rissanen
525b8e58a2 net: l2: virtual: Add support for VPN public/private key set/get
Add support for getting public address and setting private
key for the virtual interface.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-28 21:51:57 +01:00
Jukka Rissanen
c073a01b39 net: shell: events: Print VPN event information
Add VPN events information printouts to event monitor.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-28 21:51:57 +01:00
Jukka Rissanen
d95d391968 net: stats: Add VPN statistics support
Enable collection of VPN statistics and allow user to fetch it.

Signed-off-by: Jukka Rissanen <jukka.rissanen@gmail.com>
2025-03-28 21:51:57 +01:00
Jukka Rissanen
b7dec6c195 net: Add option for VPN enablement
Add support for setting up VPN enablers in the network stack.
These are to be used by the VPN implementation like Wireguard.

Signed-off-by: Jukka Rissanen <jukka.rissanen@gmail.com>
2025-03-28 21:51:57 +01:00
Jukka Rissanen
0a8bad7e28 net: dhcpv4: Add parsing of received domain name
Currently we ignore the received domain name but make sure we
print it in order to avoid unknown option prints.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-28 21:51:33 +01:00
Jukka Rissanen
22f15de7a6 net: dhcpv4: Add parsing of received host name
Currently we ignore the received host name but make sure we
print it in order to avoid unknown option prints.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-28 21:51:33 +01:00
Jukka Rissanen
8ec4fba67c net: dhcpv4: Add parsing of broadcast address
Currently we ignore the broadcast address but make sure we
print it in order to avoid unknown option prints.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-28 21:51:33 +01:00
Cla Mattia Galliard
eb029b9ee1 net: http: server: Avoid compiler warnings for zero-length-arrays
Avoid compiler warnings for zero-length-arrays in the http-server. By using
memcpy instead of strcpy.

Signed-off-by: Cla Mattia Galliard <cla-mattia.galliard@zuehlke.com>
2025-03-28 16:11:27 +01:00
Triveni Danda
589333e4d9 wifi: shell: Add support for EAP-TLS method
Add support to read identity and private key password if
configured in Enterprise mode.

Signed-off-by: Triveni Danda <triveni.danda@nordicsemi.no>
2025-03-28 16:10:36 +01:00
Triveni Danda
7b6f2572e5 net: lib: wifi_credentials: Use getopt API for adding network options
Use getopt API to process arguments for `cred add` command.

Signed-off-by: Triveni Danda <triveni.danda@nordicsemi.no>
2025-03-28 16:10:36 +01:00
Cla Mattia Galliard
72fcca0304 net: virtual: Fix compiler warnings related to interface name
Fix compiler warning by adjusting the number of chars copied to the
destination. Compiler does not like if the destination size of the
`strncpy`-operation is the same as the number of characters written. Even
though it is not a bug in this case. Only copying size-1 characters fixes
the warning and exhibits the same behavior.

Signed-off-by: Cla Mattia Galliard <cla-mattia.galliard@zuehlke.com>
2025-03-27 21:33:40 +01:00
Fin Maaß
651d6a3b58 net: dhcpv4: remove redundant dependencys
Remove ``depends on NET_DHCPV4`` on options,
that are inside a ``if NET_DHCPV4``.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2025-03-27 17:18:49 +01:00
Jukka Rissanen
17a4315998 net: mdns_responder: Print return value if error in socket call
If socket call fails when mdns_responder creates listeners, then
print the return value to make it easier to figure out what is
wrong. Typically one needs to increase the size of
CONFIG_ZVFS_OPEN_MAX if errno is ENFILE.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-26 21:57:18 +01:00