Commit graph

6489 commits

Author SHA1 Message Date
Jukka Rissanen
9a0e9be8c3 net: shell: dns: Add service discovery command
Add "net dns service <dns-service-name>" which can resolve
service names like "_http._tcp.dns-sd.org" described in DNS-SD
RFC 6763.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-06-18 09:08:41 -04:00
Jukka Rissanen
7799f0c994 net: dns: Allow user to specify max answer length via Kconfig
If the default max. answer length of 512 bytes is not enough,
user can specify it by setting CONFIG_DNS_RESOLVER_MAX_ANSWER_SIZE
to suitable value.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-06-18 09:08:41 -04:00
Jukka Rissanen
cf8b7d715d net: dns: Add service discovery support
Allow PTR queries with dns_resolve_service() API.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-06-18 09:08:41 -04:00
Jukka Rissanen
2ed2232f17 net: socket: mgmt: Create proper socket options for net_mgmt sockets
We cannot use the network management event number directly as
a socket option value because the management value is uint64_t
and that cannot be mapped directly to 32 bit integer.
So have an intermediate socket option that is mapped to actual
network management request number in getsockopt() and setsockopt().

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-06-18 10:54:44 +02:00
Jukka Rissanen
5a9a39caf3 net: mgmt: Convert the mgmt API to use 64-bit masks
Instead of using 32 bit enum values for event numbers, convert
the code to use 64 bit long bit fields. This means that the
user API is changed to use 64 bit event values instead of 32
bit event values.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-06-18 10:54:44 +02:00
Benjamin Cabé
1032dd47b2 net: coap: fix offset typo in insert_be16
Fix usage of the wrong variable in insert_be16 which could cause
insertion at the wrong offset.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-06-18 07:40:12 +02:00
Benjamin Cabé
312bea8cae net: socket: use proper tracing macro for socketpair()
SYS_PORT_TRACING_OBJ_FUNC_* are for when the function being
traced is a method of an object. Use SYS_PORT_TRACING_FUNC_* instead.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-06-18 07:38:44 +02:00
Pieter De Gendt
b3316fc4fd net: l2: wifi: shell: Fix passphrase long opt help text
A passphrase needs to be passed with --passphrase instead of --psk.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-06-17 17:47:11 +02:00
Joakim Andersson
2e5a03877f net: tls_credentials_shell: Add credential buffer load argument
Add argument to the TLS credential `cred buf` command that enables
a shell bypass to write the TLS credential directly to the credential
buffer.
This is useful for writing load credentials that cannot fit in a single
`cred buf` command and would otherwise have to be split into multiple
cred buf commands.
Sending multiple in succession like that from a script for example very
easily causes the shell RX buffer to get full, resulting in multiple
`RX ring buffer full.` warnings.
This is very difficult for a script to handle.

Using a bypass has much better performance and can easily avoid the
RX ring buffer full condition without increasing the RX ring buffer
to much.
It is also easier for a script to use.

Signed-off-by: Joakim Andersson <joerchan@gmail.com>
2025-06-17 17:45:26 +02:00
Jukka Rissanen
8704b3add7 net: ppp: Bind DNS to device ppp network interface
Make sure received DNS server information is bound to the
ppp network interface.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-06-17 16:08:56 +02:00
Jukka Rissanen
57c452fb79 net: shell: conn: Print packet socket information correctly
The "net conn" command printed AF_PACKET socket as AF_UNK(3).
Fix this by printing "AF_PACKET" in this case.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-06-17 16:08:56 +02:00
Jukka Rissanen
cb9052459a net: dns: Properly cleanup DNS servers per network interface
Make sure we cleanup only those DNS servers that belong to
certain network interface when the interface goes down.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-06-17 16:08:56 +02:00
Jukka Rissanen
248cb3d251 net: dhcpv6: Honor network interface for DNS servers
Bind the network interface to the network interface we
have received the DNS servers from. This is now the default.
The previous behavior can be restored by disabling the
CONFIG_NET_DHCPV6_DNS_SERVER_VIA_INTERFACE option.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-06-17 16:08:56 +02:00
Jukka Rissanen
1224c5a43a net: dhcpv4: Honor network interface for DNS servers
Bind the network interface to the network interface we
have received the DNS servers from. This is now the default.
The previous behavior can be restored by disabling the
CONFIG_NET_DHCPV4_DNS_SERVER_VIA_INTERFACE option.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-06-17 16:08:56 +02:00
Jukka Rissanen
2af5dba995 net: dns: Allow reconfiguration with network interfaces
Allow user to specify which network interfaces to bind the
server to when reconfiguring the DNS system.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-06-17 16:08:56 +02:00
Fin Maaß
89006fbe1b net: shell: iface: support deactivating auto-neg
support deactivating auto-neg in face shell.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2025-06-17 16:08:22 +02:00
Fin Maaß
f24426b31f drivers: net: ethernet: phy: add support for disabling auto-negotiation
Add option in enum phy_link_speed to disable auto-negotiation.
This allows PHY drivers to support disabling auto-negotiation.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2025-06-17 16:08:22 +02:00
Keith Packard
97f96afbd7 linker_script: Remove all SUBALIGN usage for iterable sections
SUBALIGN forces alignment to the specified value, even if the object
requires stricter alignment. This causes mis-aligned access when accessing
the resulting value.

Signed-off-by: Keith Packard <keithp@keithp.com>
2025-06-17 16:06:21 +02:00
Benjamin Cabé
1387657107 net: dns: remove redundant check in mdns_unpack_query_header
Drop this redundant check that was likely meant to be checking that Z
field is zero but in the case of reception the RFC says it MUST be
ignored anyway.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-06-16 14:04:59 -04:00
Benjamin Cabé
179045e5a5 net: mdns_responder: fix wrong context when rescheduling IPv6 probe
Use ipv6 context, not ipv4

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-06-16 08:31:32 +02:00
Benjamin Cabé
453d2367ef net: dhcpv6: fix typo in macro name
DHVP -> DHCP

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-06-16 08:29:47 +02:00
Benjamin Cabé
5e287bb73f net: coap: adopt SHELL_HELP
Adopt SHELL_HELP macro for coap_server_shell

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-06-13 10:11:29 -07:00
Adib Taraben
9b8be4971e drivers: ethernet: nxp: timestamping to all potential packets.
add timestamping on Tx to packets marked for timestamping
add timestamping on Rx to all packets for later use
fix race condidition on adding timestamp when sending delay_req

Signed-off-by: Adib Taraben <theadib@gmail.com>
2025-06-13 10:40:49 -04:00
Shrek Wang
46ba523ba8 net: tcp: Align TCP seqence validation with Spec
According to RFC 793, the seqnum test includes 4 cases when STATE >
TCP_SYN_SENT:

      Seg-len Recv-win    Test
      ------- --------    ---------------------------------------
        0       0         SEG.SEQ = RCV.NXT
        0      >0         RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND
       >0       0         not acceptable
       >0      >0         RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND
                       or RCV.NXT =< SEG.SEQ+SEG.LEN-1 <RCV.NXT+RCV.WND

After the seq validation, the 'send duplicated ACK' code in FIN_WAIT1/
2/CLOSING/TIMEWAIT state processing is duplicated, so remove them.

Added TEST_CLIENT_SEQ_VALIDATION ztest case in tests/net/tcp.

Signed-off-by: Shrek Wang <inet_eman@outlook.com>
2025-06-13 14:28:50 +02:00
Jukka Rissanen
d394b74a41 net: shell: dns: Add list command to show service records
Add "net dns list" command that will show DNS SD records
defined in the system.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-06-12 09:39:49 -07:00
Jukka Rissanen
ff805ae376 net: dns-sd: Add internal record validator function
Allow network shell DNS module to verify that the DNS SD
record is a valid one. Currently this is not exposed to
applications.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-06-12 09:39:49 -07:00
Robert Lubos
86244a9c54 net: stats: Make byte counters 64-bit
In high throughput tests it's fairly easy to overflow the current 32-bit
byte counters in net statistics (it's just over 4 GB of data).
Therefore, make the byte counters 64-bit to prevent overflows.
Rearrange some fields to avoid padding.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-06-12 09:36:38 -07:00
Robert Lubos
b877d2c1fe net: stats: Use correct format specifiers when printing stats
net_stats_t type is an unsigned type, therefore %u should be used
instead of %d when printing values of this type, otherwise negative
values will be printer if INT32_MAX is exceeded.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-06-12 09:36:38 -07:00
Maochen Wang
d4648a6767 net: l2: wifi: fix invalid option error when use -i
For 'wifi connect' or 'wifi ap enable' CMD, there is 'invalid option'
error log when input '-i' parameter. Parsing '-i' can fix this issue.

Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
2025-06-12 10:24:36 +02:00
Maochen Wang
5bcaf33d79 net: l2: wifi: fix dpp btstrap_gen CMD failure
Input 'wifi dpp btstrap_gen ...' cmd or 'wifi dpp ap_qr_code ...',
the console shows 'wrong parameter count'. Fix the typo of 'wifi
dpp btstrap_gen' and 'wifi dpp ap_qr_code' CMD's parameter count.

Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
2025-06-12 10:24:36 +02:00
Pieter De Gendt
cf39d12714 net: lib: http: Select required symbols for server
Select the NET_SOCKETS and EVENTFD kconfig symbols in order for the HTTP
server to compile.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-06-11 16:21:36 -07:00
Robert Lubos
b18bc7cc3e net: sockets_offload: Allow to enable/disable DNS offload at runtime
Add new socket offloading functions, allowing to enable/disable
offloaded DNS implementation at runtime. This may be useful if there is
a mix of offloaded/native network interfaces in the system, so the
application can choose which DNS backend to use.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-06-11 16:20:18 -07:00
Robert Lubos
35af68b840 net: mqtt: Allow to bind client to a specific interface
Add a new "if_name" pointer to the transport configuration structure,
allowing the application to bind MQTT client to a specific network
interface.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-06-11 16:18:31 -07:00
Jukka Rissanen
bd4c0b746c net: acd: Avoid removing auto IPv4 address twice
When the network interface goes down, we call
net_ipv4_autoconf_reset() which removes the autoaddress
from the network interface.
The net_ipv4_autoconf_reset() is also called when ACD is started
in which case we could see this error message

<dbg> net_if_start_acd: Starting ACD for iface 2
<err> net_if: iface 2 addr 169.254.174.230 (net_if_ipv4_addr_rm():4625)
<dbg> net_if_ipv4_addr_rm: Address 169.254.174.230 not found (-22)

This error is superfluous and not needed. So before trying to
remove the address, check if the interface already has it set and
only then remove it.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-06-11 10:26:56 -07:00
Jukka Rissanen
902c95ab95 net: if: Do not start ACD for localhost or point2point links
When adding IPv4 address to the network interface, there is no
need to start ACD procedure for localhost or point-to-point links.
The ACD start function would mark the IP address like 127.0.0.1 as
tentative and never make it preferred which would then cause issues
when selecting the network address for sending.
As the ACD start is also called when the network interface comes up,
add the localhost and point-to-point link check to ACD start function
so that we will avoid ACD checks in this case.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-06-11 10:26:56 -07:00
Fin Maaß
ed4d421ace drivers: ethernet: remove phy related configs from eth config
remove phy related configs from eth config.
phy related configs chould go directly into the phy.
Most ethernet drivers didn't support the now removed
functions yet. Users should instead use `phy_configure_link()`
together with the `net_eth_get_phy()` function.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2025-06-11 10:17:37 -07:00
Ling Pei Lee
75bfd799c4 net: shell: iface: Add link speed settings command
Add this to set link speed through net_shell.
Current zephyr version doesn't have user interface to change
speed, hence adding this to accomodate it. Full duplex will
be set by default for each link speed.

Able to change link speed using command below:
net iface set_link <iface idx> <speed> <optional:h(half)/f(full)>
eg: net iface set_link 1 100 h
    net iface set_link 1 10 f
    net iface set_link 1 1000

Able to set multiple link speed like below:
net iface set_link <iface idx> <speed1> <speed2> <optional:h/f>
eg: net iface set_link 1 10 100 h
    net iface set_link 1 1000 f 10

Signed-off-by: Ling Pei Lee <pei.lee.ling@intel.com>
2025-06-11 09:54:56 +02:00
Arunmani Alagarsamy
0faba15717 net: l2: wifi: Fix mode change issue in Wi-Fi shell
The help message for the wifi mode -s command indicates it sets
the Wi-Fi mode to station. However, the Zephyr Wi-Fi shell subsystem
was incorrectly using a get operation instead of set.

This commit corrects the behavior to properly set the Wi-Fi mode,
aligning the implementation with the help message.

Signed-off-by: Arunmani Alagarsamy <arunmani.a@silabs.com>
2025-06-10 08:51:15 +02:00
Qiankun Li
f31a411770 drivers: wifi: nxp: Modify shim driver to support btwt changes.
Align struct wlan_btwt_config_t in shim driver
with nxp wifi driver.

Signed-off-by: Qiankun Li <qiankun.li@nxp.com>
2025-06-10 08:47:25 +02:00
Qiankun Li
448b787c82 net: l2: wifi: Modify btwt_setup usage.
Soft ap supports WIFI_BTWT_AGREEMENT_MAX BTWT sessions.
The BTWT parameters for each session can be different.

The current usage can only set one set of parameters.
All sessions follow this set of parameters.

Add enhance code to support setting different
BTWT parameters for every sessions.

Usage:
wifi twt btwt_setup <sta_wait> <offset>
<twtli> <session_num>
<id0> <mantissa0> <exponent0> <nominal_wake0>
<id1> <mantissa1> <exponent1> <nominal_wake1>
<idx> <mantissax> <exponentx> <nominal_wakex>
The total number of '0, 1, ..., x' is session_num

For example:
wifi twt btwt_setup 0 0 0 2 0 112 10 128 1 32 10 64

Signed-off-by: Qiankun Li <qiankun.li@nxp.com>
2025-06-10 08:47:25 +02:00
Tim Pambor
a760ba76b6 net: ip: 6lo: Fix undefined behavior reported by UBSAN
htonl() and htons() take uint32_t/uint16_t as argument. Add the 'u' suffix
to constants to ensure the correct unsigned type is used and to avoid
undefined behavior if these functions are implemented as macros using
bit shifts.

Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
2025-06-03 21:32:54 -07:00
Cla Mattia Galliard
02d2cc519a net: sockets: Enable gethostname even if socket-offloading is selected
Also allow `gethostname` to be compiled in, even when the socket offloading
option is selected.

Signed-off-by: Cla Mattia Galliard <cla-mattia.galliard@zuehlke.com>
2025-06-03 13:51:23 +02:00
Chaitanya Tata
2f991f2bff net: lib: zperf: Add support for skipping UDP upload server report
Add support for skipping UDP upload server report, useful in test TX
only with loopback (packets are dropped, so, no report).

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2025-06-02 17:37:55 +02:00
Shrek Wang
6e7756a542 net: tcp: Change SYN FIN to use send_data_timer
The send_queue was used as SYN/FIN packet retransmission. Before
the SYN/FIN being ACKed and dequeue-ed, the following packets in
the send_queue cannot be sent out. That's why Zephyr had to send
a FIN+ACK instead of a duplicated ACK-only in FINWAIT1, CLOSING.
In fact, we can take SYN/FIN as kind of data and use the same
send_data_timer for retransmission, like other OSes do. This way,
the send_queue is simply used for local traffics.
Benefits (in theory):
1. The code is easier,
2. TxPkt performance is better after skipping enq/deq send_queue,
3. The struct tcp{} node is a few bytes smaller, saving memory.

Signed-off-by: Shrek Wang <inet_eman@outlook.com>
2025-06-02 13:30:19 +02:00
Pieter De Gendt
d5931bae93 net: lib: coap: Return an error on removing a non-existing observer
If we're parsing a CoAP request with an observe option of '1', but there is
no matching observer, return an error instead of returning a zero.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-05-30 10:28:02 +02:00
Robert Lubos
38e00d1969 net: tcp: Fix user_data provided to accept callback
TCP implementation provided the parent net_context pointer to the
accept callback instead of the user_data pointer registered with
net_tcp_accept(). This worked fine with the socket integration, as
sockets explicitly registered parent context as user_data, however it
shouldn't be hardcoded like this at the TCP level.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-05-29 12:05:58 +02:00
Shrek Wang
744380a278 net: tcp: Use correct seqnum for tcp_out and tcp_out_ext
Based on TCP Spec., the outgoing TCP packets shoud use SND.NXT as
the seqnum. In Zephyr, the conn->seq works as the SND.UNA and the
conn->seq + conn->unacked_len works as the SND.NXT. Currently, it
uses SND.UNA in tcp_out() as the seqnum, which might get dropped
as old packets and could not deliver the message to the peer.
A few exceptions use SND.NXT - 1 as the seqnum are: keepalive,
zero-window-probe, FIN/SYN retransmissions. And, for closing a
connection, Zephyr won't send out FIN until all the data has been
ACKed, so the conn->unacked_len is 0 and it is ok to use conn->seq
as the SND.NXT.

Signed-off-by: Shrek Wang <inet_eman@outlook.com>
2025-05-29 08:42:20 +02:00
Robert Lubos
c26f39450d net: context: Verify if CONFIG_NET_SOCKETS_PACKET_DGRAM is enabled
Verify if CONFIG_NET_SOCKETS_PACKET_DGRAM is enabled when creating a
datagram packet socket. Otherwise, it's possible to create
non-functional AF_PACKET/SOCK_DGRAM socket w/o an error.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-05-28 15:33:24 +02:00
Jukka Rissanen
e44ed8dbb8 net: ipv6: Make sure we do not access link address past array length
It is possible to manually set link address length past 6 at runtime
and trying to generate IPv6 IID address that way. This should fail
as we could read two bytes past the address buffer. There is no issues
in the copying as the target buffer has plenty of space.

Coverity-CID: 516232

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-05-28 10:05:21 +02:00
Chen Tao
b513e08271 net: wifi: fix the bug by non-wifi network call
Added network type check to fix the system crash caused by non-wifi
network card calling wifi api interface

Company:BSH Crop
Signed-off-by: Chen Tao <ct05342@163.com>
2025-05-27 11:51:23 +02:00