1081 Commits

Author SHA1 Message Date
Marek Vasut
68a8f0f1f3 net: lwip: wget: rework the '#' printing
Currently, the LWIP wget command prints excessive amount of progress
indicator '#' for very long file downloads, limit this to one line
that scales according to transfer size.

The HTTP server does report the size of the entire file in protocol
headers, which are received before the actual data transfer. Cache
this information and use it to adaptively print progress indicator
'#' until it fills one entire line worth of '#', which indicates the
transfer has completed. This way, long transfers don't print pages of
'#', but every transfer will print exactly one line worth of '#'. The
algorithm for '#' printing is the same as TFTP tsize one.

Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
Acked-by: Jerome Forissier <jerome.forissier@rm.com>
2026-02-06 16:42:45 +01:00
Marek Vasut
337f50bad2 net: lwip: tftp: add support of tsize option to client
The TFTP server can report the size of the entire file that is about to
be received in the Transfer Size Option, this is described in RFC 2349.
This functionality is optional and the server may not report tsize in
case it is not supported.

Always send tsize request to the server to query the transfer size,
and in case the server does respond, cache that information locally
in tftp_state.tsize, otherwise cache size 0. Introduce new function
tftp_client_get_tsize() which returns the cached tftp_state.tsize so
clients can determine the transfer size and use it.

Update net/lwip/tftp.c to make use of tftp_client_get_tsize() and
avoid excessive printing of '#' during TFTP transfers in case the
transfer size is reported by the server.

Submitted upstream: https://savannah.nongnu.org/patch/index.php?item_id=10557

Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
Acked-by: Jerome Forissier <jerome.forissier@arm.com>
2026-02-06 16:42:37 +01:00
Yuya Hamamachi
a28db0f1cc net: tftp: Fix TFTP Transfer Size data type
The TFTP transfer size is unsigned integer, update the data type
and print formating string accordingly to prevent an overflow in
case the file size is longer than 2 GiB.

TFTP transfer of a 3 GiB file, before (wrong) and after (right):
Loading: #################################################  16 EiB
Loading: ##################################################  3 GiB

Signed-off-by: Yuya Hamamachi <yuya.hamamachi.sx@renesas.com>
Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
2026-02-06 16:37:31 +01:00
Yuya Hamamachi
86f90e2a5f net: Stop conflating return value with file size in net_loop()
The net_loop() currently conflates return value with file size
at the end of successful transfer, in NETLOOP_SUCCESS state.

The return type of net_loop() is int, which makes this practice
workable for file sizes below 2 GiB, but anything above that will
lead to overflow and bogus negative return value from net_loop().

The return file size is only used by a few sites in the code base,
which can be easily fixed. Change the net_loop() return value to
always be only a return code, in case of error the returned value
is the error code, in case of successful transfer the value is 0
or 1 instead of 0 or net_boot_file_size . This surely always fits
into a signed integer.

By keeping the return code 0 or 1 in case of successful transfer,
no conditionals which depended on the old behavior are broken, but
all the sites had to be inspected and updated accordingly.

Fix the few sites which depend on the file size by making them
directly use the net_boot_file_size variable value. This variable
is accessible to all of those sites already, because they all
include net-common.h .

Signed-off-by: Yuya Hamamachi <yuya.hamamachi.sx@renesas.com>
Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
2026-02-06 16:37:31 +01:00
Jonas Karlman
3349e3aa1b net: lwip: nfs: Prefer nfsserverip over serverip when set
Prefer use of a 'nfsserverip' env var before falling back to 'serverip'
when using the nfs command. Similar to how the 'tftpserverip' env var
is preferred over 'serverip' by the tftp command.

This also updates the error message to closer match the error message
used by the lwIP tftp command when a server ip is not set.

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Reviewed-by: Jerome Forissier <jerome.forissier@arm.com>
2026-02-04 09:04:36 +01:00
Jonas Karlman
bd1f40a402 net: lwip: dhcp: Save DHCP siaddr field to tftpserverip env var
The DHCP siaddr field contains the IP address of next server to use in
bootstrap. Typically this will be the IP address of a TFTP server or the
IP address of the DHCP server itself.

RFC 2131, 2. Protocol Summary, Page 10:

   DHCP clarifies the interpretation of the 'siaddr' field as the
   address of the server to use in the next step of the client's
   bootstrap process.  A DHCP server may return its own address in the
   'siaddr' field, if the server is prepared to supply the next
   bootstrap service (e.g., delivery of an operating system executable
   image).  A DHCP server always returns its own address in the 'server
   identifier' option.

Set the 'tftpserverip' env variable when the siaddr field contains an
IP address that is different compared to the DHCP server IP address.

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Reviewed-by: Jerome Forissier <jerome.forissier@arm.com>
2026-02-04 09:04:36 +01:00
Jonas Karlman
8d89b16ea4 net: lwip: Use ipaddr helpers
The ip_addr_t of lwIP has support for both IPv6 and IPv4 addresses.
Some lwIP commans is directly accessing the internal addr field of the
ip_addr_t instead of using ipaddr helper functions.

Change to use ipaddr helper functions where appropriate to remove direct
access of the internal addr field. Also change a few instances from ip4
to the version less ipaddr helpers.

There is no intended functional change, besides the change from using
ip4 addr helper to using version less ipaddr helper.

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Reviewed-by: Jerome Forissier <jerome.forissier@arm.com>
2026-02-04 09:04:36 +01:00
Jonas Karlman
3299bffc7c net: lwip: dns: Call env_set() from dns loop instead of found callback
The lwIP dns command handle env_set() calls from the found callback and
printf() to console in the dns loop. Making it more complex than it
needs to be.

Simplify and ensure any environment variable that is being set is the
same value that would have been printed on console.

There should not be any intended change in behavior, besides the change
from using ip4addr helper to using version less ipaddr helper.

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Reviewed-by: Jerome Forissier <jerome.forissier@arm.com>
2026-02-04 09:04:36 +01:00
Jonas Karlman
f3b600efb3 net: lwip: nfs: Print device name based on current udevice
Use udevice name, similar to other lwip commands, instead of using the
legacy eth_get_name() when printing out the device being used.

Fixes: 230cf3bc2776 ("net: lwip: nfs: Port the NFS code to work with lwIP")
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Reviewed-by: Jerome Forissier <jerome.forissier@arm.com>
2026-02-04 09:04:36 +01:00
Jonas Karlman
35ee795d63 net: lwip: dns: Fix print of resolved IP address
The lwIP dns command only prints out cached resolved IP addresses.

When a hostname is first resolved and ERR_INPROGRESS is returned the
dns command prints out 0.0.0.0 instead of the resolved IP address.

Fix this by printing out host_ipaddr instead of the temporary ipaddr
that only is valid when ERR_OK is returned.

Fixes: 1361d9f4f00a ("lwip: dns: do not print IP address when a variable is specified")
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Reviewed-by: Jerome Forissier <jerome.forissier@arm.com>
2026-02-04 09:04:36 +01:00
Jonas Karlman
d93b3a38d5 net: lwip: add TFTPSERVERIP Kconfig option
With the legacy networking stack, it is possible to use USE_SERVERIP,
SERVERIP and BOOTP_PREFER_SERVERIP Kconfg options to force use of a
specific TFTP server ip.

Using the lwIP networking stack use of the 'tftpserverip' environment
variable provide the closest equivalent functionality.

Add USE_TFTPSERVERIP and TFTPSERVERIP Kconfig options that can be used
to add the 'tftpserverip' environment variable to force use of a
specific TFTP server ip.

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Acked-by: Jerome Forissier <jerome.forissier@arm.com>
2026-02-04 09:04:36 +01:00
Andrew Goodbody
72d4e94b2e net: lwip: dhcp: Do not write past end of buffer
sprintf will write a trailing \0 at the end of the string so when
writing into a buffer, that buffer must be sized to allow for that
trailing zero. In the DHCP code when the index is a number needing two
digits to express the index would use up the two \0 bytes in the buffer
and the trailing \0 from sprintf would be beyond the end of the
allocation. Fix this by adding a third \0 in the buffer.

This was found by code inspection when looking for an issue reported by
Michal Simek, but I do not have the hardware to reproduce, so cannot
confirm if this addresses that issue or not.

Fixes: 98ad145db61a ("net: lwip: add DHCP support and dhcp commmand")
Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
Reviewed-by: Jerome Forissier <jerome.forissier@arm.com>
2026-02-04 09:04:36 +01:00
Tom Rini
c832cd3b49 net: tftpput: Rework to exclude code from xPL phases
Given how the support for CONFIG_CMD_TFTPPUT is woven through the
support for the tftp protocol we currently end up including "put"
support in xPL phases, if enabled. This in turn can lead to size
overflow on those platforms as xPL tends to be constrained. To resolve
this, use "CMD_TFTPPUT" in the code to check for both CONFIG_CMD_TFTPPUT
being true and not being in an xPL build phase.

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Jerome Forissier <jerome@forissier.org>
2026-01-15 11:09:28 +01:00
Andrew Goodbody
230cf3bc27 net: lwip: nfs: Port the NFS code to work with lwIP
After the preparatory patches moved most of the NFS code into common
files we now add the code to enable NFS support with lwIP.

Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
2026-01-15 11:09:28 +01:00
Andrew Goodbody
3bc1197e3d net: nfs: Move most NFS code to common files
Move most of the NFS code into common files so that it can be used by an
lwIP port of NFS.

Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
2026-01-15 11:09:28 +01:00
Andrew Goodbody
046f553fe8 net: nfs: Add licence header
Add the same GPL2+ licence header to the NFS code as appears on other
NFS related files.

Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
2026-01-15 11:09:28 +01:00
Andrew Goodbody
3938ae6457 net: Move some variables to net-common files
Make some variables available to be used by either the legacy network
code or lwIP by moving them into the net-common files. This also allowed
removing a small number of duplicated variables from the lwIP code.

Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
2026-01-15 11:09:28 +01:00
Andrew Goodbody
60c228c077 net: move net_state to net-common
Move the net_state variable into common code so that it can be used by
either the legacy network code or lwIP. This is needed for porting
across the NFS support code for use with lwIP.

Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
2026-01-15 11:09:28 +01:00
Andrew Goodbody
492ff73de6 net:lwip: Add debug line to net-lwip
When debugging the LWIP NFS implementation this debug line helped to
show the cause of an error. This could be useful to someone in the
future.

Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
2026-01-15 11:09:28 +01:00
Tom Rini
dac8d9c3cc Prepare v2026.01-rc5
-----BEGIN PGP SIGNATURE-----
 
 iHUEABYKAB0WIQTzzqh0PWDgGS+bTHor4qD1Cr/kCgUCaUnFqQAKCRAr4qD1Cr/k
 CrOEAQC3eaLxXYwOXMVFP1C6w7PfYTfUDKuSdgaRYqxF0ldPwQEA3eDTIIA/CPgg
 1M+K8q8ck+cKRK0P9CagbwyzNnvi4Qw=
 =0Z3i
 -----END PGP SIGNATURE-----

Merge tag 'v2026.01-rc5' into next

Prepare v2026.01-rc5
2025-12-22 16:31:21 -06:00
Andrew Goodbody
8910efa71b net: lwip: tftp: Fix filename handling
The code to choose the filename to use does not cope with no name set at
all. Firstly the test for a name in net_boot_file_name tests the pointer
rather than the string it points to. Secondly the cleanup on exit in
this case attempts to free a global variable. Fix both issues.

Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
2025-12-18 16:27:15 +01:00
Quentin Schulz
715107089f net: remove unreachable legacy LED code
The code is guarded by a condition none of the defconfigs meet (that is
CONFIG_SYS_FAULT_ECHO_LINK_DOWN and CONFIG_LED_STATUS_RED both enabled),
so we can remove the unreachable code sections.

When doing that, there's no caller for miiphy_link anymore, so it can be
removed.

This in turns makes CONFIG_SYS_FAULT_ECHO_LINK_DOWN and
CONFIG_SYS_FAULT_MII_ADDR unused so they are removed as well.

Signed-off-by: Quentin Schulz <quentin.schulz@cherry.de>
Reviewed-by: Tom Rini <trini@konsulko.com>
2025-12-05 10:34:52 -06:00
Leonard Anderweit
c10e1c2ede net: tftp: Remove tftp_init_load_addr error path
tftp_init_load_addr() always returns 0 since commit af45c84871e4 ("tftp:
rework the logic to validate the load address"), so we don't need to
check if it failed and can remove the error handling.
Also change tftp_init_load_addr() to static void since the return value
is now unused.

Signed-off-by: Leonard Anderweit <l.anderweit@phytec.de>
Reviewed-by: Yannic Moog <y.moog@phytec.de>
2025-12-01 10:37:06 +01:00
Benjamin Hahn
fae6c54d23 bootstd: make it possible to use tftp for netboot with standardboot
Add the option to load the bootscript with the tftp command (static IP)
instead of the dhcp command (dynamic IP). For this a new function
tftpb_run similar to dhcp_run, is needed. The selection of which command
to use can be done with the ip_dyn environment variable, which can be
set to yes or no. The ip_dyn variable was chosen as it is already in use
on the imx platforms.
Also edit the bootstd doc.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Benjamin Hahn <B.Hahn@phytec.de>
2025-10-24 13:47:50 -06:00
Paul HENRYS
81e5708cc2 net: bootp: Prevent buffer overflow to avoid leaking the RAM content
CVE-2024-42040 describes a possible buffer overflow when calling
bootp_process_vendor() in bootp_handler() since the total length
of the packet is passed to bootp_process_vendor() without being
reduced to len-(offsetof(struct bootp_hdr,bp_vend)+4).

The packet length is also checked against its minimum size to avoid
reading data from struct bootp_hdr outside of the packet length.

Signed-off-by: Paul HENRYS <paul.henrys_ext@softathome.com>
Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
2025-10-22 14:28:33 +02:00
Jerome Forissier
4b8e785851 net: make dhcp_run() common for NET and NET_LWIP
There are currently two implementations of dhcp_run(): one in cmd/net.c
for NET and one in net/lwip/dhcp.c for NET_LWIP. There is no
justification for that. Therefore, move the NET version into
net/net-common.c to be used by both stacks, and drop the NET_LWIP
version which by the way does not look totally correct.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Suggested-by: Tom Rini <trini@konsulko.com>
Acked-by: Benjamin Hahn <B.Hahn@phytec.de>
2025-10-22 14:28:33 +02:00
Tom Rini
99707a0baa net: Remove BOOTP_VENDOREX support
It has been over a decade since we had a platform that implemented the
bootp vendor extension support hook. Remove this option due to lack of
use.

Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
2025-10-22 11:16:09 +02:00
Tom Rini
f822046037 net: Add SYS_FAULT_MII_ADDR to Kconfig
The support found under SYS_FAULT_ECHO_LINK_DOWN requires that the
SYS_FAULT_MII_ADDR symbol also be set. This wasn't previously found in
Kconfig, so add it now.

Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
2025-10-22 11:16:09 +02:00
Alvin Šipraga
caa2ad6f8c tftp: make TFTP ports unconditionally configurable
A few lines of code being guarded by the CONFIG_TFTP_PORT option seems
an unnecessary restriction on the TFTP support provided by a vanilla
U-Boot image. In cases where the TFTP server cannot run as superuser -
and hence cannot run on the well-known port 69 - this quirk incurs a
full reconfiguration and rebuild of the bootloader only in order to
select the appropriate destination port.

Remove the CONFIG_TFTP_PORT option entirely and make the tftpdstp and
tftpsrcp variables always have an effect. Their being unset will mean
that U-Boot behaves the same as if CONFIG_TFTP_PORT was unset. Update
the documentation accordingly. And fix up the single board which was
originally enabling this option.

Signed-off-by: Alvin Šipraga <alvin@pqrs.dk>
Reviewed-by: Quentin Schulz <quentin.schulz@cherry.de>
2025-10-22 11:09:24 +02:00
Matthias Schiffer
8db554dcbb net: mdio-uclass: introduce dm_eth_phy_connect_interface()
dm_eth_phy_connect_interface() is a variant of dm_eth_phy_connect() that
allows to set the used PHY mode, in case the MAC driver needs to fix it
up. The previously static dm_eth_connect_phy_handle() is renamed and
extended for this purpose.

Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
2025-10-10 11:07:44 -06:00
Tim Harvey
b2217c935e net: lwip: ensure alignment of packet buffers
Network packet buffers should be aligned to PKTALIGN. Add a compiler
attribute to ensure this.

Signed-off-by: Tim Harvey <tharvey@gateworks.com>
[jf: use __aligned(x) from <linux/compiler_attributes.h>]
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
2025-09-30 13:08:38 +02:00
Jerome Forissier
61a6f5ab99 net: lwip: dhcp: set ntpserverip environment variable
Once the DHCP exchange is complete, if we have an IP address for an NTP
server, set the ntpserverip environment variable accordingly. Although
not necessary to make the sntp command use that server (since it is
known internally to the lwIP stack), this makes the behavior in line
with the legacy NET stack. This is also consistent with exporting the
DNS servers etc.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Suggested-by: Michal Simek <michal.simek@amd.com>
2025-09-30 12:01:36 +02:00
Jerome Forissier
57a623230e net: lwip: dhcp: make NTP servers usable by the sntp command
When both CMD_DHCP and CMD_SNTP are enabled, one would expect the NTP
servers received by DHCP to be used by the sntp command by default. Fix
dhcp_loop() so that it is indeed the case.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reported-by: Michal Simek <michal.simek@amd.com>
2025-09-30 12:01:36 +02:00
Jerome Forissier
90c05f68fc net: lwip: ping: set net_try_count to 1
The legacy network stack sets net_try_count to 1 at the beginning of the
net_loop() function. This is required for net_start_again() to work
properly. Therefore, set the variable accordingly in the do_ping()
function when NET_LWIP=y. This fixes an issue where a ping to an
unreachable destination would run twice on the same network device. For
example with qemu_arm64_lwip_defconfig:

 => dhcp
 DHCP client bound to address 10.0.2.15 (3 ms)
 => ping 10.0.0.1
 Using virtio-net#32 device
 ping failed; host 10.0.0.1 is not alive
 Using virtio-net#32 device
 ping failed; host 10.0.0.1 is not alive
 => QEMU: Terminated

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
2025-08-18 15:47:58 +02:00
Jerome Forissier
512be89796 net: introduce CONFIG_DNS
Introduce the DNS Kconfig symbol so that various network commands may
use host names without the dns command (CMD_DNS) being selected.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
CC: E Shattow <e@freeshell.de>
2025-08-18 15:47:58 +02:00
Max Merchel
4800a6a0b3 net: add missing SPDX-License-Identifier for files originating from LiMon
The header of LiMon imported files reference a License file which
does not exist in U-Boot. Some files were forgotten when adding the
SPDX-License-Identifier.
The LiMon files were originally licensed under GPLv2 as can be seen in
commit [2ea91039].

Based on this commit, add the correct SPDX license identifier.
While at it drop the reference to the non-existing License file from all
LiMon files and update the SPDX-License-Identifier to SPDX version 3.

Signed-off-by: Max Merchel <Max.Merchel@ew.tq-group.com>
2025-08-18 15:47:57 +02:00
Jerome Forissier
6b914d5596 net: lwip: add Kconfig option to show ICMP unreachable errors
Add Kconfig symbol LWIP_ICMP_SHOW_UNREACH which, when enabled, prints a
message to the console upon reception of ICMP unreachable messages. For
example:

 $ make qemu_arm64_lwip_defconfig
 $ qemu-system-aarch64 -M virt -cpu max -nographic -bios u-boot.bin
 [...]
 => dhcp
 DHCP client bound to address 10.0.2.15 (0 ms)
 => tftp 192.168.0.100:69:Image
 Using virtio-net#32 device
 TFTP from server 192.168.0.100; our IP address is 10.0.2.15
 Filename 'Image'.
 Load address: 0x40200000
 Loading: ICMP destination unreachable (host unreachable) from 192.168.0.16
 Timeout!
 => tftp 192.168.0.16:69:Image
 Using virtio-net#32 device
 TFTP from server 192.168.0.16; our IP address is 10.0.2.15
 Filename 'Image'.
 Load address: 0x40200000
 Loading: ICMP destination unreachable (port unreachable) from 192.168.0.16
 Timeout!
 =>

Submitted upstream as https://github.com/lwip-tcpip/lwip/pull/73.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
2025-08-18 14:08:57 +02:00
Tim Harvey
51eb2bff87 net: lwip: remove eth_init from net_init as it is called later
The call to eth_init within net_init causes the network interface to
start, stop, start again which can cause issues with certain network
device drivers. Remove it to make it behave like the legacy network
path.

Fixes: 5666865decb8 ("net: lwip: fix initialization sequence before a command")
Signed-off-by: Tim Harvey <tharvey@gateworks.com>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
2025-08-01 09:30:47 +02:00
Tim Harvey
bd4de55951 net: lwip: simplify net_lwip_eth_start
For NET_LWIP eth_is_on_demand_init() is always 1 so remove the check and
simplify the code.

Suggested-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Tim Harvey <tharvey@gateworks.com>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
2025-08-01 09:30:47 +02:00
Andrew Goodbody
9104267e67 net: wget: Fix comparison of unsigned variable
content_length is an unsigned long and so testing that it is >= 0 will
always be true. Instead test that it is != -1 as that is the condition
set on error.

This issue found by Smatch.

Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
2025-08-01 09:30:47 +02:00
Andrew Goodbody
c29c5ed296 net: Incorrect NOP macro used for test
In tcp_parse_options the uchar p[0] is attempted to test for a match
with the 32bit macro TCP_0_NOP which can never be true. Instead test
against the 8bit macro TCP_1_NOP.

This issue found by Smatch.

Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
2025-08-01 09:30:47 +02:00
Jerome Forissier
77f0bed326 net: extract function net_sntp_set_rtc() from sntp_handler()
Extract the code that sets the RTC clock from sntp_handler() in
net/sntp.c and make it a new function net_sntp_set_rtc() in
net/net-common.c. This will allow re-use with NET_LWIP.

According to [1] it is safe to assume that all devices have been
converted to DM_RTC so drop the useless code.

[1] https://lists.denx.de/pipermail/u-boot/2025-June/591376.html

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
2025-07-08 11:07:37 +02:00
Jerome Forissier
9501274f94 lwip: add net_lwip_dns_resolve()
Add a helper fonction to convert an IP address (supplied as a text
string) or a host name to an ip_addr_t.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
2025-07-08 11:07:37 +02:00
Jerome Forissier
d3761a31ef lwip: split net/lwip/wget.c
Split net/lwip/wget.c in two: one part which implements CONFIG_WGET
stays in net/ while the part that implements CONFIG_CMD_WGET is moved
into cmd/.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
2025-07-08 11:07:37 +02:00
Jerome Forissier
d63c4434bf lwip: move net/lwip/ping.c to cmd/lwip
Prepare to split the ping command from cmd/net-lwip.c by moving the
implementation from net/lwip/dns.c to cmd/lwip.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
2025-07-08 11:07:37 +02:00
Jerome Forissier
1c55e0370b lwip: move net/lwip/dns.c to cmd/lwip
Prepare to split the dns command from cmd/net-lwip.c by moving the
implementation from net/lwip/dns.c to cmd/lwip.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
2025-07-08 11:07:37 +02:00
Jerome Forissier
0a9374deb8 lwip: remove net/lwip/eth_internal.h
net/lwip/eth_internal.h is not used. Remove it.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
2025-07-08 11:07:37 +02:00
Tim Harvey
d373436f50 net: lwip: wget: initialize dns if a hostname is used in a URL
Initialize dns servers if a hostname (vs ipaddr) is used in a URL.
Otherwise the wget will fail without displaying an error due to
dns_gethostbyname failing silently when no DNS servers are set unless
you have previously performed a 'dns <arg>' command.

Signed-off-by: Tim Harvey <tharvey@gateworks.com>
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
2025-07-08 11:07:37 +02:00
Tim Harvey
a383869d6b net: lwip: move dns init to common function
move the dns init including setting the dns servers from env vars to a
common function as other commands that support hostname lookups will
need this.

Signed-off-by: Tim Harvey <tharvey@gateworks.com>
[jf: add CMD_DNS conditional to support NET_LWIP && !CMD_DNS]
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
2025-07-08 11:05:29 +02:00
Tim Harvey
e4e97f7052 net: lwip: tftp: add support for setting blocksize at runtime
Add support for setting the blocksize at runtime via the tftpblocksize env
variable as such is done with the legacy stack (CONFIG_NET).

Signed-off-by: Tim Harvey <tharvey@gateworks.com>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
2025-07-08 09:53:59 +02:00