Skip to contentSkip to conversation

net: lwip: dhcp: support arguments for TFTP file download

PATCH In review Jerome Forissier 2 participants 3 messages Nov 14, 2024 – Nov 26, 2024 Networking

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 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().

---
 net/lwip/dhcp.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
net/lwip/dhcp.c +13 -1
index 23b56226921..281f4620958 100644
@@ -111,9 +111,21 @@ static int dhcp_loop(struct udevice *udev)
 
 int do_dhcp(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
+	int ret;
+
 	eth_set_current();
 
-	return dhcp_loop(eth_get_dev());
+	ret = dhcp_loop(eth_get_dev());
+	if (ret)
+		return ret;
+
+	if (argc > 1) {
+		struct cmd_tbl cmdtp = {};
+
+		return do_tftpb(&cmdtp, 0, argc, argv);
+	}
+
+	return CMD_RET_SUCCESS;
 }
 
 int dhcp_run(ulong addr, const char *fname, bool autoload)
Signature · 1 line
2.40.1
#1 lore raw
Quoted 11 lines · Jerome 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().

Applied to u-boot/master, thanks!

But please note, I believe this is what breaks test_efi_helloworld_net_http now as we can no longer abuse "wget 200000 EFI/arm64/helloworld.efi" for example:
U-Boot> wget 200000 EFI/arm64/helloworld.efi
invalid uri, no file path
Invalid URL. Use http(s)://
U-Boot>

Signature · 1 line
Tom
#2 lore raw

Hi Tom,

Quoted 16 lines · Tom Rini
Quoted 11 lines · Jerome 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().

Applied to u-boot/master, thanks!

Quoted 7 lines

But please note, I believe this is what breaks test_efi_helloworld_net_http now as we can no longer abuse "wget 200000 EFI/arm64/helloworld.efi" for example:
U-Boot> wget 200000 EFI/arm64/helloworld.efi
invalid uri, no file path
Invalid URL. Use http(s)://
U-Boot>

That's actually caused by commit 356011f7ac25 ("lwip: fix code style issues") :-/ I've just sent a fix [1]. Sorry for the breakage.

[1] https://lists.denx.de/pipermail/u-boot/2024-November/573054.html

Thanks,

Signature · 1 line
Jerome