From patchwork Thu Nov 14 17:10:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Forissier X-Patchwork-Id: 843184 Delivered-To: patch@linaro.org Received: by 2002:adf:9bcc:0:b0:382:184f:390f with SMTP id e12csp398461wrc; Thu, 14 Nov 2024 09:10:27 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCU5A0TgyvGUlUp8gJ0lJBXdxPa9+6J0eEgrfDC1DW0kD6P+8f33PlBcR1YoMCCRPl8wFqdciQ==@linaro.org X-Google-Smtp-Source: AGHT+IGi3MSCNuzmpHbs+rFhUDkGFO8zo41oJdbLEV/PbL567x+d/i3gVH+fzHnE/R862sWwAnE2 X-Received: by 2002:a17:907:80e:b0:a9e:b5d0:e5c with SMTP id a640c23a62f3a-a9ef003347amr2180023266b.61.1731604227514; Thu, 14 Nov 2024 09:10:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1731604227; cv=none; d=google.com; s=arc-20240605; b=SLa31wLz8BTNgjjuwC7tOlSRxOTrz0VRl9lubnEz+NAUScm2XJL6S9UbvhOek8iGYR XqEli8LpPzuQaJ7ljsffKIC4idMha8j9+sRCGdg5tKUDSF1/M14HILs5juor4xqflvMi VziybjaTfOBqBRSmR3YHgGfF+bkhWLS9Sy6FLPOKUyqXXiX+SW5jXhf3+Q3Ueihq2KYY 5biXzOmGPQgX6TjYyo9TNsUiOmnbyeAmTCXM/oZficbSARDWys4C7b0rtWUP/HdezK7k AAXMOMsQHnPL5Eq410W1wiQ3viUynvkrbCqY6MqfTKVOReumiIFSSwL1miMZCjRj1DTN 9/dA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=In9lyNBUo93v9l3e0XRU+toCJG6eH5W2D5roPezacjY=; fh=lT8tIX2q4e0zrgCcrwaQtu2XTlCX5uZwLd5CnzLNmPA=; b=KEJ2ZVecfOr9WUcybPdp+S16xjpwSe/u8nTs5oUlXtE+fG8U0guXwY1wE6QDpSQFAx OpPlqLZWYmIolNGcbIAUJFb05rDnlSGvaRVyUsOMUqUwUVSIch+I4htyfJlrsflrt7BM 3l9Gu52n3wqGgXWUbH+9LEgzL9kY3xCXKSe/db1p5vYk2kW8MHk9WkqY/xr1Vu2UEU7m eAovJSxXLA42Z4p3FTtcIdJYLFRGU0NPsn+4YXFoJzViHJgWtQ82EUw/TvLcrlHMQIvG 1Z8TugXWSZZJs4T92X2QBXmJ1TYiENDZBblD0sKVUlwFMw7+Ad7S18fdtTTbzd11FwVx SnBA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=w3c2Ur5O; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id a640c23a62f3a-aa20e0187f5si101543266b.284.2024.11.14.09.10.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Nov 2024 09:10:27 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=w3c2Ur5O; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6CA1188B16; Thu, 14 Nov 2024 18:10:26 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="w3c2Ur5O"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8E90D89112; Thu, 14 Nov 2024 18:10:25 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8F2F688AE8 for ; Thu, 14 Nov 2024 18:10:23 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jerome.forissier@linaro.org Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4315839a7c9so8073115e9.3 for ; Thu, 14 Nov 2024 09:10:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1731604223; x=1732209023; darn=lists.denx.de; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=In9lyNBUo93v9l3e0XRU+toCJG6eH5W2D5roPezacjY=; b=w3c2Ur5OTN7ogFyP49vXeQqBKSTDYoi7/kZ9R9ePONzuiDsil/qXGvaFvURBUhC8sj XuYKRmqvyOcWe+sVpWmnxQk6eIu4+oHhkYAWIePl7Vqz2rPXqyJ5+B9l/fuI56hbgiq3 q6gOdLf56XYXjbUz+of6IYU87yJ91Mg0VE99wgY+wtBK97xOOxTfnH1w7diJDNSbkgK1 i3JpOiC0x3nfDrZHJl8cj66Z4R7U1/Lic9Ugg648Ooxbl46eOO1TiCoXMBhFWI/EiWl3 47QmIiMfZjCXesAH39NcoCKaaty833SKCpKe8T7l+TQfWdxxfTQWwHCn1JfkCaIFh2VO 0R8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731604223; x=1732209023; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=In9lyNBUo93v9l3e0XRU+toCJG6eH5W2D5roPezacjY=; b=pI5Q6WuYkacQh0j5zbwQ+ARK+YeDfg43KIhFFENo/Pnqf5Y1YO45hFAo0Yw5RlpbnJ t53G2IRgUW1B8rwcYBLnPqGCt7jGprjVvRJsPElTtYsHnagoifrEJGzQHlefe1xBL5xp R1I5rSzUHjTOjbg47TGbe9h60qxRMb1HgoqH3j1XDKBvrpzQl/AHOFcpFbSj4QqXzp5D l3wuACfHYAEfwuGDgyGpT3dsMdBOpBgW6iPIhK9OZq5/rk/oLPjOjhu4WA7skw5fbN70 tfhmdrWJWEb2IIjhwGhcuYjx+NUup513arFNNRqu81eGwptpS0+pxhXeV65d0kew/yKN EOrg== X-Gm-Message-State: AOJu0YzqhE+XtZiDZhJ8ji2tDGmIkUx+mKjZAJdpHBhfjIjBaZgUKVM+ MoZ6Rhzic40YH7zaYU3yCkXanMJC9rmM03oy/NL8xKTf0Qj9SJipTYFYH640d4MChgPbJXyVCLv M4dI= X-Received: by 2002:a05:600c:3b82:b0:42c:bb10:7292 with SMTP id 5b1f17b1804b1-432b74fc98cmr210819855e9.1.1731604222797; Thu, 14 Nov 2024 09:10:22 -0800 (PST) Received: from builder.. ([2a01:e0a:3cb:7bb0:3895:27b4:20b7:7653]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432dab7206csm26433175e9.7.2024.11.14.09.10.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Nov 2024 09:10:22 -0800 (PST) From: Jerome Forissier To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Tom Rini , Heinrich Schuchardt , E Shattow , Jerome Forissier , Joe Hershberger , Ramon Fried Subject: [PATCH] net: lwip: dhcp: support arguments for TFTP file download Date: Thu, 14 Nov 2024 18:10:01 +0100 Message-Id: <20241114171002.2073594-1-jerome.forissier@linaro.org> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean 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 --- net/lwip/dhcp.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/net/lwip/dhcp.c b/net/lwip/dhcp.c index 23b56226921..6f987e469d6 100644 --- a/net/lwip/dhcp.c +++ b/net/lwip/dhcp.c @@ -111,9 +111,34 @@ 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) { + int i; + char **tftp_argv; + struct cmd_tbl cmdtp = {}; + + /* Invoke tftpboot with the arguments passed to dhcp */ + if (argc > 3) + return CMD_RET_FAILURE; + tftp_argv = malloc(argc * sizeof(char *)); + if (!tftp_argv) + return CMD_RET_FAILURE; + tftp_argv[0] = "tftpboot"; + for (i = 1; i < argc; i++) + tftp_argv[i] = argv[i]; + ret = do_tftpb(&cmdtp, 0, argc, tftp_argv); + free(tftp_argv); + return ret; + } + + return CMD_RET_SUCCESS; } int dhcp_run(ulong addr, const char *fname, bool autoload)