summaryrefslogtreecommitdiff
path: root/net
AgeCommit message (Collapse)Author
2026-01-15net: tftpput: Rework to exclude code from xPL phasesTom Rini
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-15net: lwip: nfs: Port the NFS code to work with lwIPAndrew Goodbody
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-15net: nfs: Move most NFS code to common filesAndrew Goodbody
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-15net: nfs: Add licence headerAndrew Goodbody
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-15net: Move some variables to net-common filesAndrew Goodbody
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-15net: move net_state to net-commonAndrew Goodbody
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-15net:lwip: Add debug line to net-lwipAndrew Goodbody
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>
2025-12-22Merge tag 'v2026.01-rc5' into nextTom Rini
Prepare v2026.01-rc5
2025-12-18net: lwip: tftp: Fix filename handlingAndrew Goodbody
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-05net: remove unreachable legacy LED codeQuentin Schulz
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-01net: tftp: Remove tftp_init_load_addr error pathLeonard Anderweit
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-10-24bootstd: make it possible to use tftp for netboot with standardbootBenjamin Hahn
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-22net: bootp: Prevent buffer overflow to avoid leaking the RAM contentPaul HENRYS
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-22net: make dhcp_run() common for NET and NET_LWIPJerome Forissier
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-22net: Remove BOOTP_VENDOREX supportTom Rini
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-22net: Add SYS_FAULT_MII_ADDR to KconfigTom Rini
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-22tftp: make TFTP ports unconditionally configurableAlvin Šipraga
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-10net: mdio-uclass: introduce dm_eth_phy_connect_interface()Matthias Schiffer
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-09-30net: lwip: ensure alignment of packet buffersTim Harvey
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-30net: lwip: dhcp: set ntpserverip environment variableJerome Forissier
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-30net: lwip: dhcp: make NTP servers usable by the sntp commandJerome Forissier
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-08-18net: lwip: ping: set net_try_count to 1Jerome Forissier
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-18net: introduce CONFIG_DNSJerome Forissier
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-18net: add missing SPDX-License-Identifier for files originating from LiMonMax Merchel
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-18net: lwip: add Kconfig option to show ICMP unreachable errorsJerome Forissier
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-01net: lwip: remove eth_init from net_init as it is called laterTim Harvey
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-01net: lwip: simplify net_lwip_eth_startTim Harvey
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-01net: wget: Fix comparison of unsigned variableAndrew Goodbody
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-01net: Incorrect NOP macro used for testAndrew Goodbody
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-07-08net: extract function net_sntp_set_rtc() from sntp_handler()Jerome Forissier
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-08lwip: add net_lwip_dns_resolve()Jerome Forissier
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-08lwip: split net/lwip/wget.cJerome Forissier
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-08lwip: move net/lwip/ping.c to cmd/lwipJerome Forissier
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-08lwip: move net/lwip/dns.c to cmd/lwipJerome Forissier
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-08lwip: remove net/lwip/eth_internal.hJerome Forissier
net/lwip/eth_internal.h is not used. Remove it. Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
2025-07-08net: lwip: wget: initialize dns if a hostname is used in a URLTim Harvey
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-08net: lwip: move dns init to common functionTim Harvey
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-08net: lwip: tftp: add support for setting blocksize at runtimeTim Harvey
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-08net: lwip: call sys_check_timeouts and schedule on rxTim Harvey
Call schedule() in net_lwip_rx() to service U-Boot tasks and actions during packet rx. As a cleanup also move sys_check_timeouts() here and remove it from the functions that call net_lwip_rx(). This resolves the issue of an active watchdog resetting the board on long network activities. 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-06-26net: consolidate PXE processor architecture type KconfigHeinrich Schuchardt
DHCP and DHCPv6 use the same value defined in https://www.iana.org/assignments/dhcpv6-parameters#processor-architecture to encode the processor architecture type. We should only use a single Kconfig symbol for both protocols. Furthermore we should make the value customizable. This allows for instance to choose between "x86 BIOS" or "x64 UEFI". As "x86 BIOS" is encoded as 0, we should not use this value to switch off transmission of the DHCP option. Use 0xFF instead. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Tom Rini <trini@konsulko.com>
2025-05-29Merge patch series "Remove <env.h> from <net.h>"Tom Rini
Tom Rini <trini@konsulko.com> says: Hey all, This is a v3 of Simon's series[1] and depends on the series[2] I posted the other day that removes <env.h> from <command.h>. With this series done, I believe we've tackled all of the current cases of headers which include <env.h> without directly needing it. Much of this series is in fact Simon's v2 with the main differneces being: - Removing <env.h> from <net.h> at the end - Removing env_to_ip() given how little it's used rather than shuffling around where it's declared and un-inline'ing it. For a rarely used helper, this ends up being cleaner I think. Especially looking at some of the users (which called env_get repeatedly). If there's strong opinion here about using the other method[3] we can do that instead. - Setting aside for now how to handle CMD_ELF=y and NO_NET=y because today it's actually fine as we unconditionally build lib/net_utils.c where string_to_ip() is defined. I'm unsure if a further series is warranted here or not. We rely on link-time optimization to keep code readable too. [1]: https://lore.kernel.org/all/20250501010456.3930701-1-sjg@chromium.org [2]: https://lore.kernel.org/all/20250514225002.15361-1-trini@konsulko.com [3]: https://lore.kernel.org/all/20250501010456.3930701-23-sjg@chromium.org Link: https://lore.kernel.org/r/20250515234154.1859366-1-trini@konsulko.com
2025-05-29global: Avoid indirect inclusion of <env.h> from <net.h>Tom Rini
Now that env_get_ip() has been removed, the include file <net.h> does not need anything from <env.h>. Furthermore, include/env.h itself includes other headers which can lead to longer indirect inclusion paths. To prepare to remove <env.h> from <net.h> fix all of the remaining places which had relied on this indirect inclusion to instead include <env.h> directly. Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> # net/lwip Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Wolfgang Wallner <wolfgang.wallner@br-automation.com> Reviewed-by: Martyn Welch <martyn.welch@collabora.com> Signed-off-by: Tom Rini <trini@konsulko.com>
2025-05-29net: Include env.h in pcap.cSimon Glass
This file uses the environment but does not include the header file. Update it. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-29net: Remove env_get_ip helper() functionTom Rini
Currently, we have the function env_get_ip which takes an IP address in string form and returns a struct in_addr representation of that address. It is however little used and means that a number of places indirectly (and unclearly) get <env.h> via <net.h>. To clean this up start by replacing env_get_ip() calls with string_to_ip() calls. This is generally a no-op as env_get_ip(str) is an inline of string_to_ip(env_get(str)) but in a few cases we can or already have stored the result of env_get(str) and can save the additional call. Signed-off-by: Tom Rini <trini@konsulko.com>
2025-05-26Merge tag 'v2025.07-rc3' into nextTom Rini
Prepare v2025.07-rc3
2025-05-23net: tftp: don't call stop callback from UDP handlerAlexander Sverdlin
Contrary to doc/develop/driver-model/ethernet.rst contract, eth_ops .free_pkt can be called after .stop, there are several error paths in TFTP, for instance: eth_halt() <= tftp_handler() <= net_process_received_packet() <= eth_rx() ... am65_cpsw_free_pkt() <= eth_rx() Which results in (deliberately "tftpboot"ing non-existing file): TFTP error: 'File not found' (1) Not retrying... am65_cpsw_nuss_port ethernet@8000000port@1: RX dma free_pkt failed -22 Avoid the DMA error message (and follow the documentation) by deferring eth_halt() until net_loop() calls net_start_again() and only do eth_halt_state_only() instead. Fixes: aafda38fb266 ("Add error codes/handling for TFTP-server") Signed-off-by: Alexander Sverdlin <alexander.sverdlin@siemens.com>
2025-05-23Merge patch series "BOOTP/DHCPv4 enhancements"Tom Rini
Sean Edmond <seanedmond@microsoft.com> says: In our datacenter application, a single DHCP server is servicing 36000+ clients. Improvements are required to the DHCPv4 retransmission behavior to align with RFC and ensure less pressure is exerted on the server: - retransmission backoff interval maximum is configurable (environment variable bootpretransmitperiodmax) - initial retransmission backoff interval is configurable (environment variable bootpretransmitperiodinit) - transaction ID is kept the same for each BOOTP/DHCPv4 request (not recreated on each retry) For our application we'll use: - bootpretransmitperiodmax=16000 - bootpretransmitperiodinit=2000 A new configuration BOOTP_RANDOM_XID has been added to enable a randomized BOOTP/DHCPv4 transaction ID. Enhance DHCPv4 sending/parsing option 209 (PXE config file). A previous patch was accepted. A new patch fixes a possible double free() and addresses latest review comments. Link: https://lore.kernel.org/r/20240509023918.2504185-1-seanedmond@microsoft.com
2025-05-23net: bootp: add config option BOOTP_RANDOM_XIDSean Edmond
The new config option BOOTP_RANDOM_XID will randomize the transaction ID for each new BOOT/DHCPv4 exchange. Signed-off-by: Sean Edmond <seanedmond@microsoft.com> Reviewed-by: Tom Rini <trini@konsulko.com>
2025-05-23net: bootp: BOOTP/DHCPv4 retransmission improvementsSean Edmond
This patch introduces 3 improvements to align with RFC 951: - retransmission backoff interval maximum is configurable - initial retranmission backoff interval is configurable - transaction ID is kept the same for each BOOTP/DHCPv4 request In applications where thousands of nodes are serviced by a single DHCP server, maximizing the retransmission backoff interval at 2 seconds (the current u-boot default) exerts high pressure on the DHCP server and network layer. RFC 951 “7.2. Client Retransmission Strategy” states that the retransmission backoff interval should be limited to 60 seconds. This patch allows the interval to be configurable using the environment variable "bootpretransmitperiodmax" The initial retranmission backoff period defaults to 250ms, which is also too small for these scenarios with many clients. This patch makes the initial retransmission interval to be configurable using the environment variable "bootpretransmitperiodinit". Also, on a retransmission it is not expected for the transaction ID to change (only the 'secs' field should be updated). Let's save the transaction ID and use the same transaction ID for each BOOTP/DHCPv4 exchange. Signed-off-by: Sean Edmond <seanedmond@microsoft.com>
2025-05-23net: Enhancements for dhcp option 209Sean Edmond
- Enable option 209 by default - Set pxelinux_configfile to NULL to avoid potential double free - change hardcoded 209 to a define Signed-off-by: Sean Edmond <seanedmond@microsoft.com>