summaryrefslogtreecommitdiff
path: root/net/lwip
AgeCommit message (Collapse)Author
5 daysnet: 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>
5 daysnet: 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-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-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-20net: lwip: tftp: time out if there is no reply from serverJerome Forissier
When there is no reply from the TFTP server, do_tftpb() should eventually time out. Add a 10 second timer for that purpose. Reported-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
2025-05-20net-lwip: tftp: add LMB and buffer checksJerome Forissier
Legacy NET tftp invokes a store_block() function which performs buffer validation (LMB, address wrapping). Do the same with NET_LWIP. Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Suggested-by: Sughosh Ganu <sughosh.ganu@linaro.org> Acked-by: Sughosh Ganu <sughosh.ganu@linaro.org> Tested-by: Sughosh Ganu <sughosh.ganu@linaro.org>
2025-05-20net-lwip: wget: add LMB and buffer checksJerome Forissier
Legacy NET wget invokes a store_block() function which performs buffer validation (LMB, address wrapping). Do the same with NET_LWIP. Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Suggested-by: Sughosh Ganu <sughosh.ganu@linaro.org> Acked-by: Sughosh Ganu <sughosh.ganu@linaro.org> Tested-by: Sughosh Ganu <sughosh.ganu@linaro.org>
2025-05-20net, net-lwip: wget: suppress console output when called by EFIJerome Forissier
Functions called from EFI applications should not do console output. Refactor the wget code to implement this requirement. The wget_http_info struct is used to hold the boolean that signifies whether the output is allowed or not. Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2025-05-20net-lwip: change static function wget_loop() to be wget_do_request()Jerome Forissier
wget_do_request() currently does so little before calling the static function wget_loop() that we may as well rename wget_loop() to wget_do_request() and put everything in one function. Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Sughosh Ganu <sughosh.ganu@linaro.org>
2025-04-23net: lwip: use timer_early_get_count() when CONFIG_SANDBOX_TIMER=yJerome Forissier
When the sandbox timer is available, use it. This allows skipping time in the tests (sandbox_eth_skip_timeout()). Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2025-04-23net: lwip: add restart support to pingJerome Forissier
Use net_start_again() in do_ping() to determine if a failed ping should be restarted on a different interface. Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2025-04-23net: lwip: provide net_start_again()Jerome Forissier
Implement net_start_again() when NET_LWIP=y in a very similar way to NET. This will be used in a future commit to determine if a failed ping needs to be tried again on a different interface. Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2025-04-23net: lwip: fix initialization sequence before a commandJerome Forissier
The things that are done prior to executing a network command with NET_LWIP are not consistent with what is done with NET. It impacts the selection of the current device, and more precisely if the active device is invalid NET would return an error while NET_LWIP would try to pick a new device. This incorrect behavior was detected thanks to the eth_rotate sandbox test (dm_test_eth_rotate()). Fix it by re-using a sequence similar to what NET has in net_loop(). This piece of code is inserted in a function called net_lwip_eth_start() renamed from net_lwip_eth_set_current(). Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2025-04-11Merge patch series "Switch to using $(PHASE_) in Makefiles"Tom Rini
Tom Rini <trini@konsulko.com> says: This series switches to always using $(PHASE_) in Makefiles when building rather than $(PHASE_) or $(XPL_). It also starts on documenting this part of the build, but as a follow-up we need to rename doc/develop/spl.rst and expand on explaining things a bit. Link: https://lore.kernel.org/r/20250401225851.1125678-1-trini@konsulko.com
2025-04-11Kbuild: Always use $(PHASE_)Tom Rini
It is confusing to have both "$(PHASE_)" and "$(XPL_)" be used in our Makefiles as part of the macros to determine when to do something in our Makefiles based on what phase of the build we are in. For consistency, bring this down to a single macro and use "$(PHASE_)" only. Signed-off-by: Tom Rini <trini@konsulko.com>
2025-04-08Merge branch 'next'Tom Rini
Note that this undoes the changes of commit cf6d4535cc4c ("x86: emulation: Disable bloblist for now") as that was intended only for the release due to time.
2025-03-31net: lwip: Remove error print on failed txIlias Apalodimas
When an ethernet driver fails to send a frame we print an error in lwIP. But depending on how often that error is it might significantly delay transmissions. For example downloading a big file with the rpi4 spams the console with 'send error: -101', but removing the print makes the file download with an average speed of ~8.5MiB/s since the packets are retransmitted. So let's move it to a 'debug' in lwIP and expect ethernet drivers to handle the failure if it's severe. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
2025-03-31net: lwip: do_ping() should return CMD_RET_FAILURE when no deviceJerome Forissier
do_ping() expects ping_loop() to return a negative value on error, so that it can propagate it to the caller as CMD_RET_FAILURE. This is not the case when no ethernet device is found, so fix that. Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2025-03-11net: lwip: add support for built-in root certificatesJerome Forissier
Introduce Kconfig symbols WGET_BUILTIN_CACERT and WGET_BUILTIN_CACERT_PATH to provide root certificates at build time. Usage example: wget -O cacert.crt https://cacerts.digicert.com/DigiCertTLSECCP384RootG5.crt make qemu_arm64_lwip_defconfig echo CONFIG_WGET_BUILTIN_CACERT=y >>.config echo CONFIG_WGET_BUILTIN_CACERT_PATH=cacert.crt >>.config make olddefconfig make -j$(nproc) CROSS_COMPILE="ccache aarch64-linux-gnu-" qemu-system-aarch64 -M virt -nographic -cpu max \ -object rng-random,id=rng0,filename=/dev/urandom \ -device virtio-rng-pci,rng=rng0 -bios u-boot.bin => dhcp # HTTPS transfer using the builtin CA certificates => wget https://digicert-tls-ecc-p384-root-g5.chain-demos.digicert.com/ 1867 bytes transferred in 1 ms (1.8 MiB/s) Bytes transferred = 1867 (74b hex) Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2025-03-11net: lwip: extend wget to support CA (root) certificatesJerome Forissier
Add the "cacert" (Certification Authority certificates) subcommand to wget to pass root certificates to the code handling the HTTPS protocol. The subcommand is enabled by the WGET_CACERT Kconfig symbol. Usage example: => dhcp # Download some root certificates (note: not authenticated!) => wget https://cacerts.digicert.com/DigiCertTLSECCP384RootG5.crt # Provide root certificates => wget cacert $fileaddr $filesize # Enforce verification (it is optional by default) => wget cacert required # Forget the root certificates => wget cacert 0 0 # Disable verification => wget cacert none Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2025-03-11net: lwip: add CONFIG_LWIP_DEBUG_RXTXJerome Forissier
Add Kconfig symbol LWIP_DEBUG_RXTX to dump the incoming and outgoing packets when NET_LWIP=y. Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2025-03-11net: lwip: rename linkoutput() as net_lwip_tx()Jerome Forissier
Rename static function linkoutput() as net_lwip_tx() for consistency with net_lwip_rx(). Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2025-02-12net: Kconfig: depend on DM_RNG for WGET_HTTPSJerome Forissier
net/lwip/wget.c/mbedtls_hardware_poll() is calling dm_rng_read() but dependency is not recorded anywhere that's why depend on DM_RNG when WGET_HTTPS is used. Suggested-by: Michal Simek <michal.simek@amd.com> Co-developed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Tested-by: Michal Simek <michal.simek@amd.com>
2025-02-12net: lwip: move eth_init() out of new_netif()Jerome Forissier
Move the initialization of the ethernet devices out of the new_netif() function. Indeed, new_netif() accepts a struct device argument, which is expected to be valid and active. The activation and selection of this device are achieved by eth_init() (on first time the network stack is used) and eth_set_current(). This is what takes care of the ethrotate and ethact environment variables. Therefore, move these calls to a new function: net_lwip_set_current(), and use it whenever a net-lwip command is run. This patch hopefully fixes the incorrect net-lwip behavior observed on boards with multiple ethernet interfaces [1]. Tested on an i.MX8MPlus EVK equipped wih two ethernet ports. The dhcp command succeeds whether the cable is plugged into the first or second port. [1] https://lists.denx.de/pipermail/u-boot/2025-January/576326.html Reported-by: E Shattow <e@freeshell.de> Tested-by: E Shattow <e@freeshell.de> Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
2024-12-25Merge tag 'v2025.01-rc5' into nextTom Rini
Prepare v2025.01-rc5
2024-12-19net: lwip: check if network device is available in do_dhcpHeinrich Schuchardt
eth_get_dev() returns NULL if no network device is available. Not checking the return value leads to a crash when the device pointer is dereferenced. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
2024-12-19net: lwip: do not return CMD_RET_USAGE if no interfaceHeinrich Schuchardt
If the dns command cannot find a network interface, we should return CMD_RETFAIURE and not -1 (CMD_RET_USAGE). Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
2024-12-09Merge tag 'v2025.01-rc4' into nextTom Rini
Prepare v2025.01-rc4
2024-12-04efi_loader: net: set EFI bootdevice device path to HTTP when loaded from wgetAdriano Cordova
Set the device path of the efi boot device to an HTTP device path (as formed by efi_dp_from_http) when the next boot stage is loaded using wget (i.e., when wget is used with wget_info.set_bootdev=1). When loaded from HTTP, the device path should account for it so that the next boot stage is aware (e.g. grub only loads its http stack if it itself was loaded from http, and it checks this from its device path). Signed-off-by: Adriano Cordova <adrianox@gmail.com> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2024-12-04net: wget: let wget_with_dns work with dns disabledAdriano Cordova
This was marked as TODO in the code: - Enable use of wget_with_dns even if CMD_DNS is disabled if the given uri has the ip address for the http server. - Move the check for CMD_DNS inside wget_with_dns. - Rename wget_with_dns to wget_do_request Signed-off-by: Adriano Cordova <adrianox@gmail.com> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
2024-12-04net-lwip: zero terminate string with headers in wget_lwip_fill_info()Adriano Cordova
This patch comes as a companion to the same patch but for the legacy net stack. Commit 1327c2a8d6 ("net/lwip: wget: integrate struct wget_info into wget code") introduced function wget_fill_info() which retrieves the headers from the HTTP server response. As we want to parse the string in later patches we need to ensure that it is NUL terminated. We must further check that wget_info->headers in not NULL. Otherwise a crash occurs. Signed-off-by: Adriano Cordova <adrianox@gmail.com>
2024-12-04lwip: wget: pass port and server_name via wget_ctxAdriano Cordova
Commit 5907c81 ("net: lwip: Enable https:// support for wget") was not correctly rebased on top of the changes introduced by Commit 6cc4d04 ("net/lwip: wget: put server_name and port into wget_ctx") in next. This commit re-applies a couple of lines from 6cc4d04. Fixes: Commit 5907c81 ("net: lwip: Enable https:// support for wget") Signed-off-by: Adriano Cordova <adrianox@gmail.com>
2024-11-30net: lwip: wget: fix legacy syntaxJerome Forissier
Commit 356011f7ac25 ("lwip: fix code style issues") has inadvertently broken the support for the legacy syntax: => wget 192.168.0.16:test.bin invalid uri, no file path Invalid URL. Use http(s):// The reason is two calls to strncpy() were replaced by strlcpy() without paying attention to the fact that they are not equivalent in the present case. Since we are using a character counter (n) and since we do not depend on having a properly null-terminated string at each step in the parsing, strlcpy() is not justified and strncpy() is the right tool for the job. So use it again. Reported-by: Tom Rini <trini@konsulko.com> Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
2024-11-25Merge tag 'v2025.01-rc3' into nextTom Rini
Prepare v2025.01-rc3
2024-11-22net: lwip: dhcp: support arguments for TFTP file downloadJerome Forissier
The dhcp command is supposed to have the following syntax as per "help dhcp": dhcp [loadAddress] [[hostIPaddr:]bootfilename] In other words, any arguments should be passed to an implicit tftpboot command after the DHCP exchange has occurred. Add the missing code to the lwIP version of do_dhcp(). Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
2024-11-22net: lwip: provide entropy to MBed TLS in one goIlias Apalodimas
We currently provide entropy to mbedTLS using 8b chunks. Take into account the 'len' parameter passed by MBed TLS to the entropy gathering function instead. Note that the current code works because len is always 128 (defined at compile time), therefore mbedtls_hardware_poll() is called repeatedly and the buffer is filled correctly. But passing 'len' to dm_rng_read() is both better and simpler. Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Suggested-by: Simon Glass <sjg@chromium.org> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2024-11-22net: lwip: fix get_udev_ipv4_info()Jerome Forissier
The local variables ipstr, maskstr and gwstr in static function get_udev_ipv4_info() cannot be pointers to read-only data, since they may be written to in case the device index is > 0. Therefore make them char arrays allocated on the stack. Reported-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reported-by: Adriano Cordova <adrianox@gmail.com> Link: https://lists.denx.de/pipermail/u-boot/2024-November/572066.html Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-11-22net: lwip: fix dhcp_loop()Jerome Forissier
The local variables ipstr, maskstr and gwstr in static function dhcp_loop() cannot be pointers to read-only data, since they may be written to in case the device index is > 0. Therefore make them char arrays allocated on the stack. Reported-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-11-18Kconfig: describe NET, NO_NET, LWIP_DEBUG and LWIP_ASSERTJerome Forissier
Some Kconfig symbols introduced in commit 8cb330355bd5 ("net: introduce alternative implementation as net/lwip/") need a full description. The NET symbol needs one, too. Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-11-18net: lwip/wget: correct SERVER_NAME_SIZEHeinrich Schuchardt
The maximum length of a domain name is 253 as defined in RFC 1035. So SERVER_NAME_SIZE should be 254 including NUL. Fixes: 3c656c928bd7 ("net: lwip: add wget command") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-11-16net/lwip: wget: integrate struct wget_info into wget codeAdriano Cordova
Each wget request now fills the struct wget_info. Also, the efi bootdevice is now set conditionally to the set_bootdevice variable in wget_info and a buffer size check is performed if check_buffer_size is set. Signed-off-by: Adriano Cordova <adrianox@gmail.com>