From patchwork Wed Jul 4 00:36:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Hershberger X-Patchwork-Id: 939043 X-Patchwork-Delegate: joe.hershberger@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ni.com Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41L2Cm3glKz9s4c for ; Wed, 4 Jul 2018 10:38:28 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 4C179C21F62; Wed, 4 Jul 2018 00:37:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 45D39C21F24; Wed, 4 Jul 2018 00:37:08 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 6FDDAC21FAC; Wed, 4 Jul 2018 00:37:02 +0000 (UTC) Received: from mx0b-00010702.pphosted.com (mx0a-00010702.pphosted.com [148.163.156.75]) by lists.denx.de (Postfix) with ESMTPS id 7A482C21F8F for ; Wed, 4 Jul 2018 00:36:58 +0000 (UTC) Received: from pps.filterd (m0098780.ppops.net [127.0.0.1]) by mx0a-00010702.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w640ZPAw023645; Tue, 3 Jul 2018 19:36:47 -0500 Received: from ni.com (skprod2.natinst.com [130.164.80.23]) by mx0a-00010702.pphosted.com with ESMTP id 2k0dpk0yen-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 03 Jul 2018 19:36:47 -0500 Received: from us-aus-exhub2.ni.corp.natinst.com (us-aus-exhub2.ni.corp.natinst.com [130.164.68.32]) by us-aus-skprod2.natinst.com (8.16.0.22/8.16.0.22) with ESMTPS id w640akrJ020387 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 3 Jul 2018 19:36:46 -0500 Received: from us-aus-exch3.ni.corp.natinst.com (130.164.68.13) by us-aus-exhub2.ni.corp.natinst.com (130.164.68.32) with Microsoft SMTP Server (TLS) id 15.0.1156.6; Tue, 3 Jul 2018 19:36:46 -0500 Received: from us-aus-exhub2.ni.corp.natinst.com (130.164.68.32) by us-aus-exch3.ni.corp.natinst.com (130.164.68.13) with Microsoft SMTP Server (TLS) id 15.0.1156.6; Tue, 3 Jul 2018 19:36:46 -0500 Received: from osboxes.amer.corp.natinst.com (130.164.49.7) by us-aus-exhub2.ni.corp.natinst.com (130.164.68.32) with Microsoft SMTP Server id 15.0.1156.6 via Frontend Transport; Tue, 3 Jul 2018 19:36:46 -0500 From: Joe Hershberger To: Date: Tue, 3 Jul 2018 19:36:39 -0500 Message-ID: <20180704003643.10133-1-joe.hershberger@ni.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-07-03_11:, , signatures=0 X-Proofpoint-Spam-Reason: safe Cc: Tom Rini , Alexander Graf , Joe Hershberger , Jason Kridner Subject: [U-Boot] [PATCH 1/5] net: When checking prerequisites, consider boot_file_name X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" For net_boot_common, we allow the serverip to be specified as part of the boot file name. For net commands that require serverip, include that source as a valid specification of serverip. Signed-off-by: Joe Hershberger Reviewed-by: Alexander Graf --- include/net.h | 3 +++ net/net.c | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/net.h b/include/net.h index f9984ae86c..de2d7bba19 100644 --- a/include/net.h +++ b/include/net.h @@ -839,6 +839,9 @@ ushort env_get_vlan(char *); /* copy a filename (allow for "..." notation, limit length) */ void copy_filename(char *dst, const char *src, int size); +/* check if serverip is specified in filename from the command line */ +int is_serverip_in_cmd(void); + /* get a random source port */ unsigned int random_port(void); diff --git a/net/net.c b/net/net.c index f35695b4fc..bff3e9c5b5 100644 --- a/net/net.c +++ b/net/net.c @@ -1341,7 +1341,7 @@ static int net_check_prereq(enum proto_t protocol) /* Fall through */ case TFTPGET: case TFTPPUT: - if (net_server_ip.s_addr == 0) { + if (net_server_ip.s_addr == 0 && !is_serverip_in_cmd()) { puts("*** ERROR: `serverip' not set\n"); return 1; } @@ -1512,6 +1512,11 @@ void copy_filename(char *dst, const char *src, int size) *dst = '\0'; } +int is_serverip_in_cmd(void) +{ + return !!strchr(net_boot_file_name, ':'); +} + #if defined(CONFIG_CMD_NFS) || \ defined(CONFIG_CMD_SNTP) || \ defined(CONFIG_CMD_DNS)