From patchwork Wed Jun 6 12:32:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 137825 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp743719lji; Wed, 6 Jun 2018 05:32:34 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLr1YUl+szgxstypnlPznln2qG+z2XA71CEeeNu2EEVqG4aqfwv2orAWqbMgysmz+yWhzia X-Received: by 2002:a50:8b96:: with SMTP id m22-v6mr3610337edm.165.1528288354803; Wed, 06 Jun 2018 05:32:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528288354; cv=none; d=google.com; s=arc-20160816; b=pTGTSC8b5Fqc63ePh2f7+D62GmWcfM/BSC5+Af6Gx4gnYN4ETkh8j1Qr0bOOCdPQa8 qEMdWWZRht+poIGzd1NlHElfdx+nYFxSwbot9ktX+z6Ltf5KhWGeGl3I1F9laCG7+Hwo etdpa8OXZv2YAiyoVPEffVW5oNe8GiCUKW7TN8LCRyJREIXxFVXjErkIW+aAUH3P31aV 4NKsIf7rbnJaMyJkyYaBIoyn4dw3d1MEeQfYd6+UJdm9ZqGgJnPFvcEoXGQEEELCG3Yz 6+B4C+sop0tPlXvAlUm9R+eCN7w06/76zphEup9OrIg5xNVYpvVdRnKh3CFEYD1aPXdc EvVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:message-id:date:to:from :arc-authentication-results; bh=KAp2QL/6TwiQnPTMWv4qaRsbtp7dpJbnEeH+YLPvlk8=; b=TMIJz8cKBVUy7Qc44WOQkRDtgePFLNGg63jHyGSPUFWOyEJwPJWuIAsb+rKkQ4CJvk 8+2S+V8qSNJKzTQQeFe/4oSypcQLNMAxwjz7kBBM8rW83R1qCxy138+I8lTjdGQYMNFe 7AbnBNuyQ6jROPy/WQVH3ndqGb2KlC2QIZyU/MR316Pv4HAsU6LT5IPl/OQIM5xwhKAi 1rZGwFosfLkn9LG1Jjt1qwsrLvl9ztym5AC1ntTusppM7/Od8nr+PZQ57tXYGf4+DdkL iQdiNS2xbfevKZW1McKEOfu3fjCn0qtw/BUVOZbY28u9vx9PhB2jcFdjH2vDRtVxJNhE jZ5w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id i43-v6si1146124ede.243.2018.06.06.05.32.34; Wed, 06 Jun 2018 05:32:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 5C06DC21C57; Wed, 6 Jun 2018 12:32:26 +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=RCVD_IN_DNSWL_BLOCKED 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 09DE8C21FDA; Wed, 6 Jun 2018 12:32:08 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id AD0B6C21C38; Wed, 6 Jun 2018 12:32:05 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id 4CA20C21C50 for ; Wed, 6 Jun 2018 12:32:05 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id DCDAEAEB5; Wed, 6 Jun 2018 12:32:04 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Wed, 6 Jun 2018 14:32:01 +0200 Message-Id: <20180606123202.53631-1-agraf@suse.de> X-Mailer: git-send-email 2.12.3 Cc: Joe Hershberger Subject: [U-Boot] [PATCH 1/2] net: Add option to prefer bootp/dhcp serverip 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Currently we can choose between 2 different types of behavior for the serverip variable: 1) Always overwrite it with the DHCP server IP address (default) 2) Ignore what the DHCP server says (CONFIG_BOOTP_SERVERIP) This patch adds a 3rd option: 3) Use serverip from DHCP if no serverip is given (CONFIG_BOOTP_PREFER_SERVERIP) With this new option, we can have the default case that a boot file gets loaded from the DHCP provided TFTP server work while allowing users to specify their own serverip variable to explicitly use a different tftp server. Signed-off-by: Alexander Graf --- README | 5 +++++ cmd/Kconfig | 9 +++++++++ net/bootp.c | 7 ++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/README b/README index fb331f910d..d8a99281ca 100644 --- a/README +++ b/README @@ -1511,10 +1511,15 @@ The following options need to be configured: CONFIG_BOOTP_TIMEOFFSET CONFIG_BOOTP_VENDOREX CONFIG_BOOTP_MAY_FAIL + CONFIG_BOOTP_PREFER_SERVERIP CONFIG_BOOTP_SERVERIP - TFTP server will be the serverip environment variable, not the BOOTP server. + CONFIG_BOOTP_PREFER_SERVERIP - TFTP server will be the + serverip environment variable if previously unset, otherwise + the DHCP provided serverip is used. + CONFIG_BOOTP_MAY_FAIL - If the DHCP server is not found after the configured retry count, the call will fail instead of starting over. This can be used to fail over diff --git a/cmd/Kconfig b/cmd/Kconfig index e283cb9a8a..e77a4131b3 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -1121,6 +1121,15 @@ config BOOTP_HOSTNAME help The name may or may not be qualified with the local domain name. +config BOOTP_PREFER_SERVERIP + bool "Leave serverip variable in place if existing" + default n + depends on CMD_BOOTP + help + By default a BOOTP/DHCP reply will overwrite the tftp target ip + address. With this option enabled, it will leave it alone if + already specified, but populate it if no serverip is specified. + config BOOTP_SUBNETMASK bool "Request & store 'netmask' from BOOTP/DHCP server" default y diff --git a/net/bootp.c b/net/bootp.c index 9d7cb5d30c..91de4cd426 100644 --- a/net/bootp.c +++ b/net/bootp.c @@ -147,9 +147,14 @@ static void store_net_params(struct bootp_hdr *bp) { #if !defined(CONFIG_BOOTP_SERVERIP) struct in_addr tmp_ip; + bool overwrite_serverip = true; + +#if defined(CONFIG_BOOTP_PREFER_SERVERIP) + overwrite_serverip = false; +#endif net_copy_ip(&tmp_ip, &bp->bp_siaddr); - if (tmp_ip.s_addr != 0) + if (tmp_ip.s_addr != 0 && (overwrite_serverip || !net_server_ip.s_addr)) net_copy_ip(&net_server_ip, &bp->bp_siaddr); memcpy(net_server_ethaddr, ((struct ethernet_hdr *)net_rx_packet)->et_src, 6); From patchwork Wed Jun 6 12:32:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 137824 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp743317lji; Wed, 6 Jun 2018 05:32:10 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKOrwwPVH49dtcshsCipBc2Z1wwmmtkoRNm3I0n0TpCR0kRXzSufNgTbCrVzLe+QCVpoBIl X-Received: by 2002:a50:89d3:: with SMTP id h19-v6mr3571084edh.225.1528288330661; Wed, 06 Jun 2018 05:32:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528288330; cv=none; d=google.com; s=arc-20160816; b=dneRugWGndRkCvdZhj31bP7m2UUJpMKJmNiTbYMJCOEd0oo2pZki3vdpcGD/rmVWtf v15QWLXanzZdfGMxKfyhk2VEeBAgFa+rhIUloVAGNir2/U8TxIbIVHN6RQiYdIBbBNHs Af3WH6aYVoYh+Gu3cynZXVwaYZ/en7unR7AHJwyW1hVIqgkd4N98lqmz81g/vIINDJJt qTO+mjMN01tBfbzyqMC+PPZ22KifeNg2bLdQOK7Ze7uU3bxDmjxM6R7CPEOlNe6+In3K 12T9wF6hZhaH/qTGVQfjd3TvDzTttAinPVwRPJWjH29JRoWVoXFsTr7x8C2WycMza+Rx tNZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:arc-authentication-results; bh=86ETeJfYhefIG9QQgSjQtZrnlJkUBsqCbleEA+/Gz7s=; b=d8XsqG10SIV9NvysnOKsCLJOE9VGUvYvgxENxqw2Rej9wuZMaXvw8Ci945/dyKSS0v RduWY+2vDnJRf/rPpaWxHVeaCpb99HdvY3tAygawV7RtUaOMAwksiTlajoVcQbfK+/Iw bnOqxs5Z5bjOffhPIGogSCSl34fL6s0PDttw2PnAD89hV6XIu7YGQO6uNjnhn4q3bs68 5UNIgzKQ2poWxdbDh2p21utZlRvxNfqYHdfHlLQAVdrYTL8sePOFIebHkhP55rbxi7oc z5zGOqVd8ufyWEmSAI9L5E2hqwH3Ke6Xqe116fp9WlchJd3co0t/tLzkDX2bPx47v2si 76Lw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id b7-v6si1344052edc.68.2018.06.06.05.32.09; Wed, 06 Jun 2018 05:32:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 863CDC22006; Wed, 6 Jun 2018 12:32:09 +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=RCVD_IN_DNSWL_BLOCKED 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 5297DC21C50; Wed, 6 Jun 2018 12:32:07 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 9F1D2C21C57; Wed, 6 Jun 2018 12:32:05 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id 4BFF4C21C38 for ; Wed, 6 Jun 2018 12:32:05 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id DCC13AE28; Wed, 6 Jun 2018 12:32:04 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Wed, 6 Jun 2018 14:32:02 +0200 Message-Id: <20180606123202.53631-2-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180606123202.53631-1-agraf@suse.de> References: <20180606123202.53631-1-agraf@suse.de> Cc: Joe Hershberger Subject: [U-Boot] [PATCH 2/2] ax25: Switch to CONFIG_BOOTP_PREFER_SERVERIP 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: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The ax25-ae350 target currently uses CONFIG_BOOTP_SERVERIP which means we ignore the DHCP provided TFTP ip address. This breaks every case where we do now provide a serverip environment variable. Instead, let's use the new CONFIG_BOOT_PREFER_SERVERIP option to fall back to the DHCP provided TFTP IP if no serverip environment variable is set. Signed-off-by: Alexander Graf --- configs/ax25-ae350_defconfig | 1 + include/configs/ax25-ae350.h | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/configs/ax25-ae350_defconfig b/configs/ax25-ae350_defconfig index 5a69eb50c5..9e0ca3452d 100644 --- a/configs/ax25-ae350_defconfig +++ b/configs/ax25-ae350_defconfig @@ -45,3 +45,4 @@ CONFIG_TIMER=y CONFIG_ATCPIT100_TIMER=y CONFIG_DISTRO_DEFAULTS=y CONFIG_CPU_RISCV_64=y +CONFIG_BOOTP_PREFER_SERVERIP=y diff --git a/include/configs/ax25-ae350.h b/include/configs/ax25-ae350.h index b1ca5ac11a..b230896734 100644 --- a/include/configs/ax25-ae350.h +++ b/include/configs/ax25-ae350.h @@ -11,7 +11,6 @@ * CPU and Board Configuration Options */ #define CONFIG_BOOTP_SEND_HOSTNAME -#define CONFIG_BOOTP_SERVERIP /* * Miscellaneous configurable options