Commit graph

993 commits

Author SHA1 Message Date
Weijie Gao
7e0370f37d miiphy: define mii_devs with LIST_HEAD()
When enabling net console and console multiplexing, a boot crash was
observed using mtk_eth driver with stdin/stdout set to "serial,nc"
in persistent environment:

> CPU:   MediaTek MT7981
> Model: OpenWrt One
> DRAM:  1 GiB
> Core:  35 devices, 15 uclasses, devicetree: separate
> spi-nand: spi_nand spi_nand@0: Winbond SPI NAND was found.
> spi-nand: spi_nand spi_nand@0: 128 MiB, block size: 128 KiB, page size: 2048, OOB size: 64
> Loading Environment from UBI... SF: Detected w25q128 with page size 256 Bytes, erase size 4 KiB, total 16 MiB
> mtd: partition "ubi" extends beyond the end of device "spi-nand0" -- size truncated to 0x7f00000
> Read 126976 bytes from volume ubootenv to 000000007f7bf0c0
> Read 126976 bytes from volume ubootenv2 to 000000007f7de100
> OK
> "Synchronous Abort" handler, esr 0x96000004, far 0xeafffffeea000018
> elr: 0000000041e63cd4 lr : 0000000041e1b844 (reloc)
> elr: 000000007ff9ecd4 lr : 000000007ff56844
> x0 : eafffffeea000018 x1 : 000000007fb552e0
> x2 : 00000000000000fe x3 : 0000000000000000

The cause is that "serial,nc" forced the console subsystem to
initialize the ethernet driver before ethernet subsystem
initialization (console_init_r() is called before initr_net()).

During the mtk_eth driver initialization, mdio_register() will be
called, and miiphy_get_dev_by_name() will then be called.

The miiphy_get_dev_by_name() will check the list "mii_devs" to see
if the passed device name exists. However the mii_devs is defined
without initialization:
> static struct list_head mii_devs;
and the actual initialization is done in the following chain:
initr_net -> eth_initialize -> eth_common_init -> miiphy_init
Since initr_net() hasn't be called, iterating over the mii_devs
will access to physical address 0 (mii_devs.next == NULL) and will
cause the crash.

The fix is to define mii_devs using:
> static LIST_HEAD(mii_devs);

As the "current_mii" is defined as a static variable, it will
always be NULL in board_r stage and initializing it will NULL is
unnecessary. So the entire miiphy_init() can be remove.

Signed-off-by: Weijie Gao <hackpascal@gmail.com>
2025-03-04 08:03:47 -06:00
Adriano Cordova
32a6c5eac0 legacy-net: wget: fix wget_info handling after new tcp legacy stack
Check wget_info->buffer_size for overflow and do not clean the wget_info struct
on failure, let the owner of the struct handle the error. The latter is necesary
, e.g., for when a request fails because the provided buffer was too small.

Signed-off-by: Adriano Cordova <adriano.cordova@canonical.com>
2025-02-28 15:26:05 +01:00
Jerome Forissier
a091d173e3 net: Kconfig: depend on DM_RNG for WGET_HTTPS
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-12 12:37:24 -06:00
Jerome Forissier
9f6b9f57fe net: lwip: move eth_init() out of new_netif()
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>
2025-02-12 12:36:57 -06:00
Heinrich Schuchardt
1f68057e03 net: eth_bootdev_hunt() should not run DHCP
Currently when booting dhcp_run() may be executed multiple times:
once in eth_bootdev_hunt() and once in the network booting bootmeth.

We need to call eth_bootdev_hunt() when setting up the EFI sub-system to
supply the simple network protocol. We don't need an IP address set up.

We can reduce the bootime by not executing dhcp_run() in
eth_bootdev_hunt().

Furthermore eth_bootdev_hunt() with autostart=yes leads on the legacy
network stack leads to downloading a file via TFTP and to booting the
downloaded file.

Instead of running dchp_run() just check that there is a network device
in eth_bootdev_hunt().

Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2025-01-05 02:30:48 +01:00
Sean Edmond
ec9263b4f1 Fix neighbor discovery ethernet address saving
When a successful neighbor advertisement is received, the ethernet
address should be saved for later use to avoid having to redo the
neighbor discovery process.

For example, with TFTP the address should get saved into
"net_server_ethaddr".  This is being done correctly with ARP for IPv4,
but not for neighbor discovery with IPv6.

Signed-off-by: Sean Edmond <seanedmond@microsoft.com>
Reviewed-by: Viacheslav Mitrofanov <v.v.mitrofanov@yadro.com>
2025-01-01 14:40:04 -06:00
Jerome Forissier
eeee0e2b85 net: tftpput: reset timeout_count when an ACK is received
timeout_count is never reset once a tftpput transfer has started. If for
whatever reason timeouts occur frequently, but the server keeps replying
nonetheless, the transfer may be needlessly aborted.

Reset timer_count on reception of an ACK to avoid this situation.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
2025-01-01 14:40:04 -06:00
Mikhail Kshevetskiy
395ee74991 net: tftpboot: clear timeout_count on every successful block
We have a some boards that rarely starts networking abnormally, so there are
many timeouts during file transfer. In the same time there is a normal transfer
between timeouts. In this case we can continue transfer (instead of connection
aborting) by just clearing timeout counter on every successful block.

This patch does not affect the case when several timeouts happen one after
another. The transfer will be aborted. Thus the transfer will be
continued in the case of unstable link, but will be aborted in the case
of inaccessible server.

Feature downside: it may greatly slowdown (instead of abort) file transfer
in the case of unstable link.

Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
2025-01-01 14:35:46 -06:00
Mikhail Kshevetskiy
15770c61d4 net/net: fix include ordering
fix include ordering to follow
  https://docs.u-boot.org/en/latest/develop/codingstyle.html#include-files

Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
Reviewed-by: Simon Glass <sjg@chromium.org>
2024-12-28 11:59:42 -06:00
Mikhail Kshevetskiy
0eff920826 net/tcp: define a fallback value for rcv_wnd size
Some driver implements it's own network packet pool, so PKTBUFSRX is zero.
This results in zero-size TCP receive window, so data transfer doesn't
work. Avoid it by setting a reasonable fallback value.

Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
Reviewed-by: Simon Glass <sjg@chromium.org>
2024-12-28 11:59:42 -06:00
Mikhail Kshevetskiy
3a44b8ba94 net/tcp: simplify tcp header filling code
This patch:
 * remove useless code,
 * use a special function for pretty printing of tcp flags,
 * simplify the code

The behavior should not be changed.

Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
Reviewed-by: Simon Glass <sjg@chromium.org>
2024-12-28 11:59:42 -06:00
Mikhail Kshevetskiy
bf962de97c net/tcp: improve tcp framework, use better state machine
Changes:
 * Fix initial send sequence always zero issue
 * Use state machine close to RFC 9293. This should make TCP
   transfers more reliable (now we can upload a huge array
   of data from the board to external server)
 * Improve TCP framework a lot. This should make tcp client
   code much more simple.
 * rewrite wget with new tcp stack
 * rewrite fastboot_tcp with new tcp stack

It's quite hard to fix the initial send sequence (ISS) issue
with the separate patch. A naive attempt to fix an issue
inside the tcp_set_tcp_header() function will break tcp packet
retransmit logic in wget and other clients.

Example:
  Wget stores tcp_seq_num value before tcp_set_tcp_header() will
  be called and (on failure) retransmit the packet with the stored
  tcp_seq_num value. Thus:
    * the same ISS must allways be used (current case)
    * or tcp clients needs to generate a proper ISS when
      required.

A proper ISS fix will require a big redesing comparable with
a this one.

Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
Reviewed-by: Simon Glass <sjg@chromium.org>
2024-12-28 11:59:42 -06:00
Mikhail Kshevetskiy
82bf3aafa6 net/tcp: rename ack_edge and seq_init to more common rcv_nxt and irs
Use the names from RFC 9293

Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
Reviewed-by: Simon Glass <sjg@chromium.org>
2024-12-28 11:59:42 -06:00
Mikhail Kshevetskiy
2b17749870 net/tcp: add connection info to tcp_stream structure
Changes:
 * Avoid use net_server_ip in tcp code, use tcp_stream data instead
 * Ignore packets from other connections if connection already created.
   This prevents us from connection break caused by other tcp stream.

Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
Reviewed-by: Simon Glass <sjg@chromium.org>
2024-12-28 11:59:42 -06:00
Mikhail Kshevetskiy
ddedfe1cb8 net/tcp: put connection specific data into a tcp_stream structure
no functional changes

Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
Reviewed-by: Simon Glass <sjg@chromium.org>
2024-12-28 11:59:42 -06:00
Mikhail Kshevetskiy
40d3d6557d net/tcp: fix selective acknowledge
Current code assume that all (except last) packets are of the same size.
This is definitely wrong. Replace SACK code with a new one, that does
not rely on this assumption. Also this code uses less memory.

Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
Reviewed-by: Simon Glass <sjg@chromium.org>
2024-12-28 11:59:42 -06:00
Mikhail Kshevetskiy
77da29b868 net/tcp: fix TCP options processing
Current TCP code may miss an option if TCP_O_NOP option was used before
it for proper aligning.

Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
Reviewed-by: Simon Glass <sjg@chromium.org>
2024-12-28 11:59:42 -06:00
Tom Rini
5cfbf8c364 Prepare v2025.01-rc5
-----BEGIN PGP SIGNATURE-----
 
 iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmdqIAsACgkQFHw5/5Y0
 tyxmdAv/a0dUsibc2oyLJzRFioJO6ib0dro5EHiH1oyF3igOTGe1ifxeQyR/0bb8
 /3Qtr19f77INNjgQmRNpLbBfeoIMm3MeVF+zwQzEvUDEHNNQ0nnxu/yNnJB6Ebej
 xF/vdAP4JoV+KFQXMCMjIyFZcjZh4wGn1L1T8y7GQHS+p1zf0EYA7tPbk5rbwk/E
 xAFSymtWvOZVjLgV9YKp/RqS1+vGHaKydwzUZAncXJzeAMFD2Wm7mnDkd828U/eR
 7vs5BCnRwTgj7iWE6KXJUhFz2hrrBMFTEIV4GNW28vBSCoArlWshLbpKRolEoKY9
 i+dfkBDhghw9fVcTBOSP7BkiFwQl02jPB4Vf8G5ykK11CHO8XTpdjE5buGS1zsiW
 dTX9w4pynCl07p0qYsgGPYf2cE1k6dG6XFNUzH3owyNGiF+66VQeG05V79moQp9F
 ZF0/rux475UhZceXDImdecgkBDsc9gRvu0aX9ZYQtaBCgKJnQ8nyYPXGWZ/u0TSl
 1WVADGUq
 =4mOT
 -----END PGP SIGNATURE-----

Merge tag 'v2025.01-rc5' into next

Prepare v2025.01-rc5
2024-12-25 22:31:04 -06:00
Marek Vasut
9899a6a750 net: renesas: Enable TFTP_TSIZE on all Renesas hardware
TFTP transfer size can be used to re-size the TFTP progress bar on
single line based on the server reported file size. Enable it by
default for Renesas hardware to avoid long scrolling walls of '#'
character during long TFTP transfers.

Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
2024-12-20 22:20:37 +01:00
Heinrich Schuchardt
d701c6ab42 net: lwip: check if network device is available in do_dhcp
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-19 12:17:37 -06:00
Heinrich Schuchardt
b6691d0add net: lwip: do not return CMD_RET_USAGE if no interface
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-19 12:17:32 -06:00
Tom Rini
9bc62c980d Prepare v2025.01-rc4
-----BEGIN PGP SIGNATURE-----
 
 iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmdXaqUACgkQFHw5/5Y0
 tyzwDQv/W1C47W86RQKdu6LmlaJEQU/LV1wS6AvhxHtWvrWwg85/yIuiIErRbMyk
 +4Nof/grgie2j8lVGMEkABDdLdRwW4J70/TZn/w3NLBVKCU8dYAfCfWPo6mJeJkr
 tYupNkxDCMGA4EUkSNc/wdjH2yubMD2+wEaBf2Hz2Yp0B8BKGJg9Vf09YWQQHof0
 rByq4ThZ41W9njwk03UdcacN3HzVml7iJfoEg8RmqHThomQKD2WMNeCthzQUgRI2
 /sk8jNNyUli+/wzNlFqjYUKPB+V2DWxjVDNnrxvcb2i+Whgrb7+3rPtP7zhR3WVc
 oaHmW8CVe5/fhykrDHKG+IeLc59C1YOF3O9jG5LpjEoWDvTnt9Tnr+Rg4TYcAUdI
 4RhA16RSHmKs5MVnxF9xD9iIZ8x9WSq2cqkTHUAVbes2gyS4ITvXmoP674Khao8C
 qmtEJpz51Ye7g2OmfKB2Nr4C7fOWNkgq0teLjxZ7rdwuPyMRtsurY7j5Sw96AxWY
 HkWm6svP
 =5zS1
 -----END PGP SIGNATURE-----

Merge tag 'v2025.01-rc4' into next

Prepare v2025.01-rc4
2024-12-09 16:29:47 -06:00
Adriano Cordova
e55a4acb54 efi_loader: net: set EFI bootdevice device path to HTTP when loaded from wget
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-04 12:24:37 +01:00
Adriano Cordova
9bab7d2a7c net: wget: let wget_with_dns work with dns disabled
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-04 12:24:37 +01:00
Adriano Cordova
dc7c8a2532 net-lwip: zero terminate string with headers in wget_lwip_fill_info()
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-04 12:24:37 +01:00
Heinrich Schuchardt
737c2dca95 net: zero terminate string with headers in wget_fill_info()
Commit 2dd076a9c1 ("net: wget: integrate struct wget_info into legacy
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.

Fixes: 2dd076a9c1 ("net: wget: integrate struct wget_info into legacy wget code")
Signed-off-by: Adriano Cordova <adrianox@gmail.com>
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2024-12-04 12:24:37 +01:00
Adriano Cordova
ab49ede318 lwip: wget: pass port and server_name via wget_ctx
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-12-04 12:24:37 +01:00
Jerome Forissier
a37064cb2e net: lwip: wget: fix legacy syntax
Commit 356011f7ac ("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-30 11:52:47 -06:00
Tom Rini
48380f9b2a Prepare v2025.01-rc3
-----BEGIN PGP SIGNATURE-----
 
 iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmdFAVQACgkQFHw5/5Y0
 tyyyfQwAuHAoOJ2Q5KnesduF9tkzeSRoziCNig3D+VItbJSxKqnBxPB9U+AxxsZ8
 JVA1e5qSwcblqybyWHrFUVTYVlI4j9oJIOTQKtEmUnDUNY+vd5eT9+V8kmQqnbU0
 mhE8fuH6wSHQ3K+tdVSJuWxcZJfFOE5dZKAxz0z/LysqNfJ/r/iqg2l0YYozId2s
 Kyyq7K25jNilcWAw4zUbGcdvM+H53KNzQ3WcZ36HwenlXWoQJOKCbEEskYxAaa0e
 hSEAQCNeuD1oVoZH1jc9dP6htLx5gmOaSbIScwfaOMqBQHyWQTjv/sMEy8wGSMdA
 PqDGClxU0GCenhbS6waY9GPMLYV0JtyXsAmjrWUOXStLrGMBCrP6Xu6T2Ol7+7pt
 O+ZPZM5Xhmo0UR2sY4sWjDIC1AHVXaLZlbC7vfjadkZ30UZvwIXgDFJemS3nDW96
 /JJo/6sgdLGJGvNYGb4mitKO5+kIiz6kKeMvzcfBj+PWybfYhUbqc/AARtlf9Hzp
 +gvtFlCF
 =Q9hw
 -----END PGP SIGNATURE-----

Merge tag 'v2025.01-rc3' into next

Prepare v2025.01-rc3
2024-11-25 17:34:08 -06:00
Jerome Forissier
13e13f5867 net: lwip: dhcp: support arguments for TFTP file download
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-22 14:51:26 -06:00
Ilias Apalodimas
2cde2f4a00 net: lwip: provide entropy to MBed TLS in one go
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-22 14:40:53 -06:00
Jerome Forissier
7d80e7368e net: lwip: fix get_udev_ipv4_info()
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-22 14:37:49 -06:00
Jerome Forissier
8c95d84b39 net: lwip: fix dhcp_loop()
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-22 14:37:21 -06:00
Jerome Forissier
deb9a07cf1 Kconfig: describe NET, NO_NET, LWIP_DEBUG and LWIP_ASSERT
Some Kconfig symbols introduced in commit 8cb330355b ("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-18 13:32:16 -06:00
Heinrich Schuchardt
2071583c8f net: lwip/wget: correct SERVER_NAME_SIZE
The maximum length of a domain name is 253 as defined in RFC 1035.
So SERVER_NAME_SIZE should be 254 including NUL.

Fixes: 3c656c928b ("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-18 13:32:12 -06:00
Adriano Cordova
9063dba2d3 net: net_utils: Move ip_to_string to lib/net_utils.c
The function string_to_ip is already in net_utils, which is
compiled unconditionally, but ip_to_string is currently only
accessible if the legacy network stack is selected. This
commit puts ip_to_string in net_utils.c and removes it from the
legacy network code.

Signed-off-by: Adriano Cordova <adrianox@gmail.com>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2024-11-18 16:12:35 +01:00
Adriano Cordova
1327c2a8d6 net/lwip: wget: integrate struct wget_info into wget code
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>
2024-11-16 21:35:06 +01:00
Adriano Cordova
6cc4d0492b net/lwip: wget: put server_name and port into wget_ctx
Currently server_name and port are local variables in wget_loop.
This commit puts them inside ctx, so that they are accessible
from the http callbacks.

Signed-off-by: Adriano Cordova <adrianox@gmail.com>
2024-11-16 21:35:05 +01:00
Adriano Cordova
de28a2a5f2 net: wget: make wget_with_dns return value compatible with its lwip version
There are two wget_with_dns functions, one in the legacy network
stack and one in lwip, but the return values are not compatible.
This commit modifies the legacy version of wget_with_dns so that
the return values are compatible: 0 on success, otherwise a negative
error. This way wget_with_dns can be called in a network stack
agnostic way.

Signed-off-by: Adriano Cordova <adrianox@gmail.com>
2024-11-16 21:35:05 +01:00
Adriano Cordova
2dd076a9c1 net: wget: integrate struct wget_info into legacy wget code
Each wget request now fills the struct wget_info. The efi
bootdevice is now set conditionally to the set_bootdevice
variable in wget_info, and the same holds for lmb memory check.

Signed-off-by: Adriano Cordova <adrianox@gmail.com>
2024-11-16 21:35:05 +01:00
Adriano Cordova
1de93fda99 net: wget: Add interface to issue wget_requests using wget_http_info
Declare and define a global default struct wget_http_info
and an interface to issue wget requests providing a custom
struct wget_http_info. This code is common to legacy wget
and lwip wget. The idea is that the command wget should use
the default wget_http_info and other internal u-boot code
can call wget_request with their own wget_http_info struct.

Signed-off-by: Adriano Cordova <adrianox@gmail.com>
2024-11-16 21:35:05 +01:00
Adriano Cordova
657b799585 net: Kconfig: add CONFIG_WGET symbol
Let net/wget.c and net/lwip/wget.c depend on CONFIG_WGET, and
cmd/wget.c depend on CONFIG_CMD_WGET. This way, the wget code
can be used regardless of whether the wget command is available.

Signed-off-by: Adriano Cordova <adrianox@gmail.com>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2024-11-16 21:35:05 +01:00
Jerome Forissier
356011f7ac lwip: fix code style issues
Fix various code style issues in the lwIP code.

Reported-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-11-14 18:14:05 -06:00
Tom Rini
b30787ad24 Merge patch series "Enable https for wget"
Ilias Apalodimas <ilias.apalodimas@linaro.org> says:

Hi all,

This is a respin of [1] adding https support to wget. In short

patch#1 enables the crypto algorithms we need in mbedTLS
patches#2, #3 enable anf fix the lwIP part we need
patch#4 is adding https:// parsing support in our wget
patch#5 is making https:// the default for QEMU lwip defconfig so
people can easily test
and finaly patch#6 updates our documentation

[1] https://lore.kernel.org/u-boot/20241024112449.1362319-1-ilias.apalodimas@linaro.org/

Link: https://lore.kernel.org/r/20241110083017.367565-1-ilias.apalodimas@linaro.org
2024-11-12 19:10:01 -06:00
Ilias Apalodimas
5907c81647 net: lwip: Enable https:// support for wget
With the recent changes of lwip & mbedTLS we can now download from
https:// urls instead of just http://.
Adjust our wget lwip version parsing to support both URLs.
While at it adjust the default TCP window for QEMU since https seems to
require at least 16384

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
2024-11-12 19:09:52 -06:00
Jerome Forissier
385af1b898 net: wget: drop Content-Length processing
We don't do anything with Content-Length except a debug print, and the
strict_strtoul() call is incorrect (it always returns -EINVAL and leaves
content_length to zero due to the presence of trailing characters after
the decimal valuoe of Content-Length). So let's just drop this piece of
code.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
2024-11-12 19:08:57 -06:00
Jerome Forissier
e65c5e3e73 net: lwip: add TFTP_BLOCKSIZE
Add support for setting the TFTP block size. The default value (1468)
is fine for Ethernet and allows a better throughput than the TFTP
default (512), if the server supports the blksize option of course.

I tested this change with qemu_arm64_lwip_defconfig. The throughput is
now 875 KiB/s vs. 313 KiB/s before. That is still a low number, but I
think we can't expect more without implementing the windowsize option.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-10-16 11:11:57 -06:00
Jerome Forissier
3c656c928b net: lwip: add wget command
Add support for the wget command with NET_LWIP. The command normally
expects a URL: wget [loadaddr] url, but it also accepts the legacy
syntax: wget [loadaddr] [server:]file.
The server IP may alternatively be supplied via ${httpserverip} which
has higher priority than ${serverip}.

Based on code initially developed by Maxim U.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Co-developed-by: Maxim Uvarov <muvarov@gmail.com>
Cc: Maxim Uvarov <muvarov@gmail.com>
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-10-16 11:11:56 -06:00
Jerome Forissier
aedcfec9ed net: lwip: add dns command
Add CMD_DNS when NET_LWIP is enabled to provide the dns command using
lwIP.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-10-16 11:11:56 -06:00
Jerome Forissier
7a5e00d5c3 net: lwip: add ping command
Add support for the the ping command with NET_LWIP. The implementation
is derived from lwIP's contrib/apps/ping/ping.c.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-10-16 11:11:56 -06:00